Handle hostnames with upper-case letters
[webmin.git] / samba / conf_pass.cgi
1 #!/usr/local/bin/perl
2 # conf_pass.cgi
3 # Display password options options
4
5 require './samba-lib.pl';
6
7 # check acls
8
9 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
10 &error("$text{'eacl_np'} $text{'eacl_pcp'}") unless $access{'conf_pass'};
11
12 &ui_print_header(undef, $text{'passwd_title'}, "");
13
14 &get_share("global");
15
16 print "<form action=save_pass.cgi>\n";
17 print "<table border width=100%>\n";
18 print "<tr $tb> <td><b>$text{'passwd_title'}</b></td> </tr>\n";
19 print "<tr $cb> <td><table width=100%>\n";
20 print "<tr> <td><b>$text{'passwd_encrypt'}</b></td>\n";
21 printf "<td><input type=radio name=encrypt_passwords value=yes %s> $text{'yes'}\n",
22         &istrue("encrypt passwords") ? "checked" : "";
23 printf "&nbsp; <input type=radio name=encrypt_passwords value=no %s> $text{'no'}</td>\n",
24         &istrue("encrypt passwords") ? "" : "checked";
25
26 print "<td><b>$text{'passwd_allownull'}</b></td>\n";
27 printf "<td><input type=radio name=null_passwords value=yes %s> $text{'yes'}\n",
28         &istrue("null passwords") ? "checked" : "";
29 printf "$gap <input type=radio name=null_passwords value=no %s> $text{'no'}</td></tr>\n",
30         &istrue("null passwords") ? "" : "checked";
31
32 print "<tr> <td><b>$text{'passwd_program'}</b></td>\n";
33 printf "<td><input type=radio name=passwd_program_def value=1 %s> $text{'default'}\n",
34         &getval("passwd program") eq "" ? "checked" : "";
35 printf "<input type=radio name=passwd_program_def value=0 %s>\n",
36         &getval("passwd program") eq "" ? "" : "checked";
37 printf "<input size=15 name=passwd_program value=\"%s\"></td>\n",
38         &getval("passwd program");
39
40 print "<td><b>$text{'passwd_sync'}</b></td>\n";
41 printf "<td><input type=radio name=unix_password_sync value=yes %s> $text{'yes'}\n",
42         &istrue("unix password sync") ? "checked" : "";
43 printf "$gap <input type=radio name=unix_password_sync value=no %s> $text{'no'}</td></tr>\n",
44         &istrue("unix password sync") ? "" : "checked";
45
46 print "<tr> <td valign=top><b>$text{'passwd_chat'}</b></td>\n";
47 print "<td colspan=3>\n";
48 printf "<input type=radio name=passwd_chat_def value=1 %s> $text{'default'}\n",
49         &getval("passwd chat") eq "" ? "checked" : "";
50 printf "<input type=radio name=passwd_chat_def value=0 %s> $text{'passwd_below'}<br>\n",
51         &getval("passwd chat") eq "" ? "" : "checked";
52 print "<table border> <tr><td><b>$text{'passwd_waitfor'}</b></td> <td><b>$text{'passwd_send'}</b></td></tr>\n";
53 $pc = &getval("passwd chat");
54 while($pc =~ /^"([^"]*)"\s*(.*)/ || $pc =~ /^(\S+)\s*(.*)/) {
55         if ($send) { push(@send, $1); $send = 0; }
56         else { push(@recv, $1); $send = 1; }
57         $pc = $2;
58         }
59 for($i=0; $i<(@recv < 5 ? 5 : @recv+1); $i++) {
60         printf "<tr><td><input name=chat_recv_$i value=\"%s\" size=20></td>\n",
61                 $recv[$i] eq "." ? "" : $recv[$i];
62         printf "<td><input name=chat_send_$i value=\"%s\" size=20></td></tr>\n",
63                 $send[$i];
64         }
65 print "</table></td> </tr>\n";
66
67 print "<tr> <td valign=top><b>$text{'passwd_map'}</b></td>\n";
68 print "<td colspan=3>\n";
69 printf "<input type=radio name=username_map_def value=1 %s> $text{'config_none'}\n",
70         &getval("username map") eq "" ? "checked" : "";
71 printf"<input type=radio name=username_map_def value=0 %s> $text{'passwd_below'}<br>\n",
72         &getval("username map") eq "" ? "" : "checked";
73 print "<table border> <tr><td><b>$text{'passwd_unixuser'}</b></td>\n";
74 print "                   <td><b>$text{'passwd_winuser'}</b></td></tr>\n";
75 open(UMAP, &getval("username map"));
76 while(<UMAP>) {
77         s/\r|\n//g;
78         s/[#;].*$//g;
79         if (/^\s*(\S+)\s*=\s*(.*)$/) {
80                 local $uunix = $1;
81                 local $rest = $2;
82                 while($rest =~ /^\s*"([^"]*)"(.*)$/ ||
83                       $rest =~ /^\s*(\S+)(.*)$/) {
84                         push(@uunix, $uunix);
85                         push(@uwin, $1);
86                         $rest = $2;
87                         }
88                 }
89         }
90 close(UMAP);
91 for($i=0; $i<@uunix+1; $i++) {
92         printf "<tr> <td><input name=umap_unix_$i size=8 value=\"%s\"></td>\n",
93                 $uunix[$i];
94         printf "<td><input name=umap_win_$i size=30 value=\"%s\"></td> </tr>\n",
95                 $uwin[$i];
96         }
97 print "</table></td> </tr>\n";
98
99 print "</table></td></tr></table><p>\n";
100 print "<input type=submit value=$text{'save'}></form>\n";
101
102 &ui_print_footer("", $text{'index_sharelist'});