X-Spam-Check-By: sourceware.org Date: Mon, 22 Jan 2007 14:29:34 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: "id -Gn" w/ username doesn't return all associated groups. Issue with getgrent()? Message-ID: <20070122132934.GU27843@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <001a01c73dae$7dec4af0$6152a8c0 AT ziesemermark> <20070122093419 DOT GR27843 AT calimero DOT vinschen DOT de> <45B4B622 DOT 9040406 AT byu DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45B4B622.9040406@byu.net> User-Agent: Mutt/1.4.2.2i Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Jan 22 06:03, Eric Blake wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > According to Corinna Vinschen on 1/22/2007 2:34 AM: > >> When "id" is called without a username, it calls the getgroups(...) function > >> which appears to work as expected. However, when a specific username is > >> passed, even the username of the current user, getugroups(...) is called, > >> and does _not_ appear to work as expected. > > > > That's by design. getgroups() has access to the user token of the > > current process and returns every group which is in this token. > > getgrent() is a function which enumerates /etc/groups. > > So my translation of this would be that the bug is not in id, but in the > fact that your /etc/groups is out-of-date. Use mkgroups to remedy the > situation. A little bit more specific: Use the mkgroup -u flag. By default, mkgroup does not add the users to the gr_mem field since that's not necessary for correct operation of setuid(2). By adding the users to the gr_mem field (the -u option), you probably get what you want. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/