aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-11-05 12:28:12 +0000
committerFuwn <[email protected]>2024-11-05 12:28:12 +0000
commita2e181293e3d724ddb34259b7cf85aefd9388e2c (patch)
tree004867d8edb48cc360db01b31b14147d402785a0
parentdocs(readme): add secrets file format information (diff)
downloadpia.nix-a2e181293e3d724ddb34259b7cf85aefd9388e2c.tar.xz
pia.nix-a2e181293e3d724ddb34259b7cf85aefd9388e2c.zip
fix(cli): strengthen superuser escalation check
-rw-r--r--cli.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/cli.nix b/cli.nix
index 2fa39eb..8218ebd 100644
--- a/cli.nix
+++ b/cli.nix
@@ -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