From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26470 invoked by alias); 28 Aug 2008 20:55:17 -0000 Received: (qmail 26464 invoked by alias); 28 Aug 2008 20:55:17 -0000 X-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_05,KAM_MX,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com X-Spam-Level: Subject: RHEL5 - group: Allow group_tool ls to be scriptable To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: 46bf9c4fd9ba8e96224430bb90c33e2483bc7ff9 X-Git-Newrev: f92fd23fde054edc4585145e5b7122c1addb95b4 From: Lon Hohberger Message-Id: <20080828205408.A74D8120379@lists.fedorahosted.org> Date: Thu, 28 Aug 2008 21:37:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q3/txt/msg00358.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f92fd23fde054edc4585145e5b7122c1addb95b4 Commit: f92fd23fde054edc4585145e5b7122c1addb95b4 Parent: 46bf9c4fd9ba8e96224430bb90c33e2483bc7ff9 Author: Lon Hohberger AuthorDate: Thu Aug 28 16:52:36 2008 -0400 Committer: Lon Hohberger CommitterDate: Thu Aug 28 16:53:54 2008 -0400 group: Allow group_tool ls 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 Show information one group\n"); + printf("ls 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)