From 86b2133e9fc4a4812f9ea60e06dd91cf1ea10bd2 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 16 Nov 2007 23:21:33 +0000 Subject: [PATCH] Added support for comments on interfaces --- net/CHANGELOG | 2 ++ net/delete_aifcs.cgi | 2 +- net/delete_bifcs.cgi | 2 +- net/edit_aifc.cgi | 2 +- net/edit_bifc.cgi | 13 ++++++++++++- net/edit_range.cgi | 2 +- net/index.cgi | 9 ++++----- net/lang/en | 3 +++ net/list_ifcs.cgi | 20 +++++++++++++++++--- net/mod_aifc.cgi | 2 +- net/open-linux-lib.pl | 9 +++++++++ net/redhat-linux-lib.pl | 9 +++++++++ net/save_aifc.cgi | 2 +- net/save_bifc.cgi | 7 ++++++- net/save_range.cgi | 2 +- 15 files changed, 69 insertions(+), 17 deletions(-) diff --git a/net/CHANGELOG b/net/CHANGELOG index 159ce1bd0..f5218e5ec 100644 --- a/net/CHANGELOG +++ b/net/CHANGELOG @@ -33,3 +33,5 @@ Fixed broken SuSE 10.2+ support. Re-wrote Gentoo networking support code to work with 2006 and later versions. ---- Changes since 1.380 ---- Added support for VLANs and channel bonding on Debian, thanks to Tim Oberfoell. +Boot-time network interfaces can have comments on Redhat-based systems. +The list of interfaces is now separated into active and boot time using tabs. diff --git a/net/delete_aifcs.cgi b/net/delete_aifcs.cgi index 8bfedb37b..a923dcdaa 100755 --- a/net/delete_aifcs.cgi +++ b/net/delete_aifcs.cgi @@ -17,5 +17,5 @@ foreach $d (@d) { } &webmin_log("delete", "aifcs", scalar(@d)); -&redirect("list_ifcs.cgi"); +&redirect("list_ifcs.cgi?mode=active"); diff --git a/net/delete_bifcs.cgi b/net/delete_bifcs.cgi index 0be51f14a..d29e19639 100755 --- a/net/delete_bifcs.cgi +++ b/net/delete_bifcs.cgi @@ -47,5 +47,5 @@ foreach $d (reverse(@d)) { } &webmin_log($in{'apply'} ? "apply" : "delete", "bifcs", scalar(@d)); -&redirect("list_ifcs.cgi"); +&redirect("list_ifcs.cgi?mode=boot"); diff --git a/net/edit_aifc.cgi b/net/edit_aifc.cgi index f976c039e..2e740f25b 100755 --- a/net/edit_aifc.cgi +++ b/net/edit_aifc.cgi @@ -141,5 +141,5 @@ else { } print "\n"; -&ui_print_footer("list_ifcs.cgi", $text{'ifcs_return'}); +&ui_print_footer("list_ifcs.cgi?mode=active", $text{'ifcs_return'}); diff --git a/net/edit_bifc.cgi b/net/edit_bifc.cgi index 2468be77e..dcc52f19f 100755 --- a/net/edit_bifc.cgi +++ b/net/edit_bifc.cgi @@ -36,6 +36,15 @@ print " ", " \n"; print " \n"; +# Comment, if allowed +if (defined(&can_iface_desc) && &can_iface_desc($b)) { + print "\n"; + print "\n"; + } + +# Interface name print "\n"; +# IP address print "\n", $b && !$b->{'bootp'} && !$b->{'dhcp'} ? $b->{'address'} : ""; +# Netmask print "\n"; if ($in{'virtual'} && $in{'new'} && $virtual_netmask) { # Virtual netmask cannot be edited @@ -282,5 +293,5 @@ else { } print "
$text{'ifcs_desc'}", + &ui_textbox("desc", $b ? $b->{'desc'} : undef, 60), + "
$text{'ifcs_name'} \n"; if ($in{'new'} && $in{'virtual'}) { print "\n"; @@ -55,6 +64,7 @@ else { } print "$text{'ifcs_ip'} \n"; $virtual = (!$b && $in{'virtual'}) || ($b && $b->{'virtual'} ne ""); $dhcp = &can_edit("dhcp") && !$virtual; @@ -78,6 +88,7 @@ else { printf "
$text{'ifcs_mask'}
\n"; -&ui_print_footer("list_ifcs.cgi", $text{'ifcs_return'}); +&ui_print_footer("list_ifcs.cgi?mode=boot", $text{'ifcs_return'}); diff --git a/net/edit_range.cgi b/net/edit_range.cgi index 3d4604d95..94747d314 100755 --- a/net/edit_range.cgi +++ b/net/edit_range.cgi @@ -56,5 +56,5 @@ else { } print "\n"; -&ui_print_footer("list_ifcs.cgi", $text{'ifcs_return'}); +&ui_print_footer("list_ifcs.cgi?mode=boot", $text{'ifcs_return'}); diff --git a/net/index.cgi b/net/index.cgi index 0cc77af0a..159e968dc 100755 --- a/net/index.cgi +++ b/net/index.cgi @@ -21,11 +21,10 @@ foreach $i ('ifcs', 'routes', 'dns', 'hosts', if (defined(&apply_network) && $access{'apply'} && !$zone) { # Allow the user to apply the network config print "
\n"; - print "
\n"; - print "\n"; - print "\n"; - print "\n"; - print "
$text{'index_applydesc'}
\n"; + print &ui_buttons_start(); + print &ui_buttons_row("apply.cgi", $text{'index_apply'}, + $text{'index_applydesc'}); + print &ui_buttons_end(); } &ui_print_footer("/", $text{'index'}); diff --git a/net/lang/en b/net/lang/en index 19c8aee0a..1f4760a05 100644 --- a/net/lang/en +++ b/net/lang/en @@ -9,9 +9,12 @@ index_apply2=Apply Selected Interfaces ifcs_title=Network Interfaces ifcs_now=Interfaces Active Now +ifcs_activedesc=Interfaces listed in this table are currently active on the system. In most cases, you should edit them under the Boot Time tab. +ifcs_bootdesc=Interfaces listed in this table will be activated when the system boots up, and will generally be active now too. ifcs_name=Name ifcs_type=Type ifcs_ip=IP Address +ifcs_desc=Interface description ifcs_mask=Netmask ifcs_status=Status ifcs_virtual=Virtual diff --git a/net/list_ifcs.cgi b/net/list_ifcs.cgi index ff8828362..2d1c70c9c 100755 --- a/net/list_ifcs.cgi +++ b/net/list_ifcs.cgi @@ -8,11 +8,21 @@ $access{'ifcs'} || &error($text{'ifcs_ecannot'}); $allow_add = &can_create_iface() && !$noos_support_add_ifcs; &ui_print_header(undef, $text{'ifcs_title'}, ""); +# Start tabs for active/boot time interfaces +@tabs = ( [ "active", $text{'ifcs_now'}, "list_ifcs.cgi?mode=active" ] ); +$defmode = "active"; +if (!$access{'bootonly'}) { + push(@tabs, [ "boot", $text{'ifcs_boot'}, "list_ifcs.cgi?mode=boot" ] ); + $defmode = "boot"; + } +print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || $defmode, 1); + # Show interfaces that are currently active @act = &active_interfaces(); if (!$access{'bootonly'}) { # Table heading and links - print &ui_subheading($text{'ifcs_now'}); + print &ui_tabs_start_tab("mode", "active"); + print $text{'ifcs_activedesc'},"

