1.\" $OpenBSD: getpass.3,v 1.18 2016/09/03 12:47:28 jmc Exp $ 2.\" 3.\" Copyright (c) 1989, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.Dd $Mdocdate: September 3 2016 $ 31.Dt GETPASS 3 32.Os 33.Sh NAME 34.Nm getpass 35.Nd get a password 36.Sh SYNOPSIS 37.In pwd.h 38.In unistd.h 39.Ft char * 40.Fn getpass "const char *prompt" 41.Sh DESCRIPTION 42.Bf -symbolic 43This function is obsolete. 44Consider using 45.Xr readpassphrase 3 . 46.Ef 47.Pp 48The 49.Fn getpass 50function displays a prompt to, and reads in a password from, 51.Pa /dev/tty . 52If this file is not accessible, 53.Fn getpass 54displays the prompt on the standard error output and reads from the standard 55input. 56.Pp 57The password may be up to 58.Dv _PASSWORD_LEN 59(currently 128, as defined in the 60.In pwd.h 61include file) 62characters in length. 63Any additional 64characters and the terminating newline character are discarded. 65.Pp 66.Fn getpass 67turns off character echoing while reading the password. 68.Pp 69The calling process should zero the password with 70.Xr explicit_bzero 3 71as soon as possible to 72avoid leaving the cleartext password visible in the process's address 73space. 74.Sh RETURN VALUES 75Upon successful completion, 76.Fn getpass 77returns a pointer to a NUL-terminated string of at most 78.Dv _PASSWORD_LEN 79characters. 80If an error is encountered, the terminal state is restored and 81a null pointer is returned. 82.Sh FILES 83.Bl -tag -width /dev/tty -compact 84.It Pa /dev/tty 85.El 86.Sh ERRORS 87.Bl -tag -width Er 88.It Bq Er EINTR 89The 90.Fn getpass 91function was interrupted by a signal. 92.It Bq Er EIO 93The process is a member of a background process attempting to read 94from its controlling terminal, the process is ignoring or blocking 95the SIGTTIN signal or the process group is orphaned. 96.It Bq Er EMFILE 97The process has already reached its limit for open file descriptors. 98.It Bq Er ENFILE 99The system file table is full. 100.El 101.Sh SEE ALSO 102.Xr crypt 3 , 103.Xr readpassphrase 3 104.Sh STANDARDS 105Historically, 106.Bx 107versions of 108.Fn getpass 109have accepted a password on the standard input if 110.Pa /dev/tty 111is unavailable. 112This contradicts 113.St -xpg4.2 114but the 115.Ox 116implementation is conformant in all other respects. 117Removed from 118.St -p1003.1-2001 . 119.Sh HISTORY 120A 121.Fn getpass 122function appeared in 123.At v7 . 124.Sh CAVEATS 125The 126.Fn getpass 127function leaves its result in an internal static object and returns 128a pointer to that object. 129Subsequent calls to 130.Fn getpass 131will modify the same object. 132