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

Re: add user ?

On Thu, 20 Feb 1997, Dave Kinchlea wrote:

> If you are working from a clean install of, say, RedHat, all of the
> applications *should* be using the same method of locking (and I would
> hope that none ignore a lock of /etc/passwd) but if you have started to
> mix and match passwd programs (including chfn, chsh, adduser and/or
> anything you might have created locally) you enter into muddy waters. It
> is vital that ALL of the different programs agree on which method to use
> (or that they use both file locking and lockf/fcntl/flock) AND that in the
> case of /etc/passwd locks, none feel it is right to ignore the lock
> (feeling it is stale).

I run a *clean* Redhat 4.0 on Intel.
My passwd,login,rlogin,su,etc. programs came from 
passwd-0.50-2.src.rpm and all do use pam.
My adduser script came from adduser-1.2-1.src.rpm.
I can see at least one bug in it 
(even if i believe that this certain version of adduser uses the same
  mechanism of /etc/passwd locking as other programs do)
in adduser script we have:

  PLOCK="/etc/.pwd.lock"		# Standard method of locking the  password file.
  if [ -f $PLOCK ]; then
  	echo "$PASSWD is locked.  Try again later." ; exit 1
  touch $PLOCK ;
What will happen if two addusers run simultaniosely ?
Look, if command will be successeful for both processes !
(then both will touch $PLOCK ... - we will have a mess in /etc/passwd file!)

What is wrong with my adduser script ?
(of course, I can fix it by hands - use ln instead of touch for example)
Does anyone know what does pam do with /etc/passwd ?
Does it use any kind of lock ?

How is /etc/group file locked ?


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