From: Michael Meffie Date: Wed, 17 Mar 2010 23:16:50 +0000 (-0400) Subject: pts mem -supergroup option X-Git-Tag: openafs-devel-1_5_74~60 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5b44b5dfe0d7aee14f87df9a6b8c5e582473d0fe;p=packages%2Fo%2Fopenafs.git pts mem -supergroup option Improve pts support for supergroups with an option to list the supergroups of a group. Change-Id: I4fe1cd131cd334386bc16ce733e01e29e0511d4f Reviewed-on: http://gerrit.openafs.org/1600 Reviewed-by: Andrew Deason Tested-by: Andrew Deason Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/doc/man-pages/pod1/pts_membership.pod b/doc/man-pages/pod1/pts_membership.pod index 0154bb234..d6680fe0f 100644 --- a/doc/man-pages/pod1/pts_membership.pod +++ b/doc/man-pages/pod1/pts_membership.pod @@ -8,16 +8,20 @@ pts_membership - Displays the membership list for a user or group
B S<<< B<-nameorid> >+ >>> + [B<-supergroups>] S<<< [B<-cell> >] >>> [B<-localauth>] [B<-noauth>] [B<-force>] [B<-help>] -B S<<< B<-na> >+ >>> S<<< [B<-c> >] >>> +B S<<< B<-na> >+ >>> + [B<-s>] S<<< [B<-c> >] >>> [B<-no>] [B<-l>] [B<-f>] [B<-h>] -B S<<< B<-na> >+ >>> [-c >] +B S<<< B<-na> >+ >>> + [B<-s>] S<<< [B<-c> >] >>> [B<-no>] [B<-l>] [B<-f>] [B<-h>] -B S<<< B<-na> >+ >>> S<<< [B<-c> >] >>> +B S<<< B<-na> >+ >>> + [B<-s>] S<<< [B<-c> >] >>> [B<-no>] [B<-l>] [B<-f>] [B<-h>] =for html @@ -50,6 +54,13 @@ mix users, machines, and groups on the same command line, as well as names and IDs. Precede the GID of each group with a hyphen to indicate that it is negative. +=item B<-supergroups> + +List the groups to which each group specified by the B<-nameorid> +argument belongs, in addition to user and machine members. Group +membership may be nested when B is compilied with the +SUPERGROUPS option enabled. + =item B<-cell> > Names the cell in which to run the command. For more details, see diff --git a/src/ptserver/pts.c b/src/ptserver/pts.c index 56cfc743a..5108b1ea4 100644 --- a/src/ptserver/pts.c +++ b/src/ptserver/pts.c @@ -623,6 +623,24 @@ ListMembership(struct cmd_syndesc *as, void *arock) printf(" %s\n", list.namelist_val[j]); if (list.namelist_val) free(list.namelist_val); + if (as->parms[1].items && id < 0) { /* -supergroups */ + list.namelist_val = 0; + list.namelist_len = 0; + code = pr_ListSuperGroups(ids.idlist_val[i], &list); + if (code == RXGEN_OPCODE) { + continue; /* server does not support supergroups */ + } else if (code != 0) { + afs_com_err(whoami, code, + "; unable to get supergroups of %s (id: %d)", + name, id); + continue; + } + printf("Groups %s (id: %d) is a member of:\n", name, id); + for (j = 0; j < list.namelist_len; j++) + printf(" %s\n", list.namelist_val[j]); + if (list.namelist_val) + free(list.namelist_val); + } } if (ids.idlist_val) free(ids.idlist_val); @@ -1144,6 +1162,7 @@ main(int argc, char **argv) ts = cmd_CreateSyntax("membership", ListMembership, NULL, "list membership of a user or group"); cmd_AddParm(ts, "-nameorid", CMD_LIST, 0, "user or group name or id"); + cmd_AddParm(ts, "-supergroups", CMD_FLAG, CMD_OPTIONAL, "show supergroups"); add_std_args(ts); cmd_CreateAlias(ts, "groups"); diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c index b3ee8be6a..9e1b915f0 100644 --- a/src/ptserver/ptuser.c +++ b/src/ptserver/ptuser.c @@ -752,3 +752,27 @@ pr_SetFieldsEntry(afs_int32 id, afs_int32 mask, afs_int32 flags, afs_int32 ngrou nusers, 0, 0); return code; } + +int +pr_ListSuperGroups(afs_int32 gid, namelist * lnames) +{ + afs_int32 code; + prlist alist; + idlist *lids; + afs_int32 over; + + alist.prlist_len = 0; + alist.prlist_val = 0; + code = ubik_PR_ListSuperGroups(pruclient, 0, gid, &alist, &over); + if (code) + return code; + if (over) { + fprintf(stderr, "supergroup list for id %d exceeds display limit\n", + gid); + } + lids = (idlist *) & alist; + code = pr_IdToName(lids, lnames); + + xdr_free((xdrproc_t) xdr_prlist, &alist); + return code; +} diff --git a/src/ptserver/ptuser.h b/src/ptserver/ptuser.h index 8653febe7..e5971106b 100644 --- a/src/ptserver/ptuser.h +++ b/src/ptserver/ptuser.h @@ -52,5 +52,6 @@ extern int pr_SetMaxGroupId(afs_int32 mid); extern afs_int32 pr_SetFieldsEntry(afs_int32 id, afs_int32 mask, afs_int32 flags, afs_int32 ngroups, afs_int32 nusers); +extern int pr_ListSuperGroups(afs_int32 gid, namelist *lnames); #endif /* PTUSER_H */