\n"; local @tds; @links = ( ); if ($access{'ifcs'} >= 2) { @@ -79,11 +89,12 @@ if (!$access{'bootonly'}) { if ($access{'ifcs'} >= 2) { print &ui_form_end([ [ "delete", $text{'index_delete1'} ] ]); } - print "


\n"; + print &ui_tabs_end_tab(); } # Show interfaces that get activated at boot -print &ui_subheading($text{'ifcs_boot'}); +print &ui_tabs_start_tab("mode", "boot"); +print $text{'ifcs_bootdesc'},"

\n"; print &ui_form_start("delete_bifcs.cgi", "post"); @links = ( &select_all_link("b", 1), &select_invert_link("b", 1) ); @@ -185,6 +196,9 @@ print &ui_form_end([ [ "delete", $text{'index_delete2'} ], [ "deleteapply", $text{'index_delete3'} ], undef, [ "apply", $text{'index_apply2'} ] ]); +print &ui_tabs_end_tab(); + +print &ui_tabs_end(1); &ui_print_footer("", $text{'index_return'}); diff --git a/net/mod_aifc.cgi b/net/mod_aifc.cgi index f6fdb5ced..19054e24e 100755 --- a/net/mod_aifc.cgi +++ b/net/mod_aifc.cgi @@ -21,5 +21,5 @@ if ($acl{$base_remote_user,$mod->{'module'}}) { } print "

