1 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
24 .TH GETPASS 3 2014-08-19 "Linux" "Linux Programmer's Manual"
26 getpass \- get a password
28 .B #include <unistd.h>
30 .BI "char *getpass(const char *" prompt );
33 Feature Test Macro Requirements for glibc (see
34 .BR feature_test_macros (7)):
45 (_XOPEN_SOURCE\ >=\ 500 ||
46 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
47 !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
56 This function is obsolete.
58 If you want to read input without terminal echoing enabled,
59 see the description of the
68 (the controlling terminal of the process), outputs the string
70 turns off echoing, reads one line (the "password"),
71 restores the terminal state and closes
77 returns a pointer to a static buffer containing (the first
79 bytes of) the password without the trailing
80 newline, terminated by a null byte (\(aq\\0\(aq).
81 This buffer may be overwritten by a following call.
82 On error, the terminal state is restored,
84 is set appropriately, and NULL is returned.
86 The function may fail if
89 The process does not have a controlling terminal.
95 .\" function appeared in Version 7 AT&T UNIX.
97 .SS Multithreading (see pthreads(7))
100 function is not thread-safe.
102 Present in SUSv2, but marked LEGACY.
103 Removed in POSIX.1-2001.
105 .\" For libc4 and libc5, the prompt is not written to
111 .\" cannot be opened, the password is read from
113 .\" The static buffer has length 128 so that only the first 127
114 .\" bytes of the password are returned.
115 .\" While reading the password, signal generation
120 .\" is disabled and the corresponding characters
121 .\" (usually control-C, control-\e, control-Z and control-Y)
122 .\" are transmitted as part of the password.
123 .\" Since libc 5.4.19 also line editing is disabled, so that also
124 .\" backspace and the like will be seen as part of the password.
126 In the GNU C library implementation, if
128 cannot be opened, the prompt is written to
130 and the password is read from
132 There is no limit on the length of the password.
133 Line editing is not disabled.
135 According to SUSv2, the value of
139 in case it is smaller than 8, and can in any case be obtained using
140 .IR sysconf(_SC_PASS_MAX) .
141 However, POSIX.2 withdraws the constants
147 .\" Libc4 and libc5 have never supported
150 .\" .BR _SC_PASS_MAX .
151 The glibc version accepts
157 The calling process should zero the password as soon as possible to avoid
158 leaving the cleartext password visible in the process's address space.