Global flags are dropped on sudo-rs: 'sudo -E' preserves nothing
Description
dokku re-executes itself as the dokku user with sudo -E (dokku:94):
sudo -u dokku -E -H "$0" "$@"sudo-rs, the default sudo on Ubuntu 25.10 and later, does not support preserving the entire environment. It prints a warning and drops it:
sudo: preserving the entire environment is not supported, '-E' is ignoredEvery global flag works by exporting an environment variable before that re-exec (plugins/common/functions:493-502), so none of them survive it.
Reproduction
On Ubuntu 26.04 with sudo-rs 0.2.13:
$ dokku --quiet redis:list
=====> redis services # --quiet should have suppressed this
l
st
$ dokku --force redis:destroy l
! WARNING: Potentially Destructive Action
! This command will destroy redis service l.
! To proceed, type "l"--quiet, --trace and --force are all affected. The warning is also printed on every dokku invocation, which breaks any test asserting exact command output.
The long flag is not the fix
--preserve-env on its own is rejected the same way. Only the selective form works:
$ FOO=bar sudo -E printenv FOO
sudo: preserving the entire environment is not supported, '-E' is ignored
$ FOO=bar sudo --preserve-env printenv FOO
sudo: preserving the entire environment is not supported, '--preserve-env' is ignored
$ FOO=bar sudo --preserve-env=FOO printenv FOO
barSuggested fix
Name the variables that have to cross the re-exec:
sudo -u dokku --preserve-env=DOKKU_QUIET_OUTPUT,DOKKU_TRACE,DOKKU_APPS_FORCE_DELETE,DOKKU_APP_NAME,SSH_USER -H "$0" "$@"Those are the ones set from user intent rather than derived; the rest are re-derived when the script runs again as dokku. --preserve-env= has been supported by sudo since 1.8.x, so it should not need a version check, though that is worth confirming against the oldest supported distro.
Environment
- Ubuntu 26.04,
sudo-rs 0.2.13-0ubuntu1.2 - dokku
v0.38.27-161-g61ff696e0
Source: dokku/dokku