diff options
Diffstat (limited to 'utils/update-rd-tokens')
-rwxr-xr-x | utils/update-rd-tokens | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/utils/update-rd-tokens b/utils/update-rd-tokens index 63b4750..8983b17 100755 --- a/utils/update-rd-tokens +++ b/utils/update-rd-tokens @@ -32,31 +32,32 @@ if ($> != 0 ) { my $num_args = $#ARGV + 1; if ($num_args <= 0) { - print STDERR "WARNING: this will update all users tokens (except for admin)\n"; + print STDERR "WARNING: this will update all user tokens (except for admin)\n"; } my %EXCLUDED_USERS = map { $_ => 1 } @ARGV; $EXCLUDED_USERS{'admin'} = 1; +my $ret = 0; my ($dbh, undef, $errorstring) = RHRD::rddb::opendb(); if(defined $dbh) { my @users = RHRD::rddb::list_users($dbh); if(!defined $users[0] && defined $users[2]) { print STDERR "$users[2]\n"; - exit 1; - } - - foreach my $user (@users) { - next if(exists($EXCLUDED_USERS{$user})); - my $token = mkpasswd(-length => 16, -minnum => 3, -minupper => 3, -minspecial => 0); - RHRD::rddb::set_token($dbh, $user, $token); - print "$user -> $token\n"; + $ret = 1; + } else { + foreach my $user (@users) { + next if(exists($EXCLUDED_USERS{$user})); + my $token = mkpasswd(-length => 16, -minnum => 3, -minupper => 3, -minspecial => 0); + RHRD::rddb::set_token($dbh, $user, $token); + print "$user -> $token\n"; + } } RHRD::rddb::closedb($dbh); } else { print STDERR "$errorstring\n"; - exit 1; + $ret = 1; } -exit 0 +exit $ret; |