MAC address editing
authorJamie Cameron <jcameron@webmin.com>
Tue, 15 Dec 2009 05:34:05 +0000 (21:34 -0800)
committerJamie Cameron <jcameron@webmin.com>
Tue, 15 Dec 2009 05:34:05 +0000 (21:34 -0800)
net/CHANGELOG
net/edit_bifc.cgi
net/redhat-linux-lib.pl
net/save_bifc.cgi

index 3af5173..34009e9 100644 (file)
@@ -52,3 +52,5 @@ Updated the Hostname and DNS Client page to always show the hostname from config
 On Debian systems, if the dns-nameservers option is defined in /etc/network/interfaces, it will be updated when changing nameservers.
 ---- 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.
index 024018c..f5c15b4 100755 (executable)
@@ -200,7 +200,17 @@ if(($in{'vlan'}) or (&iface_type($b->{'name'}) =~ /^(.*) (VLAN)$/)) {
        print &ui_table_row($text{'vlan_id'},
                $in{'new'} ? &ui_textbox("vlanid", $vlanid, 10)
                           : $vlanid.&ui_hidden("vlanid", $vlanid));
-}
+       }
+
+# Hardware address, if non-virtual
+if ((!$b && $in{'virtual'} eq "") ||
+    ($b && $b->{'virtual'} eq "" &&
+     defined(&boot_iface_hardware) &&
+     &boot_iface_hardware($b->{'name'}))) {
+       $hardfield = &ui_opt_textbox("ether", $b->{'ether'}, 18,
+                                    $text{'aifc_default'});
+       print &ui_table_row($text{'aifc_hard'}, $hardfield);
+       }
 
 print &ui_table_end();
      
index 3af6cd7..08d441f 100755 (executable)
@@ -97,6 +97,7 @@ while($f = readdir(CONF)) {
                $b->{'broadcast'} = $conf{'BROADCAST'};
                $b->{'gateway'} = $conf{'GATEWAY'};
                $b->{'mtu'} = $conf{'MTU'};
+               $b->{'ether'} = $conf{'HWADDR'};
                $b->{'dhcp'} = ($conf{'BOOTPROTO'} eq 'dhcp');
                $b->{'bootp'} = ($conf{'BOOTPROTO'} eq 'bootp');
                $b->{'edit'} = ($b->{'name'} !~ /^ppp|irlan/);
@@ -147,6 +148,7 @@ else {
                delete($conf{'GATEWAY'});
                }
        $conf{'MTU'} = $_[0]->{'mtu'};
+       $conf{'HWADDR'} = $_[0]->{'ether'};
        $conf{'ONBOOT'} = $_[0]->{'up'} ? "yes" : "no";
        $conf{'ONPARENT'} = $_[0]->{'up'} ? "yes" : "no"
                if ($_[0]->{'virtual'} ne '');
@@ -750,5 +752,10 @@ sub save_dhcp_hostname
 {
 }
 
+sub boot_iface_hardware
+{
+return $_[0] =~ /^eth/;
+}
+
 1;
 
index cbc8a53..f5f9582 100755 (executable)
@@ -176,6 +176,13 @@ else {
                $b->{'mtu'} = $in{'mtu_def'} ? undef : $in{'mtu'};
                }
 
+       # MAC address
+       if (defined($in{'ether'}) && !$in{'ether_def'}) {
+               $in{'ether'} =~ /^[A-Fa-f0-9:]+$/ ||
+                       &error(&text('aifc_ehard', $in{'ether'}));
+               $b->{'ether'} = $in{'ether'};
+               }
+
        if ($in{'new'} && !$access{'up'} ||
            &can_edit("up", $b) && $in{'up'} && $access{'up'}) {
                $b->{'up'}++;