forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacl_security.pl
executable file
·144 lines (128 loc) · 5.44 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
require 'apache-lib.pl';
# acl_security_form(&options)
# Output HTML for editing security options for the apache module
sub acl_security_form
{
print "<tr> <td valign=top rowspan=4><b>$text{'acl_virts'}</b></td>\n";
print "<td rowspan=4 valign=top>\n";
printf "<input type=radio name=virts_def value=1 %s> %s\n",
$_[0]->{'virts'} eq '*' ? 'checked' : '', $text{'acl_vall'};
printf "<input type=radio name=virts_def value=0 %s> %s<br>\n",
$_[0]->{'virts'} eq '*' ? '' : 'checked', $text{'acl_vsel'};
print "<select name=virts multiple size=5>\n";
local $conf = &get_config();
local @virts = ( { 'value' => '__default__' },
&find_directive_struct("VirtualHost", $conf) );
local %vcan = map { $_, 1 } split(/\s+/, $_[0]->{'virts'});
local $v;
foreach $v (@virts) {
local @vn = &virt_acl_name($v);
local ($can) = grep { $vcan{$_} } @vn;
local $vn = $can || $vn[0];
printf "<option value=\"%s\" %s>%s</option>\n",
$vn, $can ? "selected" : "",
$vn eq "__default__" ? $text{'acl_defserv'} : $vn;
delete($vcan{$can}) if ($can);
}
foreach $vn (keys %vcan) {
next if ($vn eq "*");
printf "<option value=\"%s\" %s>%s</option>\n",
$vn, "selected",
$vn eq "__default__" ? $text{'acl_defserv'} : $vn;
}
print "</select></td>\n";
print "<td><b>$text{'acl_global'}</b></td> <td><select name=global>\n";
printf "<option value=1 %s>$text{'yes'}</option>\n",
$_[0]->{'global'} == 1 ? "selected" : "";
printf "<option value=2 %s>$text{'acl_htaccess'}</option>\n",
$_[0]->{'global'} == 2 ? "selected" : "";
printf "<option value=0 %s>$text{'no'}</option></select></td> </tr>\n",
$_[0]->{'global'} == 0 ? "selected" : "";
print "<tr> <td><b>$text{'acl_create'}</b></td> <td>\n";
printf "<input type=radio name=create value=1 %s> $text{'yes'}\n",
$_[0]->{'create'} ? "checked" : "";
printf "<input type=radio name=create value=0 %s> $text{'no'}</td> </tr>\n",
$_[0]->{'create'} ? "" : "checked";
print "<tr> <td><b>$text{'acl_vuser'}</b></td> <td>\n";
printf "<input type=radio name=vuser value=1 %s> $text{'yes'}\n",
$_[0]->{'vuser'} ? "checked" : "";
printf "<input type=radio name=vuser value=0 %s> $text{'no'}</td> </tr>\n",
$_[0]->{'vuser'} ? "" : "checked";
print "<tr> <td><b>$text{'acl_vaddr'}</b></td> <td>\n";
printf "<input type=radio name=vaddr value=1 %s> $text{'yes'}\n",
$_[0]->{'vaddr'} ? "checked" : "";
printf "<input type=radio name=vaddr value=0 %s> $text{'no'}</td> </tr>\n",
$_[0]->{'vaddr'} ? "" : "checked";
print "<tr> <td><b>$text{'acl_pipe'}</b></td> <td>\n";
printf "<input type=radio name=pipe value=1 %s> $text{'yes'}\n",
$_[0]->{'pipe'} ? "checked" : "";
printf "<input type=radio name=pipe value=0 %s> $text{'no'}</td>\n",
$_[0]->{'pipe'} ? "" : "checked";
print "<td><b>$text{'acl_stop'}</b></td> <td>\n";
printf "<input type=radio name=stop value=1 %s> $text{'yes'}\n",
$_[0]->{'stop'} ? "checked" : "";
printf "<input type=radio name=stop value=0 %s> $text{'no'}</td> </tr>\n",
$_[0]->{'stop'} ? "" : "checked";
print "<tr> <td><b>$text{'acl_apply'}</b></td> <td>\n";
printf "<input type=radio name=apply value=1 %s> $text{'yes'}\n",
$_[0]->{'apply'} ? "checked" : "";
printf "<input type=radio name=apply value=0 %s> $text{'no'}</td>\n",
$_[0]->{'apply'} ? "" : "checked";
print "<td><b>$text{'acl_names'}</b></td> <td>\n";
printf "<input type=radio name=names value=1 %s> $text{'yes'}\n",
$_[0]->{'names'} ? "checked" : "";
printf "<input type=radio name=names value=0 %s> $text{'no'}</td> </tr>\n",
$_[0]->{'names'} ? "" : "checked";
print "<tr> <td><b>$text{'acl_dir'}</b></td>\n";
printf "<td colspan=3><input name=dir size=30 value='%s'> %s</td> </tr>\n",
$_[0]->{'dir'}, &file_chooser_button("dir", 1);
print "<tr> <td><b>$text{'acl_aliasdir'}</b></td>\n";
printf "<td colspan=3><input name=aliasdir size=30 value='%s'> %s</td> </tr>\n",
$_[0]->{'aliasdir'}, &file_chooser_button("aliasdir", 1);
print "<tr> <td valign=top><b>$text{'acl_types'}</b></td>\n";
print "<td colspan=3>\n";
printf "<input type=radio name=types_def value=1 %s> $text{'acl_all'} \n",
$_[0]->{'types'} eq '*' ? "checked" : "";
printf "<input type=radio name=types_def value=0 %s> $text{'acl_sel'}<br>\n",
$_[0]->{'types'} eq '*' ? "" : "checked";
map { $types{$_}++ } split(/\s+/, $_[0]->{'types'});
print "<select name=types size=5 multiple>\n";
for($i=0; $text{"type_$i"}; $i++) {
printf "<option value=\"%d\" %s>%s</option>\n",
$i, $types{$i} ? "selected" : "", $text{"type_$i"};
}
print "</select></td> </tr>\n";
print "<tr> <td valign=top><b>$text{'acl_dirs'}</b></td>\n";
print "<td colspan=3>\n";
print &ui_radio("dirsmode", $_[0]->{'dirsmode'},
[ [ 0, $text{'acl_dirs0'} ],
[ 1, $text{'acl_dirs1'} ],
[ 2, $text{'acl_dirs2'} ] ]),"<br>\n";
print &ui_textarea("dirs", join("\n", split(/\s+/, $_[0]->{'dirs'})), 5, 50);
print "</td> </tr>\n";
}
# acl_security_save(&options)
# Parse the form for security options for the apache module
sub acl_security_save
{
if ($in{'virts_def'}) {
$_[0]->{'virts'} = "*";
}
else {
$_[0]->{'virts'} = join(" ", split(/\0/, $in{'virts'}));
}
$_[0]->{'global'} = $in{'global'};
$_[0]->{'create'} = $in{'create'};
$_[0]->{'vuser'} = $in{'vuser'};
$_[0]->{'stop'} = $in{'stop'};
$_[0]->{'apply'} = $in{'apply'};
$_[0]->{'vaddr'} = $in{'vaddr'};
$_[0]->{'dir'} = $in{'dir'};
$_[0]->{'aliasdir'} = $in{'aliasdir'};
$_[0]->{'types'} = $in{'types_def'} ? '*'
: join(" ", split(/\0/, $in{'types'}));
$_[0]->{'pipe'} = $in{'pipe'};
$_[0]->{'names'} = $in{'names'};
$_[0]->{'dirsmode'} = $in{'dirsmode'};
$_[0]->{'dirs'} = join(" ", split(/\s+/, $in{'dirs'}));
}