summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-user24
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;