diff options
-rwxr-xr-x | debian/rules | 4 | ||||
-rwxr-xr-x | etc/init.d/vyatta-ofr | 7 | ||||
-rw-r--r-- | scripts/vyatta-interfaces.pl | 39 | ||||
-rw-r--r-- | src/cli_new.c | 21 |
4 files changed, 34 insertions, 37 deletions
diff --git a/debian/rules b/debian/rules index 244a67b..95634d1 100755 --- a/debian/rules +++ b/debian/rules @@ -17,7 +17,7 @@ DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) PACKAGE=vyatta-cfg PKGDIR=$(CURDIR)/debian/$(PACKAGE) -CFLAGS = -Wall -g +CFLAGS = -Wall -g configure = ./configure configure += --host=$(DEB_HOST_GNU_TYPE) @@ -31,7 +31,7 @@ configure += LDFLAGS="-Wl,-z,defs" ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else - CFLAGS += -O2 + CFLAGS += -Os endif configure: configure.ac Makefile.am diff --git a/etc/init.d/vyatta-ofr b/etc/init.d/vyatta-ofr index 75a03b4..4fb4c1e 100755 --- a/etc/init.d/vyatta-ofr +++ b/etc/init.d/vyatta-ofr @@ -66,15 +66,10 @@ 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 /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 diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index d382922..b5d38af 100644 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -37,6 +37,7 @@ use VyattaMisc; use Getopt::Long; use POSIX; use NetAddr::IP; +use Fcntl; use strict; use warnings; @@ -44,7 +45,6 @@ use warnings; my $dhcp_daemon = '/sbin/dhclient'; my $dhclient_dir = '/var/lib/dhcp3/'; - my ($eth_update, $eth_delete, $addr, $dev, $mac, $mac_update, $op_dhclient); GetOptions("eth-addr-update=s" => \$eth_update, @@ -65,7 +65,7 @@ if (defined $op_dhclient) { op_dhcp_command($op_dhclient, $dev); } sub is_ip_configured { my ($intf, $ip) = @_; - my $wc = `ip addr show $intf | grep $ip | wc -l`; + my $wc = `ip addr show $intf | grep -c $ip`; if (defined $wc and $wc > 0) { return 1; } else { @@ -96,6 +96,15 @@ sub is_ip_duplicate { } } +sub touch { + my $file = shift; + my $t = time; + + sysopen (my $f, $file, O_RDWR|O_CREAT) + or die "Can't touch $file: $!"; + close $f; + utime $t, $t, $file; +} sub dhcp_write_file { my ($file, $data) = @_; @@ -121,7 +130,7 @@ sub is_dhcp_enabled { # FIXME: this is wrong and depends on name of interface -> type # which is not dependable - if ($intf =~ m/^eth/ || $intf =~ m/^bond/) { + if ($intf =~ m/^eth/) { if ($intf =~ m/(\w+)\.(\d+)/) { $config->setLevel("interfaces ethernet $1 vif $2"); } else { @@ -129,6 +138,8 @@ sub is_dhcp_enabled { } } elsif ($intf =~ m/^br/) { $config->setLevel("interfaces bridge $intf"); + } elsif ($intf =~ m/^bond/) { + $config->setLevel("interfaces bonding $intf"); } else { # # FIXME: currently we only support dhcp on ethernet @@ -247,7 +258,8 @@ sub run_dhclient { dhcp_update_config($intf_config_file, $intf); my $cmd = "$dhcp_daemon -q -nw -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file $intf 2> /dev/null &"; # adding & at the end to make the process into a daemon immediately - system ($cmd); + system ($cmd) == 0 + or warn "start $dhcp_daemon failed: $?\n"; } sub stop_dhclient { @@ -255,16 +267,17 @@ sub stop_dhclient { my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = generate_dhclient_intf_files($intf); my $release_cmd = "$dhcp_daemon -q -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file -r $intf 2> /dev/null"; - system ($release_cmd); - system ("rm -f $intf_config_file"); + system ($release_cmd) == 0 + or warn "stop $dhcp_daemon failed: $?\n"; + unlink ($intf_config_file); } sub update_eth_addrs { my ($addr, $intf) = @_; if ($addr eq "dhcp") { + touch("/var/lib/dhcp3/$intf"); run_dhclient($intf); - system ("touch /var/lib/dhcp3/$intf\;"); return; } my $version = is_ip_v4_or_v6($addr); @@ -310,7 +323,9 @@ sub delete_eth_addrs { if ($addr eq "dhcp") { stop_dhclient($intf); - system("rm -f /var/lib/dhcp3/dhclient_$intf\_lease; rm -f /var/lib/dhcp3/$intf\; rm -f /var/run/vyatta/dhclient/dhclient_release_$intf\;"); + unlink("/var/lib/dhcp3/dhclient_$intf\_lease"); + unlink("/var/lib/dhcp3/$intf"); + unlink("/var/run/vyatta/dhclient/dhclient_release_$intf"); exit 0; } my $version = is_ip_v4_or_v6($addr); @@ -464,16 +479,14 @@ sub op_dhcp_command { } else { print "Releasing DHCP lease on $intf ...\n"; stop_dhclient($intf); - if(! -d $tmp_dhclient_dir ){ - system ("mkdir $tmp_dhclient_dir\;"); - } - system ("touch $release_file\;"); + mkdir ($tmp_dhclient_dir) if (! -d $tmp_dhclient_dir ); + touch ($release_file); exit 0; } } elsif ($op_command eq "dhcp-renew") { print "Renewing DHCP lease on $intf ...\n"; run_dhclient($intf); - system ("rm -f $release_file\;"); + unlink ($release_file); exit 0; } diff --git a/src/cli_new.c b/src/cli_new.c index ae48903..dc6b760 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -2138,24 +2138,13 @@ const char *type_to_name(vtw_type_e type) { void dump_log(int argc, char **argv) { int i; - int len; - char *cp; - len = 0; - for (i=0; i<argc;++i) - len += strlen(argv[i]); - len += argc; - cp = my_malloc(len, "dump_log"); - len = 0; - for (i=0; i<argc;++i){ - strcpy(cp+len, argv[i]); - len += strlen(argv[i]); - cp[len]= ' '; - ++len; + printf("Command:"); + for (i = 0; i < argc; ++i) { + putchar(' '); + puts(argv[i]); } - cp[len-1]=0; - printf("Command: %s\n",cp); - my_free(cp); + putchar('\n'); } #endif |