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

As the following SSCCE shows, locking works correctly.
And lckpwdf correctly creates a lock file /etc/.pwd.lock.

However, this 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?

-Wayne

# cat lckpwdf-test.c
#include
#include
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