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 <= 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 to indicate the error, and NULL is returned.
39

ERRORS

41       ENXIO  The process does not have a controlling terminal.
42

FILES

44       /dev/tty
45

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

BUGS

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

SEE ALSO

77       crypt(3)
78

COLOPHON

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