Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[carry 1738] Clear hook environ variables on empty Env #4323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Jun 19, 2024

  1. libcontainer/configs/config: Clear hook environ variables on empty Env

    The runtime spec has [1]:
    
      * env (array of strings, OPTIONAL) with the same semantics as IEEE
        Std 1003.1-2008's environ.
    
    And running execle or similar with NULL env results in an empty
    environent:
    
      $ cat test.c
      #include <unistd.h>
    
      int main()
      {
        return execle("/usr/bin/env", "env", NULL, NULL);
      }
      $ cc -o test test.c
      $ ./test
      ...no output...
    
    Go's Cmd.Env, on the other hand, has [2]:
    
      If Env is nil, the new process uses the current process's
      environment.
    
    This commit works around that by setting Env to an empty slice in
    those cases to avoid leaking the runtime environment into the hooks.
    
    [1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
    [2]: https://golang.org/pkg/os/exec/#Cmd
    
    Signed-off-by: W. Trevor King <wking@tremily.us>
    (cherry picked from commit c11bd33)
    Signed-off-by: lfbzhm <lifubang@acmcoder.com>
    wking authored and lifubang committed Jun 19, 2024
    Configuration menu
    Copy the full SHA
    c9dcc3d View commit details
    Browse the repository at this point in the history

Commits on Jun 21, 2024

  1. add tests for env param in hooks

    Signed-off-by: lfbzhm <lifubang@acmcoder.com>
    lifubang committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    827bbdb View commit details
    Browse the repository at this point in the history