Support MAC address editing on Debian too
authorJamie Cameron <jcameron@webmin.com>
Tue, 15 Dec 2009 19:31:35 +0000 (11:31 -0800)
committerJamie Cameron <jcameron@webmin.com>
Tue, 15 Dec 2009 19:31:35 +0000 (11:31 -0800)
net/CHANGELOG
net/debian-linux-lib.pl
net/edit_bifc.cgi
net/redhat-linux-lib.pl

index 34009e9..62cd6a7 100644 (file)
@@ -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.
index ea4b16c..f88af97 100755 (executable)
@@ -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;
 
index f5c15b4..1d8474f 100755 (executable)
@@ -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,
index 08d441f..f3333c7 100755 (executable)
@@ -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 '');