1GETPASS(3)                 Linux Programmer's Manual                GETPASS(3)
2
3
4

NAME

6       getpass - get a password
7

SYNOPSIS

9       #include <unistd.h>
10
11       char *getpass( const char *prompt);
12

DESCRIPTION

14       This function is obsolete.  Do not use it.
15
16       The  getpass() function opens /dev/tty (the controlling terminal of the
17       process), outputs the string prompt, turns off echoing, reads one  line
18       (the  "password"),  restores  the  terminal  state  and closes /dev/tty
19       again.
20

RETURN VALUE

22       The function getpass() returns a pointer to a static buffer  containing
23       (the  first  PASS_MAX  bytes of) the password without the trailing new‐
24       line, terminated by a null byte ('\0').  This buffer may be overwritten
25       by  a  following call.  On error, the terminal state is restored, errno
26       is set appropriately, and NULL is returned.
27

ERRORS

29       The function may fail if
30
31       ENXIO  The process does not have a controlling terminal.
32

FILES

34       /dev/tty
35

CONFORMING TO

37       Present in SUSv2, but marked LEGACY.  Removed in POSIX.1-2001.
38

NOTES

40       For libc4 and libc5, the prompt is  not  written  to  /dev/tty  but  to
41       stderr.   Moreover,  if /dev/tty cannot be opened, the password is read
42       from stdin.  The static buffer has length 128 so that  only  the  first
43       127  bytes  of  the password are returned.  While reading the password,
44       signal generation (SIGINT, SIGQUIT, SIGSTOP, SIGTSTP) is  disabled  and
45       the  corresponding  characters (usually control-C, control-\, control-Z
46       and control-Y) are transmitted as part of  the  password.   Since  libc
47       5.4.19  also  line  editing is disabled, so that also backspace and the
48       like will be seen as part of the password.
49
50       For glibc2, if /dev/tty cannot be opened,  the  prompt  is  written  to
51       stderr  and  the password is read from stdin.  There is no limit on the
52       length of the password.  Line editing is not disabled.
53
54       According to the SUSv2, the value of PASS_MAX must be defined in  <lim‐
55       its.h>  in  case  it is smaller than 8, and can in any case be obtained
56       using sysconf(_SC_PASS_MAX).  However, POSIX.2 withdraws the  constants
57       PASS_MAX and _SC_PASS_MAX, and the function getpass().  Libc4 and libc5
58       have  never  supported  PASS_MAX  or  _SC_PASS_MAX.    Glibc2   accepts
59       _SC_PASS_MAX and returns BUFSIZ (e.g., 8192).
60

BUGS

62       The  calling  process  should  zero the password as soon as possible to
63       avoid leaving the cleartext password visible in the  process's  address
64       space.
65

SEE ALSO

67       crypt(3)
68

COLOPHON

70       This  page  is  part of release 3.25 of the Linux man-pages project.  A
71       description of the project, and information about reporting  bugs,  can
72       be found at http://www.kernel.org/doc/man-pages/.
73
74
75
76Linux                             2000-12-05                        GETPASS(3)
Impressum