From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15567 invoked by alias); 24 Sep 2008 20:19:22 -0000 Received: (qmail 15561 invoked by alias); 24 Sep 2008 20:19:22 -0000 X-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,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: STABLE2 - 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/STABLE2 X-Git-Reftype: branch X-Git-Oldrev: 14409bc4ff53cd8c596d2eb06b881840195089de X-Git-Newrev: 2fd99f351d7d694c3b7773500bc7994a6cb3196e From: Lon Hohberger Message-Id: <20080924201754.EE56712042B@lists.fedorahosted.org> Date: Wed, 24 Sep 2008 21:17: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/msg00525.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=2fd99f351d7d694c3b7773500bc7994a6cb3196e Commit: 2fd99f351d7d694c3b7773500bc7994a6cb3196e Parent: 14409bc4ff53cd8c596d2eb06b881840195089de Author: Lon Hohberger AuthorDate: Thu Aug 28 16:52:36 2008 -0400 Committer: Lon Hohberger CommitterDate: Wed Sep 24 16:17:47 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 99b3b3f..6764d28 100644 --- a/group/tool/main.c +++ b/group/tool/main.c @@ -89,7 +89,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"); @@ -258,7 +260,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; @@ -275,6 +277,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); @@ -323,7 +337,7 @@ int do_ls(int argc, char **argv) } printf("]\n"); } - return 0; + return ret; } static int connect_daemon(char *path)