From 78faab3db4716a8eabc99f3f01d624aff9bacddf Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 15 Dec 2009 11:31:35 -0800 Subject: [PATCH] Support MAC address editing on Debian too --- net/CHANGELOG | 2 +- net/debian-linux-lib.pl | 14 ++++++++++++++ net/edit_bifc.cgi | 4 ++-- net/redhat-linux-lib.pl | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/net/CHANGELOG b/net/CHANGELOG index 34009e915..62cd6a73b 100644 --- a/net/CHANGELOG +++ b/net/CHANGELOG @@ -53,4 +53,4 @@ On Debian systems, if the dns-nameservers option is defined in /etc/network/inte ---- Changes since 1.480 ---- Updated bonding support to use the new format in Debian 5.0, thanks to Caspar Smit. ---- Changes since 1.500 ---- -Added a field for editing the MAC address to apply at boot time on Redhat-based systems. +Added a field for editing the MAC address to apply at boot time on Redhat and Debian-based systems. diff --git a/net/debian-linux-lib.pl b/net/debian-linux-lib.pl index ea4b16c76..f88af97b8 100755 --- a/net/debian-linux-lib.pl +++ b/net/debian-linux-lib.pl @@ -75,6 +75,11 @@ foreach $iface (@ifaces) { elsif($param eq 'slaves') { $cfg->{'partner'} = $value; } + elsif($param eq 'hwaddr') { + local @v = split(/\s+/, $value); + $cfg->{'ether_type'} = $v[0]; + $cfg->{'ether'} = $v[1]; + } else { $cfg->{$param} = $value; } } $cfg->{'dhcp'} = ($method eq 'dhcp'); @@ -122,6 +127,10 @@ else { my @autos = get_auto_defs(); my $amode = $gconfig{'os_version'} > 3 || scalar(@autos); if (!$cfg->{'up'} && !$amode) { push(@options, ['noauto', '']); } +if ($cfg->{'ether'}) { + push(@options, [ 'hwaddr', ($cfg->{'ether_type'} || 'ether').' '. + $cfg->{'ether'} ]); + } # Set bonding parameters if(($cfg->{'bond'} == 1) && ($gconfig{'os_version'} >= 5)) { @@ -831,5 +840,10 @@ sub supports_vlans return $gconfig{'os_type'} eq 'debian-linux' && &has_command("vconfig"); } +sub boot_iface_hardware +{ +return $_[0] =~ /^eth/; +} + 1; diff --git a/net/edit_bifc.cgi b/net/edit_bifc.cgi index f5c15b4af..1d8474f86 100755 --- a/net/edit_bifc.cgi +++ b/net/edit_bifc.cgi @@ -203,8 +203,8 @@ if(($in{'vlan'}) or (&iface_type($b->{'name'}) =~ /^(.*) (VLAN)$/)) { } # Hardware address, if non-virtual -if ((!$b && $in{'virtual'} eq "") || - ($b && $b->{'virtual'} eq "" && +if (($in{'new'} && $in{'virtual'} eq "") || + (!$in{'new'} && $b->{'virtual'} eq "" && defined(&boot_iface_hardware) && &boot_iface_hardware($b->{'name'}))) { $hardfield = &ui_opt_textbox("ether", $b->{'ether'}, 18, diff --git a/net/redhat-linux-lib.pl b/net/redhat-linux-lib.pl index 08d441fe8..f3333c7cd 100755 --- a/net/redhat-linux-lib.pl +++ b/net/redhat-linux-lib.pl @@ -97,7 +97,7 @@ while($f = readdir(CONF)) { $b->{'broadcast'} = $conf{'BROADCAST'}; $b->{'gateway'} = $conf{'GATEWAY'}; $b->{'mtu'} = $conf{'MTU'}; - $b->{'ether'} = $conf{'HWADDR'}; + $b->{'ether'} = $conf{'MACADDR'}; $b->{'dhcp'} = ($conf{'BOOTPROTO'} eq 'dhcp'); $b->{'bootp'} = ($conf{'BOOTPROTO'} eq 'bootp'); $b->{'edit'} = ($b->{'name'} !~ /^ppp|irlan/); @@ -148,7 +148,7 @@ else { delete($conf{'GATEWAY'}); } $conf{'MTU'} = $_[0]->{'mtu'}; - $conf{'HWADDR'} = $_[0]->{'ether'}; + $conf{'MACADDR'} = $_[0]->{'ether'}; $conf{'ONBOOT'} = $_[0]->{'up'} ? "yes" : "no"; $conf{'ONPARENT'} = $_[0]->{'up'} ? "yes" : "no" if ($_[0]->{'virtual'} ne '');