putpwent(3)

putpwent3

Write a password file entry

Usage

#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>

int putpwent(const struct passwd *restrict p, FILE *restrict stream);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

putpwent():

    Since glibc 2.19:
        _DEFAULT_SOURCE
    glibc 2.19 and earlier:
        _SVID_SOURCE

Library

Standard C library (libc, -lc)

Overview

The putpwent() function writes a password entry from the structure p in the file associated with stream.

The passwd structure is defined in <pwd.h> as follows:

struct passwd {
    char    *pw_name;        /* username */
    char    *pw_passwd;      /* user password */
    uid_t    pw_uid;         /* user ID */
    gid_t    pw_gid;         /* group ID */
    char    *pw_gecos;       /* real name */
    char    *pw_dir;         /* home directory */
    char    *pw_shell;       /* shell program */
};

Return value

The putpwent() function returns 0 on success. On failure, it returns -1, and errno is set to indicate the error.

Errors

EINVAL

Invalid (NULL) argument given.

Attributes

For an explanation of the terms used in this section, see attributes(7).

InterfaceAttributeValue
putpwent()Thread safetyMT-Safe locale

Releases

19 releases since Debian 1.1 (Buzz); the text changed 13 times.

  1. 1.1–2.2
  2. 3.0
  3. 3.1
  4. 4.0
  5. 5.0
  6. 6.0
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. Arch

Standards

None.

History

SVr4.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.