getpass()
Prompt for and read a password
Synopsis:
#include <unistd.h>
char *getpass( const char *prompt );
Arguments:
- prompt
- The string you want to display to prompt for the password.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The getpass() function can be used to get a password. It opens the current terminal, displays the given prompt, suppresses echoing, reads up to 32 characters into a static buffer, and restores echoing. This function adds a null character to the end of the string, but ignores additional characters and the newline character.
Returns:
A pointer to the static buffer.
Classification:
Safety: | |
---|---|
Cancellation point | Yes |
Signal handler | No |
Thread | No |
Caveats:
This function leaves its result in an internal static buffer and returns a pointer to it. Subsequent calls to getpass() modify the same buffer. The calling process should zero the password as soon as possible to avoid leaving the clear-text password visible in the process's address space.