xref: /original-bsd/lib/libc/gen/getpass.3 (revision 56b48dd2)
1.\" Copyright (c) 1989, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)getpass.3	6.3 (Berkeley) 04/19/91
7.\"
8.Dd
9.Dt GETPASS 3
10.Os
11.Sh NAME
12.Nm getpass
13.Nd get a password
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft char *
17.Fn getpass "const char *prompt"
18.Sh DESCRIPTION
19The
20.Fn getpass
21function prompts for a password
22from
23.Pa /dev/tty .
24If the file
25.Pa /dev/tty is not accessible,
26.Fn getpass
27reads from the
28.Em stdin .
29The prompt string must be
30.Dv NUL Ns -terminated
31and after it is written
32to the output,
33.Fn getpass
34turns off character echoing.
35.Pp
36.Sh RETURN VALUES
37If successful,
38.Fn getpass
39returns a pointer to the
40password. The password may be up to 128
41characters long and is null terminated.
42The calling process should zero the password as soon as possible
43to avoid leaving the cleartext password visible in the process's
44address space.
45.Sh FILES
46.Bl -tag -width /dev/tty - compact
47.It Pa /dev/tty
48.El
49.Sh SEE ALSO
50.Xr crypt 3
51.Sh HISTORY
52A
53.Fn getpass
54function appeared in
55.At v7 .
56.Sh BUGS
57The
58.Fn getpass
59function leaves its result in an internal static object and returns
60a pointer to that object. Subsequent calls to
61.Fn getpass
62will modify the same object.
63