Skip to content

Commit

Permalink
MAC address editing
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Dec 15, 2009
1 parent 6033843 commit 5206e92
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions net/CHANGELOG
Expand Up @@ -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.
12 changes: 11 additions & 1 deletion net/edit_bifc.cgi
Expand Up @@ -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();

Expand Down
7 changes: 7 additions & 0 deletions net/redhat-linux-lib.pl
Expand Up @@ -97,6 +97,7 @@ sub boot_interfaces
$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/);
Expand Down Expand Up @@ -147,6 +148,7 @@ sub save_interface
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 '');
Expand Down Expand Up @@ -750,5 +752,10 @@ sub save_dhcp_hostname
{
}

sub boot_iface_hardware
{
return $_[0] =~ /^eth/;
}

1;

7 changes: 7 additions & 0 deletions net/save_bifc.cgi
Expand Up @@ -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'}++;
Expand Down

0 comments on commit 5206e92

Please sign in to comment.