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 _
|
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(
|
||||||
|
|
Loading…
Reference in a new issue