getpwent bug?

Jens Rehsack rehsack at googlemail.com
Fri Jul 16 19:20:55 UTC 2010


On 07/16/10 18:13, Dan Nelson wrote:
> 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.

The dups I got are not duplicate:
$ less /var/yp/group
# $FreeBSD: src/etc/group,v 1.19.2.3 2002/06/30 17:57:17 des Exp $
#
wheel:*:0:root,trevor
staff:*:20:root
win32::1001:melanie,sarah
os2::1002:
dos::1003:
unix::1004:
music::1005:melanie,sarah
gamers::1006:
devel::1007:trevor
wwwdevel::15000:wwwglobal,trevor

All the rest (see attachment) are from /etc/group.

Jens
-------------- next part --------------
$VAR1 = [
          'wheel',
          '*',
          0,
          'root trevor mel'
        ];
$VAR1 = [
          'daemon',
          '*',
          1,
          ''
        ];
$VAR1 = [
          'kmem',
          '*',
          2,
          ''
        ];
$VAR1 = [
          'sys',
          '*',
          3,
          ''
        ];
$VAR1 = [
          'tty',
          '*',
          4,
          ''
        ];
$VAR1 = [
          'operator',
          '*',
          5,
          'root'
        ];
$VAR1 = [
          'mail',
          '*',
          6,
          ''
        ];
$VAR1 = [
          'bin',
          '*',
          7,
          ''
        ];
$VAR1 = [
          'news',
          '*',
          8,
          ''
        ];
$VAR1 = [
          'man',
          '*',
          9,
          ''
        ];
$VAR1 = [
          'games',
          '*',
          13,
          ''
        ];
$VAR1 = [
          'ftp',
          '*',
          14,
          ''
        ];
$VAR1 = [
          'staff',
          '*',
          20,
          ''
        ];
$VAR1 = [
          'sshd',
          '*',
          22,
          ''
        ];
$VAR1 = [
          'smmsp',
          '*',
          25,
          ''
        ];
$VAR1 = [
          'mailnull',
          '*',
          26,
          ''
        ];
$VAR1 = [
          'guest',
          '*',
          31,
          ''
        ];
$VAR1 = [
          'bind',
          '*',
          53,
          ''
        ];
$VAR1 = [
          'proxy',
          '*',
          62,
          ''
        ];
$VAR1 = [
          'authpf',
          '*',
          63,
          ''
        ];
$VAR1 = [
          '_pflogd',
          '*',
          64,
          ''
        ];
$VAR1 = [
          '_dhcp',
          '*',
          65,
          ''
        ];
$VAR1 = [
          'uucp',
          '*',
          66,
          ''
        ];
$VAR1 = [
          'dialer',
          '*',
          68,
          ''
        ];
$VAR1 = [
          'network',
          '*',
          69,
          ''
        ];
$VAR1 = [
          'audit',
          '*',
          77,
          ''
        ];
$VAR1 = [
          'www',
          '*',
          80,
          ''
        ];
$VAR1 = [
          'oper',
          '*',
          200,
          'root trevor pgsql'
        ];
$VAR1 = [
          'nogroup',
          '*',
          65533,
          ''
        ];
$VAR1 = [
          'nobody',
          '*',
          65534,
          ''
        ];
$VAR1 = [
          'messagebus',
          '*',
          556,
          ''
        ];
$VAR1 = [
          'polkit',
          '*',
          559,
          ''
        ];
$VAR1 = [
          'haldaemon',
          '*',
          560,
          ''
        ];
$VAR1 = [
          'avahi',
          '*',
          558,
          ''
        ];
$VAR1 = [
          'gdm',
          '*',
          92,
          ''
        ];
$VAR1 = [
          'pgsql',
          '*',
          70,
          ''
        ];
smmsp is returned more than once (No 2 comes here)
$VAR1 = [
          'smmsp',
          '*',
          25,
          ''
        ];
guest is returned more than once (No 2 comes here)
$VAR1 = [
          'guest',
          '*',
          31,
          ''
        ];
authpf is returned more than once (No 2 comes here)
$VAR1 = [
          'authpf',
          '*',
          63,
          ''
        ];
$VAR1 = [
          'devel',
          '',
          1007,
          'trevor'
        ];
tty is returned more than once (No 2 comes here)
$VAR1 = [
          'tty',
          '*',
          4,
          ''
        ];
bin is returned more than once (No 2 comes here)
$VAR1 = [
          'bin',
          '*',
          7,
          ''
        ];
