forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacl_security.pl
executable file
·85 lines (75 loc) · 2.27 KB
/
acl_security.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use strict;
use warnings;
do 'acl-lib.pl';
our (%text, %in);
# acl_security_form(&options)
# Output HTML for editing security options for the acl module
sub acl_security_form
{
my ($o) = @_;
print &ui_table_row($text{'acl_users'},
&ui_radio("users_def", $o->{'users'} eq '*' ? 1 :
$o->{'users'} eq '~' ? 2 : 0,
[ [ 1, $text{'acl_uall'} ],
[ 2, $text{'acl_uthis'}."<br>" ],
[ 0, $text{'acl_usel'} ] ])."<br>\n".
&ui_select("users", [ split(/\s+/, $o->{'users'}) ],
[ (map { $_->{'name'} } &list_users()),
(map { [ '_'.$_->{'name'},
&text('acl_gr', $_->{'name'}) ] }
&list_groups()) ],
6, 1));
print &ui_table_row($text{'acl_mods'},
&ui_radio("mode", $o->{'mode'},
[ [ 0, $text{'acl_all'} ],
[ 1, $text{'acl_own'}."<br>" ],
[ 2, $text{'acl_sel'}."<br>" ] ]).
&ui_select("mods", [ split(/\s+/, $o->{'mods'}) ],
[ map { [ $_->{'dir'}, $_->{'desc'} ] }
&list_module_infos() ],
6, 1));
foreach my $f (&list_acl_yesno_fields()) {
print &ui_table_row($text{'acl_'.$f},
&ui_yesno_radio($f, $o->{$f}));
}
print &ui_table_hr();
print &ui_table_row($text{'acl_groups'},
&ui_yesno_radio("groups", $o->{'groups'}));
print &ui_table_row($text{'acl_gassign'},
&ui_radio("gassign_def", $o->{'gassign'} eq '*' ? 1 : 0,
[ [ 1, $text{'acl_gall'} ],
[ 0, $text{'acl_gsel'} ] ])."<br>\n".
&ui_select("gassign", [ split(/\s+/, $o->{'gassign'}) ],
[ map { $_->{'name'} } &list_groups() ],
6, 1));
}
# acl_security_save(&options)
# Parse the form for security options for the acl module
sub acl_security_save
{
my ($o) = @_;
if ($in{'users_def'} == 1) {
$o->{'users'} = '*';
}
elsif ($in{'users_def'} == 2) {
$o->{'users'} = '~';
}
else {
$o->{'users'} = join(" ", split(/\0/, $in{'users'}));
}
$o->{'mode'} = $in{'mode'};
$o->{'mods'} = $in{'mode'} == 2 ? join(" ", split(/\0/, $in{'mods'}))
: undef;
foreach my $f (&list_acl_yesno_fields()) {
$o->{$f} = $in{$f};
}
$o->{'groups'} = $in{'groups'};
$o->{'gassign'} = $in{'gassign_def'} ? '*' :
join(" ", split(/\0/, $in{'gassign'}));
}
sub list_acl_yesno_fields
{
return ('create', 'delete', 'rename', 'acl', 'cert', 'others', 'chcert',
'lang', 'cats', 'theme', 'ips', 'perms', 'sync', 'unix', 'sessions',
'switch', 'times', 'pass', 'sql');
}