helpers2.1: for some reason sudo -E doesn't preserve PATH even though it's exported, so we gotta explicitly use --preserve-env=PATH

This commit is contained in:
Alexandre Aubin 2024-06-23 14:49:11 +02:00
parent b3409729a6
commit 5f6df6a859

View file

@ -174,9 +174,9 @@ ynh_system_user_delete() {
# Execute a command after sudoing as $app # Execute a command after sudoing as $app
# #
# Note that exported bash env variables are kept (using -E option of sudo) # Note that the $PATH variable is preserved (using --preserve-env=PATH)
# #
# usage: ynh_exec_as_app COMMAND [ARG ...] # usage: ynh_exec_as_app COMMAND [ARG ...]
ynh_exec_as_app() { ynh_exec_as_app() {
sudo -E -u "$app" "$@" sudo --preserve-env=PATH -u "$app" "$@"
} }