public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: RHEL5 - group: Allow group_tool ls <name> <level> to be scriptable Date: Thu, 28 Aug 2008 21:37:00 -0000 [thread overview] Message-ID: <20080828205408.A74D8120379@lists.fedorahosted.org> (raw) 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)
reply other threads:[~2008-08-28 20:55 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080828205408.A74D8120379@lists.fedorahosted.org \ --to=lon@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).