diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-25 20:40:04 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-25 20:40:33 (GMT) |
commit | 53f3a59216455a5aa3208191be76782eba246ba1 (patch) | |
tree | 539e2b53d2d9d976d6cc075853941ff253daf626 /utils/rhrd-user | |
parent | df6717fea5d717e3ed3a27612339b9b80930abca (diff) |
implemented command to list groups of user
Diffstat (limited to 'utils/rhrd-user')
-rwxr-xr-x | utils/rhrd-user | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/utils/rhrd-user b/utils/rhrd-user index a473ddc..9d606eb 100755 --- a/utils/rhrd-user +++ b/utils/rhrd-user @@ -27,7 +27,7 @@ use String::MkPasswd qw(mkpasswd); sub print_usage { print STDERR "Usage: rhrd-user list\n" . - " rhrd-user (check|remove) <username>\n" . + " rhrd-user (check|remove|groups) <username>\n" . " rhrd-user add <username> [ <fullname> ]\n"; } @@ -84,6 +84,21 @@ sub remove return 0; } +sub groups +{ + my ($ctx, $username) = @_; + + my @groups = RHRD::rddb::get_user_groups($ctx, $username); + if(!defined $groups[0] && defined $groups[1]) { + print STDERR "$groups[1]: $groups[2]"; + return 1; + } + for my $user (@groups) { + print $user . "\n"; + } + return 0; +} + my $num_args = $#ARGV + 1; if($num_args < 1) { @@ -125,6 +140,13 @@ if(defined $ctx) { } else { $ret = remove($ctx, $username); } + } elsif($cmd eq "groups") { + if($num_args != 2) { + print_usage(); + $ret = 1; + } else { + $ret = groups($ctx, $username); + } } else { print_usage(); $ret = 1; |