dialer is returned more than once (No 2 comes here)
$VAR1 = [
          'dialer',
          '*',
          68,
          ''
        ];
$VAR1 = [
          'music',
          '',
          1005,
          'trevor melanie sarah'
        ];
$VAR1 = [
          'ldap',
          '*',
          389,
          ''
        ];
kmem is returned more than once (No 2 comes here)
$VAR1 = [
          'kmem',
          '*',
          2,
          ''
        ];
ftp is returned more than once (No 2 comes here)
$VAR1 = [
          'ftp',
          '*',
          14,
          ''
        ];
sshd is returned more than once (No 2 comes here)
$VAR1 = [
          'sshd',
          '*',
          22,
          ''
        ];
proxy is returned more than once (No 2 comes here)
$VAR1 = [
          'proxy',
          '*',
          62,
          ''
        ];
network is returned more than once (No 2 comes here)
$VAR1 = [
          'network',
          '*',
          69,
          ''
        ];
nogroup is returned more than once (No 2 comes here)
$VAR1 = [
          'nogroup',
          '*',
          65533,
          ''
        ];
$VAR1 = [
          'palm',
          '',
          1000,
          'trevor'
        ];
$VAR1 = [
          'mrtg',
          '*',
          279,
          ''
        ];
mail is returned more than once (No 2 comes here)
$VAR1 = [
          'mail',
          '*',
          6,
          ''
        ];
_pflogd is returned more than once (No 2 comes here)
$VAR1 = [
          '_pflogd',
          '*',
          64,
          ''
        ];
nobody is returned more than once (No 2 comes here)
$VAR1 = [
          'nobody',
          '*',
          65534,
          ''
        ];
$VAR1 = [
          'dhcpd',
          '*',
          900,
          ''
        ];
$VAR1 = [
          'win32',
          '',
          1001,
          'melanie sarah'
        ];
daemon is returned more than once (No 2 comes here)
$VAR1 = [
          'daemon',
          '*',
          1,
          ''
        ];
operator is returned more than once (No 2 comes here)
$VAR1 = [
          'operator',
          '*',
          5,
          'root'
        ];
man is returned more than once (No 2 comes here)
$VAR1 = [
          'man',
          '*',
          9,
          ''
        ];
staff is returned more than once (No 2 comes here)
$VAR1 = [
          'staff',
          '*',
          20,
          'root'
        ];
$VAR1 = [
          'os2',
          '',
          1002,
          ''
        ];
$VAR1 = [
          'unix',
          '',
          1004,
          ''
        ];
wheel is returned more than once (No 2 comes here)
$VAR1 = [
          'wheel',
          '*',
          0,
          'root trevor mel'
        ];
news is returned more than once (No 2 comes here)
$VAR1 = [
          'news',
          '*',
          8,
          ''
        ];
games is returned more than once (No 2 comes here)
$VAR1 = [
          'games',
          '*',
          13,
          ''
        ];
bind is returned more than once (No 2 comes here)
$VAR1 = [
          'bind',
          '*',
          53,
          ''
        ];
uucp is returned more than once (No 2 comes here)
$VAR1 = [
          'uucp',
          '*',
          66,
          ''
        ];
www is returned more than once (No 2 comes here)
$VAR1 = [
          'www',
          '*',
          80,
          ''
        ];
$VAR1 = [
          'wwwdevel',
          '',
          15000,
          'wwwglobal trevor'
        ];
mailnull is returned more than once (No 2 comes here)
$VAR1 = [
          'mailnull',
          '*',
          26,
          ''
        ];
_dhcp is returned more than once (No 2 comes here)
$VAR1 = [
          '_dhcp',
          '*',
          65,
          ''
        ];
$VAR1 = [
          'squid',
          '*',
          100,
          ''
        ];
$VAR1 = [
          'dos',
          '',
          1003,
          ''
        ];
$VAR1 = [
          'cyrus',
          '*',
          60,
          ''
        ];
sys is returned more than once (No 2 comes here)
$VAR1 = [
          'sys',
          '*',
          3,
          ''
        ];
audit is returned more than once (No 2 comes here)
$VAR1 = [
          'audit',
          '*',
          77,
          ''
        ];
$VAR1 = [
          'pulse-rt',
          '*',
          557,
          ''
        ];
$VAR1 = [
          'pulse',
          '*',
          563,
          ''
        ];
$VAR1 = [
          'pulse-access',
          '*',
          564,
          ''
        ];


More information about the freebsd-questions mailing list