]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getpass.3
ffix
[thirdparty/man-pages.git] / man3 / getpass.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
2.\"
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.
7.\"
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.
12.\"
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.
17.\"
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,
21.\" USA.
22.\"
69962544 23.TH GETPASS 3 2000-12-05 "Linux" "Linux Programmer's Manual"
fea681da
MK
24.SH NAME
25getpass \- get a password
26.SH SYNOPSIS
27.B #include <unistd.h>
28.sp
29.B "char *getpass( const char *" prompt );
30.SH DESCRIPTION
c13182ef
MK
31This function is obsolete.
32Do not use it.
fea681da
MK
33.PP
34The
35.BR getpass ()
36function opens
37.I /dev/tty
38(the controlling terminal of the process), outputs the string
39.IR prompt ,
40turns off echoing, reads one line (the "password"),
41restores the terminal state and closes
42.I /dev/tty
43again.
44.SH "RETURN VALUE"
45The function
e511ffb6 46.BR getpass ()
2f0af33b
MK
47returns a pointer to a static buffer containing the (first
48.B PASS_MAX
49bytes of) the password without the trailing
28d88c17 50newline, terminated by a null byte ('\\0').
fea681da
MK
51This buffer may be overwritten by a following call.
52On error, the terminal state is restored,
53.I errno
54is set appropriately, and NULL is returned.
55.SH ERRORS
56The function may fail if
57.TP
58.B ENXIO
c13182ef 59The process does not have a controlling terminal.
2b2581ee
MK
60.SH FILES
61.I /dev/tty
62.\" .SH HISTORY
63.\" A
64.\" .BR getpass ()
65.\" function appeared in Version 7 AT&T UNIX.
66.SH "CONFORMING TO"
67Present in SUSv2, but marked LEGACY.
68Removed in POSIX.1-2001.
fea681da
MK
69.SH NOTES
70For libc4 and libc5, the prompt is not written to
71.I /dev/tty
72but to
73.IR stderr .
74Moreover, if
75.I /dev/tty
76cannot be opened, the password is read from
77.IR stdin .
78The static buffer has length 128 so that only the first 127
79bytes of the password are returned.
8bd58774
MK
80While reading the password, signal generation
81.RB (SIGINT ,
82.BR SIGQUIT ,
83.BR SIGSTOP ,
84.BR SIGTSTOP )
85is disabled and the corresponding characters
fea681da
MK
86(usually control-C, control-\e, control-Z and control-Y)
87are transmitted as part of the password.
88Since libc 5.4.19 also line editing is disabled, so that also
89backspace and the like will be seen as part of the password.
90.PP
91For glibc2, if
92.I /dev/tty
93cannot be opened, the prompt is written to
94.I stderr
95and the password is read from
96.IR stdin .
97There is no limit on the length of the password.
98Line editing is not disabled.
99.PP
2f0af33b
MK
100According to the SUSv2, the value of
101.B PASS_MAX
102must be defined in
fea681da
MK
103.I <limits.h>
104in case it is smaller than 8, and can in any case be obtained using
105.IR sysconf(_SC_PASS_MAX) .
2f0af33b
MK
106However, POSIX.2 withdraws the constants
107.B PASS_MAX
108and
109.BR _SC_PASS_MAX ,
110and the function
f87925c6 111.BR getpass ().
2f0af33b
MK
112Libc4 and libc5 have never supported
113.B PASS_MAX
114or
115.BR _SC_PASS_MAX .
116Glibc2 accepts
117.BR _SC_PASS_MAX
118and returns
119.B BUFSIZ
120(e.g., 8192).
fea681da
MK
121.SH BUGS
122The calling process should zero the password as soon as possible to avoid
123leaving the cleartext password visible in the process's address space.
e37e3282
MK
124.SH "SEE ALSO"
125.BR crypt (3)