Commit 4a73b9ce authored by Leigh B Stoller's avatar Leigh B Stoller

Move chpass into an accountproxy command, rather the ssh invoking

chpass directly.
parent 59fb0036
...@@ -42,6 +42,7 @@ sub usage() ...@@ -42,6 +42,7 @@ sub usage()
print "Usage: accountsetup adduser ...\n"; print "Usage: accountsetup adduser ...\n";
print " accountsetup deluser ...\n"; print " accountsetup deluser ...\n";
print " accountsetup moduser ...\n"; print " accountsetup moduser ...\n";
print " accountsetup chpass ...\n";
print " accountsetup addproject ...\n"; print " accountsetup addproject ...\n";
print " accountsetup addgroup ...\n"; print " accountsetup addgroup ...\n";
print " accountsetup delproject ...\n"; print " accountsetup delproject ...\n";
...@@ -124,6 +125,7 @@ my @GDIRLIST = ("exp", "images", "logs", "tarfiles", "rpms", "tiplogs"); ...@@ -124,6 +125,7 @@ my @GDIRLIST = ("exp", "images", "logs", "tarfiles", "rpms", "tiplogs");
sub AddUser(); sub AddUser();
sub DeleteUser(); sub DeleteUser();
sub ModifyUser(); sub ModifyUser();
sub ChangePassword();
sub AddProject(); sub AddProject();
sub AddGroup(); sub AddGroup();
sub DelProject(); sub DelProject();
...@@ -177,6 +179,10 @@ SWITCH: for ($cmd) { ...@@ -177,6 +179,10 @@ SWITCH: for ($cmd) {
ModifyUser(); ModifyUser();
last SWITCH; last SWITCH;
}; };
/^chpass$/ && do {
ChangePassword();
last SWITCH;
};
/^addproject$/ && do { /^addproject$/ && do {
AddProject(); AddProject();
last SWITCH; last SWITCH;
...@@ -233,7 +239,6 @@ sub AddUser() ...@@ -233,7 +239,6 @@ sub AddUser()
my $hdir = shift(@ARGV); my $hdir = shift(@ARGV);
my $gid = shift(@ARGV); my $gid = shift(@ARGV);
my $shell = shift(@ARGV); my $shell = shift(@ARGV);
my $hash = (@ARGV ? shift(@ARGV) : undef);
if (! -d "$hdir") { if (! -d "$hdir") {
# XXX we only handle homedirs of the form /users/$user here... # XXX we only handle homedirs of the form /users/$user here...
...@@ -284,13 +289,6 @@ sub AddUser() ...@@ -284,13 +289,6 @@ sub AddUser()
chmod(0700, "$hdir/$dir") chmod(0700, "$hdir/$dir")
or fatal("Could not chmod '$hdir/$dir' to 0700: $!"); or fatal("Could not chmod '$hdir/$dir' to 0700: $!");
} }
#
# Finally, set any initial password hash
#
if (defined($hash) &&
mysystem("$CHPASS -p '$hash' $user")) {
fatal("Could not initialize password");
}
return 0; return 0;
} }
...@@ -346,6 +344,20 @@ sub ModifyUser() ...@@ -346,6 +344,20 @@ sub ModifyUser()
return 0; return 0;
} }
sub ChangePassword()
{
if (@ARGV != 2) {
fatal("chpass: Wrong number of arguments");
}
my $user = shift(@ARGV);
my $hash = shift(@ARGV);
if (mysystem("$CHPASS -p '$hash' $user")) {
fatal("Could not change password");
}
return 0;
}
# #
# Usage: deactivate username # Usage: deactivate username
# #
......
...@@ -467,7 +467,8 @@ sub AddUser() ...@@ -467,7 +467,8 @@ sub AddUser()
$pswd =~ s/\*/\\\*/g; $pswd =~ s/\*/\\\*/g;
print "Initializing user $user password on $CONTROL.\n"; print "Initializing user $user password on $CONTROL.\n";
if (system("$SSH -host $CONTROL $CHPASS -p '$pswd' $user")) { if (system("$SSH -host $CONTROL ".
" \"$ACCOUNTPROXY chpass $user '$pswd'\"")) {
fatal("Could not initialize password for $user on $CONTROL!"); fatal("Could not initialize password for $user on $CONTROL!");
} }
} }
...@@ -678,7 +679,7 @@ sub UpdatePassword() ...@@ -678,7 +679,7 @@ sub UpdatePassword()
my $new_pswd = shift(@ARGV); my $new_pswd = shift(@ARGV);
# Lets not do this if no changes. # Lets not do this if no changes.
if ($new_pswd eq $target_user->pswd()) { if ($new_pswd eq $target_user->pswd() && !$force) {
print "Password has not changed ...\n"; print "Password has not changed ...\n";
return 0; return 0;
} }
...@@ -752,9 +753,10 @@ sub UpdatePassword() ...@@ -752,9 +753,10 @@ sub UpdatePassword()
$UID = 0; $UID = 0;
if ($CONTROL ne $BOSSNODE) { if ($CONTROL ne $BOSSNODE) {
print "Updating user $user password on $CONTROL.\n"; print "Updating user $user password on $CONTROL.\n";
if (system("$SSH -host $CONTROL $CHPASS -p '$safe_pswd' $user")) { if (system("$SSH -host $CONTROL ".
fatal("Could not change password for user $user on $CONTROL!"); " \"$ACCOUNTPROXY chpass $user '$safe_pswd'\"")) {
fatal("Could not change password for $user on $CONTROL!");
} }
} }
$UID = $SAVEUID; $UID = $SAVEUID;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment