While reading about how to properly ask a user for a password in CLIs, this SO answer and this SSE answer recommend the usage of unistd's getpass.

However, this function is being documented as obsolete and multi-thread unsafe. I fail to understand how the recommended replacement (using termios with echo disabled, example in this answer) is more secure than getpass. I was also wondering if getpass was safe to use in a single-thread program.

  • The glibc man page says that on some systems, the maximum password length might be less than 8 bytes. – immibis Jun 24 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.