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

Re: New!!!: Base-passwd 2.0

I've just reviewed the code for chsh, passwd, vipw and rpc.yppasswd and they
all use the /etc/ptmp locking mechanism.  Although it's slightly different
from how I remember it for SunOS.

> 1) open(2) /etc/ptmp (with O_CREAT|O_EXCL)
>         (if that fails, wait and try again)
> 2) read in /etc/passwd and write changed passwd file to /etc/ptmp
>         (in this way /etc/passwd is maintained intact for others to use
>         while you make your changes)
> 3) rename(2) /etc/ptmp to /etc/passwd
>         (rename is a guaranteed atomic action)
> The same is tru for /etc/group except that /etc/gtmp is used.

The only thing that changes is that in step 3 they do a hard link
from /etc/passwd to /etc/ptmp and then unlink /etc/ptmp.  (Effectively
a rename.  I suspect that a rename isn't guaranteed atomic in linux?)

Anyone can confirm the above by checking out the nis and loginutils
source packages.

I would suggest using this same locking mechanism and even making sure
all debian utils that deal with /etc/passwd uses this same mechanism.

At my old IT job, not all the in house UNIX utils used use this, and
once a month (sometimes even once a week) /etc/passwd would be corrupted
(at the time /etc/passwd was over 6000 entries!).  The symptomes were
that usually about half of all users couldn't login.  Eek!  Oh well.

I hope this helps!


Behan Webster     mailto:behanw@verisim.com
(613) 224-7547    http://www.verisim.com/

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com

Reply to: