--- webmin/net/acl_security.pl Mon Jul 1 00:00:00 2002 +++ webmin-tpo/net/acl_security.pl Sun Jul 21 18:13:49 2002 @@ -10,10 +10,14 @@ $_[0]->{'ifcs'} == 2 ? "checked" : ""; printf " $text{'acl_view'}\n", $_[0]->{'ifcs'} == 1 ? "checked" : ""; -printf " $text{'no'}\n", +printf " $text{'no'}\n", $_[0]->{'ifcs'} ? "" : "checked"; +printf " $text{'acl_ifcs_only'}\n", + $_[0]->{'ifcs'} == 3 ? "checked" : ""; +print " ", + &interfaces_chooser_button("interfaces", 1)," \n"; -print "$text{'acl_routes'} \n"; +print " $text{'acl_routes'} \n"; printf " $text{'yes'}\n", $_[0]->{'routes'} == 2 ? "checked" : ""; printf " $text{'acl_view'}\n", @@ -26,10 +30,10 @@ $_[0]->{'dns'} == 2 ? "checked" : ""; printf " $text{'acl_view'}\n", $_[0]->{'dns'} == 1 ? "checked" : ""; -printf " $text{'no'}\n", +printf " $text{'no'} \n", $_[0]->{'dns'} ? "" : "checked"; -print "$text{'acl_hosts'} \n"; +print " $text{'acl_hosts'} \n"; printf " $text{'yes'}\n", $_[0]->{'hosts'} == 2 ? "checked" : ""; printf " $text{'acl_view'}\n", @@ -46,5 +50,6 @@ $_[0]->{'routes'} = $in{'routes'}; $_[0]->{'dns'} = $in{'dns'}; $_[0]->{'hosts'} = $in{'hosts'}; +$_[0]->{'interfaces'} = $in{'interfaces'}; } --- webmin/net/edit_aifc.cgi Sun Jul 14 00:00:00 2002 +++ webmin-tpo/net/edit_aifc.cgi Sun Jul 21 18:24:57 2002 @@ -3,15 +3,24 @@ # Edit or create an active interface require './net-lib.pl'; -$access{'ifcs'} == 2 || &error($text{'ifcs_ecannot'}); +$access{'ifcs'} == 2 || $access{'ifcs'} == 3 || &error($text{'ifcs_ecannot'}); + &ReadParse(); if ($in{'new'}) { &header($text{'aifc_create'}, ""); } else { - &header($text{'aifc_edit'}, ""); @act = &active_interfaces(); $a = $act[$in{'idx'}]; + + if ($access{'ifcs'} == 3) { + map { $can_interfaces{$_}++ } split(/\s+/, $access{'interfaces'}); + if (! $can_interfaces{$a->{'fullname'}}) { + &error($text{'ifcs_ecannot_this'}); + } + } + + &header($text{'aifc_edit'}, ""); } print "
\n"; --- webmin/net/edit_bifc.cgi Sun Jul 14 00:00:00 2002 +++ webmin-tpo/net/edit_bifc.cgi Sun Jul 21 18:33:19 2002 @@ -3,15 +3,23 @@ # Edit or create a bootup interface require './net-lib.pl'; -$access{'ifcs'} == 2 || &error($text{'ifcs_ecannot'}); +$access{'ifcs'} == 2 || $access{'ifcs'} == 3 || &error($text{'ifcs_ecannot'}); &ReadParse(); if ($in{'new'}) { &header($text{'bifc_create'}, ""); } else { - &header($text{'bifc_edit'}, ""); @boot = &boot_interfaces(); $b = $boot[$in{'idx'}]; + + if ($access{'ifcs'} == 3) { + map { $can_interfaces{$_}++ } split(/\s+/, $access{'interfaces'}); + if (! $can_interfaces{$b->{'fullname'}}) { + &error($text{'ifcs_ecannot_this'}); + } + } + + &header($text{'bifc_edit'}, ""); } print "
\n"; --- webmin/net/list_ifcs.cgi Sun Jul 14 00:00:00 2002 +++ webmin-tpo/net/list_ifcs.cgi Sun Jul 21 18:30:34 2002 @@ -18,12 +18,18 @@ "$text{'ifcs_mask'} ", "$text{'ifcs_status'} \n"; +if ($access{'ifcs'} == 3) { + map { $can_interfaces{$_}++ } split(/\s+/, $access{'interfaces'}); + } + @act = &active_interfaces(); @act = sort iface_sort @act; foreach $a (@act) { print " "; if ($a->{'virtual'} ne "") { print "  "; } - if ($a->{'edit'} && $access{'ifcs'} == 2) { + if ($a->{'edit'} && + ( ($access{'ifcs'} == 2) || + ($access{'ifcs'} == 3 && $can_interfaces{$a->{'fullname'}} ))) { print "{'index'}\">", &html_escape($a->{'fullname'}),"\n"; } @@ -58,7 +64,9 @@ foreach $a (@boot) { print " "; if ($a->{'virtual'} ne "") { print "  "; } - if ($a->{'edit'} && $access{'ifcs'} == 2) { + if ($a->{'edit'} && + ( ($access{'ifcs'} == 2) || + ($access{'ifcs'} == 3 && $can_interfaces{$a->{'fullname'}} ))) { print "{'index'}\">", &html_escape($a->{'fullname'}),"\n"; } --- webmin/net/interface_chooser.cgi Mon Jul 22 14:09:56 2002 +++ webmin-tpo/net/interface_chooser.cgi Sun Jul 21 18:41:53 2002 @@ -0,0 +1,128 @@ +#!/usr/bin/perl +# interface_chooser.cgi +# +# Based on user_chooser.cgi by Jamie Cameron +# (c) Tomas Pospisek +# Licensed under the webmin license +# +# made possible by: +# Sourcepole http://sourcepole.ch +# under contract from: +# AO Media Services http://www.ao-asif.ch/aoi/media/ +# Thanks! +# +# TODO: +# replace active_interfaces by a merged list from active_* and boot_interfaces +# +# This CGI generated the HTML for choosing an interface or a list of interfaces. + +require './../web-lib.pl'; +require './net-lib.pl'; +&init_config(); +&ReadParse(); +%access = &get_module_acl(); + +if ($in{'multi'}) { + # selecting multiple interfaces. + if ($in{'frame'} == 0) { + # base frame + &PrintHeader(); + print "\n"; + print "$text{'interfaces_title1'}\n"; + print "\n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print "\n"; + print "\n"; + } + elsif ($in{'frame'} == 1) { + # list of all interfaces to choose from + &header(); + print "\n"; + print "$text{'interfaces_all'}\n"; + print "\n"; + foreach $if (&active_interfaces()) { + if ($in{'interface'} eq $if->{'fullname'}) { print "\n"; } + else { print "\n"; } + print "\n"; + } + print "
$if->{'fullname'}
\n"; + } + elsif ($in{'frame'} == 2) { + # show chosen interfaces + &header(); + print "$text{'interfaces_sel'}\n"; + print <<'EOF'; + + +
+EOF + } + elsif ($in{'frame'} == 3) { + # output OK and Cancel buttons + &header(); + print "
\n"; + print "\n"; + print "\n"; + print "  \n"; + print "
\n"; + } + } +else { + # selecting just one interface .. display a list of all interfaces to choose from + &header(); + print "\n"; + print "$text{'interfaces_title2'}\n"; + print "\n"; + foreach $if (&active_interfaces()) { + if ($in{'interface'} eq $if->{'fullname'}) { print "\n"; } + else { print "\n"; } + print "\n"; + } + print "
$if->{'fullname'}
\n"; + } + --- webmin/net/lang/en Mon Jul 1 00:00:00 2002 +++ webmin-tpo/net/lang/en Sun Jul 21 18:29:33 2002 @@ -24,6 +24,7 @@ ifcs_return=network interfaces ifcs_unknown=Unknown ifcs_ecannot=You are not allowed to edit network interfaces +ifcs_ecannot_this=You are not allowed to edit this network interface aifc_create=Create Active Interface aifc_edit=Edit Active Interface @@ -64,7 +65,7 @@ routes_title=Routing and Gateways routes_boot=Routing configuration activated at boot time routes_default=Default router -routes_none=None +routes_none=None (or from DHCP) routes_device=Device routes_gateway=Gateway routes_forward=Act as router? @@ -133,4 +134,12 @@ acl_dns=Can edit DNS client settings? acl_hosts=Can edit host addresses? acl_view=View only +acl_ifcs_only=Only interfaces +interfaces_title1=Choose Interfaces... +interfaces_all=All Interfaces... +interfaces_sel=Selected Interfaces +interfaces_ok=OK +interfaces_cancel=Cancel +interfaces_clear=Clear +interfaces_title2=Select User... --- webmin/web-lib.pl Mon Jul 1 00:00:00 2002 +++ webmin-tpo/web-lib.pl Mon Jul 22 14:18:21 2002 @@ -1251,6 +1251,15 @@ return "\n"; } +# interfaces_chooser_button(field, multiple, [form]) +# Returns HTML for a javascript button for choosing an interface or interfaces +sub interfaces_chooser_button +{ + local $form = @_ > 2 ? $_[2] : 0; + local $w = $_[1] ? 500 : 300; + return "\n"; +} + # group_chooser_button(field, multiple, [form]) # Returns HTML for a javascript button for choosing a Unix group or groups sub group_chooser_button