\n"; -&ui_print_footer("list_ifcs.cgi", $text{'ifcs_return'}); +&ui_print_footer("list_ifcs.cgi?mode=active", $text{'ifcs_return'}); diff --git a/net/open-linux-lib.pl b/net/open-linux-lib.pl index 8be5f9252..c39080530 100644 --- a/net/open-linux-lib.pl +++ b/net/open-linux-lib.pl @@ -32,6 +32,7 @@ while($f = readdir(CONF)) { : "Automatic"; $b->{'dhcp'} = $conf{'DYNAMIC'} eq 'dhcp'; $b->{'edit'} = ($b->{'name'} !~ /^ppp|plip/); + $b->{'desc'} = $conf{'NAME'}; $b->{'index'} = scalar(@rv); $b->{'file'} = "$net_scripts_dir/$f"; push(@rv, $b); @@ -67,6 +68,7 @@ $conf{'NETWORK'} = sprintf "%d.%d.%d.%d", ($ip4 & int($nm4))&0xff; $conf{'BROADCAST'} = $_[0]->{'broadcast'}; $conf{'ONBOOT'} = $_[0]->{'up'} ? "yes" : "no"; +$conf{'NAME'} = $_[0]->{'desc'}; &write_env_file("$net_scripts_dir/ifcfg-$name", \%conf); &unlock_file("$net_scripts_dir/ifcfg-$name"); } @@ -87,6 +89,13 @@ sub can_edit return $_[0] ne "bootp" && $_[0] ne "mtu"; } +# can_iface_desc([&iface]) +# Returns 1 if boot-interfaces can have comments +sub can_iface_desc +{ +return 1; +} + # valid_boot_address(address) # Is some address valid for a bootup interface sub valid_boot_address diff --git a/net/redhat-linux-lib.pl b/net/redhat-linux-lib.pl index 27a946f0b..70714e6da 100644 --- a/net/redhat-linux-lib.pl +++ b/net/redhat-linux-lib.pl @@ -67,6 +67,7 @@ while($f = readdir(CONF)) { $b->{'num'} = $conf{'CLONENUM_START'}; $b->{'up'} = 1; $b->{'edit'} = 1; + $b->{'desc'} = $conf{'NAME'}; $b->{'index'} = scalar(@rv); $b->{'file'} = "$net_scripts_dir/$f"; push(@rv, $b); @@ -91,6 +92,7 @@ while($f = readdir(CONF)) { $b->{'dhcp'} = ($conf{'BOOTPROTO'} eq 'dhcp'); $b->{'bootp'} = ($conf{'BOOTPROTO'} eq 'bootp'); $b->{'edit'} = ($b->{'name'} !~ /^ppp|irlan/); + $b->{'desc'} = $conf{'NAME'}; $b->{'index'} = scalar(@rv); $b->{'file'} = "$net_scripts_dir/$f"; push(@rv, $b); @@ -148,6 +150,7 @@ else { $conf{'BOOTPROTO'} = $_[0]->{'bootp'} ? "bootp" : $_[0]->{'dhcp'} ? "dhcp" : "none"; } +$conf{'NAME'} = $_[0]->{'desc'}; &write_env_file("$net_scripts_dir/ifcfg-$name", \%conf); if (-d &translate_filename($devices_dir)) { &link_file("$net_scripts_dir/ifcfg-$name", @@ -680,6 +683,11 @@ sub range_input { local $new = !$_[0]; +# Range description +print " $text{'ifcs_desc'}\n"; +print "",&ui_textbox("desc", $_[0] ? $_[0]->{'desc'} : undef, 60), + " \n"; + # Base interface print " $text{'range_iface'}\n"; if ($new) { @@ -733,6 +741,7 @@ if ($in{'new'}) { $_[0]->{'range'} = $in{'range'}; $_[0]->{'fullname'} = $in{'iface'}."-range".$in{'range'}; } +$_[0]->{'desc'} = $in{'desc'}; &check_ipaddress($in{'start'}) || &error($text{'range_estart'}); $_[0]->{'start'} = $in{'start'}; diff --git a/net/save_aifc.cgi b/net/save_aifc.cgi index 9f242bd6a..f20c46f32 100755 --- a/net/save_aifc.cgi +++ b/net/save_aifc.cgi @@ -147,5 +147,5 @@ else { &webmin_log($in{'new'} ? 'create' : 'modify', "aifc", $a->{'fullname'}, $a); } -&redirect("list_ifcs.cgi"); +&redirect("list_ifcs.cgi?mode=active"); diff --git a/net/save_bifc.cgi b/net/save_bifc.cgi index 733437439..3b87e39ad 100755 --- a/net/save_bifc.cgi +++ b/net/save_bifc.cgi @@ -127,6 +127,11 @@ else { $b->{'address'} = $in{'address'}; } + # Set description if possible + if (defined($in{'desc'})) { + $b->{'desc'} = $in{'desc'}; + } + if ($virtual_netmask && $b->{'virtual'} ne "") { # Always use this netmask for virtuals $b->{'netmask'} = $virtual_netmask; @@ -229,5 +234,5 @@ else { &webmin_log($in{'new'} ? 'create' : 'modify', "bifc", $b->{'fullname'}, $b); } -&redirect("list_ifcs.cgi"); +&redirect("list_ifcs.cgi?mode=boot"); diff --git a/net/save_range.cgi b/net/save_range.cgi index 24d6cdeb5..f64aa2e09 100755 --- a/net/save_range.cgi +++ b/net/save_range.cgi @@ -53,5 +53,5 @@ else { &webmin_log($in{'new'} ? 'create' : 'modify', "range", $b->{'fullname'}, $b); } -&redirect("list_ifcs.cgi"); +&redirect("list_ifcs.cgi?mode=boot");