#include <shadow.h>
int lckpwdf(void);
int ulckpwdf(void);
MT-Safe
lckpwdf() and ulckpwdf() are routines that are used to gain modification access to the password databases, through the lock file. A process first uses lckpwdf() to lock the lock file, thereby gaining exclusive rights to modify the /etc/passwd or /etc/shadow password database. Upon completing modifications, a process should release the lock on the lock file using ulckpwdf(). This mechanism prevents simultaneous modification of the password databases. /etc/.pwd.lock is the lock file. It is used to coordinate modification access to the password databases /etc/passwd and /etc/shadow.
lckpwdf() attempts to lock the file /etc/.pwd.lock within 15 seconds. If unsuccessful, for example, /etc/.pwd.lock is already locked, it returns -1. If successful, a return code other than -1 is returned.
ulckpwdf() attempts to unlock the file /etc/.pwd.lock. If unsuccessful, for example, /etc/.pwd.lock is already unlocked, it returns -1. If successful, it returns 0.
lckpwdf() and ulckpwdf() return -1 on failure, and 0 otherwise.
These routines are for internal use only; compatibility is not guaranteed.