IlanCosman / tide

🌊 The ultimate Fish prompt.
MIT License
2.9k stars 108 forks source link

Add sudo prompt item #469

Closed re-xyr closed 9 months ago

re-xyr commented 9 months ago

Description

Adds a simple prompt item that displays an icon if sudo can be called without a password.

Motivation and Context

This is most useful in reminding the user that sudo has been called recently and hasn't timed out yet.

How Has This Been Tested

It correctly displays an icon when sudo can be called without a password, and displays nothing otherwise.

Checklist

IlanCosman commented 9 months ago

I don't really get why this would be useful. Could you describe a situation where this would be helpful?

re-xyr commented 9 months ago

I took this feature from starship, where it was initially proposed at starship/starship#816. The motivation cited was:

I want to know when user credentials are cached for running any command as I want sudo to prompt for credentials when used by untrusted programs (just to know that the program is trying to do superuser stuff, in which case I kill it).

It's notable though that in starship, the sudo prompt module is disabled by default to "avoid cluttering the prompt too much", so maybe I can set it to disabled by default as well.

Another thing mentioned by a user is that

calling sudo -n true has the side effect of resetting the credentials timeout

so we might want to mention that in the wiki if this end up being merged.

IlanCosman commented 9 months ago

To be honest, this seems like security theater, or at the very least encouraging really bad practices. I don't like it, sorry :(