Handle hostnames with upper-case letters
[webmin.git] / passwd / edit_passwd.cgi
1 #!/usr/local/bin/perl
2 # Show password change form
3
4 require './passwd-lib.pl';
5 &ReadParse();
6 &error_setup($text{'passwd_err'});
7
8 @user = getpwnam($in{'user'});
9 @user || &error($text{'passwd_euser'});
10 &can_edit_passwd(\@user) || &error($text{'passwd_ecannot'});
11 &ui_print_header(undef, $text{'passwd_title'}, "");
12
13 print &ui_form_start("save_passwd.cgi", "post");
14 print &ui_hidden("user", $user[0]);
15 print &ui_hidden("one", $in{'one'});
16 print &ui_table_start($text{'passwd_header'}, undef, 2);
17
18 # Login and real name
19 %uconfig = &foreign_config("useradmin");
20 $user[6] =~ s/,.*$// if ($uconfig{'extra_real'});
21 print &ui_table_row($text{'passwd_for'},
22         $user[0].( $user[6] ? " ($user[6])" : "" ));
23
24 # Old password field
25 if ($access{'old'} == 1 ||
26     $access{'old'} == 2 && $user[0] ne $remote_user) {
27         print &ui_table_row($text{'passwd_old'},
28                 &ui_password("old", undef, 30));
29         }
30
31 # New password
32 print &ui_table_row($text{'passwd_new'},
33         &ui_password("new", undef, 30));
34
35 # New password again
36 if ($access{'repeat'}) {
37         print &ui_table_row($text{'passwd_repeat'},
38                 &ui_password("repeat", undef, 30));
39         }
40
41 # Force change at next login
42 if (!$config{'passwd_cmd'} && $access{'expire'}) {
43         &foreign_require("useradmin", "user-lib.pl");
44         $pft = &useradmin::passfiles_type();
45         ($uuser) = grep { $_->{'user'} eq $in{'user'} }
46                         &useradmin::list_users();
47         if ($uuser->{'max'} && ($pft == 2 || $pft == 5)) {
48                 print &ui_table_row(" ",
49                         &ui_checkbox("expire", 1, $text{'passwd_expire'}, 0));
50                 }
51         }
52
53 # Change in other modules
54 if ($access{'others'} == 2) {
55         print &ui_table_row(" ",
56                 &ui_checkbox("others", 1, $text{'passwd_others'}, 1));
57         }
58
59 print &ui_table_end();
60 print &ui_form_end([ [ undef, $text{'passwd_change'} ] ]);
61
62 &ui_print_footer($in{'one'} ? ( "/", $text{'index'} ) :
63                               ( "", $text{'index_return'} ));
64