Pin factory-reset elevation to the packaged command
Use the installed executable for non-root self-elevation, including calls from a development checkout or symlink. Reported-by: Aleksej <aleksejhairov@yandex.ru>
This commit is contained in:
1 parent
d3cfd53b99
commit
7d4773311e
1 file changed
+3
-1
@@ -29,6 +29,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
PROVISIONING_DIR=/var/lib/omarchy/provisioning
|
PROVISIONING_DIR=/var/lib/omarchy/provisioning
|
||||||
|
PACKAGED_PATH=/usr/bin/omarchy-system-factory-reset
|
||||||
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
|
OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
|
||||||
TOP_MNT=/run/omarchy-system-factory-reset/top
|
TOP_MNT=/run/omarchy-system-factory-reset/top
|
||||||
NEXT_NAME=@omarchy-reset-next
|
NEXT_NAME=@omarchy-reset-next
|
||||||
@@ -37,9 +38,10 @@ LOG_FILE=/var/log/omarchy-system-factory-reset.log
|
|||||||
# Self-elevate so the menu entry (and a bare shell invocation) need no sudo
|
# Self-elevate so the menu entry (and a bare shell invocation) need no sudo
|
||||||
# prefix. The caller's gum theme vars are forwarded as `env` arguments rather
|
# prefix. The caller's gum theme vars are forwarded as `env` arguments rather
|
||||||
# than via `sudo -E`, so styling survives even under an env_reset sudoers.
|
# than via `sudo -E`, so styling survives even under an env_reset sudoers.
|
||||||
|
# Always elevate the packaged copy, including when invoked from a dev checkout.
|
||||||
if (( EUID != 0 )); then
|
if (( EUID != 0 )); then
|
||||||
mapfile -t gum_env < <(env | grep '^GUM_' || true)
|
mapfile -t gum_env < <(env | grep '^GUM_' || true)
|
||||||
exec sudo env "${gum_env[@]}" "$0" "$@"
|
exec sudo env "${gum_env[@]}" "$PACKAGED_PATH" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATH="$OMARCHY_PATH/bin:$PATH"
|
export PATH="$OMARCHY_PATH/bin:$PATH"
|
||||||
|
|||||||
Reference in new issue
Block a user