3 # Changes a user's password on all cluster servers. Also changes
4 # the password in other modules.
7 $ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
8 $ENV{'WEBMIN_VAR'} ||= "/var/webmin";
9 if ($0 =~ /^(.*\/)[^\/]+$/) {
13 $0 = "$pwd/change-passwd.pl";
14 do './cluster-passwd-lib.pl';
16 if ($ARGV[0] eq "--old" || $ARGV[0] eq "-old") {
20 @ARGV == 1 || &errordie("usage: change-passwd.pl [-old] <username>");
21 if (&foreign_installed("cluster-useradmin") != 1) {
22 &errordie("Cluster Users and Groups module is not available");
26 @hosts = &cluster_useradmin::list_useradmin_hosts();
27 @ulist = &get_all_users(\@hosts);
28 ($user) = grep { $_->{'user'} eq $ARGV[0] } @ulist;
29 $user || &errordie("User $ARGV[0] does not exist");
33 # Ask for the old password
34 print "(current) UNIX password: ";
37 &unix_crypt($old, $user->{'pass'}) eq $user->{'pass'} ||
38 &errordie("Old password is incorrect");
42 print "New password: ";
45 print "Retype new password: ";
48 $pass eq $again || &errordie("Passwords don't match");
50 # Check password sanity
51 $err = &useradmin::check_password_restrictions($pass, $ARGV[0]);
52 &errordie($err) if ($err);
54 # Do it on all servers
55 &modify_on_hosts(\@hosts, $user->{'user'}, $pass, 1, \&print_func);
66 # print_func(mode, message)
74 print "$indent$_[1]\n";
77 print "$indent$_[1]\n\n";
84 print "$indent$_[1]\n\n";