mirror of
https://github.com/boltgolt/howdy.git
synced 2024-09-19 09:51:19 +02:00
add doas support
This commit is contained in:
parent
30728a6d36
commit
84c8438aa5
1 changed files with 8 additions and 14 deletions
|
@ -11,21 +11,15 @@ import builtins
|
|||
from i18n import _
|
||||
|
||||
# Try to get the original username (not "root") from shell
|
||||
try:
|
||||
user = os.getlogin()
|
||||
except Exception:
|
||||
user = os.environ.get("SUDO_USER")
|
||||
sudo_user = os.environ.get("SUDO_USER")
|
||||
doas_user = os.environ.get("DOAS_USER")
|
||||
env_user = getpass.getuser()
|
||||
user = next((u for u in [sudo_user, doas_user, env_user] if u), "")
|
||||
|
||||
# If that fails, try to get the direct user
|
||||
if user == "root" or user is None:
|
||||
env_user = getpass.getuser().strip()
|
||||
|
||||
# If even that fails, error out
|
||||
if env_user == "":
|
||||
# If that fails, error out
|
||||
if user == "":
|
||||
print(_("Could not determine user, please use the --user flag"))
|
||||
sys.exit(1)
|
||||
else:
|
||||
user = env_user
|
||||
|
||||
# Basic command setup
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
Loading…
Reference in a new issue