luaposix 35.1 Reference

# Module `posix.pwd`

Password Database Operations.

Query the system password database.

## Functions

endpwent () | Release password database resources.
getpwent () | Fetch next password entry.
getpwnam (name) | Fetch named user.
getpwuid (uid) | Fetch password entry with given user id.
setpwent () | Rewind next getpwent back to start of database.

## Tables

PosixPasswd | Password record.

## Functions

endpwent ()
  Release password database resources.

  ### See also:

  - endpwent(3)
  - getpwent
getpwent ()
  Fetch next password entry.

  ### Returns:

  PosixPasswd next password record

  ### See also:

  - getpwent(3)
  - endpwent

  ### Usage:

      local pwd = require "posix.pwd"
      t = pwd.getpwent ()
      while t ~= nil do
        process (t)
        t = pwd.getpwent ()
      end
      pwd.endpwent ()

getpwnam (name)
  Fetch named user.

  ### Parameters:

  - name string user name

  ### Returns:

  PosixPasswd passwd record for name, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  getpwnam(3)

  ### Usage:

      local pwd = require "posix.pwd"
      t = pwd.getpwnam "root"

getpwuid (uid)
  Fetch password entry with given user id.

  ### Parameters:

  - uid int user id

  ### Returns:

  PosixPasswd passwd record for uid, if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  getpwuid(3)

  ### Usage:

      local pwd = require "posix.pwd"
      t = pwd.getpwuid (0)

setpwent ()
  Rewind next getpwent back to start of database.

  ### See also:

  - setpwent(3)
  - getpwent

## Tables

PosixPasswd
  Password record.

  ### Fields:

  - pw_name string user's login name
  - pw_uid int unique user id
  - pw_gid int user's default group id
  - pw_dir string initial working directory
  - pw_shell string user's login shell path

generated by LDoc 1.4.6 Last updated 2021-09-09 17:41:28