From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: 'group' command gives wrong/extra group Resent-From: owen@illinois.edu Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 02 Nov 2010 21:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 7320@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.128873403110117 (code B ref -1); Tue, 02 Nov 2010 21:41:01 +0000 Received: (at submit) by debbugs.gnu.org; 2 Nov 2010 21:40:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PDOak-0002d8-KS for submit@debbugs.gnu.org; Tue, 02 Nov 2010 17:40:31 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PDOWY-0002bE-JS for submit@debbugs.gnu.org; Tue, 02 Nov 2010 17:36:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDOam-0005cO-T0 for submit@debbugs.gnu.org; Tue, 02 Nov 2010 17:40:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:53620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDOam-0005cJ-G2 for submit@debbugs.gnu.org; Tue, 02 Nov 2010 17:40:32 -0400 Received: from [140.186.70.92] (port=36650 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDOak-00067V-JX for bug-coreutils@gnu.org; Tue, 02 Nov 2010 17:40:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDOai-0005c9-R5 for bug-coreutils@gnu.org; Tue, 02 Nov 2010 17:40:29 -0400 Received: from lists.informatics.illinois.edu ([128.174.154.52]:41340 helo=mail.lis.illinois.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDOai-0005bq-Mt for bug-coreutils@gnu.org; Tue, 02 Nov 2010 17:40:28 -0400 Received: (qmail 31958 invoked from network); 2 Nov 2010 21:40:21 -0000 Received: from gwork013.lis.illinois.edu ([128.174.155.13]) by lists.informatics.illinois.edu (qmail-ldap-1.03) with QMQP; 2 Nov 2010 21:40:21 -0000 From: owen@illinois.edu Date: Tue, 2 Nov 2010 16:40:21 -0500 Message-ID: <20101102214020.GA19779@128.174.154.111> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.1 (----) X-Mailman-Approved-At: Tue, 02 Nov 2010 17:40:29 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) Hi, It appears that the 'groups' command doesn't get the list of groups for a currently-running process quite right. The conditions I tested were where the UID and EUID of the process were different, and the GID and EGID were both set to the primary group of the EUID. The groups command looked up the real user and added the primary group from /etc/passwd to the list of groups the user was in, even though the process had no permissions for this extra group. So, for example say /etc/passwd has at least these 2 entries: root:x:0:0:root:/root:/bin/sh user:x:1000:1000:user:/home/user:/bin/sh and /etc/group has at least these 3 entries: root:x:0: other:x:500: user:x:1000: If a process as UID=0, EUID=1000, GID=1000, and EGID=1000 and no supplemental groups, the correct list of groups should be user but the groups command shows user root If the passwd file is changed like so: root:x:0:500:root:/root:/bin/sh then the output of groups is user other --- Tested on Debian Slink groups (GNU coreutils) 8.5 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by David MacKenzie and James Youngman. -- <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> <> Brynnen Owen ( this space for rent )<> <> owen@illinois.edu ( )<> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: 'group' command gives wrong/extra group Resent-From: James Youngman Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 08 Nov 2010 11:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: owen@illinois.edu Cc: 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.128921720014665 (code B ref 7320); Mon, 08 Nov 2010 11:54:02 +0000 Received: (at 7320) by debbugs.gnu.org; 8 Nov 2010 11:53:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PFQHo-0003oU-76 for submit@debbugs.gnu.org; Mon, 08 Nov 2010 06:53:20 -0500 Received: from mail-wy0-f172.google.com ([74.125.82.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PFOzX-000352-2m for 7320@debbugs.gnu.org; Mon, 08 Nov 2010 05:30:23 -0500 Received: by wyb28 with SMTP id 28so5352651wyb.3 for <7320@debbugs.gnu.org>; Mon, 08 Nov 2010 02:35:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.242.78 with SMTP id h56mr5204494wer.47.1289212500355; Mon, 08 Nov 2010 02:35:00 -0800 (PST) Received: by 10.216.231.31 with HTTP; Mon, 8 Nov 2010 02:35:00 -0800 (PST) In-Reply-To: <20101102214020.GA19779@128.174.154.111> References: <20101102214020.GA19779@128.174.154.111> Date: Mon, 8 Nov 2010 10:35:00 +0000 X-Google-Sender-Auth: eHQWf_nXMp-R0o212yPldYfb7wQ Message-ID: From: James Youngman Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -2.6 (--) X-Mailman-Approved-At: Mon, 08 Nov 2010 06:53:19 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Does the same thing happen with "id -G"? From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: Confirmed on coreutils-8.4-13 References: <20101102214020.GA19779@128.174.154.111> In-Reply-To: <20101102214020.GA19779@128.174.154.111> Resent-From: "Marc W. Mengel" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Apr 2012 18:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: <7320@debbugs.gnu.org> Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133546541032213 (code B ref 7320); Thu, 26 Apr 2012 18:37:01 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Apr 2012 18:36:50 +0000 Received: from localhost ([127.0.0.1]:54632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNTYg-0008NW-If for submit@debbugs.gnu.org; Thu, 26 Apr 2012 14:36:50 -0400 Received: from gateway02.fnal.gov ([131.225.104.19]:60830) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNTIL-0007ze-6f for 7320@debbugs.gnu.org; Thu, 26 Apr 2012 14:19:58 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gateway02.fnal.gov (Postfix) with ESMTP id BD360171022E for <7320@debbugs.gnu.org>; Thu, 26 Apr 2012 13:18:56 -0500 (CDT) X-Virus-Scanned: amavisd-new at fnal.gov Received: from gateway02.fnal.gov ([127.0.0.1]) by localhost (gateway02.fnal.gov [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2jKTWPd4dogI for <7320@debbugs.gnu.org>; Thu, 26 Apr 2012 13:16:54 -0500 (CDT) X-Mailgw-Auth: no Received: from MAIL06V-CAS04.fnal.gov (mail06v-cas04.fnal.gov [131.225.199.9]) by gateway02.fnal.gov (Postfix) with ESMTP id 28C881711D31 for <7320@debbugs.gnu.org>; Thu, 26 Apr 2012 13:16:54 -0500 (CDT) Received: from bel-kwinith.fnal.gov (131.225.80.212) by MAIL06V-CAS04.fnal.gov (131.225.199.9) with Microsoft SMTP Server (TLS) id 14.1.355.2; Thu, 26 Apr 2012 13:16:53 -0500 Message-ID: <4F999115.7010802@fnal.gov> Date: Thu, 26 Apr 2012 13:16:53 -0500 From: "Marc W. Mengel" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.26) Gecko/20120216 Red Hat/3.1.18-2.el6_2 Thunderbird/3.1.18 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [131.225.80.212] X-Spam-Score: -1.9 (-) X-Mailman-Approved-At: Thu, 26 Apr 2012 14:36:49 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This is still broken in RedHat in coreutils-8.4-13 All of "groups" and "id" and "id -G" report groups that you don't have if you list a new/different primary group in /etc/passwd. This is just plain wrong. "id" and "groups" should list the groups you actually have, not what you would possibly have if you logged out and back in again. From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: Confirmed on coreutils-8.4-13 Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 11:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "Marc W. Mengel" Cc: 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133552495826950 (code B ref 7320); Fri, 27 Apr 2012 11:10:02 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 11:09:18 +0000 Received: from localhost ([127.0.0.1]:55165 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNj37-00070c-Uf for submit@debbugs.gnu.org; Fri, 27 Apr 2012 07:09:18 -0400 Received: from mx.meyering.net ([88.168.87.75]:37010) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNj33-00070S-GR for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 07:09:15 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 4B5546009F; Fri, 27 Apr 2012 13:08:08 +0200 (CEST) From: Jim Meyering In-Reply-To: <4F999115.7010802@fnal.gov> (Marc W. Mengel's message of "Thu, 26 Apr 2012 13:16:53 -0500") References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> Date: Fri, 27 Apr 2012 13:08:08 +0200 Message-ID: <87vckltotj.fsf@rho.meyering.net> Lines: 79 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Marc W. Mengel wrote: > This is still broken in RedHat in coreutils-8.4-13 > > All of "groups" and "id" and "id -G" report groups that you don't have > if you list a new/different primary group in /etc/passwd. > > This is just plain wrong. "id" and "groups" should list the groups you > actually have, not what you would possibly have if you logged out and > back in again. Thank you for the report. It looks like there is indeed a bug. I demonstrated it with this: echo 'for i in 1 2; do id -G; sleep 1.5; done; sleep 4' \ |su -s /bin/sh ftp - & sleep 1; perl -pi -e 's/^(ftp:x:\d+):(\d+)/$1:9876/' /etc/passwd Those id -G commands printed the following: 50 50 9876 With the patch below, they print this: 50 50 The problem is that group-list.c(print_group_list), called by id.c did not invoke xgetgroups properly. xgetgroups is just a wrapper around mgetgroups, which has this comment: If USERNAME is NULL, store the supplementary groups of the current process, and GID should be -1 or the effective group ID (getegid). In the case you've noted, USERNAME is indeed NULL, so print_group_list should pass the effective group ID, and not getpwuid(ruid)->pw_gid. This also shows that when username is NULL, print_group_list's call to getpwuid is now useless and wasteful. With all that, here's the patch I expect to commit: diff --git a/src/group-list.c b/src/group-list.c index cf49911..edbb342 100644 --- a/src/group-list.c +++ b/src/group-list.c @@ -38,11 +38,14 @@ print_group_list (const char *username, bool use_names) { bool ok = true; - struct passwd *pwd; + struct passwd *pwd = NULL; - pwd = getpwuid (ruid); - if (pwd == NULL) - ok = false; + if (username) + { + pwd = getpwuid (ruid); + if (pwd == NULL) + ok = false; + } if (!print_group (rgid, use_names)) ok = false; @@ -58,8 +61,7 @@ print_group_list (const char *username, gid_t *groups; int i; - int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), - &groups); + int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : egid), &groups); if (n_groups < 0) { if (username) From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 13:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "Marc W. Mengel" , owen@illinois.edu Cc: 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133553429111258 (code B ref 7320); Fri, 27 Apr 2012 13:45:02 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 13:44:51 +0000 Received: from localhost ([127.0.0.1]:55203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNlTd-0002vW-NV for submit@debbugs.gnu.org; Fri, 27 Apr 2012 09:44:50 -0400 Received: from mx.meyering.net ([88.168.87.75]:37417) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNlTY-0002vK-2o for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 09:44:47 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id AA01360140; Fri, 27 Apr 2012 15:43:37 +0200 (CEST) From: Jim Meyering In-Reply-To: <87vckltotj.fsf@rho.meyering.net> (Jim Meyering's message of "Fri, 27 Apr 2012 13:08:08 +0200") References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> Date: Fri, 27 Apr 2012 15:43:37 +0200 Message-ID: <8762clthme.fsf_-_@rho.meyering.net> Lines: 142 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Marc W. Mengel wrote: >> This is still broken in RedHat in coreutils-8.4-13 >> >> All of "groups" and "id" and "id -G" report groups that you don't have >> if you list a new/different primary group in /etc/passwd. >> >> This is just plain wrong. "id" and "groups" should list the groups you >> actually have, not what you would possibly have if you logged out and >> back in again. > > Thank you for the report. > It looks like there is indeed a bug. > > I demonstrated it with this: ... > With all that, here's the patch I expect to commit: > > diff --git a/src/group-list.c b/src/group-list.c Here's a complete patch. Note the lack of a test case. Even in a root-only test, and briefly, I don't want to change the password database. >From 3bcb3ea46d685f499c7a02efb1cbbbf15f858325 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 27 Apr 2012 13:28:32 +0200 Subject: [PATCH] id,groups: with no user name, print only real and/or effective IDs, ... i.e., don't use the getpw* functions. Before this change, running groups or id with no user name argument would include a group name or ID from /etc/passwd. Thus, under unusual circumstances (default group is changed, but has not taken effect for a given session), those programs could print a name or ID that is neither real nor effective. To demonstrate, run this: echo 'for i in 1 2; do id -G; sleep 1.5; done' \ |su -s /bin/sh ftp - & sleep 1; perl -pi -e 's/^(ftp:x:\d+):(\d+)/$1:9876/' /etc/passwd Those id -G commands printed the following: 50 50 9876 With this change, they print this: 50 50 * src/group-list.c (print_group_list): When username is NULL, pass egid, not getpwuid(ruid)->pw_gid), to xgetgroups, per the API requirements of xgetgroups callee, mgetgroups. When not using the password database, don't call getpwuid. * NEWS (Bug fixes): Mention it. Originally reported by Brynnen Owen as http://bugs.gnu.org/7320. Raised again by Marc Mengel in http://bugzilla.redhat.com/816708. --- NEWS | 8 ++++++++ THANKS.in | 2 ++ src/group-list.c | 14 ++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index ef4e508..c50336b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,14 @@ GNU coreutils NEWS -*- = outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + id and groups, when invoked with no user name argument, would print + the default group ID listed in the password database, and sometimes + that ID would be neither real nor effective. For example, in a session + for which the default group has just been changed, the new group ID + would be listed, even though it is not yet effective. + ** New features fmt now accepts the --goal=3DWIDTH (-g) option. diff --git a/THANKS.in b/THANKS.in index d23f7b3..a7403fd 100644 --- a/THANKS.in +++ b/THANKS.in @@ -98,6 +98,7 @@ Brian Silverman bsilverman@conceptxde= sign.com Brian Youmans 3diff@gnu.org Britton Leo Kerin fsblk@aurora.uaf.edu Bruce Robertson brucer@theodolite.dyndns.org +Brynnen Owen owen@illinois.edu Carl Johnson carlj@cjlinux.home.org Carl Lowenstein cdl@mpl.UCSD.EDU Carl Roth roth@urs.us @@ -355,6 +356,7 @@ Manfred Hollstein manfred@s-direktnet= .de =D0=9C=D0=B0=D1=80=D0=BA =D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80= =D0=B3 socketpair@gmail.com Marc Boucher marc@mbsi.ca Marc Haber mh+debian-bugs@zugschlus.de +Marc Mengel mengel@fnal.gov Marc Lehman schmorp@schmorp.de Marc Olzheim marcolz@stack.nl Marco Franzen Marco.Franzen@Thyron.com diff --git a/src/group-list.c b/src/group-list.c index cf49911..edbb342 100644 --- a/src/group-list.c +++ b/src/group-list.c @@ -38,11 +38,14 @@ print_group_list (const char *username, bool use_names) { bool ok =3D true; - struct passwd *pwd; + struct passwd *pwd =3D NULL; - pwd =3D getpwuid (ruid); - if (pwd =3D=3D NULL) - ok =3D false; + if (username) + { + pwd =3D getpwuid (ruid); + if (pwd =3D=3D NULL) + ok =3D false; + } if (!print_group (rgid, use_names)) ok =3D false; @@ -58,8 +61,7 @@ print_group_list (const char *username, gid_t *groups; int i; - int n_groups =3D xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1= ), - &groups); + int n_groups =3D xgetgroups (username, (pwd ? pwd->pw_gid : egid), &gr= oups); if (n_groups < 0) { if (username) -- 1.7.10.336.gc5e31 From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 14:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jim Meyering Cc: owen@illinois.edu, 7320@debbugs.gnu.org, "Marc W. Mengel" Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133553571113607 (code B ref 7320); Fri, 27 Apr 2012 14:09:01 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 14:08:31 +0000 Received: from localhost ([127.0.0.1]:55519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNlqY-0003XP-PS for submit@debbugs.gnu.org; Fri, 27 Apr 2012 10:08:31 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:44004) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNlqW-0003XA-7J for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 10:08:28 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBALummk9tTnli/2dsb2JhbAANN4Vorw4FAQEEGQpWEAsNDQIFFgsCAgkDAgECAUUGDQEHAQGFRIIvqXKTI4EvjnyBGAScE40T Received: from unknown (HELO [192.168.1.79]) ([109.78.121.98]) by mail2.vodafone.ie with ESMTP; 27 Apr 2012 15:07:17 +0100 Message-ID: <4F9AA814.5000004@draigBrady.com> Date: Fri, 27 Apr 2012 15:07:16 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> <8762clthme.fsf_-_@rho.meyering.net> In-Reply-To: <8762clthme.fsf_-_@rho.meyering.net> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) looks good From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: "Marc W. Mengel" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 14:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jim Meyering Cc: owen@illinois.edu, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133553860621197 (code B ref 7320); Fri, 27 Apr 2012 14:57:02 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 14:56:46 +0000 Received: from localhost ([127.0.0.1]:55553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNmbF-0005Vp-TK for submit@debbugs.gnu.org; Fri, 27 Apr 2012 10:56:46 -0400 Received: from gateway01.fnal.gov ([131.225.104.18]:35852) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNmbD-0005Vh-0A for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 10:56:44 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gateway01.fnal.gov (Postfix) with ESMTP id 90924D81650; Fri, 27 Apr 2012 09:55:37 -0500 (CDT) X-Virus-Scanned: amavisd-new at fnal.gov Received: from gateway01.fnal.gov ([127.0.0.1]) by localhost (gateway01.fnal.gov [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VmFqY2G-iDy0; Fri, 27 Apr 2012 09:55:37 -0500 (CDT) X-Mailgw-Auth: no Received: from MAIL03V-CAS01.fnal.gov (mail03v-cas01.fnal.gov [131.225.199.5]) by gateway01.fnal.gov (Postfix) with ESMTP id 7A129D81635; Fri, 27 Apr 2012 09:55:37 -0500 (CDT) Received: from bel-kwinith.fnal.gov (131.225.80.212) by MAIL03V-CAS01.fnal.gov (131.225.199.5) with Microsoft SMTP Server (TLS) id 14.1.355.2; Fri, 27 Apr 2012 09:55:37 -0500 Message-ID: <4F9AB368.2090707@fnal.gov> Date: Fri, 27 Apr 2012 09:55:36 -0500 From: "Marc W. Mengel" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.26) Gecko/20120216 Red Hat/3.1.18-2.el6_2 Thunderbird/3.1.18 MIME-Version: 1.0 References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> <8762clthme.fsf_-_@rho.meyering.net> In-Reply-To: <8762clthme.fsf_-_@rho.meyering.net> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [131.225.80.212] X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) The other test case is to make a copy of "id" and make it setuid to some user (i.e. mysql) and run it; it will show itself as having mysql's primary group, even though it doesn't. From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 14:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: owen@illinois.edu, 7320@debbugs.gnu.org, "Marc W. Mengel" Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133553870521352 (code B ref 7320); Fri, 27 Apr 2012 14:59:02 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 14:58:25 +0000 Received: from localhost ([127.0.0.1]:55558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNmcq-0005YL-PY for submit@debbugs.gnu.org; Fri, 27 Apr 2012 10:58:24 -0400 Received: from mx.meyering.net ([88.168.87.75]:37640) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNmco-0005YE-M4 for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 10:58:23 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 18C5D60081; Fri, 27 Apr 2012 16:57:16 +0200 (CEST) From: Jim Meyering In-Reply-To: <4F9AA814.5000004@draigBrady.com> ("=?UTF-8?Q?P=C3=A1draig?= Brady"'s message of "Fri, 27 Apr 2012 15:07:16 +0100") References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> <8762clthme.fsf_-_@rho.meyering.net> <4F9AA814.5000004@draigBrady.com> Date: Fri, 27 Apr 2012 16:57:16 +0200 Message-ID: <87ipglrzn7.fsf@rho.meyering.net> Lines: 4 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) P=E1draig Brady wrote: > looks good Thanks for the quick review. From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 16:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "Marc W. Mengel" Cc: owen@illinois.edu, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133554429029645 (code B ref 7320); Fri, 27 Apr 2012 16:32:01 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 16:31:30 +0000 Received: from localhost ([127.0.0.1]:55619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNo4u-0007i4-Bo for submit@debbugs.gnu.org; Fri, 27 Apr 2012 12:31:29 -0400 Received: from mx.meyering.net ([88.168.87.75]:37909) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNo4q-0007hu-NZ for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 12:31:25 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id F093C6009F; Fri, 27 Apr 2012 18:30:17 +0200 (CEST) From: Jim Meyering In-Reply-To: <4F9AB368.2090707@fnal.gov> (Marc W. Mengel's message of "Fri, 27 Apr 2012 09:55:36 -0500") References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> <8762clthme.fsf_-_@rho.meyering.net> <4F9AB368.2090707@fnal.gov> Date: Fri, 27 Apr 2012 18:30:17 +0200 Message-ID: <877gx1rvc6.fsf@rho.meyering.net> Lines: 15 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Marc W. Mengel wrote: > The other test case is to make a copy of "id" and make it > setuid to some user (i.e. mysql) and run it; it will show > itself as having mysql's primary group, even though it doesn't. Oh! Yes, that will work. Thanks. With that, I'll add a test like this: New: $ sudo src/setuidgid -g 3 root src/id -G 3 Old: $ sudo src/setuidgid -g 3 root id -G 3 0 From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 16:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "Marc W. Mengel" Cc: owen@illinois.edu, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.133554590432105 (code B ref 7320); Fri, 27 Apr 2012 16:59:02 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 16:58:24 +0000 Received: from localhost ([127.0.0.1]:55635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNoUy-0008Ll-7f for submit@debbugs.gnu.org; Fri, 27 Apr 2012 12:58:24 -0400 Received: from mx.meyering.net ([88.168.87.75]:37988) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNoUt-0008Lb-30 for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 12:58:21 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id EAB7860064; Fri, 27 Apr 2012 18:57:11 +0200 (CEST) From: Jim Meyering In-Reply-To: <877gx1rvc6.fsf@rho.meyering.net> (Jim Meyering's message of "Fri, 27 Apr 2012 18:30:17 +0200") References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> <8762clthme.fsf_-_@rho.meyering.net> <4F9AB368.2090707@fnal.gov> <877gx1rvc6.fsf@rho.meyering.net> Date: Fri, 27 Apr 2012 18:57:11 +0200 Message-ID: <87ty05qfiw.fsf@rho.meyering.net> Lines: 87 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Marc W. Mengel wrote: >> The other test case is to make a copy of "id" and make it >> setuid to some user (i.e. mysql) and run it; it will show >> itself as having mysql's primary group, even though it doesn't. > > Oh! Yes, that will work. Thanks. > With that, I'll add a test like this: > > New: > $ sudo src/setuidgid -g 3 root src/id -G > 3 > > Old: > $ sudo src/setuidgid -g 3 root id -G > 3 0 Here's the new test that I'll merge into the actual fix: >From d11303c1e643d31aea70e15f79ecf8b55038446a Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 27 Apr 2012 18:44:08 +0200 Subject: [PATCH] tests: add a test for the just-fixed id/groups bug * tests/misc/id-setgid: New file. * tests/Makefile.am (TESTS): Add it. --- tests/Makefile.am | 1 + tests/misc/id-setgid | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 tests/misc/id-setgid diff --git a/tests/Makefile.am b/tests/Makefile.am index ce2366b..cd1fc5c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -198,6 +198,7 @@ TESTS = \ misc/head-pos \ misc/id-context \ misc/id-groups \ + misc/id-setgid \ misc/md5sum \ misc/md5sum-bsd \ misc/md5sum-newline \ diff --git a/tests/misc/id-setgid b/tests/misc/id-setgid new file mode 100755 index 0000000..12fab38 --- /dev/null +++ b/tests/misc/id-setgid @@ -0,0 +1,34 @@ +#!/bin/sh +# Verify that id -G prints the right group when run set-GID. + +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +print_ver_ id +require_root_ + +g=$(id -u $NON_ROOT_USERNAME) || framework_failure_ + +# Construct a different group number. +gp1=$(expr $g + 1) + +echo $gp1 > exp || framework_failure_ + +setuidgid -g $gp1 $NON_ROOT_USERNAME env PATH="$PATH" id -G > out || fail=1 +compare exp out || fail=1 +# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g + +Exit $fail -- 1.7.10.365.g7cacb From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: id and groups may lie Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 27 Apr 2012 17:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "Marc W. Mengel" Cc: owen@illinois.edu, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.13355493044628 (code B ref 7320); Fri, 27 Apr 2012 17:56:01 +0000 Received: (at 7320) by debbugs.gnu.org; 27 Apr 2012 17:55:04 +0000 Received: from localhost ([127.0.0.1]:55658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNpNn-0001Ca-FK for submit@debbugs.gnu.org; Fri, 27 Apr 2012 13:55:04 -0400 Received: from mx.meyering.net ([88.168.87.75]:38139) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SNpNl-0001CB-0E for 7320@debbugs.gnu.org; Fri, 27 Apr 2012 13:55:02 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 0151B6038C; Fri, 27 Apr 2012 19:53:53 +0200 (CEST) From: Jim Meyering In-Reply-To: <87ty05qfiw.fsf@rho.meyering.net> (Jim Meyering's message of "Fri, 27 Apr 2012 18:57:11 +0200") References: <20101102214020.GA19779@128.174.154.111> <4F999115.7010802@fnal.gov> <87vckltotj.fsf@rho.meyering.net> <8762clthme.fsf_-_@rho.meyering.net> <4F9AB368.2090707@fnal.gov> <877gx1rvc6.fsf@rho.meyering.net> <87ty05qfiw.fsf@rho.meyering.net> Date: Fri, 27 Apr 2012 19:53:53 +0200 Message-ID: <87lilhqcwe.fsf@rho.meyering.net> Lines: 64 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Jim Meyering wrote: > >> Marc W. Mengel wrote: >>> The other test case is to make a copy of "id" and make it >>> setuid to some user (i.e. mysql) and run it; it will show >>> itself as having mysql's primary group, even though it doesn't. >> >> Oh! Yes, that will work. Thanks. >> With that, I'll add a test like this: >> >> New: >> $ sudo src/setuidgid -g 3 root src/id -G >> 3 >> >> Old: >> $ sudo src/setuidgid -g 3 root id -G >> 3 0 > > Here's the new test that I'll merge into the actual fix: > >>>From d11303c1e643d31aea70e15f79ecf8b55038446a Mon Sep 17 00:00:00 2001 > From: Jim Meyering > Date: Fri, 27 Apr 2012 18:44:08 +0200 > Subject: [PATCH] tests: add a test for the just-fixed id/groups bug > > * tests/misc/id-setgid: New file. > * tests/Makefile.am (TESTS): Add it. > --- > tests/Makefile.am | 1 + > tests/misc/id-setgid | 34 ++++++++++++++++++++++++++++++++++ Nearly missed it. I'd added a new root-only test without listing it in the root_tests list. Once we depend on GNU make, we should be able to automate this. Folding this in: >From 7418ab4c137d5fb608ea9cd974aabf5f6a76445e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 27 Apr 2012 19:51:54 +0200 Subject: [PATCH] tests: fix syntax-check failure * tests/Makefile.am (root_tests): It's a root-only test, so add it here, too. --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index cd1fc5c..72717e3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,6 +36,7 @@ root_tests = \ ls/nameless-uid \ misc/chcon \ misc/chroot-credentials \ + misc/id-setgid \ misc/selinux \ misc/truncate-owned-by-other \ mkdir/writable-under-readonly \ -- 1.7.10.365.g7cacb From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 07 07:48:25 2012 Received: (at control) by debbugs.gnu.org; 7 Oct 2012 11:48:25 +0000 Received: from localhost ([127.0.0.1]:59175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TKpLN-0007QG-8l for submit@debbugs.gnu.org; Sun, 07 Oct 2012 07:48:25 -0400 Received: from mx.meyering.net ([88.168.87.75]:40395) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TKpLK-0007Q7-Am for control@debbugs.gnu.org; Sun, 07 Oct 2012 07:48:23 -0400 Received: from hx.meyering.net (hx.meyering.net [192.168.0.33]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 2F318603EA for ; Sun, 7 Oct 2012 13:47:58 +0200 (CEST) Date: Sun, 07 Oct 2012 13:47:58 +0200 Message-Id: <87pq4u8pw1.fsf@hx.meyering.net> To: control@debbugs.gnu.org From: Jim Meyering Subject: control message for bug #7320 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.3 (-) tags 7320 fixed close 7320 8.18 From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 25 20:10:22 2014 Received: (at control) by debbugs.gnu.org; 26 Jun 2014 00:10:22 +0000 Received: from localhost ([127.0.0.1]:60925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzxGe-0004aU-AB for submit@debbugs.gnu.org; Wed, 25 Jun 2014 20:10:21 -0400 Received: from mail4.vodafone.ie ([213.233.128.170]:5151) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzxGb-0004a4-V6 for control@debbugs.gnu.org; Wed, 25 Jun 2014 20:10:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqMBADxkq1NtT2RN/2dsb2JhbAANS4QZgw2KJKB1lUwydoUYCipUDQIFFgsCCwMCAQIBOQYCAhUIAQGIQ6RYd54tF4EqjW+CYYFMBaF4kAc Received: from unknown (HELO [192.168.1.79]) ([109.79.100.77]) by mail3.vodafone.ie with ESMTP; 26 Jun 2014 01:10:11 +0100 Message-ID: <53AB64E2.2030209@draigBrady.com> Date: Thu, 26 Jun 2014 01:10:10 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: control@debbugs.gnu.org X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 7320 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: unarchive 7320 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject 0.0 TVD_SPACE_RATIO TVD_SPACE_RATIO unarchive 7320 From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Jun 2014 01:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: fixed To: Petr =?UTF-8?Q?Stod=C5=AFlka?= Cc: coreutils@gnu.org, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.14037476017803 (code B ref 7320); Thu, 26 Jun 2014 01:54:02 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Jun 2014 01:53:21 +0000 Received: from localhost ([127.0.0.1]:60954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzysK-00021m-Mn for submit@debbugs.gnu.org; Wed, 25 Jun 2014 21:53:21 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:16019) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzysH-00021S-IS for 7320@debbugs.gnu.org; Wed, 25 Jun 2014 21:53:18 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AscCAMF8q1NtTjOc/2dsb2JhbAANS4NfU4hPuxgBgR6EeAEBAQQnUhALDQQDAQIBCQ0CBQIPCQMCAQIBPQgGDQEFAgEBFgGILAMFpEefJxeOaxEHCQkGB4QkBY90ghSBQYhOhWGGPYlKa4EL Received: from unknown (HELO [192.168.1.79]) ([109.78.51.156]) by mail1.vodafone.ie with ESMTP; 26 Jun 2014 02:53:10 +0100 Message-ID: <53AB7D04.3000202@draigBrady.com> Date: Thu, 26 Jun 2014 02:53:08 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 References: <53AABDDB.2020209@redhat.com> In-Reply-To: <53AABDDB.2020209@redhat.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------050901050009010303000602" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------050901050009010303000602 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit On 06/25/2014 01:17 PM, Petr Stodůlka wrote: > Hi, > > command 'id' prints wrong groups for the session. This is similar to reported bug #7320 [0], > which was patched earlier for 'groups' and 'id -G', however just 'id' still prints wrong groups. > I propose this patch based on previous solution: > ---------------------------------------------------------------------- > diff --git a/src/id.c b/src/id.c > index 3348f80..6cfe884 100644 > --- a/src/id.c > +++ b/src/id.c > @@ -399,8 +399,12 @@ print_full_info (const char *username) > gid_t *groups; > int i; > > - int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1), > - &groups); > + int n_groups; > + if(username) > + n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1), > + &groups); > + else > + n_groups = xgetgroups (username, egid, &groups); > if (n_groups < 0) > { > if (username) > -------------------------------------------------------------------- > > [0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7320 Logic looks correct. The attached refactors slightly, and adds a test and NEWS. I'll apply upon your ack. thanks! Pádraig. --------------050901050009010303000602 Content-Type: text/x-patch; name="id-effective-group.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="id-effective-group.patch" >From 2fd678d1201dbb1c877aba139190b0ac1025964f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Stod=C5=AFlka?= Date: Wed, 25 Jun 2014 18:26:23 +0100 Subject: [PATCH] id: output the effective group for the process * src/id.c (print_full_info): When no user is specified, output the effective group for the _process_, rather than the default group from the system database, which may be different. * tests/id/setgid.sh: Add a case for `id` as well as `id -G`. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/7320 Reported at http://bugzilla.redhat.com/1016163 --- NEWS | 6 ++++++ src/id.c | 19 ++++++++++--------- tests/id/setgid.sh | 9 +++++++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 6532785..e5ea77c 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,12 @@ GNU coreutils NEWS -*- outline -*- now copies all input to stdout. Previously nothing was output in this case. [bug introduced with the --lines=-N feature in coreutils-5.0.1] + id, when invoked with no user name argument, now prints the correct group ID. + Previously, in the default output format, it would print the default group ID + in the password database, which may be neither real nor effective. For e.g., + when run set-GID, or when the database changes outside the current session. + [bug introduced in coreutils-8.1] + ln -sf now replaces symbolic links whose targets can't exist. Previously it would display an error, requiring --no-dereference to avoid the issue. [bug introduced in coreutils-5.3.0] diff --git a/src/id.c b/src/id.c index 3348f80..f46bb41 100644 --- a/src/id.c +++ b/src/id.c @@ -399,19 +399,20 @@ print_full_info (const char *username) gid_t *groups; int i; - int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1), - &groups); + gid_t primary_group; + if (username) + primary_group = pwd ? pwd->pw_gid : -1; + else + primary_group = egid; + + int n_groups = xgetgroups (username, primary_group, &groups); if (n_groups < 0) { if (username) - { - error (0, errno, _("failed to get groups for user %s"), - quote (username)); - } + error (0, errno, _("failed to get groups for user %s"), + quote (username)); else - { - error (0, errno, _("failed to get groups for the current process")); - } + error (0, errno, _("failed to get groups for the current process")); ok = false; return; } diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh index aa43ea3..a81b42c 100755 --- a/tests/id/setgid.sh +++ b/tests/id/setgid.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Verify that id -G prints the right group when run set-GID. +# Verify that id [-G] prints the right group when run set-GID. # Copyright (C) 2012-2014 Free Software Foundation, Inc. @@ -27,9 +27,14 @@ gp1=$(expr $g + 1) echo $gp1 > exp || framework_failure_ +# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ id -G > out || fail=1 compare exp out || fail=1 -# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g + +# With coreutils-8.22 and earlier, id would erroneously print groups=$g +chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ + id > out || fail=1 +grep -F "groups=$gp1" out || fail=1 Exit $fail -- 1.7.7.6 --------------050901050009010303000602-- From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session Resent-From: Jim Meyering Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Jun 2014 02:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: fixed To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: Petr =?UTF-8?Q?Stod=C5=AFlka?= , Coreutils , 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.140375075314938 (code B ref 7320); Thu, 26 Jun 2014 02:46:01 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Jun 2014 02:45:53 +0000 Received: from localhost ([127.0.0.1]:60986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WzzhA-0003ss-EN for submit@debbugs.gnu.org; Wed, 25 Jun 2014 22:45:52 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:40380) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wzzh6-0003sU-Va for 7320@debbugs.gnu.org; Wed, 25 Jun 2014 22:45:49 -0400 Received: by mail-wg0-f50.google.com with SMTP id m15so2807553wgh.33 for <7320@debbugs.gnu.org>; Wed, 25 Jun 2014 19:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=3gUWowvHCJpmSGOkkf3I+pzDFoglIdPK1IPBc43WgpE=; b=LsKjarul3+TeiohP82x5rh1vyRf6AACZ8loOM6r9BTHmm+BTLfHwEoScRaWlTYqO1l CRf5HE8GX3At5jkBNfx80Czj/CCQwi35pSYpKu9MDYHjsJT7qmbSnlGqR2YlaDHUtjzJ bXe5GeZmiSgnUEdrGpbbj53uSy67Kj6RjSgMyuKFi529RXJTyILr6NiAHGz2rx4tT4Xi 2oqFFZA5WZYS6JrWGNBh7+7A5bfb4RO4dFk35lvTYAqdlo3Xz3GiT8gcVmxr1d4psBXo +nmzEXiIZq6d2Iqc53xaJw/RkICBeP92COx1FMP8ZAH3i+6EDgs1bEmsG8NDl+4ja5Tg 4ncQ== X-Received: by 10.181.12.76 with SMTP id eo12mr796119wid.15.1403750742894; Wed, 25 Jun 2014 19:45:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.17.227 with HTTP; Wed, 25 Jun 2014 19:45:22 -0700 (PDT) In-Reply-To: <53AB7D04.3000202@draigBrady.com> References: <53AABDDB.2020209@redhat.com> <53AB7D04.3000202@draigBrady.com> From: Jim Meyering Date: Wed, 25 Jun 2014 19:45:22 -0700 X-Google-Sender-Auth: yRIJtEXsSrAoNpDnKNZv5F1PCR0 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Wed, Jun 25, 2014 at 6:53 PM, P=C3=A1draig Brady wrot= e: > On 06/25/2014 01:17 PM, Petr Stod=C5=AFlka wrote: >> Hi, >> >> command 'id' prints wrong groups for the session. This is similar to rep= orted bug #7320 [0], >> which was patched earlier for 'groups' and 'id -G', however just 'id' st= ill prints wrong groups. >> I propose this patch based on previous solution: >> ---------------------------------------------------------------------- >> diff --git a/src/id.c b/src/id.c >> index 3348f80..6cfe884 100644 >> --- a/src/id.c >> +++ b/src/id.c >> @@ -399,8 +399,12 @@ print_full_info (const char *username) >> gid_t *groups; >> int i; >> >> - int n_groups =3D xgetgroups (username, (pwd ? pwd->pw_gid : -1), >> - &groups); >> + int n_groups; >> + if(username) >> + n_groups =3D xgetgroups (username, (pwd ? pwd->pw_gid : -1), >> + &groups); >> + else >> + n_groups =3D xgetgroups (username, egid, &groups); >> if (n_groups < 0) >> { >> if (username) >> -------------------------------------------------------------------- >> >> [0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D7320 > > Logic looks correct. > The attached refactors slightly, and adds a test and NEWS. > I'll apply upon your ack. Nice patch. Looks perfect. Thanks to both of you. From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Jun 2014 05:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: fixed To: =?UTF-8?Q?P=C3=A1draig?= Brady , Petr =?UTF-8?Q?Stod=C5=AFlka?= Cc: coreutils@gnu.org, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.14037614616725 (code B ref 7320); Thu, 26 Jun 2014 05:45:02 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Jun 2014 05:44:21 +0000 Received: from localhost ([127.0.0.1]:32842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X02Ts-0001kO-Uh for submit@debbugs.gnu.org; Thu, 26 Jun 2014 01:44:21 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:54075) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X02Tq-0001jz-4O for 7320@debbugs.gnu.org; Thu, 26 Jun 2014 01:44:19 -0400 Received: from [192.168.1.10] (p548E4BA4.dip0.t-ipconnect.de [84.142.75.164]) by mrelayeu.kundenserver.de (node=mreue101) with ESMTP (Nemesis) id 0MgwCW-1XM5bg1jm4-00M3kE; Thu, 26 Jun 2014 07:44:04 +0200 Message-ID: <53ABB323.1090702@bernhard-voelker.de> Date: Thu, 26 Jun 2014 07:44:03 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 References: <53AABDDB.2020209@redhat.com> <53AB7D04.3000202@draigBrady.com> In-Reply-To: <53AB7D04.3000202@draigBrady.com> Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:MlHumqHKEyDBTgeNftNW7LMFSOGqHLPN834ZXdHin/k gWkKR58QPzMcomMPrg1lyc2dza75SAPrJgP81PMLe95RSCpxfE KELuKkPEPgAFX+YH+hBOvG/stndnnMsH8wq3NAZLoF7XanxfAl FZGTVCx/50442iRA8tRqFn7idU/LWnY7tj9fB0+Xm0XHVb38sr aE1HLCZGFZLZiLennDBZPox6tLoD14Y6Ius7ralw2BRHWACzxd x/EWnpgVaURXXzEObuT8oZIvSd0eQCIdkDF13d4TjSzjRMA/dD b0txWmxhaBh0O8dsH34YTCiA3UkmjMg+vm1Z/64/sVinRetG98 O9hzSfGSilzKbv5vT/bJ4oiMaBxrGHRT8CUiUXzOb X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/26/2014 03:53 AM, Pádraig Brady wrote: > diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh > index aa43ea3..a81b42c 100755 > --- a/tests/id/setgid.sh > +++ b/tests/id/setgid.sh > @@ -1,5 +1,5 @@ > #!/bin/sh > -# Verify that id -G prints the right group when run set-GID. > +# Verify that id [-G] prints the right group when run set-GID. > > # Copyright (C) 2012-2014 Free Software Foundation, Inc. > > @@ -27,9 +27,14 @@ gp1=$(expr $g + 1) > > echo $gp1 > exp || framework_failure_ > > +# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g > chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ shouldn't we better avoid group name resolution here? - chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ + chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \ > id -G > out || fail=1 > compare exp out || fail=1 > -# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g > + > +# With coreutils-8.22 and earlier, id would erroneously print groups=$g > +chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ Likewise. > + id > out || fail=1 > +grep -F "groups=$gp1" out || fail=1 > > Exit $fail Another minor nit: for a better diagnostic, it'd be better to use the construct we already use in many places: ... || { cat out; fail=1; } Otherwise +1. Thanks & have a nice day, Berny From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Jun 2014 10:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: fixed To: Bernhard Voelker Cc: Petr =?UTF-8?Q?Stod=C5=AFlka?= , coreutils@gnu.org, 7320@debbugs.gnu.org Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.140377821211950 (code B ref 7320); Thu, 26 Jun 2014 10:24:01 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Jun 2014 10:23:32 +0000 Received: from localhost ([127.0.0.1]:32983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X06pz-00036V-FV for submit@debbugs.gnu.org; Thu, 26 Jun 2014 06:23:32 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:30263) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X06ps-000364-Ms for 7320@debbugs.gnu.org; Thu, 26 Jun 2014 06:23:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAGrzq1NtTK+g/2dsb2JhbAANTYNfxFwBgSCEeAEBAQQyAUYQCw0BCgkWDwkDAgECAUUGDQEHAQGIQ6Q6nk0XjwAHhEMBBI95jCWFYZAL Received: from unknown (HELO [192.168.1.79]) ([109.76.175.160]) by mail1.vodafone.ie with ESMTP; 26 Jun 2014 11:23:13 +0100 Message-ID: <53ABF48D.9050301@draigBrady.com> Date: Thu, 26 Jun 2014 11:23:09 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 References: <53AABDDB.2020209@redhat.com> <53AB7D04.3000202@draigBrady.com> <53ABB323.1090702@bernhard-voelker.de> In-Reply-To: <53ABB323.1090702@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/26/2014 06:44 AM, Bernhard Voelker wrote: > On 06/26/2014 03:53 AM, Pádraig Brady wrote: >> diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh >> index aa43ea3..a81b42c 100755 >> --- a/tests/id/setgid.sh >> +++ b/tests/id/setgid.sh >> @@ -1,5 +1,5 @@ >> #!/bin/sh >> -# Verify that id -G prints the right group when run set-GID. >> +# Verify that id [-G] prints the right group when run set-GID. >> >> # Copyright (C) 2012-2014 Free Software Foundation, Inc. >> >> @@ -27,9 +27,14 @@ gp1=$(expr $g + 1) >> >> echo $gp1 > exp || framework_failure_ >> >> +# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g >> chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ > > shouldn't we better avoid group name resolution here? > > - chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ > + chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \ > >> id -G > out || fail=1 >> compare exp out || fail=1 >> -# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g >> + >> +# With coreutils-8.22 and earlier, id would erroneously print groups=$g >> +chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ > > Likewise. > >> + id > out || fail=1 >> +grep -F "groups=$gp1" out || fail=1 >> >> Exit $fail > > Another minor nit: > for a better diagnostic, it'd be better to use the construct > we already use in many places: > > ... || { cat out; fail=1; } Cool, that saves 2 syscalls per id invocation. We can save another 2 by also using + for the user. Pushed with these changes. thanks! Pádraig. diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh index a81b42c..e0543f4 100755 --- a/tests/id/setgid.sh +++ b/tests/id/setgid.sh @@ -20,7 +20,8 @@ print_ver_ id require_root_ -g=$(id -u $NON_ROOT_USERNAME) || framework_failure_ +u=$(id -u $NON_ROOT_USERNAME) || framework_failure_ +g=u # Construct a different group number. gp1=$(expr $g + 1) @@ -28,13 +29,13 @@ gp1=$(expr $g + 1) echo $gp1 > exp || framework_failure_ # With coreutils-8.16 and earlier, id -G would print both: $gp1 $g -chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ +chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \ id -G > out || fail=1 -compare exp out || fail=1 +compare exp out || { cat out; fail=1; } # With coreutils-8.22 and earlier, id would erroneously print groups=$g -chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \ +chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \ id > out || fail=1 -grep -F "groups=$gp1" out || fail=1 +grep -F "groups=$gp1" out || { cat out; fail=1; } Exit $fail From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session Resent-From: Jim Meyering Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Jun 2014 16:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: fixed To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: Petr =?UTF-8?Q?Stod=C5=AFlka?= , Bernhard Voelker , Coreutils , 7320 <7320@debbugs.gnu.org> Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.14038009813853 (code B ref 7320); Thu, 26 Jun 2014 16:44:01 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Jun 2014 16:43:01 +0000 Received: from localhost ([127.0.0.1]:33920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0ClF-0000zr-2l for submit@debbugs.gnu.org; Thu, 26 Jun 2014 12:43:01 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:53301) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0Cl9-0000zK-5r for 7320@debbugs.gnu.org; Thu, 26 Jun 2014 12:42:55 -0400 Received: by mail-we0-f169.google.com with SMTP id t60so4002843wes.28 for <7320@debbugs.gnu.org>; Thu, 26 Jun 2014 09:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=C9xd7yBn8bCaTMGXJI4jHonbTWHvPFq/7H6MsdQFiog=; b=Apc27yyyD6Cu/iT+D16w7IeXgTFUp/7kd9Dif3bALJjY6461Tv5iK3gZYoJagD+m9v TYBKKL8wVDYdVknK0Ofb0x2LxzrpvjbwM268ySfS510LK29BJLFOymP4KVeKWMxpilo6 AFWUVGpPcVhU6naeE6g8NAD73NmsOK6pfAylV77e7BwFk19MJa/82L/N04stqnFfO33J yip6w1hBqaLqabFeC+8OTT9B+lNlDLpgtiyjBUBAoNgMCNp45Bjk5HawyEj+BEyQulVM zLvNqefYggM3/QohZcpGPqHMuPVMiqplrD9NkLRx2uFdvLvwWK64fGBC0gi5bn5hEJ4e V25w== X-Received: by 10.180.77.17 with SMTP id o17mr5698487wiw.31.1403800961920; Thu, 26 Jun 2014 09:42:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.17.227 with HTTP; Thu, 26 Jun 2014 09:42:21 -0700 (PDT) In-Reply-To: <53ABF48D.9050301@draigBrady.com> References: <53AABDDB.2020209@redhat.com> <53AB7D04.3000202@draigBrady.com> <53ABB323.1090702@bernhard-voelker.de> <53ABF48D.9050301@draigBrady.com> From: Jim Meyering Date: Thu, 26 Jun 2014 09:42:21 -0700 X-Google-Sender-Auth: eQ24pej1E_8eiGQ8RoU6VINr_Sg Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Thu, Jun 26, 2014 at 3:23 AM, P=E1draig Brady wrote: > -g=3D$(id -u $NON_ROOT_USERNAME) || framework_failure_ > +u=3D$(id -u $NON_ROOT_USERNAME) || framework_failure_ > +g=3Du This will work better :-) g=3D$u From unknown Thu Jun 19 14:20:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 26 Jun 2014 17:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7320 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: fixed To: Jim Meyering Cc: Petr =?UTF-8?Q?Stod=C5=AFlka?= , Bernhard Voelker , Coreutils , 7320 <7320@debbugs.gnu.org> Received: via spool by 7320-submit@debbugs.gnu.org id=B7320.140380357211500 (code B ref 7320); Thu, 26 Jun 2014 17:27:02 +0000 Received: (at 7320) by debbugs.gnu.org; 26 Jun 2014 17:26:12 +0000 Received: from localhost ([127.0.0.1]:33951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0DR0-0002zH-WB for submit@debbugs.gnu.org; Thu, 26 Jun 2014 13:26:12 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:58322) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0DQu-0002yL-8h for 7320@debbugs.gnu.org; Thu, 26 Jun 2014 13:26:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0CABNWrFNtTK+g/2dsb2JhbAANTYcnvRmEDwGBI4R4AQEBBCMPAUYQCw0LAgIFFgsCAgkDAgECAUUGDQEFAgEBiEOjXnedSBeBK41VB4J3gUwBBKIDkA4 Received: from unknown (HELO [192.168.1.79]) ([109.76.175.160]) by mail1.vodafone.ie with ESMTP; 26 Jun 2014 18:25:52 +0100 Message-ID: <53AC5799.2080601@draigBrady.com> Date: Thu, 26 Jun 2014 18:25:45 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 References: <53AABDDB.2020209@redhat.com> <53AB7D04.3000202@draigBrady.com> <53ABB323.1090702@bernhard-voelker.de> <53ABF48D.9050301@draigBrady.com> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 06/26/2014 05:42 PM, Jim Meyering wrote: > On Thu, Jun 26, 2014 at 3:23 AM, Pádraig Brady wrote: >> -g=$(id -u $NON_ROOT_USERNAME) || framework_failure_ >> +u=$(id -u $NON_ROOT_USERNAME) || framework_failure_ >> +g=u > > This will work better :-) > g=$u It's already pushed with that amendment as it luckily failed with the above :) cheers, Pádraig.