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
88 Present in SUSv2, but marked LEGACY.
89 Removed in POSIX.1-2001.
91 .\" For libc4 and libc5, the prompt is not written to
97 .\" cannot be opened, the password is read from
99 .\" The static buffer has length 128 so that only the first 127
100 .\" bytes of the password are returned.
101 .\" While reading the password, signal generation
106 .\" is disabled and the corresponding characters
107 .\" (usually control-C, control-\e, control-Z and control-Y)
108 .\" are transmitted as part of the password.
109 .\" Since libc 5.4.19 also line editing is disabled, so that also
110 .\" backspace and the like will be seen as part of the password.
111 You should use instead
112 .BR readpassphrase (3bsd),
116 In the GNU C library implementation, if
118 cannot be opened, the prompt is written to
120 and the password is read from
122 There is no limit on the length of the password.
123 Line editing is not disabled.
125 According to SUSv2, the value of
129 in case it is smaller than 8, and can in any case be obtained using
130 .IR sysconf(_SC_PASS_MAX) .
131 However, POSIX.2 withdraws the constants
137 .\" Libc4 and libc5 have never supported
140 .\" .BR _SC_PASS_MAX .
141 The glibc version accepts
147 The calling process should zero the password as soon as possible to avoid
148 leaving the cleartext password visible in the process's address space.