diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-10-24 09:57:30 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-10-24 09:57:30 -0700 |
commit | 07ac603a29d1157d0ed0d1629c2bf620b8846ef0 (patch) | |
tree | 807ddd4efcd5ac2b22b868d3670501ef2f6cf63a | |
parent | 510bd206970da7a8d5764f5465856952d11d6a73 (diff) | |
parent | b6b8db9771c217c0d0347e4880f3a516029532a6 (diff) | |
download | vyatta-cfg-07ac603a29d1157d0ed0d1629c2bf620b8846ef0.tar.gz vyatta-cfg-07ac603a29d1157d0ed0d1629c2bf620b8846ef0.zip |
Merge branch 'islavista' of suva.vyatta.com:/git/vyatta-cfg into islavista
-rwxr-xr-x | etc/init.d/vyatta-ofr | 38 | ||||
-rw-r--r-- | etc/shell/level/users/allowed-op | 2 | ||||
-rwxr-xr-x | scripts/VyattaConfigLoad.pm | 1 | ||||
-rwxr-xr-x | scripts/VyattaConfigOutput.pm | 2 | ||||
-rw-r--r-- | src/delete.c | 19 | ||||
-rw-r--r-- | templates/interfaces/ethernet/node.def | 17 | ||||
-rw-r--r-- | templates/interfaces/loopback/node.def | 17 |
7 files changed, 75 insertions, 21 deletions
diff --git a/etc/init.d/vyatta-ofr b/etc/init.d/vyatta-ofr index 8ff02ab..75a03b4 100755 --- a/etc/init.d/vyatta-ofr +++ b/etc/init.d/vyatta-ofr @@ -12,7 +12,7 @@ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -66,6 +66,22 @@ have_rl_system () { # if necessary, provide initial config init_bootfile () { + # try floppy + # if we do not discover an fd device, try loading the floppy module + grep -q fd /proc/devices || modprobe -q floppy 2>/dev/null + grep -q ext2 /proc/filesystems || modprobe -q ext2 2>/dev/null + grep -q vfat /proc/filesystems || modprobe -q vfat 2>/dev/null + if [ ! -d /media/floppy/config ] && grep -q fd /proc/devices + then + mkdir -p /media/floppy + mount /dev/fd0 /media/floppy -o sync || + mount -t ext2 /dev/fd0 /media/floppy -o sync || + mount -t vfat /dev/fd0 /media/floppy + fi 2>/dev/null + + [ -d /media/floppy/config ] && + mount -o bind /media/floppy/config /opt/vyatta/etc/config + if [ -f $BOOTFILE ] && grep -q '/\*XORP Configuration File, v1.0\*/' \ $BOOTFILE >&/dev/null; then CURTIME=$(date +%F-%H%M%S) @@ -78,7 +94,7 @@ init_bootfile () { $vyatta_sbindir/vyatta_current_conf_ver.pl > $BOOTFILE fi fi - chgrp ${GROUP} $BOOTFILE + chgrp ${GROUP} $BOOTFILE chmod 660 $BOOTFILE ## remove the unnecessary and potentially conflicting ## config-directory statement (i.e. /mnt/floppy vs. /media/floppy @@ -103,6 +119,19 @@ load_bootfile () fi } + +# Unload the RAID modules that we are not using. It is safe to try to +# unload all of the RAID modules. The kernel will refuse to unload any +# that we are actually using. +# +cleanup_raid() +{ + MD_MODULES='linear multipath raid0 raid1 raid456 raid5 raid6 raid10' + rmmod $MD_MODULES > /tmp/vyatta_raid_cleanup_log 2>&1 +} + + + start () { log_action_begin_msg "Mounting Vyatta Config" @@ -110,13 +139,14 @@ start () chgrp ${GROUP} ${vyatta_configdir} log_action_end_msg $? init_bootfile - log_daemon_msg "Starting Vyatta Router" + log_daemon_msg "Starting Vyatta router" migrate_bootfile for s in ${subinit[@]} ; do log_progress_msg $s ${vyatta_sbindir}/${s}.init start || (log_end_msg $? && return) done load_bootfile + cleanup_raid chmod g-w,o-w / log_end_msg $? @@ -125,7 +155,7 @@ start () stop() { local -i status=0 - log_daemon_msg "Stopping Vyatta Router" + log_daemon_msg "Stopping Vyatta router" for ((i=${#sub_inits[@]} - 1; i >= 0; i--)) ; do s=${subinit[$i]} log_progress_msg $s diff --git a/etc/shell/level/users/allowed-op b/etc/shell/level/users/allowed-op index c387a99..40c1a91 100644 --- a/etc/shell/level/users/allowed-op +++ b/etc/shell/level/users/allowed-op @@ -6,7 +6,6 @@ disconnect exit no ping -reboot release renew set @@ -15,4 +14,5 @@ telnet terminal traceroute undebug +update vpn diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index b1b7598..5305dc8 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -35,6 +35,7 @@ my %config_rank = ( 'system host-name' => 1005, 'interfaces' => 1000, 'interfaces bridge' => 990, + 'interfaces bonding' => 995, 'interfaces ethernet' => 980, 'interfaces tunnel' => 910, 'system gateway-address' => 890, diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm index 1933d22..fa0b274 100755 --- a/scripts/VyattaConfigOutput.pm +++ b/scripts/VyattaConfigOutput.pm @@ -75,7 +75,7 @@ sub displayValues { $default = $txt; } } - my $is_password = ($name =~ /^.*password$/); + my $is_password = ($name =~ /^.*(password|pre-shared-secret)$/); my $HIDE_PASSWORD = '****************'; $config->setLevel(join ' ', @cur_path); if ($is_multi) { diff --git a/src/delete.c b/src/delete.c index 6fe4eb3..3011c12 100644 --- a/src/delete.c +++ b/src/delete.c @@ -78,6 +78,23 @@ static void reset_default(const char *def_val) if (def_val == NULL) return; + //strip off quotes + char tmp_val[1025]; + char *ptr = index(def_val,'"'); + if (ptr != NULL) { + strcpy(tmp_val,ptr+1); + ptr = rindex(tmp_val,'"'); + if (ptr != NULL) { + *ptr = '\0'; + } + else { + strcpy(tmp_val,def_val); //go with original value. + } + } + else { + strcpy(tmp_val,def_val); + } + char filename[strlen(m_path.path) + 10]; touch(); sprintf(filename, "%s/node.val", m_path.path); @@ -85,7 +102,7 @@ static void reset_default(const char *def_val) FILE *fp = fopen(filename, "w"); if (fp == NULL) bye("can not open: %s", filename); - fputs(def_val, fp); + fputs(tmp_val, fp); fclose(fp); sprintf(filename, "%s/def", m_path.path); diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def index ba15828..3023a70 100644 --- a/templates/interfaces/ethernet/node.def +++ b/templates/interfaces/ethernet/node.def @@ -1,19 +1,20 @@ tag: type: txt help: Set ethernet interface +syntax:expression: pattern $VAR(@) "^eth[0-9]+$" \ + ; "interface must be (eth0 - eth999)" syntax:expression: exec " \ - if [ -z \"`ip link | grep eth | egrep -v 'eth[0-9]+[.]' | grep $VAR(@)`\" ]; then \ - echo Invalid ethernet interface [$VAR(@)]; \ - exit 1 ; \ - fi ; " + if [ -f /sys/class/net/$VAR(@) ]; then \ + echo \"Ethernet interface does not exist: $VAR(@)\"; \ + exit 1; \ + fi" + update: sudo ip link set "$VAR(@)" up vyatta-vtysh -c "configure terminal" \ -c "interface $VAR(@)" -c "link-detect" delete: sudo ip link set "$VAR(@)" down -allowed: for dev in /sys/class/net/*; +allowed: for dev in /sys/class/net/eth*; do if [[ -d $dev && -L $dev/device ]] - then if [[ $(cat $dev/type) -eq 1 ]] - then echo -n ${dev##*/} " " - fi + then echo -n ${dev##*/} " " fi done diff --git a/templates/interfaces/loopback/node.def b/templates/interfaces/loopback/node.def index 7b7a304..e57f4b1 100644 --- a/templates/interfaces/loopback/node.def +++ b/templates/interfaces/loopback/node.def @@ -1,9 +1,14 @@ tag: type: txt help: Set loopback interface -syntax:expression: exec " \ - if [ -z \"`ip addr | grep $VAR(@) `\" ]; then \ - echo loopback interface $VAR(@) doesn\\'t exist on this system ; \ - exit 1 ; \ - fi ; " -update:expression: "sudo ip link set $VAR(@) up" +allowed: echo "lo" +syntax:expression: exec "\ + if [ ! -d /sys/class/net/$VAR(@) ]; then \ + echo \"loopback interface $VAR(@) does not exist\"; \ + exit 1; \ + elif [ $(cat /sys/class/net/$VAR(@)/type) -ne 772 ]; then \ + echo \"interface $VAR(@) is not a loopback interface\"; \ + exit 1; \ + fi" + +update: sudo ip link set $VAR(@) up |