Handle hostnames with upper-case letters
[webmin.git] / usermin / edit_session.cgi
1 #!/usr/local/bin/perl
2 # edit_session.cgi
3 # Edit session login options
4
5 require './usermin-lib.pl';
6 $access{'session'} || &error($text{'acl_ecannot'});
7 print "Set-Cookie: sessiontest=1; path=/\n";
8 &ui_print_header(undef, $text{'session_title'}, "");
9 &get_usermin_miniserv_config(\%miniserv);
10 $ver = &get_usermin_version();
11
12 &get_usermin_config(\%uconfig);
13 print "$text{'session_desc1'}<p>\n";
14 print "$text{'session_desc2'}<p>\n";
15
16 print "<form action=change_session.cgi>\n";
17 print "<table border>\n";
18 print "<tr $tb> <td><b>$text{'session_header'}</b></td> </tr>\n";
19 print "<tr $cb> <td nowrap>\n";
20
21 # Bad password delay
22 printf "<input type=radio name=passdelay value=0 %s> %s<br>\n",
23         $miniserv{'passdelay'} ? '' : 'checked', $text{'session_pdisable'};
24 printf "<input type=radio name=passdelay value=1 %s> %s<br>\n",
25         $miniserv{'passdelay'} ? 'checked' : '', $text{'session_penable'};
26
27 # Block hosts
28 printf "&nbsp;&nbsp;&nbsp;<input type=checkbox name=blockhost_on value=1 %s>\n",
29         $miniserv{'blockhost_failures'} ? "checked" : "";
30 print &text('session_blockhost',
31     &ui_textbox("blockhost_failures", $miniserv{'blockhost_failures'}, 4),
32     &ui_textbox("blockhost_time", $miniserv{'blockhost_time'}, 4)),"<br>\n";
33
34 # Block users
35 printf "&nbsp;&nbsp;&nbsp;<input type=checkbox name=blockuser_on value=1 %s>\n",
36         $miniserv{'blockuser_failures'} ? "checked" : "";
37 print &text('session_blockuser',
38     &ui_textbox("blockuser_failures", $miniserv{'blockuser_failures'}, 4),
39     &ui_textbox("blockuser_time", $miniserv{'blockuser_time'}, 4)),"<br>\n";
40
41 # Log to syslog
42 eval "use Sys::Syslog qw(:DEFAULT setlogsock)";
43 if (!$@) {
44         printf "<input type=checkbox name=syslog value=1 %s> %s\n",
45                 $miniserv{'syslog'} ? "checked" : "", $text{'session_syslog2'};
46         }
47 else {
48         print "<input type=hidden name=syslog value='$miniserv{'syslog'}'>\n";
49         }
50 print "<p>\n";
51
52 printf "<input type=radio name=session value=0 %s> %s<br>\n",
53         !$miniserv{'session'} ? "checked" : "", $text{'session_disable'};
54 printf "<input type=radio name=session value=1 %s> %s<br>\n",
55         $miniserv{'session'} ? "checked" : "", $text{'session_enable'};
56 printf "&nbsp;&nbsp;&nbsp;<input type=checkbox name=logouttime_on value=1 %s>\n",
57         $miniserv{'logouttime'} ? "checked" : "";
58 print &text('session_logouttime',
59         "<input name=logouttime value='$miniserv{'logouttime'}' size=10>"),"<br>\n";
60 #printf "&nbsp;&nbsp;&nbsp;<input type=checkbox name=locking value=1 %s>\n",
61 #       $gconfig{'locking'} ? "checked" : "";
62 #print "$text{'session_locking'}<br>\n";
63 printf "&nbsp;&nbsp;&nbsp;<input type=checkbox name=remember value=1 %s>\n",
64         $uconfig{'noremember'} ? "" : "checked";
65 print "$text{'session_remember'}<br>\n";
66 print "&nbsp;&nbsp;&nbsp;";
67 printf "<input type=checkbox name=realname value=1 %s>\n",
68         $uconfig{'realname'} ? "checked" : "";
69 print "$text{'session_realname'}<br>\n";
70 if ($ver >= 1.153) {
71         printf "&nbsp;&nbsp;&nbsp;<input type=checkbox name=utmp value=1 %s>\n",
72                 $miniserv{'utmp'} ? "checked" : "";
73         print "$text{'session_utmp'}<br>\n";
74         }
75 printf "&nbsp;&nbsp;&nbsp;<input type=radio name=banner_def value=1 %s> %s\n",
76         $uconfig{'loginbanner'} ? "" : "checked", $text{'session_banner1'};
77 printf "<input type=radio name=banner_def value=0 %s> %s\n",
78         $uconfig{'loginbanner'} ? "checked" : "", $text{'session_banner0'};
79 printf "<input name=banner size=30 value='%s'> %s<br>\n",
80         $uconfig{'loginbanner'}, &file_chooser_button("banner");
81 print "<p>\n";
82
83 printf "<input type=radio name=localauth value=0 %s> %s<br>\n",
84         !$miniserv{'localauth'} ? "checked" : "", $text{'session_localoff'};
85 printf "<input type=radio name=localauth value=1 %s> %s<br>\n",
86         $miniserv{'localauth'} ? "checked" : "", $text{'session_localon'};
87 print "<p>\n";
88
89 # Authentication mode
90 @users = &get_usermin_miniserv_users();
91 $authmode = $users[0]->{'pass'} eq 'e' ? 2 :
92             $miniserv{'no_pam'} ? 1 : 0;
93 printf "<input type=radio name=authmode value=0 %s> %s<br>\n",
94         $authmode == 0 ? "checked" : "", $text{'session_authmode0'};
95 print "&nbsp;&nbsp;&nbsp;",
96         &ui_checkbox("pam_conv", 1, $text{'session_pamconv'},
97                      $miniserv{'pam_conv'}),"<br>\n";
98 printf "<input type=radio name=authmode value=1 %s>\n",
99         $authmode == 1 ? "checked" : "";
100 print &text('session_authmode1',
101       "<input name=passwd_file size=20 value='$miniserv{'passwd_file'}'>",
102       "<input name=passwd_uindex size=2 value='$miniserv{'passwd_uindex'}'>",
103       "<input name=passwd_pindex size=2 value='$miniserv{'passwd_pindex'}'>"),
104       "<br>\n";
105 printf "<input type=radio name=authmode value=2 %s> %s\n",
106         $authmode == 2 ? "checked" : "", $text{'session_authmode2'};
107 printf "<input name=extauth size=30 value='%s'><p>\n",
108         $miniserv{'extauth'};
109
110 # Unix password change
111 print &ui_oneradio("cmd_def", 1, $text{'session_cmddef1'},
112                    !$gconfig{'passwd_cmd'}),"<br>\n";
113 print &ui_oneradio("cmd_def", 0, $text{'session_cmddef0'},
114                    $gconfig{'passwd_cmd'})," ",
115       &ui_textbox("cmd", $gconfig{'passwd_cmd'}, 40),"<p>\n";
116
117 if ($ver >= 1.047 && $miniserv{'passwd_cindex'} ne '') {
118         #print "$text{'session_pmodedesc'}<br>\n";
119         foreach $m (0 .. 2) {
120                 printf "<input type=radio name=passwd_mode value=%d %s> %s\n",
121                         $m, $miniserv{'passwd_mode'} == $m ? "checked" : "",
122                         $text{'session_pmode'.$m};
123                 print $m == 2 ? "<p>\n" : "<br>\n";
124                 }
125         }
126
127 # Prompt to choose password at login
128 if ($ver >= 1.087) {
129         printf "<input type=checkbox name=passwd_blank value=1 %s> %s<br>\n",
130                 $miniserv{'passwd_blank'} ? "checked" : "",
131                 $text{'session_blank'};
132         }
133
134 if ($ver >= 1.003) {
135         printf "<input type=checkbox name=domainuser value=1 %s> %s<br>\n",
136                 $miniserv{'domainuser'} ? "checked" : "",
137                 $text{'session_domain'};
138         }
139 if ($ver >= 1.021) {
140         printf "<input type=checkbox name=domainstrip value=1 %s> %s<br>\n",
141                 $miniserv{'domainstrip'} ? "checked" : "",
142                 $text{'session_strip'};
143         printf "<input type=checkbox name=user_mapping_on value=1 %s> %s\n",
144                 $miniserv{'user_mapping'} ? "checked" : "",
145                 $text{'session_usermap'};
146         printf "<input name=user_mapping size=30 value='%s'> %s<br>\n",
147                 $miniserv{'user_mapping'}, &file_chooser_button("user_mapping");
148         print "&nbsp;" x 3;
149         printf "$text{'session_userfmt'}\n";
150         print &ui_radio("user_mapping_reverse",
151                         int($miniserv{'user_mapping_reverse'}),
152                         [ [ 0, $text{'session_userfmt0'} ],
153                           [ 1, $text{'session_userfmt1'} ] ]),"<p>\n";
154         }
155
156 # Prompt to choose password at login
157 if ($ver >= 1.142) {
158         printf "<input type=checkbox name=create_homedir value=1 %s> %s<br>\n",
159                 $uconfig{'create_homedir'} ? "checked" : "",
160                 $text{'session_homedir'};
161         print "&nbsp;" x 3;
162         print $text{'session_homedir_perms'},"\n",
163               &ui_opt_textbox("create_homedir_perms",
164                 $uconfig{'create_homedir_perms'}, 4, $text{'default'}),"<br>\n";
165         }
166
167 print "</td> </tr></table>\n";
168 print "<input type=submit value=\"$text{'save'}\"></form>\n";
169
170 &ui_print_footer("", $text{'index_return'});
171