NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/32591: cap_mkdb(1) does not update properly db files?



The following reply was made to PR bin/32591; it has been noted by GNATS.

From: Christoph Badura <bad%bsd.de@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/32591: cap_mkdb(1) does not update properly db files?
Date: Thu, 4 Sep 2008 00:49:08 +0200

 I noticed the same problme today with a simpler setup.
 I just added "datasize=384m" to the default class.  And ran
 "cap_mkdb /etc/login.conf".
 
 I see this under NetBSD 3.1/i386 but the bug seems to be present in all
 versions.
 
 There was an attempt to work around this in rev 1.22 of cap_mkdb.c but
 that handles only the case where the name of the output file is derived from
 the first input file and the ".db" file doesn't exist already.
 
 When the ".db" file does exist the following happens:
 
 cap_mkdb keeps calling cgetnext() to parse the input files.
 cgetnext() calls getent() internally passing the names of the input files
 as the db_array parameter and -1 as the fd parameter.  This causes getent()
 to iterate over the db_array file names and opening them, trying to dbopen
 the ".db" version first.  When it succeeds to open the ".db" it seem to
 pull out the old record for the current key and that will be stored in the
 new ".db" file hence preventing changes to existing records.
 
 The proper fix is to prevent getent() from opening the ".db" files for the
 input files of cap_mkdb when being called from cap_mkdb.
 
 How to repeat:
 
 echo "foo:bar" >/tmp/foo
 cap_mkdb /tmp/foo
 db -NSb hash /tmp/foo.db
 echo "foo:baz" >/tmp/foo
 cap_mkdb /tmp/foo
 db -NSb hash /tmp/foo.db
 
 --chris
 


Home | Main Index | Thread Index | Old Index