1GETPASS(3) Linux Programmer's Manual GETPASS(3)
2
3
4
6 getpass - get a password
7
9 #include <unistd.h>
10
11 char *getpass( const char * prompt );
12
14 This function is obsolete. Do not use it.
15
16 The getpass() function opens /dev/tty (the controlling terminal of the
17 process), outputs the string prompt, turns off echoing, reads one line
18 (the "password"), restores the terminal state and closes /dev/tty
19 again.
20
22 The function getpass() returns a pointer to a static buffer containing
23 the (first PASS_MAX bytes of) the password without the trailing new‐
24 line, terminated by a null byte ('\0'). This buffer may be overwritten
25 by a following call. On error, the terminal state is restored, errno
26 is set appropriately, and NULL is returned.
27
29 The function may fail if
30
31 ENXIO The process does not have a controlling terminal.
32
34 For libc4 and libc5, the prompt is not written to /dev/tty but to
35 stderr. Moreover, if /dev/tty cannot be opened, the password is read
36 from stdin. The static buffer has length 128 so that only the first
37 127 bytes of the password are returned. While reading the password,
38 signal generation (SIGINT, SIGQUIT, SIGSTOP, SIGTSTOP) is disabled and
39 the corresponding characters (usually control-C, control-\, control-Z
40 and control-Y) are transmitted as part of the password. Since libc
41 5.4.19 also line editing is disabled, so that also backspace and the
42 like will be seen as part of the password.
43
44 For glibc2, if /dev/tty cannot be opened, the prompt is written to
45 stderr and the password is read from stdin. There is no limit on the
46 length of the password. Line editing is not disabled.
47
48 According to the SUSv2, the value of PASS_MAX must be defined in <lim‐
49 its.h> in case it is smaller than 8, and can in any case be obtained
50 using sysconf(_SC_PASS_MAX). However, POSIX.2 withdraws the constants
51 PASS_MAX and _SC_PASS_MAX, and the function getpass(). Libc4 and libc5
52 have never supported PASS_MAX or _SC_PASS_MAX. Glibc2 accepts
53 _SC_PASS_MAX and returns BUFSIZ (e.g., 8192).
54
56 /dev/tty
57
59 crypt(3)
60
62 A getpass() function appeared in Version 7 AT&T UNIX.
63
65 Present in SUSv2, but marked LEGACY. Removed in POSIX.1-2001.
66
68 The calling process should zero the password as soon as possible to
69 avoid leaving the cleartext password visible in the process's address
70 space.
71
72
73
74Linux Manpage 2000-12-05 GETPASS(3)