From owner-freebsd-questions@FreeBSD.ORG Wed Jul 21 20:00:07 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 485541065677 for ; Wed, 21 Jul 2010 20:00:07 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id D41548FC15 for ; Wed, 21 Jul 2010 20:00:06 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id o6LK03JE060850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 21 Jul 2010 15:00:03 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.4/8.14.4) with ESMTP id o6LK02s2027495 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 21 Jul 2010 15:00:03 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.4/8.14.3/Submit) id o6LK02Uu027494; Wed, 21 Jul 2010 15:00:02 -0500 (CDT) (envelope-from dan) Date: Wed, 21 Jul 2010 15:00:02 -0500 From: Dan Nelson To: Jens Rehsack Message-ID: <20100721200002.GA85432@dan.emsphone.com> References: <20100715172615.GC5485@dan.emsphone.com> <86tyo0qd19.fsf@chateau.d.if> <20100716043056.GF5485@dan.emsphone.com> <20100716150719.GG5485@dan.emsphone.com> <4C408744.3030409@netbsd.org> <20100716181316.GH5485@dan.emsphone.com> <4C470615.8030608@netbsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C470615.8030608@netbsd.org> X-OS: FreeBSD 8.1-PRERELEASE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: clamav-milter 0.96 at email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Wed, 21 Jul 2010 15:00:03 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: Ashish SHUKLA , freebsd-questions@freebsd.org Subject: Re: getpwent bug? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2010 20:00:07 -0000 In the last episode (Jul 21), Jens Rehsack said: > On 07/16/10 18:13, Dan Nelson wrote: > > Hi Dan, > > > In the last episode (Jul 16), Jens Rehsack said: > >> On 07/16/10 15:07, Dan Nelson wrote: > >>> In the last episode (Jul 16), Jens Rehsack said: > >>>> Could you please take a look to my other mail (getgrent related) - there > >>>> seems another bug ... > >>> > >>> Do you have another one-liner that will reproduce it? A simple > >>> "/usr/bin/getent group" doesn't return dupes for me. Oddly enough, the > >>> *grent code doesn't use an internal counter, so the bug you found in > >>> endpwent doesn't exist in endgrent (afaik; the nsswitch code isn't that > >>> easy to read). > >> > >> Not really a one-liner: > >> perl -MData::Dumper -e 'setgrent; my %dupchk; while( my ( $name, > >> $grpass, $gid, $members ) = getgrent() ) { print "$name is returned > >> more than once (No $dupchk{$name} comes here)\n" if( $dupchk{$name}++ > >> ); print Dumper( [ $name, $grpass, $gid, $members ] ) };' > >> > >> setgrent() doesn't work here. > > > > I ran that and got dupes for group entries that exist both in /etc/groups and > > my LDAP source, but that's expected. > > You can see here > http://www.cpantesters.org/cpan/report/f5100ac6-9418-11df-9ebc-c4a68065c34d > the typical error picture. FreeBSD is the only system, where this error > occurs. I don't know how to read perl's test output; what part of that report failed, and how do you know it was due to getgrent returning duplicate values? BTW - I ran your one-liner above on a SLES 10.2 Linux box and a Solaris 10u7 box, and got duplicate entries where groups existed in both /etc/groups and LDAP, just like on FreeBSD. I think you may be relying on behaviour that getgrent doesn't guarantee on any OS. -- Dan Nelson dnelson@allantgroup.com