spiegel_podman/pkg
W. Trevor King 81d6f082f3 pkg/hooks/exec: Add a new package for local hook execution
This wraps os/exec to:

* Clear the environment when the hook doesn't set '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
  environment:

    $ 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 []string{} in those cases
  to avoid leaking the runtime environment into the hooks.

* Roll the 'timeout' value (if set) into the passed context.  There's
  no need for two separate ways to cancel hook execution.

* Add a configurable timeout on abandoning a post-kill wait.  The
  waiting goroutine will continue and eventually reap the process, but
  this avoids blocking the Run() call when that takes inordinately
  long (for example, if a GPU cleanup hook is stuck in I/O sleep [3]).

The 'env' output format is specified in POSIX [4].

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
[2]: https://golang.org/pkg/os/exec/#Cmd
[3]: https://github.com/projectatomic/libpod/pull/857#discussion_r192191002
[4]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #857
Approved by: mheon
2018-05-31 21:45:27 +00:00
..
annotations Spell check strings and comments 2018-05-25 08:45:15 +00:00
chrootuser chrootuser: default to GID 0 when given a numeric --user 2018-05-17 17:05:44 +00:00
hooks pkg/hooks/exec: Add a new package for local hook execution 2018-05-31 21:45:27 +00:00
inspect fix typos in the inspect json structs 2018-05-02 18:02:22 +00:00
kubeutils Remove dependency on kubernetes 2018-03-27 21:55:33 +00:00
registrar Initial checkin from CRI-O repo 2017-11-01 11:24:59 -04:00
registries Spell check strings and comments 2018-05-25 08:45:15 +00:00
secrets Rename addFIPSsModeSecret to addFIPSModeSecret 2018-05-25 16:37:34 +00:00
spec Clear all caps, except the bounding set, when --user is specified. 2018-05-31 13:46:08 +00:00
util Begin wiring in USERNS Support into podman 2018-05-04 17:15:55 +00:00
varlinkapi save and load should support multi-tag for docker-archive 2018-05-25 15:15:47 +00:00