Terminal issue

Discussion in 'macOS' started by Zenithal, Nov 12, 2016.

  1. Zenithal macrumors 68040

    Joined:
    Sep 10, 2009
    #1
    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?
     
  2. maflynn Moderator

    maflynn

    Staff Member

    Joined:
    May 3, 2009
    Location:
    Boston
    #2
    Its a security feature, all modern operating systems mask your password when typing it in.

    Because OS X at its very core is Unix and you're running the bash shell when using the terminal.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    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.
     

Share This Page