]> git.ipfire.org Git - thirdparty/util-linux.git/commit
nsenter: add --env for allowing environment variables inheritance
authoru2386 <hugo.cavan2386@gmail.com>
Mon, 27 Feb 2023 02:18:31 +0000 (02:18 +0000)
committeru2386 <hugo.cavan2386@gmail.com>
Thu, 2 Mar 2023 16:24:05 +0000 (16:24 +0000)
commit4e9ec856a1b91fb3ff10de10f2dac94f711705e1
tree86d0ed7caa2bc3d9255726a20020a4a728cda991
parente4e00b073800480523d15948b289eafcc717047c
nsenter: add --env for allowing environment variables inheritance

This commit adds support for the -e or --env option in nsenter, allowing a new process to inherit the environment va

If the option is not given, the environment variables will stay the same as in the current namespace.

Example:
    Setup the namespace:
        $ docker run -d -e PROJECT='util linux' --rm alpine sleep 10000
        cb0b69aa7aec
        $ docker inspect --format '{{ .State.Pid }}' cb0b69aa7aec
        470012

    Enter the namespace:
        $ nsenter --all -t 470012 --env env
        PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
        HOSTNAME=cb0b69aa7aec
        PROJECT=util linux
        HOME=/root

Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: u2386 <hugo.cavan2386@gmail.com>
bash-completion/nsenter
include/all-io.h
include/env.h
lib/env.c
sys-utils/nsenter.1.adoc
sys-utils/nsenter.c