This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

lckpwdf question: possible bug?


I was playing with lckpwdf(3) and I don't understand
what it's doing.

As the following shows locking works correctly.
And lckpwdf correctly (?) creates a lock file
"/etc/.pwd.lock".

However that file doesn't appear to be used for locking,
just created as a side-effect!  And ulckpwdf doesn't
remove the file!

Is this a bug?  Or can someone explain what is going on?
The man page was less than helpful, but it seems to
me that if the lock file is created by lckpwdf, it
should be removed by ulckpwdf.  And if the file
exists it should indicate some other process holds
the lock currently.  But if the file is never used
for locking, than it seems that lckpwdf shouldn't
create it at all.  The current behavior seems
inconsistent!

Thanks!  Below is some possibly useful information
about this issue.  (This is run on Fedora 7.)  I
appreciate the help in understanding this!

-Wayne Pollock

$ cat lckpwdf-test.c
#include <stdio.h>
#include <shadow.h>
int main (void) {
   int status = lckpwdf();
   printf("(status=%d) hit enter to quit: ", status);
   getchar();
   status = ulckpwdf();
   return status;
}

# ls -l /etc/.pwd.lock
ls: cannot access /etc/.pwd.lock: No such file or directory

# ./lckpwdf-test
(i=0) hit enter to quit:

# echo $?
0

# ls -l /etc/.pwd.lock  # THE FILE SHOULD HAVE BEEN REMOVED, BUT:
-rw------- 1 root root 0 2007-12-31 10:06 /etc/.pwd.lock

# ./lckpwdf-test &  SHOULDN'T WORK IF THE LOCK FILE IS THERE, BUT:
[1] 12414
(i=0) hit enter to quit:
[1]+  Stopped                 ./lckpwdf-test

# ls -l /etc/.pwd.lock
-rw------- 1 root root 0 2007-12-31 10:48 /etc/.pwd.lock

# ./lckpwdf-test  # THIS SHOWS LOCKING WORKS REGARDLESS OF THE LOCK FILE:
(i=-1) hit enter to quit:

# echo $?
255

# fg
./lckpwdf-test


# echo $? 0

# ls -l /etc/.pwd.lock
-rw------- 1 root root 0 2007-12-31 10:48 /etc/.pwd.lock

$ rpm -q shadow-utils
shadow-utils-4.0.18.1-15.fc7

# rpm -qa | grep glibc
glibc-common-2.6-4
glibc-devel-2.6-4
glibc-headers-2.6-4
glibc-2.6-4

$ uname -a
Linux localhost 2.6.23.1-21.fc7 #1 SMP Thu Nov 1 21:09:24 EDT 2007 i686 i686 i386 GNU/Linux


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]