liner icon indicating copy to clipboard operation
liner copied to clipboard

Password mode

Open jackpot51 opened this issue 8 years ago • 7 comments

I would like to use liner to capture usernames, followed by passwords. Currently the change required would be to not echo characters as they are received, or perhaps to use a mask char.

A mask char may be easier to implement, as it would not invalidate any of the editing interfaces

jackpot51 avatar Jan 13 '17 01:01 jackpot51

Does password mode belong in the readline implementation? To me, it seems like the features offered by a line editor aren't used when entering a password.

I would think password entering would be in the program itself, eg sudo.

MovingtoMars avatar Mar 27 '17 00:03 MovingtoMars

This should probably be handled by the readline library. Otherwise the user will have to manually disable the echoing of characters and handle escape codes and stuff themselves (this is the whole point of a readline lib). Shouldn't be too difficult to implement, just need to disable the echoing of characters for password input.

iamcodemaker avatar Apr 23 '17 17:04 iamcodemaker

So there is actually a getpass() function in libc which is obsolete. It is recommend to use the termios functions to manually disable echoing and stuch. There is an rpassword crate that does just that.

iamcodemaker avatar Apr 23 '17 17:04 iamcodemaker

I tested using liner with rpassword to read passwords and it works as expected. That's probably the best route here.

Example: https://gist.github.com/iamcodemaker/4e13516c8c82d9cdfcd92df6fc8f0b5a

iamcodemaker avatar Apr 23 '17 17:04 iamcodemaker

Shouldn't the program that wants a password just use rpassword directly?

MovingtoMars avatar Apr 28 '17 12:04 MovingtoMars

Yes, that's how the example code I linked works. Initially I thought it belonged in liner, but now I'm thinking just using rpassword directly would work better.

iamcodemaker avatar Apr 28 '17 13:04 iamcodemaker

Termion also has a read_passwd method if you wanted to avoid additional dependencies.

iamcodemaker avatar May 08 '18 17:05 iamcodemaker