Handle hostnames with upper-case letters
[webmin.git] / apache / mod_auth.pl
1 # mod_auth.pl
2 # Defines editors for text-file authentication directives
3
4 sub mod_auth_directives
5 {
6 local($rv);
7 $rv = [ [ 'AuthUserFile AuthGroupFile AuthAuthoritative', 0, 4, 'directory htaccess' ] ];
8 return &make_directives($rv, $_[0], "mod_auth");
9 }
10
11 sub edit_AuthUserFile_AuthGroupFile_AuthAuthoritative
12 {
13 local($rv, $uf, $gf);
14 $uf = $_[0] && -r "list_authusers.cgi" ? 1 : 0;
15 $gf = $_[1] && -r "list_authgroups.cgi" ? 1 : 0;
16 $rv = "<table border><tr><td><table>\n";
17
18 $rv .= "<tr> <td><b>$text{'mod_auth_ufile'}</b></td> <td>".
19        &opt_input($_[0]->{'value'}, "AuthUserFile", $text{'default'}, 45).
20        &file_chooser_button("AuthUserFile", 0).
21        ($uf ? "&nbsp;<a href=\"list_authusers.cgi?file=".$_[0]->{'value'}.
22        "&url=".&urlize(&this_url())."\">$text{'mod_auth_uedit'}</a>" : "")."</td></tr>\n";
23
24 $rv .= "<tr> <td><b>$text{'mod_auth_gfile'}</b></td> <td>".
25        &opt_input($_[1]->{'value'}, "AuthGroupFile", $text{'default'}, 45).
26        &file_chooser_button("AuthGroupFile", 0).
27        ($gf ? "&nbsp;<a href=\"list_authgroups.cgi?file=".$_[1]->{'value'}.
28        "&url=".&urlize(&this_url())."\">$text{'mod_auth_gedit'}</a>" : "")."</td></tr>\n";
29
30 $rv .= "<tr> <td><b>$text{'mod_auth_pass'}</b></td> <td>".
31        &choice_input($_[2]->{'value'}, "AuthAuthoritative", "",
32        "$text{'yes'},off", "$text{'no'},on", "$text{'default'},").
33        "</td> </tr>\n";
34 $rv .= "</table></td></tr></table>\n";
35 return (2, "$text{'mod_auth_auth'}", $rv);
36 }
37 sub save_AuthUserFile_AuthGroupFile_AuthAuthoritative
38 {
39 $in{'AuthUserFile_def'} || &allowed_auth_file($in{'AuthUserFile'}) ||
40         &error($text{'mod_auth_eudir'});
41 $in{'AuthGroupFile_def'} || &allowed_auth_file($in{'AuthGroupFile'}) ||
42         &error($text{'mod_auth_egdir'});
43 return (&parse_opt("AuthUserFile", '^\S+$', $text{'mod_auth_eufile'}) ,
44         &parse_opt("AuthGroupFile", '^\S+$', $text{'mod_auth_egfile'}) ,
45         &parse_choice("AuthAuthoritative", ""));
46 }
47
48 1;
49