On 07/16/10 15:07, Dan Nelson wrote:
In the last episode (Jul 16), Jens Rehsack said:
2010/7/16 Dan Nelson<[email protected]>:
In the last episode (Jul 16), Ashish SHUKLA said:
Well, OP is also invoking 'endpwent()' after every 'getpwent()'
invocation which according to GNU/Linux's glibc and NetBSD's libc (as
OP mentioned) should rewind the position in passwd database to the
beginning.
Ah. I missed the endpwent calls.
Was difficult for me to format the single liner ;)
To me it definitely looks like a bug in FreeBSD's getpw*() family of
functions.
As tested using sysutils/lsof, in the following program in FreeBSD, the
descriptor corresponding to '/etc/pwd.db' is closed on endpwent(3) but
position in database is never rewinded as shown in the output.
It looks like the *pwent functions keep an internal counter that
endpwent doesn't reset.
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.
Best regards,
Jens
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"