]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl) |
2 | .\" | |
e4a74ca8 | 3 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da | 4 | .\" |
7bd6328f | 5 | .TH GETPASS 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual" |
fea681da MK |
6 | .SH NAME |
7 | getpass \- get a password | |
42009080 AC |
8 | .SH LIBRARY |
9 | Standard C library | |
10 | .RI ( libc ", " \-lc ) | |
fea681da | 11 | .SH SYNOPSIS |
4653ec6e | 12 | .nf |
fea681da | 13 | .B #include <unistd.h> |
68e4db0a | 14 | .PP |
b73ce084 | 15 | .BI "char *getpass(const char *" prompt ); |
4653ec6e | 16 | .fi |
68e4db0a | 17 | .PP |
d39ad78f | 18 | .RS -4 |
2df50e3d MK |
19 | Feature Test Macro Requirements for glibc (see |
20 | .BR feature_test_macros (7)): | |
d39ad78f | 21 | .RE |
68e4db0a | 22 | .PP |
2df50e3d | 23 | .BR getpass (): |
2df50e3d | 24 | .nf |
9d2adbae | 25 | Since glibc 2.2.2: |
5c10d2c5 | 26 | _XOPEN_SOURCE && ! (_POSIX_C_SOURCE >= 200112L) |
9d2adbae MK |
27 | || /* Glibc since 2.19: */ _DEFAULT_SOURCE |
28 | || /* Glibc <= 2.19: */ _BSD_SOURCE | |
29 | Before glibc 2.2.2: | |
30 | none | |
2df50e3d | 31 | .fi |
fea681da | 32 | .SH DESCRIPTION |
c13182ef MK |
33 | This function is obsolete. |
34 | Do not use it. | |
63bed6ae MK |
35 | If you want to read input without terminal echoing enabled, |
36 | see the description of the | |
37 | .I ECHO | |
38 | flag in | |
39 | .BR termios (3). | |
fea681da MK |
40 | .PP |
41 | The | |
42 | .BR getpass () | |
43 | function opens | |
44 | .I /dev/tty | |
45 | (the controlling terminal of the process), outputs the string | |
46 | .IR prompt , | |
47 | turns off echoing, reads one line (the "password"), | |
48 | restores the terminal state and closes | |
49 | .I /dev/tty | |
50 | again. | |
47297adb | 51 | .SH RETURN VALUE |
fea681da | 52 | The function |
e511ffb6 | 53 | .BR getpass () |
cd4995f5 | 54 | returns a pointer to a static buffer containing (the first |
2f0af33b MK |
55 | .B PASS_MAX |
56 | bytes of) the password without the trailing | |
d1a71985 | 57 | newline, terminated by a null byte (\(aq\e0\(aq). |
fea681da MK |
58 | This buffer may be overwritten by a following call. |
59 | On error, the terminal state is restored, | |
60 | .I errno | |
c112329f | 61 | is set to indicate the error, and NULL is returned. |
fea681da | 62 | .SH ERRORS |
fea681da MK |
63 | .TP |
64 | .B ENXIO | |
c13182ef | 65 | The process does not have a controlling terminal. |
2b2581ee MK |
66 | .SH FILES |
67 | .I /dev/tty | |
68 | .\" .SH HISTORY | |
69 | .\" A | |
70 | .\" .BR getpass () | |
71 | .\" function appeared in Version 7 AT&T UNIX. | |
3f970b11 | 72 | .SH ATTRIBUTES |
34ed6a7e MK |
73 | For an explanation of the terms used in this section, see |
74 | .BR attributes (7). | |
c466875e MK |
75 | .ad l |
76 | .nh | |
34ed6a7e MK |
77 | .TS |
78 | allbox; | |
c466875e | 79 | lbx lb lb |
34ed6a7e MK |
80 | l l l. |
81 | Interface Attribute Value | |
82 | T{ | |
3f970b11 | 83 | .BR getpass () |
1143466a | 84 | T} Thread safety MT-Unsafe term |
34ed6a7e | 85 | .TE |
c466875e MK |
86 | .hy |
87 | .ad | |
88 | .sp 1 | |
3113c7f3 | 89 | .SH STANDARDS |
2b2581ee MK |
90 | Present in SUSv2, but marked LEGACY. |
91 | Removed in POSIX.1-2001. | |
fea681da | 92 | .SH NOTES |
af3253ca MK |
93 | .\" For libc4 and libc5, the prompt is not written to |
94 | .\" .I /dev/tty | |
95 | .\" but to | |
96 | .\" .IR stderr . | |
97 | .\" Moreover, if | |
98 | .\" .I /dev/tty | |
99 | .\" cannot be opened, the password is read from | |
100 | .\" .IR stdin . | |
101 | .\" The static buffer has length 128 so that only the first 127 | |
102 | .\" bytes of the password are returned. | |
103 | .\" While reading the password, signal generation | |
104 | .\" .RB ( SIGINT , | |
105 | .\" .BR SIGQUIT , | |
106 | .\" .BR SIGSTOP , | |
107 | .\" .BR SIGTSTP ) | |
108 | .\" is disabled and the corresponding characters | |
109 | .\" (usually control-C, control-\e, control-Z and control-Y) | |
110 | .\" are transmitted as part of the password. | |
111 | .\" Since libc 5.4.19 also line editing is disabled, so that also | |
112 | .\" backspace and the like will be seen as part of the password. | |
7f740303 | 113 | . |
af3253ca | 114 | In the GNU C library implementation, if |
fea681da MK |
115 | .I /dev/tty |
116 | cannot be opened, the prompt is written to | |
117 | .I stderr | |
118 | and the password is read from | |
119 | .IR stdin . | |
120 | There is no limit on the length of the password. | |
121 | Line editing is not disabled. | |
122 | .PP | |
fb307ec7 | 123 | According to SUSv2, the value of |
2f0af33b MK |
124 | .B PASS_MAX |
125 | must be defined in | |
fea681da MK |
126 | .I <limits.h> |
127 | in case it is smaller than 8, and can in any case be obtained using | |
128 | .IR sysconf(_SC_PASS_MAX) . | |
2f0af33b MK |
129 | However, POSIX.2 withdraws the constants |
130 | .B PASS_MAX | |
131 | and | |
132 | .BR _SC_PASS_MAX , | |
133 | and the function | |
f87925c6 | 134 | .BR getpass (). |
a6cc92e3 MK |
135 | .\" Libc4 and libc5 have never supported |
136 | .\" .B PASS_MAX | |
137 | .\" or | |
138 | .\" .BR _SC_PASS_MAX . | |
139 | The glibc version accepts | |
0daa9e92 | 140 | .B _SC_PASS_MAX |
66ee0c7e | 141 | and returns |
2f0af33b MK |
142 | .B BUFSIZ |
143 | (e.g., 8192). | |
fea681da MK |
144 | .SH BUGS |
145 | The calling process should zero the password as soon as possible to avoid | |
146 | leaving the cleartext password visible in the process's address space. | |
47297adb | 147 | .SH SEE ALSO |
e37e3282 | 148 | .BR crypt (3) |