summaryrefslogtreecommitdiff
path: root/utils/update-rd-tokens
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-09-30 15:07:41 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-09-30 15:07:41 (GMT)
commit5897b1bc3b059a29f57bde6c08344deceb41bd23 (patch)
treef2ca2ba16403ac0d65286fc1b5e3d9783440b32b /utils/update-rd-tokens
parentefb5d6557591ef21c27aa46aae220d862c36feeb (diff)
major cleanup for all utils
Diffstat (limited to 'utils/update-rd-tokens')
-rwxr-xr-xutils/update-rd-tokens23
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;