diff options
Diffstat (limited to 'utils/rhrd-user')
-rwxr-xr-x | utils/rhrd-user | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/utils/rhrd-user b/utils/rhrd-user index 4d613b6..b6d5ac6 100755 --- a/utils/rhrd-user +++ b/utils/rhrd-user @@ -27,8 +27,9 @@ use String::MkPasswd qw(mkpasswd); sub print_usage { print STDERR "Usage: rhrd-user list\n" . - " rhrd-user (check|remove|groups|is-grids) <username>\n" . + " rhrd-user (check|groups|is-grids) <username>\n" . " rhrd-user add <username> [ <fullname> ]\n" . + " rhrd-user remove [ -f ] <username>\n" . " rhrd-user set-grids <username> (1|0)\n"; } @@ -72,7 +73,13 @@ sub add sub remove { - my ($ctx, $username) = @_; + my ($ctx, $username, $force) = @_; + + if(!$force) { + return 1 if(!RHRD::utils::cmdline_ask_yn("do you really want to delete user '$username'")); + print("\n"); + } + print("removing user: $username\n"); my @results = RHRD::rddb::remove_user($ctx, $username); if(!defined $results[0] && defined $results[2]) { @@ -166,11 +173,20 @@ if(defined $ctx) { $ret = add($ctx, $username, $ARGV[2]); } } elsif($cmd eq "remove") { - if($num_args != 2) { + if($num_args < 2 || $num_args > 3) { print_usage(); $ret = 1; } else { - $ret = remove($ctx, $username); + if($num_args == 3) { + if($ARGV[1] ne '-f') { + print_usage(); + $ret = 1; + } else { + $ret = remove($ctx, $ARGV[2], 1); + } + } else { + $ret = remove($ctx, $username, 0); + } } } elsif($cmd eq "groups") { if($num_args != 2) { |