Enumerating password entries

Jeremy Allison jallison at cthulhu.engr.sgi.com
Thu Oct 22 16:34:28 GMT 1998


Luke you mentioned adding a 'number of entries' prefix
to the Samba smbpasswd file (sorry but I've lost your
original message).

The problem with this is drift - if someone hand edits
the smbpasswd file this number will get out of sync
and it'll be hard to keep it in sync.

A cleaner solution, if you don't mind a one-time startup
cost, is to to a startsmbpwent(), getsmbpwent() endsmbpswent()
sequence at startup to count the number of entries the
first time you need it - and then stat() the file to
get the last modified time which you then cache.

To do subsequent 'get_number_of_smbpasswd_entry()'
calls you then first do a stat() on the smbpasswd
file and if the last modified time hasn't changed
you just return the cached number. If it has changed
of course you need to re-read, but this is similar 
to what we do with the smb.conf file and that seems
to work well.

Thoughts anyone ?

Cheers,

	Jeremy.

-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------


More information about the samba-technical mailing list