1GETPASS(3)                 Linux Programmer's Manual                GETPASS(3)
2
3
4

NAME

6       getpass - get a password
7

SYNOPSIS

9       #include <unistd.h>
10
11       char *getpass(const char *prompt);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       getpass():
16           Since glibc 2.2.2:
17               _XOPEN_SOURCE && ! (_POSIX_C_SOURCE >= 200112L)
18                   || /* Glibc since 2.19: */ _DEFAULT_SOURCE
19                   || /* Glibc versions <= 2.19: */ _BSD_SOURCE
20           Before glibc 2.2.2:
21               none
22

DESCRIPTION

24       This  function  is obsolete.  Do not use it.  If you want to read input
25       without terminal echoing enabled, see the description of the ECHO  flag
26       in termios(3).
27
28       The  getpass() function opens /dev/tty (the controlling terminal of the
29       process), outputs the string prompt, turns off echoing, reads one  line
30       (the  "password"),  restores  the  terminal  state  and closes /dev/tty
31       again.
32

RETURN VALUE

34       The function getpass() returns a pointer to a static buffer  containing
35       (the  first  PASS_MAX  bytes of) the password without the trailing new‐
36       line, terminated by a null byte ('\0').  This buffer may be overwritten
37       by  a  following call.  On error, the terminal state is restored, errno
38       is set appropriately, and NULL is returned.
39

ERRORS

41       The function may fail if
42
43       ENXIO  The process does not have a controlling terminal.
44

FILES

46       /dev/tty
47

ATTRIBUTES

49       For  an  explanation  of  the  terms  used   in   this   section,   see
50       attributes(7).
51
52       ┌──────────┬───────────────┬────────────────┐
53Interface Attribute     Value          
54       ├──────────┼───────────────┼────────────────┤
55getpass() │ Thread safety │ MT-Unsafe term │
56       └──────────┴───────────────┴────────────────┘

CONFORMING TO

58       Present in SUSv2, but marked LEGACY.  Removed in POSIX.1-2001.
59

NOTES

61       In  the GNU C library implementation, if /dev/tty cannot be opened, the
62       prompt is written to stderr and the password is read from stdin.  There
63       is  no  limit  on the length of the password.  Line editing is not dis‐
64       abled.
65
66       According to SUSv2, the value of PASS_MAX must be defined in <limits.h>
67       in  case  it  is  smaller than 8, and can in any case be obtained using
68       sysconf(_SC_PASS_MAX).   However,  POSIX.2  withdraws   the   constants
69       PASS_MAX  and _SC_PASS_MAX, and the function getpass().  The glibc ver‐
70       sion accepts _SC_PASS_MAX and returns BUFSIZ (e.g., 8192).
71

BUGS

73       The calling process should zero the password as  soon  as  possible  to
74       avoid  leaving  the cleartext password visible in the process's address
75       space.
76

SEE ALSO

78       crypt(3)
79

COLOPHON

81       This page is part of release 4.15 of the Linux  man-pages  project.   A
82       description  of  the project, information about reporting bugs, and the
83       latest    version    of    this    page,    can     be     found     at
84       https://www.kernel.org/doc/man-pages/.
85
86
87
88Linux                             2016-03-15                        GETPASS(3)
Impressum