Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

0388631

Cancelled
Original poster
Sep 10, 2009
9,669
10,824
Why does Terminal hide your inputted account password when it asks for it after you type out a system wide command? I had to run a master command and was asked to type in my password. I did and hit enter and it accepted it.

Now I know password masking is common on unix shells and most Linux distros, but why does OSX do it and can I do anything so I can see masked characters or plain-text of my password?
 
Why does Terminal hide your inputted account password
Its a security feature, all modern operating systems mask your password when typing it in.

Now I know password masking is common on unix shells and most Linux distros, but why does OSX do it
Because OS X at its very core is Unix and you're running the bash shell when using the terminal.
 
... can I do anything so I can see masked characters or plain-text of my password?
Probably not.

There are two library functions: getpass() and readpassphrase(). They do similar things, which is to handle all the non-echoing tty stuff, interrupt safety, etc. They have different origins, which is why there's two functions instead of one.

https://developer.apple.com/legacy/...Darwin/Reference/ManPages/man3/getpass.3.html
https://developer.apple.com/legacy/...e.3.html#//apple_ref/doc/man/3/readpassphrase

Most programs that ask for a password will call one of these, because the details of exactly how to manage echo, etc. can vary.

The 'sudo' program, however, doesn't appear to use either function, and instead seems to rely on some lower-level functions for control of tty echoing. To see those functions, paste this into a Terminal window:
Code:
sudo nm /usr/bin/sudo | grep etattr
Those two functions are used to disable and enable echoing, line-editing, etc. on the tty stream. You can read their man pages for details.
 
  • Like
Reactions: 0388631
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.