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 | |
| 14 | \begin{funcdesc}{getpass}{\optional{prompt}} |
| 15 | Prompt the user for a password without echoing. The user is |
| 16 | prompted using the string \var{prompt}, which defaults to |
| 17 | \code{'Password: '}. |
Fred Drake | b3a20bc | 1999-03-12 18:34:21 +0000 | [diff] [blame] | 18 | Availability: Macintosh, \UNIX{}, Windows. |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 19 | \end{funcdesc} |
| 20 | |
| 21 | |
| 22 | \begin{funcdesc}{getuser}{} |
| 23 | Return the ``login name'' of the user. |
Fred Drake | b3a20bc | 1999-03-12 18:34:21 +0000 | [diff] [blame] | 24 | Availability: \UNIX{}, Windows. |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 25 | |
| 26 | This function checks the environment variables \envvar{LOGNAME}, |
| 27 | \envvar{USER}, \envvar{LNAME} and \envvar{USERNAME}, in order, and |
| 28 | returns the value of the first one which is set to a non-empty |
| 29 | string. If none are set, the login name from the password database |
Fred Drake | ffbe687 | 1999-04-22 21:23:22 +0000 | [diff] [blame] | 30 | is returned on systems which support the \refmodule{pwd} module, |
Fred Drake | 5ac2a07 | 1998-12-22 23:37:21 +0000 | [diff] [blame] | 31 | otherwise, an exception is raised. |
| 32 | \end{funcdesc} |