More bridge support
authorJamie Cameron <jcameron@webmin.com>
Tue, 28 Jun 2011 17:57:12 +0000 (10:57 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 28 Jun 2011 17:57:12 +0000 (10:57 -0700)
net/edit_aifc.cgi
net/linux-lib.pl
net/list_ifcs.cgi
net/redhat-linux-lib.pl
net/save_aifc.cgi

index 278e747..bee29a6 100755 (executable)
@@ -3,7 +3,7 @@
 # Edit or create an active interface
 
 require './net-lib.pl';
-@act = &active_interfaces();
+@act = &active_interfaces(1);
 
 &ReadParse();
 if ($in{'new'}) {
index 1974b34..1b59144 100755 (executable)
@@ -1,10 +1,11 @@
 # linux-lib.pl
 # Active interface functions for all flavours of linux
 
-# active_interfaces()
+# active_interfaces([include-no-address])
 # Returns a list of currently ifconfig'd interfaces
 sub active_interfaces
 {
+local ($empty) = @_;
 local(@rv, @lines, $l);
 &open_execute_command(IFC, "LC_ALL='' LANG='' ifconfig -a", 1, 1);
 while(<IFC>) {
@@ -20,7 +21,7 @@ foreach $l (@lines) {
        $l =~ /^(\S+)/; $ifc{'fullname'} = $1;
        if ($l =~ /^(\S+):(\d+)/) { $ifc{'virtual'} = $2; }
        if ($l =~ /inet addr:(\S+)/) { $ifc{'address'} = $1; }
-       elsif (!$_[0]) { next; }
+       elsif (!$empty) { next; }
        if ($l =~ /Mask:(\S+)/) { $ifc{'netmask'} = $1; }
        if ($l =~ /Bcast:(\S+)/) { $ifc{'broadcast'} = $1; }
        if ($l =~ /HWaddr (\S+)/) { $ifc{'ether'} = $1; }
index 0281c5b..e538b2e 100755 (executable)
@@ -18,7 +18,7 @@ if (!$access{'bootonly'}) {
 print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || $defmode, 1);
 
 # Show interfaces that are currently active
-@act = &active_interfaces();
+@act = &active_interfaces(1);
 if (!$access{'bootonly'}) {
        # Table heading and links
        print &ui_tabs_start_tab("mode", "active");
@@ -57,7 +57,7 @@ if (!$access{'bootonly'}) {
                local $mod = &module_for_interface($a);
                local %minfo = $mod ? &get_module_info($mod->{'module'}) : ( );
                local @cols;
-               if ($a->{'edit'} && &can_iface($a)) {
+               if ($a->{'edit'} && &can_iface($a) && $a->{'address'}) {
                        push(@cols,
                            "<a href=\"edit_aifc.cgi?idx=$a->{'index'}\">".
                            &html_escape($a->{'fullname'})."</a>");
@@ -82,8 +82,10 @@ if (!$access{'bootonly'}) {
                       $mod ? "" : " ($text{'ifcs_virtual'})").
                      (%minfo ? " ($minfo{'desc'})" : "").
                      ($a->{'speed'} ? " ".$a->{'speed'} : ""));
-               push(@cols, &html_escape($a->{'address'}));
-               push(@cols, &html_escape($a->{'netmask'}));
+               push(@cols, &html_escape($a->{'address'}) ||
+                           $text{'ifcs_noaddress'});
+               push(@cols, &html_escape($a->{'netmask'}) ||
+                           $text{'ifcs_nonetmask'});
                if (&supports_address6()) {
                        push(@cols, join("<br>\n", map { &html_escape($_) }
                                                    @{$a->{'address6'}}));
@@ -209,9 +211,10 @@ foreach $a (@boot) {
                            $a->{'dhcp'} ? $text{'ifcs_dhcp'} :
                            $a->{'address'} ? &html_escape($a->{'address'}) :
                                               $text{'ifcs_noaddress'});
-               push(@cols, $a->{'netmask'} ? &html_escape($a->{'netmask'}) :
-                           !$a->{'address'} ? $text{'ifcs_nonetmask'} :
-                                              $text{'ifcs_auto'});
+               push(@cols, $a->{'bootp'} ? $text{'ifcs_bootp'} :
+                            $a->{'dhcp'} ? $text{'ifcs_dhcp'} :
+                           $a->{'netmask'} ? &html_escape($a->{'netmask'}) :
+                                             $text{'ifcs_nonetmask'});
                if (&supports_address6()) {
                        push(@cols, $a->{'auto6'} ? $text{'ifcs_auto6'} :
                                      join("<br>\n", map { &html_escape($_) }
index d41cb3a..a994977 100755 (executable)
@@ -207,6 +207,9 @@ else {
                $conf{'IPV6ADDR_SECONDARIES'} = join(" ", @ip6s);
                }
        if ($_[0]->{'fullname'} =~ /^br(\d+)$/) {
+               &has_command("brctl") ||
+                       &error("Bridges cannot be created unless the brctl ".
+                              "command is installed");
                $conf{'TYPE'} = 'Bridge';
                }
        }
index 6986aa2..5a0a7e8 100755 (executable)
@@ -4,7 +4,7 @@
 
 require './net-lib.pl';
 &ReadParse();
-@acts = &active_interfaces();
+@acts = &active_interfaces(1);
 
 if ($in{'delete'}) {
        # delete an interface