MirOS Manual: pw_abort(3), pw_lock(3), pw_mkdb(3)

PW_LOCK(3)                 BSD Programmer's Manual                  PW_LOCK(3)


     pw_lock, pw_mkdb, pw_abort - passwd file update functions


     #include <util.h>

     pw_lock(int retries);

     pw_mkdb(char *username, int pwflags);



     The pw_lock(), pw_mkdb(), and pw_abort() functions allow a program to up-
     date the system passwd database.

     The pw_lock() function attempts to lock the passwd database by creating
     the file /etc/ptmp with an exclusive lock (using flock(2) semantics) and
     returns the file descriptor of that file. If retries is greater than
     zero, pw_lock() will try multiple times to open /etc/ptmp, waiting one
     second between tries. In addition to being a lock file, /etc/ptmp will
     also hold the contents of the new passwd file.

     The pw_mkdb() function updates the passwd file from the contents of
     /etc/ptmp via pwd_mkdb(8). If a username is specified, only the record
     for the specified user will be updated. The pwflags are specified by
     OR'ing the following values:

         _PASSWORD_SECUREONLY  only update the secure database file
         _PASSWORD_OMITV7      do not update the Version 7 format password
                               file (/etc/passwd).

     By default the secure, insecure and Version 7 format password databases
     are updated. You should finish writing to and close the file descriptor
     returned by pw_lock() before calling pw_mkdb(). If pw_mkdb() fails and
     you do not wish to retry, you should make sure to call pw_abort() to
     clean up the lock file.

     The pw_abort() function aborts a passwd file update by deleting
     /etc/ptmp. The passwd database remains unchanged.


     The pw_lock() and pw_mkdb() functions return -1 if they are unable to
     complete properly.


     /etc/master.passwd  current password file
     /etc/ptmp           password lock file
     /etc/passwd         a Version 7 format password file
     /etc/pwd.db         insecure password database file
     /etc/spwd.db        secure password database file


     flock(2), pw_init(3), pwd_mkdb(8)

MirOS BSD #10-current          August 20, 2001                               1

Generated on 2017-04-03 16:26:17 by $MirOS: src/scripts/roff2htm,v 1.88 2017/01/29 00:51:06 tg Exp $

These manual pages and other documentation are copyrighted by their respective writers; their source is available at our CVSweb, AnonCVS, and other mirrors. The rest is Copyright © 2002–2017 The MirOS Project, Germany.
This product includes material provided by mirabilos.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.