mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
More code cleanups
This commit is contained in:
@@ -8,9 +8,9 @@ $virtual_netmask = "255.255.255.255"; # Netmask for virtual interfaces
|
|||||||
sub active_interfaces
|
sub active_interfaces
|
||||||
{
|
{
|
||||||
local(@rv, @lines, $l);
|
local(@rv, @lines, $l);
|
||||||
local @boot = &boot_interfaces();
|
my @boot = &boot_interfaces();
|
||||||
local %boot = map { $_->{'address'}, $_ } @boot;
|
my %boot = map { $_->{'address'}, $_ } @boot;
|
||||||
local %bootname = map { $_->{'fullname'}, $_ } @boot;
|
my %bootname = map { $_->{'fullname'}, $_ } @boot;
|
||||||
&open_execute_command(IFC, "ifconfig -a", 1, 1);
|
&open_execute_command(IFC, "ifconfig -a", 1, 1);
|
||||||
while(<IFC>) {
|
while(<IFC>) {
|
||||||
s/\r|\n//g;
|
s/\r|\n//g;
|
||||||
@@ -19,12 +19,12 @@ while(<IFC>) {
|
|||||||
}
|
}
|
||||||
close(IFC);
|
close(IFC);
|
||||||
foreach $l (@lines) {
|
foreach $l (@lines) {
|
||||||
local %ifc;
|
my %ifc;
|
||||||
$l =~ /^([^:\s]+):/;
|
$l =~ /^([^:\s]+):/;
|
||||||
$ifc{'name'} = $ifc{'fullname'} = $1;
|
$ifc{'name'} = $ifc{'fullname'} = $1;
|
||||||
if ($l =~ /^(\S+):(\d+):\s/) { $ifc{'virtual'} = $2; }
|
if ($l =~ /^(\S+):(\d+):\s/) { $ifc{'virtual'} = $2; }
|
||||||
local $bootiface = $bootname{$ifc{'fullname'}};
|
my $bootiface = $bootname{$ifc{'fullname'}};
|
||||||
local $bootip = $bootiface ? $bootiface->{'address'} : undef;
|
my $bootip = $bootiface ? $bootiface->{'address'} : undef;
|
||||||
if ($l =~ s/inet\s+($bootip)\s+netmask\s+(\S+)\s+broadcast\s+(\S+)// ||
|
if ($l =~ s/inet\s+($bootip)\s+netmask\s+(\S+)\s+broadcast\s+(\S+)// ||
|
||||||
$l =~ s/inet\s+(\S+)\s+netmask\s+(\S+)\s+broadcast\s+(\S+)//) {
|
$l =~ s/inet\s+(\S+)\s+netmask\s+(\S+)\s+broadcast\s+(\S+)//) {
|
||||||
$ifc{'address'} = $1;
|
$ifc{'address'} = $1;
|
||||||
@@ -49,7 +49,7 @@ foreach $l (@lines) {
|
|||||||
push(@rv, \%ifc);
|
push(@rv, \%ifc);
|
||||||
|
|
||||||
# Add v6 addresses
|
# Add v6 addresses
|
||||||
local (@address6, @netmask6, @scope6);
|
my (@address6, @netmask6, @scope6);
|
||||||
while($l =~ s/inet6\s+([0-9a-f:]+)(%\S+)?\s+prefixlen\s+(\d+)(\s+scopeid\s+(\S+))?//) {
|
while($l =~ s/inet6\s+([0-9a-f:]+)(%\S+)?\s+prefixlen\s+(\d+)(\s+scopeid\s+(\S+))?//) {
|
||||||
push(@address6, $1);
|
push(@address6, $1);
|
||||||
push(@netmask6, $3);
|
push(@netmask6, $3);
|
||||||
@@ -61,17 +61,17 @@ foreach $l (@lines) {
|
|||||||
|
|
||||||
# Add aliases as virtual interfaces. Try to match boot-time interface
|
# Add aliases as virtual interfaces. Try to match boot-time interface
|
||||||
# numbers where possible
|
# numbers where possible
|
||||||
local %vtaken = map { $_->{'virtual'}, 1 }
|
my %vtaken = map { $_->{'virtual'}, 1 }
|
||||||
grep { $_->{'name'} eq $vifc{'name'} &&
|
grep { $_->{'name'} eq $vifc{'name'} &&
|
||||||
$_->{'virtual'} ne "" } @boot;
|
$_->{'virtual'} ne "" } @boot;
|
||||||
while($l =~ s/inet\s+(\S+)\s+netmask\s+(\S+)(\s+broadcast\s+(\S+))?//) {
|
while($l =~ s/inet\s+(\S+)\s+netmask\s+(\S+)(\s+broadcast\s+(\S+))?//) {
|
||||||
local %vifc = %ifc;
|
my %vifc = %ifc;
|
||||||
$vifc{'address'} = $1;
|
$vifc{'address'} = $1;
|
||||||
$vifc{'netmask'} = &parse_hex($2);
|
$vifc{'netmask'} = &parse_hex($2);
|
||||||
$vifc{'broadcast'} = $4;
|
$vifc{'broadcast'} = $4;
|
||||||
$vifc{'up'} = 1;
|
$vifc{'up'} = 1;
|
||||||
$vifc{'edit'} = $ifc{'edit'};
|
$vifc{'edit'} = $ifc{'edit'};
|
||||||
local $boot = $boot{$vifc{'address'}};
|
my $boot = $boot{$vifc{'address'}};
|
||||||
if ($boot) {
|
if ($boot) {
|
||||||
$vifc{'virtual'} = $boot->{'virtual'};
|
$vifc{'virtual'} = $boot->{'virtual'};
|
||||||
}
|
}
|
||||||
@@ -92,25 +92,26 @@ return @rv;
|
|||||||
# Create or modify an interface
|
# Create or modify an interface
|
||||||
sub activate_interface
|
sub activate_interface
|
||||||
{
|
{
|
||||||
local %act = map { $_->{'fullname'}, $_ } &active_interfaces();
|
my ($iface) = @_;
|
||||||
local $old = $act{$_[0]->{'fullname'}};
|
my %act = map { $_->{'fullname'}, $_ } &active_interfaces();
|
||||||
$act{$_[0]->{'fullname'}} = $_[0];
|
my $old = $act{$iface->{'fullname'}};
|
||||||
&interface_sync(\%act, $_[0]->{'name'}, $_[0]->{'fullname'});
|
$act{$iface->{'fullname'}} = $iface;
|
||||||
|
&interface_sync(\%act, $iface->{'name'}, $iface->{'fullname'});
|
||||||
|
|
||||||
if ($_[0]->{'virtual'} eq '') {
|
if ($iface->{'virtual'} eq '') {
|
||||||
# Remove old IPv6 addresses
|
# Remove old IPv6 addresses
|
||||||
local $l = &backquote_command("ifconfig $_[0]->{'name'}");
|
my $l = &backquote_command("ifconfig ".quotemeta($iface->{'name'}));
|
||||||
while($l =~ s/inet6\s*(\S+)\s+prefixlen\s+(\d+)//) {
|
while($l =~ s/inet6\s*(\S+)\s+prefixlen\s+(\d+)//) {
|
||||||
local $cmd = "ifconfig $_[0]->{'name'} inet6 $1 -alias 2>&1";
|
my $cmd = "ifconfig $iface->{'name'} inet6 $1 -alias 2>&1";
|
||||||
$out = &backquote_logged($cmd);
|
$out = &backquote_logged($cmd);
|
||||||
&error("Failed to remove old IPv6 address : $out") if ($?);
|
&error("Failed to remove old IPv6 address : $out") if ($?);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add IPv6 addresses
|
# Add IPv6 addresses
|
||||||
for(my $i=0; $i<@{$_[0]->{'address6'}}; $i++) {
|
for(my $i=0; $i<@{$iface->{'address6'}}; $i++) {
|
||||||
local $cmd = "ifconfig $_[0]->{'name'} inet6 ".
|
my $cmd = "ifconfig $iface->{'name'} inet6 ".
|
||||||
$_[0]->{'address6'}->[$i].
|
$iface->{'address6'}->[$i].
|
||||||
" prefixlen ".$_[0]->{'netmask6'}->[$i]." 2>&1";
|
" prefixlen ".$iface->{'netmask6'}->[$i]." 2>&1";
|
||||||
$out = &backquote_logged($cmd);
|
$out = &backquote_logged($cmd);
|
||||||
&error("Failed to add IPv6 address : $out") if ($?);
|
&error("Failed to add IPv6 address : $out") if ($?);
|
||||||
}
|
}
|
||||||
@@ -121,16 +122,16 @@ if ($_[0]->{'virtual'} eq '') {
|
|||||||
# Deactive an interface
|
# Deactive an interface
|
||||||
sub deactivate_interface
|
sub deactivate_interface
|
||||||
{
|
{
|
||||||
local %act;
|
my ($iface) = @_;
|
||||||
local @act = &active_interfaces();
|
my @act = &active_interfaces();
|
||||||
if ($_[0]->{'virtual'} eq '') {
|
if ($iface->{'virtual'} eq '') {
|
||||||
@act = grep { $_->{'name'} ne $_[0]->{'name'} } @act;
|
@act = grep { $_->{'name'} ne $iface->{'name'} } @act;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@act = grep { $_->{'fullname'} ne $_[0]->{'fullname'} } @act;
|
@act = grep { $_->{'fullname'} ne $iface->{'fullname'} } @act;
|
||||||
}
|
}
|
||||||
map { $act{$_->{'fullname'}} = $_ } @act;
|
my %act = map { $_->{'fullname'}, $_ } @act;
|
||||||
&interface_sync(\%act, $_[0]->{'name'}, $_[0]->{'fullname'});
|
&interface_sync(\%act, $iface->{'name'}, $iface->{'fullname'});
|
||||||
}
|
}
|
||||||
|
|
||||||
# interface_sync(&interfaces-hash, name, changee)
|
# interface_sync(&interfaces-hash, name, changee)
|
||||||
@@ -139,23 +140,25 @@ map { $act{$_->{'fullname'}} = $_ } @act;
|
|||||||
# rather than separate eth0:N interfaces like on Linux.
|
# rather than separate eth0:N interfaces like on Linux.
|
||||||
sub interface_sync
|
sub interface_sync
|
||||||
{
|
{
|
||||||
|
my ($act, $name, $change) = @_;
|
||||||
|
|
||||||
# Remove all IP addresses except for the primary one (unless it is being edited)
|
# Remove all IP addresses except for the primary one (unless it is being edited)
|
||||||
local $pri = $_[0]->{$_[1]};
|
my $pri = $act->{$name};
|
||||||
local $ifconfig = &has_command("ifconfig");
|
my $ifconfig = &has_command("ifconfig");
|
||||||
while(1) {
|
while(1) {
|
||||||
local $out;
|
my $out;
|
||||||
&execute_command("$ifconfig $_[1]", undef, \$out);
|
&execute_command("$ifconfig ".quotemeta($name), undef, \$out);
|
||||||
last if ($out !~ /([\000-\377]*)\s+inet\s+(\d+\.\d+\.\d+\.\d+)/);
|
last if ($out !~ /([\000-\377]*)\s+inet\s+(\d+\.\d+\.\d+\.\d+)/);
|
||||||
last if ($2 eq $pri->{'address'} && $_[2] ne $pri->{'fullname'});
|
last if ($2 eq $pri->{'address'} && $change ne $pri->{'fullname'});
|
||||||
&system_logged("$ifconfig $_[1] delete $2 >/dev/null 2>&1");
|
&system_logged("$ifconfig ".quotemeta($name)." delete $2 >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add them back again, except for the primary unless it is being changed
|
# Add them back again, except for the primary unless it is being changed
|
||||||
foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
||||||
grep { $_->{'name'} eq $_[1] } values(%{$_[0]})) {
|
grep { $_->{'name'} eq $name } values(%$act)) {
|
||||||
next if ($a->{'fullname'} eq $pri->{'fullname'} &&
|
next if ($a->{'fullname'} eq $pri->{'fullname'} &&
|
||||||
$_[2] ne $pri->{'fullname'});
|
$change ne $pri->{'fullname'});
|
||||||
local $cmd = "$ifconfig $a->{'name'}";
|
my $cmd = "$ifconfig ".quotemeta($a->{'name'});
|
||||||
if ($a->{'virtual'} ne '') {
|
if ($a->{'virtual'} ne '') {
|
||||||
$cmd .= " alias $a->{'address'}";
|
$cmd .= " alias $a->{'address'}";
|
||||||
}
|
}
|
||||||
@@ -165,14 +168,17 @@ foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
|||||||
if ($a->{'netmask'}) { $cmd .= " netmask $a->{'netmask'}"; }
|
if ($a->{'netmask'}) { $cmd .= " netmask $a->{'netmask'}"; }
|
||||||
if ($a->{'broadcast'}) { $cmd .= " broadcast $a->{'broadcast'}"; }
|
if ($a->{'broadcast'}) { $cmd .= " broadcast $a->{'broadcast'}"; }
|
||||||
if ($a->{'mtu'}) { $cmd .= " mtu $a->{'mtu'}"; }
|
if ($a->{'mtu'}) { $cmd .= " mtu $a->{'mtu'}"; }
|
||||||
local $out = &backquote_logged("$cmd 2>&1");
|
my $out = &backquote_logged("$cmd 2>&1");
|
||||||
#if ($? && $out !~ /file exists/i) {
|
&error($out) if ($?);
|
||||||
if ($?) {
|
|
||||||
&error($out);
|
|
||||||
}
|
|
||||||
if ($a->{'virtual'} eq '') {
|
if ($a->{'virtual'} eq '') {
|
||||||
if ($a->{'up'}) { $out = &backquote_logged("$ifconfig $a->{'name'} up 2>&1"); }
|
if ($a->{'up'}) {
|
||||||
else { $out = &backquote_logged("$ifconfig $a->{'name'} down 2>&1"); }
|
$out = &backquote_logged(
|
||||||
|
"$ifconfig ".quotemeta($a->{'name'})." up 2>&1");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$out = &backquote_logged(
|
||||||
|
"$ifconfig ".quotemeta($a->{'name'})." down 2>&1");
|
||||||
|
}
|
||||||
&error($out) if ($?);
|
&error($out) if ($?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,11 +189,11 @@ foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
|||||||
# Returns a list of interfaces brought up at boot time
|
# Returns a list of interfaces brought up at boot time
|
||||||
sub boot_interfaces
|
sub boot_interfaces
|
||||||
{
|
{
|
||||||
local %rc = &get_rc_conf();
|
my %rc = &get_rc_conf();
|
||||||
local @rv;
|
my @rv;
|
||||||
foreach my $r (keys %rc) {
|
foreach my $r (keys %rc) {
|
||||||
local $v = $rc{$r};
|
my $v = $rc{$r};
|
||||||
local %ifc;
|
my %ifc;
|
||||||
if ($r =~ /^ifconfig_([a-z0-9]+)$/) {
|
if ($r =~ /^ifconfig_([a-z0-9]+)$/) {
|
||||||
# Non-virtual interface
|
# Non-virtual interface
|
||||||
%ifc = ( 'name' => $1,
|
%ifc = ( 'name' => $1,
|
||||||
@@ -207,7 +213,7 @@ foreach my $r (keys %rc) {
|
|||||||
elsif ($v eq 'DHCP') {
|
elsif ($v eq 'DHCP') {
|
||||||
$ifc{'dhcp'} = 1;
|
$ifc{'dhcp'} = 1;
|
||||||
}
|
}
|
||||||
local @a = split(/\./, $ifc{'address'});
|
my @a = split(/\./, $ifc{'address'});
|
||||||
if ($v =~ /netmask\s+(0x\S+)/) {
|
if ($v =~ /netmask\s+(0x\S+)/) {
|
||||||
$ifc{'netmask'} = &parse_hex($1);
|
$ifc{'netmask'} = &parse_hex($1);
|
||||||
}
|
}
|
||||||
@@ -226,7 +232,7 @@ foreach my $r (keys %rc) {
|
|||||||
$ifc{'broadcast'} = $1;
|
$ifc{'broadcast'} = $1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
local @n = split(/\./, $ifc{'netmask'});
|
my @n = split(/\./, $ifc{'netmask'});
|
||||||
$ifc{'broadcast'} = sprintf "%d.%d.%d.%d",
|
$ifc{'broadcast'} = sprintf "%d.%d.%d.%d",
|
||||||
($a[0] | ~int($n[0]))&0xff,
|
($a[0] | ~int($n[0]))&0xff,
|
||||||
($a[1] | ~int($n[1]))&0xff,
|
($a[1] | ~int($n[1]))&0xff,
|
||||||
@@ -240,7 +246,7 @@ foreach my $r (keys %rc) {
|
|||||||
$ifc{'file'} = "/etc/rc.conf";
|
$ifc{'file'} = "/etc/rc.conf";
|
||||||
|
|
||||||
# Check for IPv6 params
|
# Check for IPv6 params
|
||||||
local $v6 = $rc{'ipv6_ifconfig_'.$ifc{'fullname'}};
|
my $v6 = $rc{'ipv6_ifconfig_'.$ifc{'fullname'}};
|
||||||
if ($v6 =~ /^inet6\s+(\S+)/ || $v6 =~ /^([0-9a-f:]+)/) {
|
if ($v6 =~ /^inet6\s+(\S+)/ || $v6 =~ /^([0-9a-f:]+)/) {
|
||||||
$ifc{'address6'} = [ $1 ];
|
$ifc{'address6'} = [ $1 ];
|
||||||
}
|
}
|
||||||
@@ -255,7 +261,7 @@ foreach my $r (keys %rc) {
|
|||||||
foreach my $rr (sort { $a cmp $b } keys %rc) {
|
foreach my $rr (sort { $a cmp $b } keys %rc) {
|
||||||
if ($rr =~ /^ipv6_ifconfig_(\S+)_alias\d+$/ &&
|
if ($rr =~ /^ipv6_ifconfig_(\S+)_alias\d+$/ &&
|
||||||
$1 eq $ifc{'fullname'}) {
|
$1 eq $ifc{'fullname'}) {
|
||||||
local $v6 = $rc{$rr};
|
my $v6 = $rc{$rr};
|
||||||
if ($v6 =~ /^inet6\s+(\S+)/ || $v6 =~ /^([0-9a-f:]+)/) {
|
if ($v6 =~ /^inet6\s+(\S+)/ || $v6 =~ /^([0-9a-f:]+)/) {
|
||||||
push(@{$ifc{'address6'}}, $1);
|
push(@{$ifc{'address6'}}, $1);
|
||||||
}
|
}
|
||||||
@@ -274,7 +280,7 @@ return @rv;
|
|||||||
# Create or update a boot-time interface
|
# Create or update a boot-time interface
|
||||||
sub save_interface
|
sub save_interface
|
||||||
{
|
{
|
||||||
local $str;
|
my $str;
|
||||||
if ($_[0]->{'dhcp'}) {
|
if ($_[0]->{'dhcp'}) {
|
||||||
$str = "DHCP";
|
$str = "DHCP";
|
||||||
}
|
}
|
||||||
@@ -288,11 +294,11 @@ if ($_[0]->{'virtual'} eq '') {
|
|||||||
&save_rc_conf('ifconfig_'.$_[0]->{'name'}, $str);
|
&save_rc_conf('ifconfig_'.$_[0]->{'name'}, $str);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
local @boot = &boot_interfaces();
|
my @boot = &boot_interfaces();
|
||||||
local ($old) = grep { $_->{'fullname'} eq $_[0]->{'fullname'} } @boot;
|
my ($old) = grep { $_->{'fullname'} eq $_[0]->{'fullname'} } @boot;
|
||||||
if (!$old && $_[0]->{'virtual'} ne '') {
|
if (!$old && $_[0]->{'virtual'} ne '') {
|
||||||
# A new virtual interface .. pick a virtual number automaticlly
|
# A new virtual interface .. pick a virtual number automaticlly
|
||||||
local $b;
|
my $b;
|
||||||
$_[0]->{'virtual'} = 0;
|
$_[0]->{'virtual'} = 0;
|
||||||
foreach $b (&boot_interfaces()) {
|
foreach $b (&boot_interfaces()) {
|
||||||
if ($b->{'name'} eq $_[0]->{'name'} &&
|
if ($b->{'name'} eq $_[0]->{'name'} &&
|
||||||
@@ -309,8 +315,8 @@ else {
|
|||||||
|
|
||||||
# Update IPv6 settings
|
# Update IPv6 settings
|
||||||
if ($_[0]->{'virtual'} eq '') {
|
if ($_[0]->{'virtual'} eq '') {
|
||||||
local @a = @{$_[0]->{'address6'}};
|
my @a = @{$_[0]->{'address6'}};
|
||||||
local @n = @{$_[0]->{'netmask6'}};
|
my @n = @{$_[0]->{'netmask6'}};
|
||||||
if (@a || $_[0]->{'auto6'}) {
|
if (@a || $_[0]->{'auto6'}) {
|
||||||
&save_rc_conf('ipv6_enable', 'YES');
|
&save_rc_conf('ipv6_enable', 'YES');
|
||||||
}
|
}
|
||||||
@@ -323,7 +329,7 @@ if ($_[0]->{'virtual'} eq '') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Delete any IPv6 aliases
|
# Delete any IPv6 aliases
|
||||||
local %rc = &get_rc_conf();
|
my %rc = &get_rc_conf();
|
||||||
foreach my $r (keys %rc) {
|
foreach my $r (keys %rc) {
|
||||||
if ($r =~ /^ipv6_ifconfig_(\S+)_alias\d+$/ &&
|
if ($r =~ /^ipv6_ifconfig_(\S+)_alias\d+$/ &&
|
||||||
$1 eq $_[0]->{'fullname'}) {
|
$1 eq $_[0]->{'fullname'}) {
|
||||||
@@ -359,7 +365,7 @@ else {
|
|||||||
# Remove a virtual interface, and shift down all aliases above it
|
# Remove a virtual interface, and shift down all aliases above it
|
||||||
&save_rc_conf('ifconfig_'.$_[0]->{'name'}.'_alias'.$_[0]->{'virtual'});
|
&save_rc_conf('ifconfig_'.$_[0]->{'name'}.'_alias'.$_[0]->{'virtual'});
|
||||||
if (!$_[1]) {
|
if (!$_[1]) {
|
||||||
local ($b, %lastb);
|
my ($b, %lastb);
|
||||||
foreach $b (&boot_interfaces()) {
|
foreach $b (&boot_interfaces()) {
|
||||||
if ($b->{'name'} eq $_[0]->{'name'} &&
|
if ($b->{'name'} eq $_[0]->{'name'} &&
|
||||||
$b->{'virtual'} ne '' &&
|
$b->{'virtual'} ne '' &&
|
||||||
@@ -421,7 +427,7 @@ return &check_ipaddress($_[0]);
|
|||||||
# Returns a hashtable containing keys nameserver, domain, search & order
|
# Returns a hashtable containing keys nameserver, domain, search & order
|
||||||
sub get_dns_config
|
sub get_dns_config
|
||||||
{
|
{
|
||||||
local $dns;
|
my $dns;
|
||||||
&open_readfile(RESOLV, "/etc/resolv.conf");
|
&open_readfile(RESOLV, "/etc/resolv.conf");
|
||||||
while(<RESOLV>) {
|
while(<RESOLV>) {
|
||||||
s/\r|\n//g;
|
s/\r|\n//g;
|
||||||
@@ -438,8 +444,8 @@ while(<RESOLV>) {
|
|||||||
}
|
}
|
||||||
close(RESOLV);
|
close(RESOLV);
|
||||||
|
|
||||||
local @order;
|
my @order;
|
||||||
local $orderfile;
|
my $orderfile;
|
||||||
if (-r "/etc/nsswitch.conf") {
|
if (-r "/etc/nsswitch.conf") {
|
||||||
# FreeBSD 5.0 and later use nsswitch.conf
|
# FreeBSD 5.0 and later use nsswitch.conf
|
||||||
$orderfile = "/etc/nsswitch.conf";
|
$orderfile = "/etc/nsswitch.conf";
|
||||||
@@ -474,7 +480,7 @@ sub save_dns_config
|
|||||||
{
|
{
|
||||||
&lock_file("/etc/resolv.conf");
|
&lock_file("/etc/resolv.conf");
|
||||||
&open_readfile(RESOLV, "/etc/resolv.conf");
|
&open_readfile(RESOLV, "/etc/resolv.conf");
|
||||||
local @resolv = <RESOLV>;
|
my @resolv = <RESOLV>;
|
||||||
close(RESOLV);
|
close(RESOLV);
|
||||||
&open_tempfile(RESOLV, ">/etc/resolv.conf");
|
&open_tempfile(RESOLV, ">/etc/resolv.conf");
|
||||||
foreach (@{$_[0]->{'nameserver'}}) {
|
foreach (@{$_[0]->{'nameserver'}}) {
|
||||||
@@ -498,7 +504,7 @@ if (-r "/etc/nsswitch.conf") {
|
|||||||
# Save to new nsswitch.conf, for FreeBSD 5.0 and later
|
# Save to new nsswitch.conf, for FreeBSD 5.0 and later
|
||||||
&lock_file("/etc/nsswitch.conf");
|
&lock_file("/etc/nsswitch.conf");
|
||||||
&open_readfile(SWITCH, "/etc/nsswitch.conf");
|
&open_readfile(SWITCH, "/etc/nsswitch.conf");
|
||||||
local @switch = <SWITCH>;
|
my @switch = <SWITCH>;
|
||||||
close(SWITCH);
|
close(SWITCH);
|
||||||
&open_tempfile(SWITCH, ">/etc/nsswitch.conf");
|
&open_tempfile(SWITCH, ">/etc/nsswitch.conf");
|
||||||
foreach (@switch) {
|
foreach (@switch) {
|
||||||
@@ -536,7 +542,7 @@ if (-r "/etc/nsswitch.conf") {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Older FreeBSD's have fewer options
|
# Older FreeBSD's have fewer options
|
||||||
local $dnsopt = $_[0]->{'order'} =~ /dns/ ? 'dns' : 'bind';
|
my $dnsopt = $_[0]->{'order'} =~ /dns/ ? 'dns' : 'bind';
|
||||||
return &common_order_input("order", $_[0]->{'order'},
|
return &common_order_input("order", $_[0]->{'order'},
|
||||||
[ [ "hosts", "Hosts" ], [ $dnsopt, "DNS" ], [ "nis", "NIS" ] ]);
|
[ [ "hosts", "Hosts" ], [ $dnsopt, "DNS" ], [ "nis", "NIS" ] ]);
|
||||||
}
|
}
|
||||||
@@ -562,7 +568,7 @@ else {
|
|||||||
# get_hostname()
|
# get_hostname()
|
||||||
sub get_hostname
|
sub get_hostname
|
||||||
{
|
{
|
||||||
local %rc = &get_rc_conf();
|
my %rc = &get_rc_conf();
|
||||||
if ($rc{'hostname'}) {
|
if ($rc{'hostname'}) {
|
||||||
return $rc{'hostname'};
|
return $rc{'hostname'};
|
||||||
}
|
}
|
||||||
@@ -572,8 +578,9 @@ return &get_system_hostname();
|
|||||||
# save_hostname(name)
|
# save_hostname(name)
|
||||||
sub save_hostname
|
sub save_hostname
|
||||||
{
|
{
|
||||||
|
my ($hostname) = @_;
|
||||||
&lock_file("/etc/rc.conf");
|
&lock_file("/etc/rc.conf");
|
||||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
&system_logged("hostname ".quotemeta($hostname)." >/dev/null 2>&1");
|
||||||
&save_rc_conf('hostname', $_[0]);
|
&save_rc_conf('hostname', $_[0]);
|
||||||
&unlock_file("/etc/rc.conf");
|
&unlock_file("/etc/rc.conf");
|
||||||
undef(@main::get_system_hostname); # clear cache
|
undef(@main::get_system_hostname); # clear cache
|
||||||
@@ -586,30 +593,30 @@ return ( "/etc/defaults/rc.conf", "/etc/rc.conf" );
|
|||||||
|
|
||||||
sub routing_input
|
sub routing_input
|
||||||
{
|
{
|
||||||
local %rc = &get_rc_conf();
|
my %rc = &get_rc_conf();
|
||||||
|
|
||||||
# Default router
|
# Default router
|
||||||
local $defr = $rc{'defaultrouter'};
|
my $defr = $rc{'defaultrouter'};
|
||||||
print &ui_table_row($text{'routes_default'},
|
print &ui_table_row($text{'routes_default'},
|
||||||
&ui_opt_textbox("defr", $defr eq 'NO' ? '' : $defr, 20,
|
&ui_opt_textbox("defr", $defr eq 'NO' ? '' : $defr, 20,
|
||||||
$text{'routes_none'}));
|
$text{'routes_none'}));
|
||||||
|
|
||||||
if (&supports_address6()) {
|
if (&supports_address6()) {
|
||||||
# IPv6 efault router
|
# IPv6 efault router
|
||||||
local $defr = $rc{'ipv6_defaultrouter'};
|
my $defr = $rc{'ipv6_defaultrouter'};
|
||||||
print &ui_table_row($text{'routes_default6'},
|
print &ui_table_row($text{'routes_default6'},
|
||||||
&ui_opt_textbox("defr6", $defr eq 'NO' ? '' : $defr, 20,
|
&ui_opt_textbox("defr6", $defr eq 'NO' ? '' : $defr, 20,
|
||||||
$text{'routes_none'}));
|
$text{'routes_none'}));
|
||||||
}
|
}
|
||||||
|
|
||||||
# Act as router?
|
# Act as router?
|
||||||
local $gw = $rc{'gateway_enable'};
|
my $gw = $rc{'gateway_enable'};
|
||||||
print &ui_table_row($text{'routes_forward'},
|
print &ui_table_row($text{'routes_forward'},
|
||||||
&ui_radio("gw", $gw || 'NO', [ [ 'YES', $text{'yes'} ],
|
&ui_radio("gw", $gw || 'NO', [ [ 'YES', $text{'yes'} ],
|
||||||
[ 'NO', $text{'no'} ] ]));
|
[ 'NO', $text{'no'} ] ]));
|
||||||
|
|
||||||
# Run route discovery
|
# Run route discovery
|
||||||
local $rd = $rc{'router_enable'};
|
my $rd = $rc{'router_enable'};
|
||||||
print &ui_table_row($text{'routes_routed'},
|
print &ui_table_row($text{'routes_routed'},
|
||||||
&ui_radio("rd", $rd || 'NO', [ [ 'YES', $text{'yes'} ],
|
&ui_radio("rd", $rd || 'NO', [ [ 'YES', $text{'yes'} ],
|
||||||
[ 'NO', $text{'no'} ] ]));
|
[ 'NO', $text{'no'} ] ]));
|
||||||
@@ -635,9 +642,9 @@ if (&supports_address6()) {
|
|||||||
# save_rc_conf(name, value)
|
# save_rc_conf(name, value)
|
||||||
sub save_rc_conf
|
sub save_rc_conf
|
||||||
{
|
{
|
||||||
local $found;
|
my $found;
|
||||||
&open_readfile(CONF, "/etc/rc.conf");
|
&open_readfile(CONF, "/etc/rc.conf");
|
||||||
local @conf = <CONF>;
|
my @conf = <CONF>;
|
||||||
close(CONF);
|
close(CONF);
|
||||||
&open_tempfile(CONF, ">/etc/rc.conf");
|
&open_tempfile(CONF, ">/etc/rc.conf");
|
||||||
foreach (@conf) {
|
foreach (@conf) {
|
||||||
@@ -658,7 +665,7 @@ if (!$found && @_ > 1) {
|
|||||||
# get_rc_conf()
|
# get_rc_conf()
|
||||||
sub get_rc_conf
|
sub get_rc_conf
|
||||||
{
|
{
|
||||||
local ($file, %rv);
|
my ($file, %rv);
|
||||||
foreach $file ("/etc/defaults/rc.conf",
|
foreach $file ("/etc/defaults/rc.conf",
|
||||||
glob("/etc/rc.conf.d/*"),
|
glob("/etc/rc.conf.d/*"),
|
||||||
"/etc/rc.conf") {
|
"/etc/rc.conf") {
|
||||||
@@ -680,11 +687,11 @@ return %rv;
|
|||||||
# Apply the interface and routing settings
|
# Apply the interface and routing settings
|
||||||
sub apply_network
|
sub apply_network
|
||||||
{
|
{
|
||||||
local $oldpwd = &get_current_dir();
|
my $oldpwd = &get_current_dir();
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
# Take down all active alias interfaces, and any that no longer exist
|
# Take down all active alias interfaces, and any that no longer exist
|
||||||
local %boot = map { $_->{'fullname'}, $_ } &boot_interfaces();
|
my %boot = map { $_->{'fullname'}, $_ } &boot_interfaces();
|
||||||
foreach my $i (&active_interfaces()) {
|
foreach my $i (&active_interfaces()) {
|
||||||
if ($i->{'virtual'} ne '' || !$boot{$i->{'fullname'}}) {
|
if ($i->{'virtual'} ne '' || !$boot{$i->{'fullname'}}) {
|
||||||
&deactivate_interface($i);
|
&deactivate_interface($i);
|
||||||
@@ -699,7 +706,7 @@ chdir($oldpwd);
|
|||||||
# Returns 1 if managing IPv6 interfaces is supported
|
# Returns 1 if managing IPv6 interfaces is supported
|
||||||
sub supports_address6
|
sub supports_address6
|
||||||
{
|
{
|
||||||
local ($iface) = @_;
|
my ($iface) = @_;
|
||||||
return $gconfig{'os_version'} >= 8;
|
return $gconfig{'os_version'} >= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,7 +714,7 @@ return $gconfig{'os_version'} >= 8;
|
|||||||
# Returns a list of active routes
|
# Returns a list of active routes
|
||||||
sub list_routes
|
sub list_routes
|
||||||
{
|
{
|
||||||
local @rv;
|
my @rv;
|
||||||
&open_execute_command(ROUTES, "netstat -rn", 1, 1);
|
&open_execute_command(ROUTES, "netstat -rn", 1, 1);
|
||||||
while(<ROUTES>) {
|
while(<ROUTES>) {
|
||||||
s/\s+$//;
|
s/\s+$//;
|
||||||
@@ -741,7 +748,7 @@ return @rv;
|
|||||||
# settings.
|
# settings.
|
||||||
sub get_default_gateway
|
sub get_default_gateway
|
||||||
{
|
{
|
||||||
local %rc = &get_rc_conf();
|
my %rc = &get_rc_conf();
|
||||||
return ( $rc{'defaultrouter'} eq 'NO' ? undef : $rc{'defaultrouter'},
|
return ( $rc{'defaultrouter'} eq 'NO' ? undef : $rc{'defaultrouter'},
|
||||||
undef );
|
undef );
|
||||||
}
|
}
|
||||||
@@ -751,7 +758,7 @@ return ( $rc{'defaultrouter'} eq 'NO' ? undef : $rc{'defaultrouter'},
|
|||||||
# in the boot time settings.
|
# in the boot time settings.
|
||||||
sub set_default_gateway
|
sub set_default_gateway
|
||||||
{
|
{
|
||||||
local ($gw, $gwdev) = @_;
|
my ($gw, $gwdev) = @_;
|
||||||
&lock_file("/etc/rc.conf");
|
&lock_file("/etc/rc.conf");
|
||||||
&save_rc_conf('defaultrouter', $gw || "NO");
|
&save_rc_conf('defaultrouter', $gw || "NO");
|
||||||
&unlock_file("/etc/rc.conf");
|
&unlock_file("/etc/rc.conf");
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ $min_virtual_number = 1;
|
|||||||
# Parses the Gentoo net config file into an array of named sections
|
# Parses the Gentoo net config file into an array of named sections
|
||||||
sub parse_gentoo_net
|
sub parse_gentoo_net
|
||||||
{
|
{
|
||||||
local @rv;
|
my @rv;
|
||||||
local $sect;
|
my $sect;
|
||||||
local $lnum = 0;
|
my $lnum = 0;
|
||||||
open(CONF, "<".$gentoo_net_config);
|
open(CONF, "<".$gentoo_net_config);
|
||||||
while(<CONF>) {
|
while(<CONF>) {
|
||||||
s/\r|\n//g;
|
s/\r|\n//g;
|
||||||
@@ -21,7 +21,7 @@ while(<CONF>) {
|
|||||||
$sect = { 'name' => $1,
|
$sect = { 'name' => $1,
|
||||||
'line' => $lnum };
|
'line' => $lnum };
|
||||||
push(@rv, $sect);
|
push(@rv, $sect);
|
||||||
local $v = $2;
|
my $v = $2;
|
||||||
if ($v =~ /^(.*)\)/) {
|
if ($v =~ /^(.*)\)/) {
|
||||||
# Ends on same line
|
# Ends on same line
|
||||||
$sect->{'values'} = [ &split_gentoo_values("$1") ];
|
$sect->{'values'} = [ &split_gentoo_values("$1") ];
|
||||||
@@ -58,8 +58,8 @@ return @rv;
|
|||||||
# Update or create a Gentoo net config file section
|
# Update or create a Gentoo net config file section
|
||||||
sub save_gentoo_net
|
sub save_gentoo_net
|
||||||
{
|
{
|
||||||
local ($old, $new) = @_;
|
my ($old, $new) = @_;
|
||||||
local @lines;
|
my @lines;
|
||||||
if ($new) {
|
if ($new) {
|
||||||
push(@lines, $new->{'name'}."=(");
|
push(@lines, $new->{'name'}."=(");
|
||||||
foreach my $v (@{$new->{'values'}}) {
|
foreach my $v (@{$new->{'values'}}) {
|
||||||
@@ -67,7 +67,7 @@ if ($new) {
|
|||||||
}
|
}
|
||||||
push(@lines, ")");
|
push(@lines, ")");
|
||||||
}
|
}
|
||||||
local $lref = &read_file_lines($gentoo_net_config);
|
my $lref = &read_file_lines($gentoo_net_config);
|
||||||
if ($old && $new) {
|
if ($old && $new) {
|
||||||
# Replace section
|
# Replace section
|
||||||
splice(@$lref, $old->{'line'}, $old->{'eline'}-$old->{'line'}+1,
|
splice(@$lref, $old->{'line'}, $old->{'eline'}-$old->{'line'}+1,
|
||||||
@@ -91,8 +91,8 @@ elsif (!$old && $new) {
|
|||||||
# Splits a string like "foo bar" "smeg spod" into an array
|
# Splits a string like "foo bar" "smeg spod" into an array
|
||||||
sub split_gentoo_values
|
sub split_gentoo_values
|
||||||
{
|
{
|
||||||
local ($str) = @_;
|
my ($str) = @_;
|
||||||
local @rv;
|
my @rv;
|
||||||
while($str =~ /^\s*"([^"]+)",?(.*)/) {
|
while($str =~ /^\s*"([^"]+)",?(.*)/) {
|
||||||
push(@rv, $1);
|
push(@rv, $1);
|
||||||
$str = $2;
|
$str = $2;
|
||||||
@@ -104,14 +104,14 @@ return @rv;
|
|||||||
# Returns a list of interfaces brought up at boot time
|
# Returns a list of interfaces brought up at boot time
|
||||||
sub boot_interfaces
|
sub boot_interfaces
|
||||||
{
|
{
|
||||||
local @rv;
|
my @rv;
|
||||||
foreach my $g (&parse_gentoo_net()) {
|
foreach my $g (&parse_gentoo_net()) {
|
||||||
if ($g->{'name'} =~ /^config_(\S+)/) {
|
if ($g->{'name'} =~ /^config_(\S+)/) {
|
||||||
local $gn = $1;
|
my $gn = $1;
|
||||||
local $n = 0;
|
my $n = 0;
|
||||||
foreach my $v (@{$g->{'values'}}) {
|
foreach my $v (@{$g->{'values'}}) {
|
||||||
# An interface definition
|
# An interface definition
|
||||||
local $iface = { 'name' => $gn,
|
my $iface = { 'name' => $gn,
|
||||||
'up' => 1,
|
'up' => 1,
|
||||||
'edit' => 1,
|
'edit' => 1,
|
||||||
'index' => scalar(@rv) };
|
'index' => scalar(@rv) };
|
||||||
@@ -122,7 +122,7 @@ foreach my $g (&parse_gentoo_net()) {
|
|||||||
$iface->{'fullname'} = $gn.":".$n;
|
$iface->{'fullname'} = $gn.":".$n;
|
||||||
$iface->{'virtual'} = $n;
|
$iface->{'virtual'} = $n;
|
||||||
}
|
}
|
||||||
local @w = split(/\s+/, $v);
|
my @w = split(/\s+/, $v);
|
||||||
if ($w[0] eq "dhcp") {
|
if ($w[0] eq "dhcp") {
|
||||||
$iface->{'dhcp'} = 1;
|
$iface->{'dhcp'} = 1;
|
||||||
}
|
}
|
||||||
@@ -160,8 +160,8 @@ foreach my $g (&parse_gentoo_net()) {
|
|||||||
}
|
}
|
||||||
elsif ($g->{'name'} =~ /^routes_(\S+)/) {
|
elsif ($g->{'name'} =~ /^routes_(\S+)/) {
|
||||||
# A route definition for an interface
|
# A route definition for an interface
|
||||||
local ($iface) = grep { $_->{'fullname'} eq $1 } @rv;
|
my ($iface) = grep { $_->{'fullname'} eq $1 } @rv;
|
||||||
local $spec = $g->{'values'}->[0];
|
my $spec = $g->{'values'}->[0];
|
||||||
if ($iface) {
|
if ($iface) {
|
||||||
if ($spec =~ /default\s+via\s+([0-9\.]+)/ ||
|
if ($spec =~ /default\s+via\s+([0-9\.]+)/ ||
|
||||||
$spec =~ /default\s+([0-9\.]+)/) {
|
$spec =~ /default\s+([0-9\.]+)/) {
|
||||||
@@ -179,11 +179,11 @@ return @rv;
|
|||||||
# Create or update a boot-time interface
|
# Create or update a boot-time interface
|
||||||
sub save_interface
|
sub save_interface
|
||||||
{
|
{
|
||||||
local ($iface) = @_;
|
my ($iface) = @_;
|
||||||
&lock_file($gentoo_net_config);
|
&lock_file($gentoo_net_config);
|
||||||
|
|
||||||
# Build the interface line
|
# Build the interface line
|
||||||
local @w;
|
my @w;
|
||||||
if ($iface->{'dhcp'}) {
|
if ($iface->{'dhcp'}) {
|
||||||
push(@w, "dhcp");
|
push(@w, "dhcp");
|
||||||
}
|
}
|
||||||
@@ -201,8 +201,8 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Find the current block for this interface
|
# Find the current block for this interface
|
||||||
local @gentoo = &parse_gentoo_net();
|
my @gentoo = &parse_gentoo_net();
|
||||||
local ($g) = grep { $_->{'name'} eq 'config_'.$iface->{'name'} } @gentoo;
|
my ($g) = grep { $_->{'name'} eq 'config_'.$iface->{'name'} } @gentoo;
|
||||||
if ($g) {
|
if ($g) {
|
||||||
# Found it .. append or replace
|
# Found it .. append or replace
|
||||||
while (!$g->{'values'}->[$iface->{'virtual'}]) {
|
while (!$g->{'values'}->[$iface->{'virtual'}]) {
|
||||||
@@ -224,12 +224,12 @@ else {
|
|||||||
# Delete a boot-time interface
|
# Delete a boot-time interface
|
||||||
sub delete_interface
|
sub delete_interface
|
||||||
{
|
{
|
||||||
local ($iface) = @_;
|
my ($iface) = @_;
|
||||||
|
|
||||||
# Find the current block for this interface
|
# Find the current block for this interface
|
||||||
&lock_file($gentoo_net_config);
|
&lock_file($gentoo_net_config);
|
||||||
local @gentoo = &parse_gentoo_net();
|
my @gentoo = &parse_gentoo_net();
|
||||||
local ($g) = grep { $_->{'name'} eq 'config_'.$iface->{'name'} } @gentoo;
|
my ($g) = grep { $_->{'name'} eq 'config_'.$iface->{'name'} } @gentoo;
|
||||||
if ($g) {
|
if ($g) {
|
||||||
# Found it .. take out the interface
|
# Found it .. take out the interface
|
||||||
if ($iface->{'virtual'} == scalar(@{$g->{'values'}})-1) {
|
if ($iface->{'virtual'} == scalar(@{$g->{'values'}})-1) {
|
||||||
@@ -266,7 +266,7 @@ return &check_ipaddress($_[0]);
|
|||||||
# get_hostname()
|
# get_hostname()
|
||||||
sub get_hostname
|
sub get_hostname
|
||||||
{
|
{
|
||||||
local %host;
|
my %host;
|
||||||
&read_env_file("/etc/conf.d/hostname", \%host);
|
&read_env_file("/etc/conf.d/hostname", \%host);
|
||||||
if ($host{'HOSTNAME'}) {
|
if ($host{'HOSTNAME'}) {
|
||||||
return $host{'HOSTNAME'};
|
return $host{'HOSTNAME'};
|
||||||
@@ -277,19 +277,20 @@ return &get_system_hostname();
|
|||||||
# save_hostname(name)
|
# save_hostname(name)
|
||||||
sub save_hostname
|
sub save_hostname
|
||||||
{
|
{
|
||||||
local %host;
|
my ($hostname) = @_;
|
||||||
|
my %host;
|
||||||
&read_env_file("/etc/conf.d/hostname", \%host);
|
&read_env_file("/etc/conf.d/hostname", \%host);
|
||||||
$host{'HOSTNAME'} = $_[0];
|
$host{'HOSTNAME'} = $hostname;
|
||||||
&write_env_file("/etc/conf.d/hostname", \%host);
|
&write_env_file("/etc/conf.d/hostname", \%host);
|
||||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
&system_logged("hostname ".quotemeta($hostname)." >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
# routing_input()
|
# routing_input()
|
||||||
# Prints HTML for editing routing settings
|
# Prints HTML for editing routing settings
|
||||||
sub routing_input
|
sub routing_input
|
||||||
{
|
{
|
||||||
local ($gw, $dev) = &get_default_gateway();
|
my ($gw, $dev) = &get_default_gateway();
|
||||||
local @ifaces = grep { $_->{'virtual'} eq '' } &boot_interfaces();
|
my @ifaces = grep { $_->{'virtual'} eq '' } &boot_interfaces();
|
||||||
print &ui_table_row($text{'routes_def'},
|
print &ui_table_row($text{'routes_def'},
|
||||||
&ui_radio("route_def", $gw ? 0 : 1,
|
&ui_radio("route_def", $gw ? 0 : 1,
|
||||||
[ [ 1, $text{'routes_nogw'}."<br>" ],
|
[ [ 1, $text{'routes_nogw'}."<br>" ],
|
||||||
@@ -331,8 +332,8 @@ closedir(DIR);
|
|||||||
# settings.
|
# settings.
|
||||||
sub get_default_gateway
|
sub get_default_gateway
|
||||||
{
|
{
|
||||||
local @ifaces = &boot_interfaces();
|
my @ifaces = &boot_interfaces();
|
||||||
local ($iface) = grep { $_->{'gateway'} } @ifaces;
|
my ($iface) = grep { $_->{'gateway'} } @ifaces;
|
||||||
if ($iface) {
|
if ($iface) {
|
||||||
return ( $iface->{'gateway'}, $iface->{'name'} );
|
return ( $iface->{'gateway'}, $iface->{'name'} );
|
||||||
}
|
}
|
||||||
@@ -346,10 +347,10 @@ else {
|
|||||||
# in the boot time settings.
|
# in the boot time settings.
|
||||||
sub set_default_gateway
|
sub set_default_gateway
|
||||||
{
|
{
|
||||||
local ($gw, $dev) = @_;
|
my ($gw, $dev) = @_;
|
||||||
&lock_file($gentoo_net_config);
|
&lock_file($gentoo_net_config);
|
||||||
local @ifaces = &boot_interfaces();
|
my @ifaces = &boot_interfaces();
|
||||||
local ($iface) = grep { $_->{'gateway'} } @ifaces;
|
my ($iface) = grep { $_->{'gateway'} } @ifaces;
|
||||||
if ($iface && $gw) {
|
if ($iface && $gw) {
|
||||||
# Change existing default route
|
# Change existing default route
|
||||||
$g = $iface->{'gentoogw'};
|
$g = $iface->{'gentoogw'};
|
||||||
@@ -375,7 +376,7 @@ elsif (!$iface && $gw) {
|
|||||||
# Returns 1 if managing IPv6 interfaces is supported
|
# Returns 1 if managing IPv6 interfaces is supported
|
||||||
sub supports_address6
|
sub supports_address6
|
||||||
{
|
{
|
||||||
local ($iface) = @_;
|
my ($iface) = @_;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
107
net/macos-lib.pl
107
net/macos-lib.pl
@@ -19,7 +19,7 @@ while(<IFC>) {
|
|||||||
}
|
}
|
||||||
close(IFC);
|
close(IFC);
|
||||||
foreach $l (@lines) {
|
foreach $l (@lines) {
|
||||||
local %ifc;
|
my %ifc;
|
||||||
$l =~ /^([^:\s]+):/;
|
$l =~ /^([^:\s]+):/;
|
||||||
$ifc{'name'} = $ifc{'fullname'} = $1;
|
$ifc{'name'} = $ifc{'fullname'} = $1;
|
||||||
if ($l =~ /^(\S+):(\d+):\s/) { $ifc{'virtual'} = $2; }
|
if ($l =~ /^(\S+):(\d+):\s/) { $ifc{'virtual'} = $2; }
|
||||||
@@ -45,9 +45,9 @@ foreach $l (@lines) {
|
|||||||
push(@rv, \%ifc);
|
push(@rv, \%ifc);
|
||||||
|
|
||||||
# Add aliases as virtual interfaces
|
# Add aliases as virtual interfaces
|
||||||
local $v = 0;
|
my $v = 0;
|
||||||
while($l =~ s/inet\s+(\S+)\s+netmask\s+(\S+)\s+broadcast\s+(\S+)//) {
|
while($l =~ s/inet\s+(\S+)\s+netmask\s+(\S+)\s+broadcast\s+(\S+)//) {
|
||||||
local %vifc = %ifc;
|
my %vifc = %ifc;
|
||||||
$vifc{'address'} = $1;
|
$vifc{'address'} = $1;
|
||||||
$vifc{'netmask'} = &parse_hex($2);
|
$vifc{'netmask'} = &parse_hex($2);
|
||||||
$vifc{'broadcast'} = $3;
|
$vifc{'broadcast'} = $3;
|
||||||
@@ -66,9 +66,9 @@ return @rv;
|
|||||||
# Create or modify an interface
|
# Create or modify an interface
|
||||||
sub activate_interface
|
sub activate_interface
|
||||||
{
|
{
|
||||||
local %act;
|
my %act;
|
||||||
map { $act{$_->{'fullname'}} = $_ } &active_interfaces();
|
map { $act{$_->{'fullname'}} = $_ } &active_interfaces();
|
||||||
local $old = $act{$_[0]->{'fullname'}};
|
my $old = $act{$_[0]->{'fullname'}};
|
||||||
$act{$_[0]->{'fullname'}} = $_[0];
|
$act{$_[0]->{'fullname'}} = $_[0];
|
||||||
&interface_sync(\%act, $_[0]->{'name'}, $_[0]->{'fullname'});
|
&interface_sync(\%act, $_[0]->{'name'}, $_[0]->{'fullname'});
|
||||||
}
|
}
|
||||||
@@ -77,8 +77,8 @@ $act{$_[0]->{'fullname'}} = $_[0];
|
|||||||
# Deactive an interface
|
# Deactive an interface
|
||||||
sub deactivate_interface
|
sub deactivate_interface
|
||||||
{
|
{
|
||||||
local %act;
|
my %act;
|
||||||
local @act = &active_interfaces();
|
my @act = &active_interfaces();
|
||||||
if ($_[0]->{'virtual'} eq '') {
|
if ($_[0]->{'virtual'} eq '') {
|
||||||
@act = grep { $_->{'name'} ne $_[0]->{'name'} } @act;
|
@act = grep { $_->{'name'} ne $_[0]->{'name'} } @act;
|
||||||
}
|
}
|
||||||
@@ -89,26 +89,28 @@ map { $act{$_->{'fullname'}} = $_ } @act;
|
|||||||
&interface_sync(\%act, $_[0]->{'name'}, $_[0]->{'fullname'});
|
&interface_sync(\%act, $_[0]->{'name'}, $_[0]->{'fullname'});
|
||||||
}
|
}
|
||||||
|
|
||||||
# interface_sync(interfaces, name, changee)
|
# interface_sync(interfaces, name, change)
|
||||||
sub interface_sync
|
sub interface_sync
|
||||||
{
|
{
|
||||||
|
my ($act, $name, $change) = @_;
|
||||||
|
|
||||||
# Remove all IP addresses except for the primary one (unless it is being edited)
|
# Remove all IP addresses except for the primary one (unless it is being edited)
|
||||||
local $pri = $_[0]->{$_[1]};
|
my $pri = $act->{$name};
|
||||||
local $ifconfig = &has_command("ifconfig");
|
my $ifconfig = &has_command("ifconfig");
|
||||||
while(1) {
|
while(1) {
|
||||||
local $out;
|
my $out;
|
||||||
&execute_command("$ifconfig $_[1]", undef, \$out);
|
&execute_command("$ifconfig ".quotemeta($name), undef, \$out);
|
||||||
last if ($out !~ /([\000-\377]*)\s+inet\s+(\d+\.\d+\.\d+\.\d+)/);
|
last if ($out !~ /([\000-\377]*)\s+inet\s+(\d+\.\d+\.\d+\.\d+)/);
|
||||||
last if ($2 eq $pri->{'address'} && $_[2] ne $pri->{'fullname'});
|
last if ($2 eq $pri->{'address'} && $change ne $pri->{'fullname'});
|
||||||
&system_logged("$ifconfig $_[1] delete $2 >/dev/null 2>&1");
|
&system_logged("$ifconfig ".quotemeta($name)." delete $2 >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add them back again, except for the primary unless it is being changed
|
# Add them back again, except for the primary unless it is being changed
|
||||||
foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
||||||
grep { $_->{'name'} eq $_[1] } values(%{$_[0]})) {
|
grep { $_->{'name'} eq $_[1] } values(%$act)) {
|
||||||
next if ($a->{'fullname'} eq $pri->{'fullname'} &&
|
next if ($a->{'fullname'} eq $pri->{'fullname'} &&
|
||||||
$_[2] ne $pri->{'fullname'});
|
$change ne $pri->{'fullname'});
|
||||||
local $cmd = "$ifconfig $a->{'name'}";
|
my $cmd = "$ifconfig ".quotemeta($a->{'name'});
|
||||||
if ($a->{'virtual'} ne '') {
|
if ($a->{'virtual'} ne '') {
|
||||||
$cmd .= " alias $a->{'address'}";
|
$cmd .= " alias $a->{'address'}";
|
||||||
}
|
}
|
||||||
@@ -118,14 +120,18 @@ foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
|||||||
if ($a->{'netmask'}) { $cmd .= " netmask $a->{'netmask'}"; }
|
if ($a->{'netmask'}) { $cmd .= " netmask $a->{'netmask'}"; }
|
||||||
if ($a->{'broadcast'}) { $cmd .= " broadcast $a->{'broadcast'}"; }
|
if ($a->{'broadcast'}) { $cmd .= " broadcast $a->{'broadcast'}"; }
|
||||||
if ($a->{'mtu'}) { $cmd .= " mtu $a->{'mtu'}"; }
|
if ($a->{'mtu'}) { $cmd .= " mtu $a->{'mtu'}"; }
|
||||||
local $out = &backquote_logged("$cmd 2>&1");
|
my $out = &backquote_logged("$cmd 2>&1");
|
||||||
#if ($? && $out !~ /file exists/i) {
|
#if ($? && $out !~ /file exists/i) {
|
||||||
if ($?) {
|
&error($out) if ($?);
|
||||||
&error($out);
|
|
||||||
}
|
|
||||||
if ($a->{'virtual'} eq '') {
|
if ($a->{'virtual'} eq '') {
|
||||||
if ($a->{'up'}) { $out = &backquote_logged("$ifconfig $a->{'name'} up 2>&1"); }
|
if ($a->{'up'}) {
|
||||||
else { $out = &backquote_logged("$ifconfig $a->{'name'} down 2>&1"); }
|
$out = &backquote_logged(
|
||||||
|
"$ifconfig ".quotemeta($a->{'name'})." up 2>&1");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$out = &backquote_logged(
|
||||||
|
"$ifconfig ".quotemeta($a->{'name'})." down 2>&1");
|
||||||
|
}
|
||||||
&error($out) if ($?);
|
&error($out) if ($?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,18 +141,18 @@ foreach $a (sort { $a->{'fullname'} cmp $b->{'fullname'} }
|
|||||||
# Returns a list of interfaces brought up at boot time
|
# Returns a list of interfaces brought up at boot time
|
||||||
sub boot_interfaces
|
sub boot_interfaces
|
||||||
{
|
{
|
||||||
local @rv;
|
my @rv;
|
||||||
local %virtual_count;
|
my %virtual_count;
|
||||||
local $lnum = 0;
|
my $lnum = 0;
|
||||||
&open_readfile(IFTAB, $iftab_file);
|
&open_readfile(IFTAB, $iftab_file);
|
||||||
while(<IFTAB>) {
|
while(<IFTAB>) {
|
||||||
s/\r|\n//g;
|
s/\r|\n//g;
|
||||||
s/#.*$//;
|
s/#.*$//;
|
||||||
if (/^(\S+)\s+(inet)\s+(.*)/i) {
|
if (/^(\S+)\s+(inet)\s+(.*)/i) {
|
||||||
local $ifc = { 'name' => $1,
|
my $ifc = { 'name' => $1,
|
||||||
'index' => scalar(@rv),
|
'index' => scalar(@rv),
|
||||||
'line' => $lnum };
|
'line' => $lnum };
|
||||||
local $opts = $3;
|
my $opts = $3;
|
||||||
next if ($opts =~ /^!/);
|
next if ($opts =~ /^!/);
|
||||||
$ifc->{'edit'} = 1 if ($ifc->{'name'} =~ /^[a-z]+[0-9]*$/i);
|
$ifc->{'edit'} = 1 if ($ifc->{'name'} =~ /^[a-z]+[0-9]*$/i);
|
||||||
if ($opts eq "-AUTOMATIC-" || $opts eq "-BOOTP-") {
|
if ($opts eq "-AUTOMATIC-" || $opts eq "-BOOTP-") {
|
||||||
@@ -162,7 +168,7 @@ while(<IFTAB>) {
|
|||||||
if ($opts =~ /^([0-9\.]+)/) {
|
if ($opts =~ /^([0-9\.]+)/) {
|
||||||
$ifc->{'address'} = $1;
|
$ifc->{'address'} = $1;
|
||||||
}
|
}
|
||||||
local @a = split(/\./, $ifc->{'address'});
|
my @a = split(/\./, $ifc->{'address'});
|
||||||
if ($opts =~ /netmask\s+([0-9\.]+)/) {
|
if ($opts =~ /netmask\s+([0-9\.]+)/) {
|
||||||
$ifc->{'netmask'} = $1;
|
$ifc->{'netmask'} = $1;
|
||||||
}
|
}
|
||||||
@@ -175,7 +181,7 @@ while(<IFTAB>) {
|
|||||||
$ifc->{'broadcast'} = $1;
|
$ifc->{'broadcast'} = $1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
local @n = split(/\./, $ifc->{'netmask'});
|
my @n = split(/\./, $ifc->{'netmask'});
|
||||||
$ifc->{'broadcast'} = sprintf "%d.%d.%d.%d",
|
$ifc->{'broadcast'} = sprintf "%d.%d.%d.%d",
|
||||||
($a[0] | ~int($n[0]))&0xff,
|
($a[0] | ~int($n[0]))&0xff,
|
||||||
($a[1] | ~int($n[1]))&0xff,
|
($a[1] | ~int($n[1]))&0xff,
|
||||||
@@ -210,7 +216,7 @@ return @rv;
|
|||||||
# Create or update a boot-time interface
|
# Create or update a boot-time interface
|
||||||
sub save_interface
|
sub save_interface
|
||||||
{
|
{
|
||||||
local $str = "$_[0]->{'name'} inet";
|
my $str = "$_[0]->{'name'} inet";
|
||||||
if ($_[0]->{'dhcp'}) {
|
if ($_[0]->{'dhcp'}) {
|
||||||
$str .= " -DHCP-";
|
$str .= " -DHCP-";
|
||||||
}
|
}
|
||||||
@@ -230,9 +236,9 @@ else {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
&lock_file($iftab_file);
|
&lock_file($iftab_file);
|
||||||
local $lref = &read_file_lines($iftab_file);
|
my $lref = &read_file_lines($iftab_file);
|
||||||
local @boot = &boot_interfaces();
|
my @boot = &boot_interfaces();
|
||||||
local ($old) = grep { $_->{'fullname'} eq $_[0]->{'fullname'} } @boot;
|
my ($old) = grep { $_->{'fullname'} eq $_[0]->{'fullname'} } @boot;
|
||||||
if ($old) {
|
if ($old) {
|
||||||
# Replacing existing interface
|
# Replacing existing interface
|
||||||
$lref->[$old->{'line'}] = $str;
|
$lref->[$old->{'line'}] = $str;
|
||||||
@@ -262,7 +268,7 @@ else {
|
|||||||
sub delete_interface
|
sub delete_interface
|
||||||
{
|
{
|
||||||
&lock_file($iftab_file);
|
&lock_file($iftab_file);
|
||||||
local $lref = &read_file_lines($iftab_file);
|
my $lref = &read_file_lines($iftab_file);
|
||||||
splice(@$lref, $_[0]->{'line'}, 1);
|
splice(@$lref, $_[0]->{'line'}, 1);
|
||||||
&flush_file_lines();
|
&flush_file_lines();
|
||||||
&unlock_file($iftab_file);
|
&unlock_file($iftab_file);
|
||||||
@@ -309,7 +315,7 @@ return &check_ipaddress($_[0]);
|
|||||||
# Returns a hashtable containing keys nameserver, domain, search & order
|
# Returns a hashtable containing keys nameserver, domain, search & order
|
||||||
sub get_dns_config
|
sub get_dns_config
|
||||||
{
|
{
|
||||||
local $dns;
|
my $dns;
|
||||||
&open_readfile(RESOLV, "/etc/resolv.conf");
|
&open_readfile(RESOLV, "/etc/resolv.conf");
|
||||||
while(<RESOLV>) {
|
while(<RESOLV>) {
|
||||||
s/\r|\n//g;
|
s/\r|\n//g;
|
||||||
@@ -335,7 +341,7 @@ sub save_dns_config
|
|||||||
{
|
{
|
||||||
&lock_file("/etc/resolv.conf");
|
&lock_file("/etc/resolv.conf");
|
||||||
&open_readfile(RESOLV, "/etc/resolv.conf");
|
&open_readfile(RESOLV, "/etc/resolv.conf");
|
||||||
local @resolv = <RESOLV>;
|
my @resolv = <RESOLV>;
|
||||||
close(RESOLV);
|
close(RESOLV);
|
||||||
&open_tempfile(RESOLV, ">/etc/resolv.conf");
|
&open_tempfile(RESOLV, ">/etc/resolv.conf");
|
||||||
foreach (@{$_[0]->{'nameserver'}}) {
|
foreach (@{$_[0]->{'nameserver'}}) {
|
||||||
@@ -375,7 +381,7 @@ return undef;
|
|||||||
# get_hostname()
|
# get_hostname()
|
||||||
sub get_hostname
|
sub get_hostname
|
||||||
{
|
{
|
||||||
local $hc = &read_hostconfig();
|
my $hc = &read_hostconfig();
|
||||||
if ($hc->{'HOSTNAME'}) {
|
if ($hc->{'HOSTNAME'}) {
|
||||||
return $hc->{'HOSTNAME'};
|
return $hc->{'HOSTNAME'};
|
||||||
}
|
}
|
||||||
@@ -385,9 +391,10 @@ return &get_system_hostname();
|
|||||||
# save_hostname(name)
|
# save_hostname(name)
|
||||||
sub save_hostname
|
sub save_hostname
|
||||||
{
|
{
|
||||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
my ($hostname) = @_;
|
||||||
|
&system_logged("hostname ".quotemeta($hostname)." >/dev/null 2>&1");
|
||||||
&lock_file($hostconfig);
|
&lock_file($hostconfig);
|
||||||
&set_hostconfig("HOSTNAME", $_[0]);
|
&set_hostconfig("HOSTNAME", $hostname);
|
||||||
&unlock_file($hostconfig);
|
&unlock_file($hostconfig);
|
||||||
undef(@main::get_system_hostname); # clear cache
|
undef(@main::get_system_hostname); # clear cache
|
||||||
}
|
}
|
||||||
@@ -399,9 +406,9 @@ return ( $hostconfig_file );
|
|||||||
|
|
||||||
sub routing_input
|
sub routing_input
|
||||||
{
|
{
|
||||||
local $hc = &read_hostconfig();
|
my $hc = &read_hostconfig();
|
||||||
local $r = $hc->{'ROUTER'};
|
my $r = $hc->{'ROUTER'};
|
||||||
local $mode = $r eq "-AUTOMATIC-" ? 1 : $r ? 2 : 0;
|
my $mode = $r eq "-AUTOMATIC-" ? 1 : $r ? 2 : 0;
|
||||||
|
|
||||||
# Default router
|
# Default router
|
||||||
print &ui_table_row($text{'routes_default'},
|
print &ui_table_row($text{'routes_default'},
|
||||||
@@ -411,14 +418,14 @@ print &ui_table_row($text{'routes_default'},
|
|||||||
[ 2, &ui_textbox("router", $mode == 2 ? $r : "", 20) ] ]));
|
[ 2, &ui_textbox("router", $mode == 2 ? $r : "", 20) ] ]));
|
||||||
|
|
||||||
# Forward traffic?
|
# Forward traffic?
|
||||||
local $f = $hc->{'IPFORWARDING'};
|
my $f = $hc->{'IPFORWARDING'};
|
||||||
print &ui_table_row($text{'routes_forward'},
|
print &ui_table_row($text{'routes_forward'},
|
||||||
&ui_yesno_radio("forward", $f eq '-YES-'));
|
&ui_yesno_radio("forward", $f eq '-YES-'));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parse_routing
|
sub parse_routing
|
||||||
{
|
{
|
||||||
local $r;
|
my $r;
|
||||||
if ($in{'router_mode'} == 0) {
|
if ($in{'router_mode'} == 0) {
|
||||||
$r = undef;
|
$r = undef;
|
||||||
}
|
}
|
||||||
@@ -439,8 +446,8 @@ else {
|
|||||||
# Add or update an entry in the hostconfig file
|
# Add or update an entry in the hostconfig file
|
||||||
sub set_hostconfig
|
sub set_hostconfig
|
||||||
{
|
{
|
||||||
local $lref = &read_file_lines($hostconfig_file);
|
my $lref = &read_file_lines($hostconfig_file);
|
||||||
local ($i, $found);
|
my ($i, $found);
|
||||||
for($i=0; $i<@$lref; $i++) {
|
for($i=0; $i<@$lref; $i++) {
|
||||||
if ($lref->[$i] =~ /^(\S+)\s*=/ && lc($1) eq lc($_[0])) {
|
if ($lref->[$i] =~ /^(\S+)\s*=/ && lc($1) eq lc($_[0])) {
|
||||||
$lref->[$i] = "$_[0]=$_[1]";
|
$lref->[$i] = "$_[0]=$_[1]";
|
||||||
@@ -457,7 +464,7 @@ if (!$found) {
|
|||||||
# Returns a hash of hostconfig file values
|
# Returns a hash of hostconfig file values
|
||||||
sub read_hostconfig
|
sub read_hostconfig
|
||||||
{
|
{
|
||||||
local %rv;
|
my %rv;
|
||||||
&open_readfile(HOST, $hostconfig_file);
|
&open_readfile(HOST, $hostconfig_file);
|
||||||
while(<HOST>) {
|
while(<HOST>) {
|
||||||
s/\r|\n//g;
|
s/\r|\n//g;
|
||||||
@@ -476,7 +483,7 @@ return \%rv;
|
|||||||
#{
|
#{
|
||||||
#system("killall ipconfigd && ipconfigd </dev/null >/dev/null 2>&1 &");
|
#system("killall ipconfigd && ipconfigd </dev/null >/dev/null 2>&1 &");
|
||||||
#system("ipconfig waitall >/dev/null 2>&1");
|
#system("ipconfig waitall >/dev/null 2>&1");
|
||||||
#local $hc = &read_hostconfig();
|
#my $hc = &read_hostconfig();
|
||||||
#system("killall -HUP netinfod >/dev/null 2>&1");
|
#system("killall -HUP netinfod >/dev/null 2>&1");
|
||||||
#system("killall -HUP lookupd >/dev/null 2>&1");
|
#system("killall -HUP lookupd >/dev/null 2>&1");
|
||||||
#}
|
#}
|
||||||
@@ -485,7 +492,7 @@ return \%rv;
|
|||||||
# Returns 1 if managing IPv6 interfaces is supported
|
# Returns 1 if managing IPv6 interfaces is supported
|
||||||
sub supports_address6
|
sub supports_address6
|
||||||
{
|
{
|
||||||
local ($iface) = @_;
|
my ($iface) = @_;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ return $_[0] =~ /^(eth|em)/;
|
|||||||
# Returns 1 if managing IPv6 interfaces is supported
|
# Returns 1 if managing IPv6 interfaces is supported
|
||||||
sub supports_address6
|
sub supports_address6
|
||||||
{
|
{
|
||||||
local ($iface) = @_;
|
my ($iface) = @_;
|
||||||
return !$iface || $iface->{'virtual'} eq '';
|
return !$iface || $iface->{'virtual'} eq '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ return &check_ipaddress_any($_[0]);
|
|||||||
# get_hostname()
|
# get_hostname()
|
||||||
sub get_hostname
|
sub get_hostname
|
||||||
{
|
{
|
||||||
local $hn = &read_file_contents("/etc/hostname");
|
my $hn = &read_file_contents("/etc/hostname");
|
||||||
$hn =~ s/\r|\n//g;
|
$hn =~ s/\r|\n//g;
|
||||||
if ($hn) {
|
if ($hn) {
|
||||||
return $hn;
|
return $hn;
|
||||||
@@ -376,8 +376,9 @@ return &get_system_hostname();
|
|||||||
# save_hostname(name)
|
# save_hostname(name)
|
||||||
sub save_hostname
|
sub save_hostname
|
||||||
{
|
{
|
||||||
local (%conf, $f);
|
my ($hostname) = @_;
|
||||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
my (%conf, $f);
|
||||||
|
&system_logged("hostname ".quotemeta($hostname)." >/dev/null 2>&1");
|
||||||
foreach $f ("/etc/hostname", "/etc/HOSTNAME", "/etc/mailname") {
|
foreach $f ("/etc/hostname", "/etc/HOSTNAME", "/etc/mailname") {
|
||||||
if (-r $f) {
|
if (-r $f) {
|
||||||
&open_lock_tempfile(HOST, ">$f");
|
&open_lock_tempfile(HOST, ">$f");
|
||||||
@@ -391,7 +392,7 @@ undef(@main::get_system_hostname); # clear cache
|
|||||||
# get_domainname()
|
# get_domainname()
|
||||||
sub get_domainname
|
sub get_domainname
|
||||||
{
|
{
|
||||||
local $d;
|
my $d;
|
||||||
&execute_command("domainname", undef, \$d, undef);
|
&execute_command("domainname", undef, \$d, undef);
|
||||||
chop($d);
|
chop($d);
|
||||||
return $d;
|
return $d;
|
||||||
@@ -400,8 +401,8 @@ return $d;
|
|||||||
# save_domainname(domain)
|
# save_domainname(domain)
|
||||||
sub save_domainname
|
sub save_domainname
|
||||||
{
|
{
|
||||||
local %conf;
|
my ($domain) = @_;
|
||||||
&execute_command("domainname ".quotemeta($_[0]));
|
&execute_command("domainname ".quotemeta($domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub routing_config_files
|
sub routing_config_files
|
||||||
@@ -436,7 +437,7 @@ print &ui_table_row($text{'routes_default6'},
|
|||||||
[ map { $_->{'name'} } @ifaces ]) ] ]));
|
[ map { $_->{'name'} } @ifaces ]) ] ]));
|
||||||
|
|
||||||
# Act as router?
|
# Act as router?
|
||||||
local %sysctl;
|
my %sysctl;
|
||||||
&read_env_file($sysctl_config, \%sysctl);
|
&read_env_file($sysctl_config, \%sysctl);
|
||||||
print &ui_table_row($text{'routes_forward'},
|
print &ui_table_row($text{'routes_forward'},
|
||||||
&ui_yesno_radio("forward",
|
&ui_yesno_radio("forward",
|
||||||
@@ -468,7 +469,7 @@ if (!$in{'gateway6_def'}) {
|
|||||||
&set_default_ipv6_gateway($gw6, $dev6);
|
&set_default_ipv6_gateway($gw6, $dev6);
|
||||||
|
|
||||||
# Save routing flag
|
# Save routing flag
|
||||||
local %sysctl;
|
my %sysctl;
|
||||||
&lock_file($sysctl_config);
|
&lock_file($sysctl_config);
|
||||||
&read_env_file($sysctl_config, \%sysctl);
|
&read_env_file($sysctl_config, \%sysctl);
|
||||||
$sysctl{'net.ipv4.ip_forward'} = $in{'forward'};
|
$sysctl{'net.ipv4.ip_forward'} = $in{'forward'};
|
||||||
|
|||||||
Reference in New Issue
Block a user