vim-suda icon indicating copy to clipboard operation
vim-suda copied to clipboard

Prompted for password even if non is required

Open WhyNotHugo opened this issue 4 years ago • 12 comments

I've sudo set up so that I can sudo by just pressing my Yubikey's button.

However, when I run SudaWrite, I'm always prompted for a password. I can type any gibberish though, and then pressing the key lets sudo operate properly.

How about not asking for a password is sudo does not require one?

WhyNotHugo avatar Feb 17 '21 08:02 WhyNotHugo

I use fprintd with sudo and I also have this problem. According to the discussions in #34 i guess it is very hard to determine whether sudo requests a password, so an extra configuration option may be the easiest way to solve this.

zeertzjq avatar Feb 17 '21 13:02 zeertzjq

an extra configuration option may be the easiest way to solve this.

That would partially work. If my yubikey is not plugged it, sudo falls back to asking for a password, so that scenario would not work. I guess if a fingerprint reader is built into the keyboard that wouldn't be an issue in that case though.

WhyNotHugo avatar Feb 18 '21 13:02 WhyNotHugo

an extra configuration option may be the easiest way to solve this.

That would partially work. If my yubikey is not plugged it, sudo falls back to asking for a password, so that scenario would not work. I guess if a fingerprint reader is built into the keyboard that wouldn't be an issue in that case though.

Oh, then maybe another option is to make sudo read from an empty stdin first. Changing -n to -S in this line should be enough. When stdin is empty, sudo will fail to read a password and exit directly, while authentication methods that come before password can still work. (Unlike -n which also suppresses other stuff like fingerprint authentication.)

I'm not familiar with YubiKey. When using fprintd the solution above causes the editor to freeze until a fingerprint is scanned, so such a solution works, but is not user-friendly.

zeertzjq avatar Feb 18 '21 13:02 zeertzjq

I have worked out a more user-friendly fix in this branch. It requires let g:suda#try_no_text_input_auth = 1 and has a configurable prompt message. This fix is based on PR #35, and I haven't documented the config options I added yet, but I think the fix should work.

zeertzjq avatar Feb 18 '21 16:02 zeertzjq

I'm working on a more user-friendly fix in this branch. It requires let g:suda#try_no_text_input_auth = 1 and has a configurable prompt message. This fix is based on PR #35, and I haven't documented the config options I added yet, but I think the fix should work.

I tested the fix with fprintd. SudaWrite works fine, but when using SudaRead spam is written to the temporary file by pam_fprintd.so. Using dd instead of cat in suda#read() may solve this only when assuming root can write to temporary files created by Vim/Neovim. I'm not sure whether it is safe to make this assumption.

zeertzjq avatar Feb 18 '21 23:02 zeertzjq

Another option may be to allow using an external terminal emulator or tmux to run sudo, so that the plugin doesn't need to care about what sudo expects at all.

zeertzjq avatar Apr 03 '21 10:04 zeertzjq

Actually, even using a new split with a terminal that does the sudo might be a good idea.

It'd also improve the experience with failed password attempts.

WhyNotHugo avatar Apr 03 '21 10:04 WhyNotHugo

This is an issue when using howdy as well, as you generally want sudo to automatically authenticate without asking for the password.

fidgetingbits avatar May 24 '21 03:05 fidgetingbits

Any updates on this? I also use fprintd and when saving via Suda it prompts for the password first, then attempts to authenticate via the fingerprint sensor, and ultimately doesn't even save the file.

d0wn2 avatar Oct 05 '21 15:10 d0wn2

is this fixed after #69?

aarondill avatar Mar 12 '24 07:03 aarondill

is this fixed after #69?

I'd say no, the change is mostly unrelated. If you have authenticated before and the authentication token is still valid, it will not ask for a password/fingerprint/yubikey. But if sudo wants you to authenticate, suda still behaves as before.

But isn't this what the option g:suda#nopass is for?

sstark avatar Mar 23 '24 16:03 sstark

@sstark not quite. this is an issue we're currently working on actually. please see this comment for a description of how it actually works: https://github.com/lambdalisue/suda.vim/issues/61#issuecomment-1990924321

and if you can come up with a better name, we're looking for one at #73

aarondill avatar Mar 23 '24 19:03 aarondill