1 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
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.
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.
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.
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,
23 .TH GETPASS 3 2000-12-05 "Linux" "Linux Programmer's Manual"
25 getpass \- get a password
27 .B #include <unistd.h>
29 .B "char *getpass( const char *" prompt );
31 This function is obsolete.
38 (the controlling terminal of the process), outputs the string
40 turns off echoing, reads one line (the "password"),
41 restores the terminal state and closes
47 returns a pointer to a static buffer containing the (first
49 bytes of) the password without the trailing
50 newline, terminated by a null byte ('\\0').
51 This buffer may be overwritten by a following call.
52 On error, the terminal state is restored,
54 is set appropriately, and NULL is returned.
56 The function may fail if
59 The process does not have a controlling terminal.
65 .\" function appeared in Version 7 AT&T UNIX.
67 Present in SUSv2, but marked LEGACY.
68 Removed in POSIX.1-2001.
70 For libc4 and libc5, the prompt is not written to
76 cannot be opened, the password is read from
78 The static buffer has length 128 so that only the first 127
79 bytes of the password are returned.
80 While reading the password, signal generation
85 is disabled and the corresponding characters
86 (usually control-C, control-\e, control-Z and control-Y)
87 are transmitted as part of the password.
88 Since libc 5.4.19 also line editing is disabled, so that also
89 backspace and the like will be seen as part of the password.
93 cannot be opened, the prompt is written to
95 and the password is read from
97 There is no limit on the length of the password.
98 Line editing is not disabled.
100 According to the SUSv2, the value of
104 in case it is smaller than 8, and can in any case be obtained using
105 .IR sysconf(_SC_PASS_MAX) .
106 However, POSIX.2 withdraws the constants
112 Libc4 and libc5 have never supported
122 The calling process should zero the password as soon as possible to avoid
123 leaving the cleartext password visible in the process's address space.