public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* RHEL5 - group: Allow group_tool ls <name> <level> to be scriptable
@ 2008-08-28 21:37 Lon Hohberger
0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2008-08-28 21:37 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f92fd23fde054edc4585145e5b7122c1addb95b4
Commit: f92fd23fde054edc4585145e5b7122c1addb95b4
Parent: 46bf9c4fd9ba8e96224430bb90c33e2483bc7ff9
Author: Lon Hohberger <lhh@redhat.com>
AuthorDate: Thu Aug 28 16:52:36 2008 -0400
Committer: Lon Hohberger <lhh@redhat.com>
CommitterDate: Thu Aug 28 16:53:54 2008 -0400
group: Allow group_tool ls <name> <level> to be scriptable
* Returns 1 if the group is not found or found and not joined
* Returns 0 if the group is found and joined
This is needed to solve rhbz 459754.
---
group/tool/main.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/group/tool/main.c b/group/tool/main.c
index f1915ad..c3565c3 100644
--- a/group/tool/main.c
+++ b/group/tool/main.c
@@ -101,7 +101,9 @@ static void print_usage(void)
printf("\n");
printf("Display group information from groupd\n");
printf("ls Show information for all groups\n");
- printf("ls <level> <name> Show information one group\n");
+ printf("ls <level> <name> Show information one group. If\n");
+ printf(" we are not a member of the group,\n");
+ printf(" return 1.\n");
printf("\n");
printf("Display debugging information\n");
printf("dump Show debug log from groupd\n");
@@ -270,7 +272,7 @@ static int member_compare(const void *va, const void *vb)
int do_ls(int argc, char **argv)
{
group_data_t data[MAX_GROUPS];
- int i, j, rv, count = 0, level;
+ int i, j, rv, count = 0, level, ret = 0;
char *name, *state_header;
int type_width = 16;
int level_width = 5;
@@ -287,6 +289,18 @@ int do_ls(int argc, char **argv)
rv = group_get_group(level, name, data);
count = 1;
+
+ /* don't output if there's no group at all */
+ if (data[0].id == 0) {
+ fprintf(stderr, "groupd has no information about "
+ "the specified group\n");
+ return 1;
+ }
+ /* If we wanted a specific group but we are not
+ joined, print it out - but return failure to
+ the caller */
+ if (data[0].member != 1)
+ ret = 1;
} else
rv = group_get_groups(MAX_GROUPS, &count, data);
@@ -335,7 +349,7 @@ int do_ls(int argc, char **argv)
}
printf("]\n");
}
- return 0;
+ return ret;
}
static int connect_daemon(char *path)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-28 20:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-28 21:37 RHEL5 - group: Allow group_tool ls <name> <level> to be scriptable Lon Hohberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).