0
0
Fork 0
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:
Philipp Mukosey 2023-06-07 19:13:43 +04:00
parent 30728a6d36
commit 84c8438aa5
No known key found for this signature in database
GPG key ID: C4311F71B7F31903

View file

@ -11,21 +11,15 @@ import builtins
from i18n import _ from i18n import _
# Try to get the original username (not "root") from shell # Try to get the original username (not "root") from shell
try: sudo_user = os.environ.get("SUDO_USER")
user = os.getlogin() doas_user = os.environ.get("DOAS_USER")
except Exception: env_user = getpass.getuser()
user = os.environ.get("SUDO_USER") user = next((u for u in [sudo_user, doas_user, env_user] if u), "")
# If that fails, try to get the direct user # If that fails, error out
if user == "root" or user is None: if user == "":
env_user = getpass.getuser().strip()
# If even that fails, error out
if env_user == "":
print(_("Could not determine user, please use the --user flag")) print(_("Could not determine user, please use the --user flag"))
sys.exit(1) sys.exit(1)
else:
user = env_user
# Basic command setup # Basic command setup
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(