0
0
Fork 0
mirror of https://github.com/boltgolt/howdy.git synced 2024-09-12 09:41:18 +02:00

Merge pull request #798 from izvyk/beta

Add doas support
This commit is contained in:
boltgolt 2023-06-25 12:52:49 +02:00 committed by GitHub
commit c17a834a52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 == "":
print(_("Could not determine user, please use the --user flag"))
sys.exit(1)
else:
user = env_user
# If that fails, error out
if user == "":
print(_("Could not determine user, please use the --user flag"))
sys.exit(1)
# Basic command setup
parser = argparse.ArgumentParser(