]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getpass.3
Maintenance scripts
[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.\"
23.TH GETPASS 3 2000-12-05 "Linux Manpage" "Linux Programmer's Manual"
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
31This function is obsolete. Do not use it.
32.PP
33The
34.BR getpass ()
35function opens
36.I /dev/tty
37(the controlling terminal of the process), outputs the string
38.IR prompt ,
39turns off echoing, reads one line (the "password"),
40restores the terminal state and closes
41.I /dev/tty
42again.
43.SH "RETURN VALUE"
44The function
45.B getpass
46returns a pointer to a static buffer containing the
47(first PASS_MAX bytes of) the password without the trailing
48newline, terminated by a NUL.
49This buffer may be overwritten by a following call.
50On error, the terminal state is restored,
51.I errno
52is set appropriately, and NULL is returned.
53.SH ERRORS
54The function may fail if
55.TP
56.B ENXIO
57The process does not have a controlling terminal.
58.SH NOTES
59For libc4 and libc5, the prompt is not written to
60.I /dev/tty
61but to
62.IR stderr .
63Moreover, if
64.I /dev/tty
65cannot be opened, the password is read from
66.IR stdin .
67The static buffer has length 128 so that only the first 127
68bytes of the password are returned.
69While reading the password, signal generation (SIGINT, SIGQUIT,
70SIGSTOP, SIGTSTOP) is disabled and the corresponding characters
71(usually control-C, control-\e, control-Z and control-Y)
72are transmitted as part of the password.
73Since libc 5.4.19 also line editing is disabled, so that also
74backspace and the like will be seen as part of the password.
75.PP
76For glibc2, if
77.I /dev/tty
78cannot be opened, the prompt is written to
79.I stderr
80and the password is read from
81.IR stdin .
82There is no limit on the length of the password.
83Line editing is not disabled.
84.PP
85According to the SUSv2, the value of PASS_MAX must be defined in
86.I <limits.h>
87in case it is smaller than 8, and can in any case be obtained using
88.IR sysconf(_SC_PASS_MAX) .
89However, POSIX.2 withdraws the constants PASS_MAX
90and _SC_PASS_MAX, and the function
91.B getpass ().
92Libc4 and libc5 have never supported PASS_MAX or _SC_PASS_MAX.
93Glibc2 accepts _SC_PASS_MAX and returns BUFSIZ (e.g., 8192).
94.SH FILES
95.I /dev/tty
96.SH "SEE ALSO"
97.BR crypt (3)
98.SH HISTORY
99A
100.B getpass
101function appeared in Version 7 AT&T UNIX.
102.SH BUGS
103The calling process should zero the password as soon as possible to avoid
104leaving the cleartext password visible in the process's address space.