On 20 Oct 2026, at 15:07, Ilya Maximets wrote:

> sudo-rs that ships with Ubuntu 26.04 doesn't support -E, so we need
> to pass all the variables that tests need in a different way.
> Let's configure 'sudo' to preserve variables we need.
>
> Still need to pass the PATH manually, as it is always replaced with
> the 'secure_path' regardless of the configuration.
>
> Signed-off-by: Ilya Maximets <[email protected]>

The change looks good to me. One small nit below, but I'm ok as is.

Acked-by: Eelco Chaudron <[email protected]>

> ---
>  .ci/linux-build.sh | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
> index 702feeb3b..4b4866afa 100755
> --- a/.ci/linux-build.sh
> +++ b/.ci/linux-build.sh
> @@ -76,6 +76,21 @@ function clang_analyze()
>      fi;
>  }
>
> +function sudo_preserve_test_env()
> +{
> +    # Preserve environment variables needed for test execution under sudo.
> +    # HOME is needed for python to find site-packages installed for the
> +    # current user.  PATH is special and can't be preserved this way.
> +    for e in HOME GITHUB_ACTIONS ASAN_OPTIONS DPDK_EAL_OPTIONS; do
> +        echo 'Defaults env_keep += "'$e'"' >> ovs-test-env
> +    done
> +
> +    sudo chown root:root ovs-test-env
> +    sudo chmod 0440 ovs-test-env
> +    sudo mv ovs-test-env /etc/sudoers.d/
> +    sudo visudo -cf /etc/sudoers.d/ovs-test-env

Maybe swap move and check to avoid copying a file that's invalid?

    sudo visudo -cf ovs-test-env
    sudo mv ovs-test-env /etc/sudoers.d/

> +}
> +
>  if [ "$DEB_PACKAGE" ]; then
>      ./boot.sh && ./configure --with-dpdk=$DPDK && make debian
>      mk-build-deps --install --root-cmd sudo --remove debian/control
> @@ -156,7 +171,9 @@ else
>          run_as_root=
>          if [ "$testsuite" != "check" ] && \
>             [ "$testsuite" != "check-ovsdb-cluster" ] ; then
> -            run_as_root="sudo -E PATH=$PATH GITHUB_ACTIONS=$GITHUB_ACTIONS"
> +            sudo_preserve_test_env
> +            run_as_root="sudo PATH=$PATH"
> +
>              sudo ip netns add ovs-system-test-ns
>              # Some system tests may rely on traffic loopback.
>              sudo ip -netns ovs-system-test-ns link set dev lo up
> -- 
> 2.55.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to