getpwent bug?

Jens Rehsack rehsack at googlemail.com
Thu Jul 22 05:59:47 UTC 2010


2010/7/21 Dan Nelson <dnelson at allantgroup.com>:
> 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?

Because I know the error picture - I've seen it on my FreeBSD box first.
I probably should add some diag() output for failing tests ...

> 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.

But the duplicated entries I get are not duplicated in the source. I sent you my
/var/yp/groups file and the output of my one-liner.

I have no LDAP setup to try out, but in this case my workaround could be a good
idea.

Best regards,
Jens


More information about the freebsd-questions mailing list