![]() |
![]() |
![]() |
Prompt for and read a password
#include <unistd.h> char *getpass( const char *prompt );
libc
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. A null character is added to the end of the string. Additional characters and the newline character are ignored.
A pointer to the static buffer.
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | No |
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.
![]() |
![]() |
![]() |