]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl) |
2 | .\" | |
3 | .\" This is free documentation; you can redistribute it and/or | |
4 | .\" modify it under the terms of the GNU General Public License as | |
5 | .\" published by the Free Software Foundation; either version 2 of | |
6 | .\" the License, or (at your option) any later version. | |
7 | .\" | |
8 | .\" The GNU General Public License's references to "object code" | |
9 | .\" and "executables" are to be interpreted as the output of any | |
10 | .\" document formatting or typesetting system, including | |
11 | .\" intermediate and printed output. | |
12 | .\" | |
13 | .\" This manual is distributed in the hope that it will be useful, | |
14 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | .\" GNU General Public License for more details. | |
17 | .\" | |
18 | .\" You should have received a copy of the GNU General Public | |
19 | .\" License along with this manual; if not, write to the Free | |
20 | .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, | |
21 | .\" USA. | |
22 | .\" | |
23 | .TH GETPASS 3 2000-12-05 "Linux Manpage" "Linux Programmer's Manual" | |
24 | .SH NAME | |
25 | getpass \- get a password | |
26 | .SH SYNOPSIS | |
27 | .B #include <unistd.h> | |
28 | .sp | |
29 | .B "char *getpass( const char *" prompt ); | |
30 | .SH DESCRIPTION | |
31 | This function is obsolete. Do not use it. | |
32 | .PP | |
33 | The | |
34 | .BR getpass () | |
35 | function opens | |
36 | .I /dev/tty | |
37 | (the controlling terminal of the process), outputs the string | |
38 | .IR prompt , | |
39 | turns off echoing, reads one line (the "password"), | |
40 | restores the terminal state and closes | |
41 | .I /dev/tty | |
42 | again. | |
43 | .SH "RETURN VALUE" | |
44 | The function | |
45 | .B getpass | |
46 | returns a pointer to a static buffer containing the | |
47 | (first PASS_MAX bytes of) the password without the trailing | |
48 | newline, terminated by a NUL. | |
49 | This buffer may be overwritten by a following call. | |
50 | On error, the terminal state is restored, | |
51 | .I errno | |
52 | is set appropriately, and NULL is returned. | |
53 | .SH ERRORS | |
54 | The function may fail if | |
55 | .TP | |
56 | .B ENXIO | |
57 | The process does not have a controlling terminal. | |
58 | .SH NOTES | |
59 | For libc4 and libc5, the prompt is not written to | |
60 | .I /dev/tty | |
61 | but to | |
62 | .IR stderr . | |
63 | Moreover, if | |
64 | .I /dev/tty | |
65 | cannot be opened, the password is read from | |
66 | .IR stdin . | |
67 | The static buffer has length 128 so that only the first 127 | |
68 | bytes of the password are returned. | |
69 | While reading the password, signal generation (SIGINT, SIGQUIT, | |
70 | SIGSTOP, SIGTSTOP) is disabled and the corresponding characters | |
71 | (usually control-C, control-\e, control-Z and control-Y) | |
72 | are transmitted as part of the password. | |
73 | Since libc 5.4.19 also line editing is disabled, so that also | |
74 | backspace and the like will be seen as part of the password. | |
75 | .PP | |
76 | For glibc2, if | |
77 | .I /dev/tty | |
78 | cannot be opened, the prompt is written to | |
79 | .I stderr | |
80 | and the password is read from | |
81 | .IR stdin . | |
82 | There is no limit on the length of the password. | |
83 | Line editing is not disabled. | |
84 | .PP | |
85 | According to the SUSv2, the value of PASS_MAX must be defined in | |
86 | .I <limits.h> | |
87 | in case it is smaller than 8, and can in any case be obtained using | |
88 | .IR sysconf(_SC_PASS_MAX) . | |
89 | However, POSIX.2 withdraws the constants PASS_MAX | |
90 | and _SC_PASS_MAX, and the function | |
91 | .B getpass (). | |
92 | Libc4 and libc5 have never supported PASS_MAX or _SC_PASS_MAX. | |
93 | Glibc2 accepts _SC_PASS_MAX and returns BUFSIZ (e.g., 8192). | |
94 | .SH FILES | |
95 | .I /dev/tty | |
96 | .SH "SEE ALSO" | |
97 | .BR crypt (3) | |
98 | .SH HISTORY | |
99 | A | |
100 | .B getpass | |
101 | function appeared in Version 7 AT&T UNIX. | |
102 | .SH BUGS | |
103 | The calling process should zero the password as soon as possible to avoid | |
104 | leaving the cleartext password visible in the process's address space. |