2 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .TH getpass 3 (date) "Linux man-pages (unreleased)"
8 getpass \- get a password
11 .RI ( libc ", " \-lc )
14 .B #include <unistd.h>
16 .BI "[[deprecated]] char *getpass(const char *" prompt );
20 Feature Test Macro Requirements for glibc (see
21 .BR feature_test_macros (7)):
27 _XOPEN_SOURCE && ! (_POSIX_C_SOURCE >= 200112L)
28 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
29 || /* glibc <= 2.19: */ _BSD_SOURCE
34 This function is obsolete.
37 If you want to read input without terminal echoing enabled,
38 see the description of the
47 (the controlling terminal of the process), outputs the string
49 turns off echoing, reads one line (the "password"),
50 restores the terminal state and closes
56 returns a pointer to a static buffer containing (the first
58 bytes of) the password without the trailing
59 newline, terminated by a null byte (\[aq]\e0\[aq]).
60 This buffer may be overwritten by a following call.
61 On error, the terminal state is restored,
63 is set to indicate the error, and NULL is returned.
67 The process does not have a controlling terminal.
71 For an explanation of the terms used in this section, see
77 Interface Attribute Value
82 T} Thread safety MT-Unsafe term
89 Present in SUSv2, but marked LEGACY.
90 Removed in POSIX.1-2001.
92 .\" For libc4 and libc5, the prompt is not written to
98 .\" cannot be opened, the password is read from
100 .\" The static buffer has length 128 so that only the first 127
101 .\" bytes of the password are returned.
102 .\" While reading the password, signal generation
107 .\" is disabled and the corresponding characters
108 .\" (usually control-C, control-\e, control-Z and control-Y)
109 .\" are transmitted as part of the password.
110 .\" Since libc 5.4.19 also line editing is disabled, so that also
111 .\" backspace and the like will be seen as part of the password.
112 You should use instead
113 .BR readpassphrase (3bsd),
117 In the GNU C library implementation, if
119 cannot be opened, the prompt is written to
121 and the password is read from
123 There is no limit on the length of the password.
124 Line editing is not disabled.
126 According to SUSv2, the value of
130 in case it is smaller than 8, and can in any case be obtained using
131 .IR sysconf(_SC_PASS_MAX) .
132 However, POSIX.2 withdraws the constants
138 .\" Libc4 and libc5 have never supported
141 .\" .BR _SC_PASS_MAX .
142 The glibc version accepts
148 The calling process should zero the password as soon as possible to avoid
149 leaving the cleartext password visible in the process's address space.