Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 1 | \section{\module{getpass} |
Fred Drake | b3a20bc | 1999-03-12 18:34:21 +0000 | [diff] [blame] | 2 | --- Portable password input} |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 3 | |
| 4 | \declaremodule{standard}{getpass} |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 5 | \modulesynopsis{Portable reading of passwords and retrieval of the userid.} |
Fred Drake | b3a20bc | 1999-03-12 18:34:21 +0000 | [diff] [blame] | 6 | \moduleauthor{Piers Lauder}{piers@cs.su.oz.au} |
| 7 | % Windows (& Mac?) support by Guido van Rossum. |
| 8 | \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 9 | |
| 10 | |
| 11 | The \module{getpass} module provides two functions: |
| 12 | |
| 13 | |
Georg Brandl | 338ef7d | 2006-03-31 18:42:16 +0000 | [diff] [blame] | 14 | \begin{funcdesc}{getpass}{\optional{prompt\optional{, stream}}} |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 15 | Prompt the user for a password without echoing. The user is |
| 16 | prompted using the string \var{prompt}, which defaults to |
Georg Brandl | 338ef7d | 2006-03-31 18:42:16 +0000 | [diff] [blame] | 17 | \code{'Password: '}. On \UNIX, the prompt is written to the |
| 18 | file-like object \var{stream}, which defaults to |
| 19 | \code{sys.stdout} (this argument is ignored on Windows). |
| 20 | |
Fred Drake | c37b65e | 2001-11-28 07:26:15 +0000 | [diff] [blame] | 21 | Availability: Macintosh, \UNIX, Windows. |
George Yoshida | 5085fe2 | 2006-04-30 03:49:56 +0000 | [diff] [blame] | 22 | \versionchanged[The \var{stream} parameter was added]{2.5} |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 23 | \end{funcdesc} |
| 24 | |
| 25 | |
| 26 | \begin{funcdesc}{getuser}{} |
| 27 | Return the ``login name'' of the user. |
Fred Drake | c37b65e | 2001-11-28 07:26:15 +0000 | [diff] [blame] | 28 | Availability: \UNIX, Windows. |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 29 | |
| 30 | This function checks the environment variables \envvar{LOGNAME}, |
| 31 | \envvar{USER}, \envvar{LNAME} and \envvar{USERNAME}, in order, and |
| 32 | returns the value of the first one which is set to a non-empty |
| 33 | string. If none are set, the login name from the password database |
Fred Drake | ffbe687 | 1999-04-22 21:23:22 +0000 | [diff] [blame] | 34 | is returned on systems which support the \refmodule{pwd} module, |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 35 | otherwise, an exception is raised. |
| 36 | \end{funcdesc} |