diff options
| author | Fuwn <[email protected]> | 2024-11-05 12:28:12 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-11-05 12:28:12 +0000 |
| commit | a2e181293e3d724ddb34259b7cf85aefd9388e2c (patch) | |
| tree | 004867d8edb48cc360db01b31b14147d402785a0 | |
| parent | docs(readme): add secrets file format information (diff) | |
| download | pia.nix-a2e181293e3d724ddb34259b7cf85aefd9388e2c.tar.xz pia.nix-a2e181293e3d724ddb34259b7cf85aefd9388e2c.zip | |
fix(cli): strengthen superuser escalation check
| -rw-r--r-- | cli.nix | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -5,11 +5,13 @@ in pkgs.writeShellScriptBin "pia" '' ID=$(${pkgs.coreutils}/bin/id -u) - if [ "$ID" -ne 0 ]; then - if [ -x $(command -v doas) ]; then + if [ "$EUID" -ne 0 ]; then + if which doas >/dev/null 2>&1; then exec doas "$0" "$@" - else + elif which sudo >/dev/null 2>&1; then exec sudo "$0" "$@" + else + echo "error: neither doas nor sudo found" >&2 fi fi |