2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
|
|
|
|
.\"
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
.\" License along with this manual; if not, write to the Free
|
|
|
|
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
|
|
|
|
.\" USA.
|
|
|
|
.\"
|
_exit.2, brk.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, getdtablesize.2, gethostname.2, getpagesize.2, getsid.2, killpg.2, mknod.2, mknodat.2, poll.2, posix_fadvise.2, pread.2, readlink.2, setpgid.2, setreuid.2, sigaltstack.2, stat.2, symlink.2, sync.2, truncate.2, vfork.2, wait.2, wait4.2, a64l.3, abs.3, acos.3, acosh.3, asin.3, asinh.3, atan.3, atan2.3, atoi.3, cbrt.3, ceil.3, copysign.3, cosh.3, dirfd.3, div.3, ecvt.3, erf.3, erfc.3, exp.3, exp2.3, fabs.3, fdim.3, ffs.3, floor.3, fma.3, fmax.3, fmin.3, fmod.3, fpclassify.3, frexp.3, ftw.3, fwide.3, gcvt.3, getcwd.3, getdate.3, getgrent.3, gethostid.3, getpass.3, getpwent.3, getsubopt.3, getw.3, hypot.3, ilogb.3, index.3, isalpha.3, isgreater.3, iswblank.3, j0.3, ldexp.3, lockf.3, log.3, log10.3, log1p.3, logb.3, lrint.3, lround.3, mkstemp.3, mktemp.3, modf.3, mq_receive.3, mq_send.3, nan.3, nextafter.3, posix_fallocate.3, posix_memalign.3, printf.3, qecvt.3, random.3, realpath.3, remainder.3, remquo.3, rint.3, round.3, scalb.3, scalbln.3, scanf.3, siginterrupt.3, signbit.3, sigset.3, sinh.3, sqrt.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strfry.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtod.3, strtok.3, strtol.3, strtoul.3, strxfrm.3, tanh.3, tgamma.3, trunc.3, ttyslot.3, ualarm.3, usleep.3, wprintf.3, armscii-8.7, cp1251.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-3.7, iso_8859-5.7, iso_8859-6.7, iso_8859-8.7, koi8-u.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 17:19:13 +00:00
|
|
|
.TH GETPASS 3 2010-09-20 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
getpass \- get a password
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <unistd.h>
|
|
|
|
.sp
|
2008-07-10 12:06:48 +00:00
|
|
|
.BI "char *getpass( const char *" prompt );
|
2010-09-17 15:22:01 +00:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.BR getpass ():
|
|
|
|
.ad l
|
|
|
|
.RS 4
|
|
|
|
.PD 0
|
|
|
|
.TP 4
|
|
|
|
Since glibc 2.2.2:
|
|
|
|
.nf
|
|
|
|
_BSD_SOURCE ||
|
brk.2, chroot.2, faccessat.2, fchmodat.2, fchownat.2, fstatat.2, futimesat.2, getdtablesize.2, getpagesize.2, getsid.2, linkat.2, mkdirat.2, mknodat.2, openat.2, pread.2, readlinkat.2, renameat.2, setpgid.2, sigaltstack.2, symlinkat.2, sync.2, timer_create.2, timer_delete.2, timer_getoverrun.2, timer_settime.2, unlinkat.2, utimensat.2, vfork.2, acosh.3, asinh.3, atanh.3, dirfd.3, dprintf.3, ecvt.3, expm1.3, fexecve.3, fmemopen.3, gcvt.3, getcwd.3, gethostid.3, getpass.3, getsubopt.3, getw.3, mbsnrtowcs.3, mkfifoat.3, mkstemp.3, mktemp.3, opendir.3, posix_memalign.3, rint.3, siginterrupt.3, stpcpy.3, stpncpy.3, strdup.3, strerror.3, strnlen.3, strsignal.3, strtol.3, strtoul.3, ualarm.3, usleep.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 06:02:38 +00:00
|
|
|
(_XOPEN_SOURCE\ >=\ 500 ||
|
brk.2, chroot.2, vfork.2, ecvt.3, gcvt.3, getcwd.3, getpass.3, mktemp.3, posix_memalign.3, strdup.3, ttyslot.3, ualarm.3, usleep.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-26 15:46:36 +00:00
|
|
|
_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
|
brk.2, chroot.2, faccessat.2, fchmodat.2, fchownat.2, fstatat.2, futimesat.2, getdtablesize.2, getpagesize.2, getsid.2, linkat.2, mkdirat.2, mknodat.2, openat.2, pread.2, readlinkat.2, renameat.2, setpgid.2, sigaltstack.2, symlinkat.2, sync.2, timer_create.2, timer_delete.2, timer_getoverrun.2, timer_settime.2, unlinkat.2, utimensat.2, vfork.2, acosh.3, asinh.3, atanh.3, dirfd.3, dprintf.3, ecvt.3, expm1.3, fexecve.3, fmemopen.3, gcvt.3, getcwd.3, gethostid.3, getpass.3, getsubopt.3, getw.3, mbsnrtowcs.3, mkfifoat.3, mkstemp.3, mktemp.3, opendir.3, posix_memalign.3, rint.3, siginterrupt.3, stpcpy.3, stpncpy.3, strdup.3, strerror.3, strnlen.3, strsignal.3, strtol.3, strtoul.3, ualarm.3, usleep.3, wcpcpy.3, wcpncpy.3, wcscasecmp.3, wcsdup.3, wcsncasecmp.3, wcsnlen.3, wcsnrtombs.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-19 06:02:38 +00:00
|
|
|
!(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
|
2010-09-17 15:22:01 +00:00
|
|
|
.TP 4
|
|
|
|
.fi
|
|
|
|
Before glibc 2.2.2: none
|
|
|
|
.PD
|
|
|
|
.RE
|
|
|
|
.ad b
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
2007-04-12 22:42:49 +00:00
|
|
|
This function is obsolete.
|
|
|
|
Do not use it.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.BR getpass ()
|
|
|
|
function opens
|
|
|
|
.I /dev/tty
|
|
|
|
(the controlling terminal of the process), outputs the string
|
|
|
|
.IR prompt ,
|
|
|
|
turns off echoing, reads one line (the "password"),
|
|
|
|
restores the terminal state and closes
|
|
|
|
.I /dev/tty
|
|
|
|
again.
|
|
|
|
.SH "RETURN VALUE"
|
|
|
|
The function
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR getpass ()
|
2008-07-10 12:06:48 +00:00
|
|
|
returns a pointer to a static buffer containing (the first
|
2007-06-22 19:42:52 +00:00
|
|
|
.B PASS_MAX
|
|
|
|
bytes of) the password without the trailing
|
2008-06-09 15:49:35 +00:00
|
|
|
newline, terminated by a null byte (\(aq\\0\(aq).
|
2004-11-03 13:51:07 +00:00
|
|
|
This buffer may be overwritten by a following call.
|
|
|
|
On error, the terminal state is restored,
|
|
|
|
.I errno
|
|
|
|
is set appropriately, and NULL is returned.
|
|
|
|
.SH ERRORS
|
|
|
|
The function may fail if
|
|
|
|
.TP
|
|
|
|
.B ENXIO
|
2007-04-12 22:42:49 +00:00
|
|
|
The process does not have a controlling terminal.
|
2007-05-19 04:30:20 +00:00
|
|
|
.SH FILES
|
|
|
|
.I /dev/tty
|
|
|
|
.\" .SH HISTORY
|
|
|
|
.\" A
|
|
|
|
.\" .BR getpass ()
|
|
|
|
.\" function appeared in Version 7 AT&T UNIX.
|
|
|
|
.SH "CONFORMING TO"
|
|
|
|
Present in SUSv2, but marked LEGACY.
|
|
|
|
Removed in POSIX.1-2001.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
|
|
|
For libc4 and libc5, the prompt is not written to
|
|
|
|
.I /dev/tty
|
|
|
|
but to
|
|
|
|
.IR stderr .
|
|
|
|
Moreover, if
|
|
|
|
.I /dev/tty
|
|
|
|
cannot be opened, the password is read from
|
|
|
|
.IR stdin .
|
|
|
|
The static buffer has length 128 so that only the first 127
|
|
|
|
bytes of the password are returned.
|
2007-06-21 05:38:48 +00:00
|
|
|
While reading the password, signal generation
|
2008-09-18 12:30:37 +00:00
|
|
|
.RB ( SIGINT ,
|
2007-06-21 05:38:48 +00:00
|
|
|
.BR SIGQUIT ,
|
|
|
|
.BR SIGSTOP ,
|
2010-06-20 02:05:35 +00:00
|
|
|
.BR SIGTSTP )
|
2007-06-21 05:38:48 +00:00
|
|
|
is disabled and the corresponding characters
|
time.1, atexit.3, bsearch.3, dlopen.3, envz_add.3, errno.3, fmtmsg.3, getgrent_r.3, getline.3, getmntent.3, getnameinfo.3, getpass.3, getpwent_r.3, gets.3, isalpha.3, printf.3, puts.3, recno.3, scandir.3, stdarg.3, sysconf.3, termios.3, wordexp.3, null.4, core.5, dir_colors.5, issue.5, proc.5, termcap.5, utmp.5, ascii.7, cpuset.7, glob.7, man-pages.7, man.7, mdoc.7, mdoc.samples.7, regex.7: Revert 9f8e673e623d (whose global s%\\e%\\\\% caused problems)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-09-26 21:56:54 +00:00
|
|
|
(usually control-C, control-\e, control-Z and control-Y)
|
2004-11-03 13:51:07 +00:00
|
|
|
are transmitted as part of the password.
|
|
|
|
Since libc 5.4.19 also line editing is disabled, so that also
|
|
|
|
backspace and the like will be seen as part of the password.
|
|
|
|
.PP
|
|
|
|
For glibc2, if
|
|
|
|
.I /dev/tty
|
|
|
|
cannot be opened, the prompt is written to
|
|
|
|
.I stderr
|
|
|
|
and the password is read from
|
|
|
|
.IR stdin .
|
|
|
|
There is no limit on the length of the password.
|
|
|
|
Line editing is not disabled.
|
|
|
|
.PP
|
2007-06-22 19:42:52 +00:00
|
|
|
According to the SUSv2, the value of
|
|
|
|
.B PASS_MAX
|
|
|
|
must be defined in
|
2004-11-03 13:51:07 +00:00
|
|
|
.I <limits.h>
|
|
|
|
in case it is smaller than 8, and can in any case be obtained using
|
|
|
|
.IR sysconf(_SC_PASS_MAX) .
|
2007-06-22 19:42:52 +00:00
|
|
|
However, POSIX.2 withdraws the constants
|
|
|
|
.B PASS_MAX
|
|
|
|
and
|
|
|
|
.BR _SC_PASS_MAX ,
|
|
|
|
and the function
|
2005-10-19 16:30:05 +00:00
|
|
|
.BR getpass ().
|
2007-06-22 19:42:52 +00:00
|
|
|
Libc4 and libc5 have never supported
|
|
|
|
.B PASS_MAX
|
|
|
|
or
|
|
|
|
.BR _SC_PASS_MAX .
|
|
|
|
Glibc2 accepts
|
2007-09-20 16:26:31 +00:00
|
|
|
.B _SC_PASS_MAX
|
2007-06-23 07:19:07 +00:00
|
|
|
and returns
|
2007-06-22 19:42:52 +00:00
|
|
|
.B BUFSIZ
|
|
|
|
(e.g., 8192).
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH BUGS
|
|
|
|
The calling process should zero the password as soon as possible to avoid
|
|
|
|
leaving the cleartext password visible in the process's address space.
|
2007-05-16 18:25:50 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR crypt (3)
|