Commit 86276af0 authored by Leigh Stoller's avatar Leigh Stoller

Merge branch 'pswd_expires_upd' into 'master'

two additional updates for EXPIRE_PASSWORDS=0 mode

See merge request !47
parents 33652d9c ee6cf209
......@@ -40,14 +40,19 @@ use Getopt::Std;
# and forces the target user into that state. Eventually, this should
# be the default mode of operation (independent of web interface).
#
# Use -e with passwd to apply the default password expire interval to
# the new password, otherwise the password is expired immediately to
# force a change.
#
sub usage()
{
print("Usage: tbacct [-f] [-b] [-u] [-v] ".
print("Usage: tbacct [-e] [-f] [-b] [-u] [-v] ".
"<add|del|mod|passwd|wpasswd|email|freeze|thaw|verify|revoke|dots|deactivate|reactivate> ".
"<user> [args]\n");
exit(-1);
}
my $optlist = "fbuvs";
my $optlist = "efbuvs";
my $expok = 0;
my $force = 0;
my $batch = 0;
my $update = 0;
......@@ -201,6 +206,9 @@ if (scalar(@ARGV) == 3 && $ARGV[0] eq "passwd") {
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"e"})) {
$expok = 1;
}
if (defined($options{"f"})) {
$force = 1;
}
......@@ -701,13 +709,13 @@ sub UpdatePassword()
}
#
# Insert into database. When changing password for someone else,
# always set the expiration to right now so that the target user
# is "forced" to change it.
# Insert into database. When changing password for someone else
# and "-e" (expok) isn't set, then set the expiration to right
# now so that the target user is "forced" to change it.
#
my $expires;
if (! $target_user->SameUser($this_user)) {
if (!$expok && ! $target_user->SameUser($this_user)) {
$expires = "now()";
}
elsif ($EXPIRE_PASSWORDS) {
......
......@@ -678,7 +678,8 @@ sub Create($$$$)
}
else {
push(@insert_data, "status='$USERSTATUS_NEWUSER'");
push(@insert_data, "pswd_expires=date_add(now(), interval 1 year)");
push(@insert_data, "pswd_expires=date_add(now(), interval 1 year)")
if ($EXPIRE_PASSWORDS);
}
# Insert into DB.
......
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