diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-01-20 15:58:08 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2020-01-20 16:42:45 +0100 |
commit | ab7744d3c1eee13a30c9f80a60251cd93f6f5160 (patch) | |
tree | acf3f51f4e83c3543f520345b01c1e8875044510 | |
parent | 9be64300d46341ab345f8c760b7a79cced7db3f9 (diff) | |
download | podman-ab7744d3c1eee13a30c9f80a60251cd93f6f5160.tar.gz podman-ab7744d3c1eee13a30c9f80a60251cd93f6f5160.tar.bz2 podman-ab7744d3c1eee13a30c9f80a60251cd93f6f5160.zip |
rootless: set C variables also on shortcut
make sure the rootless env variables are set also when we are joining
directly the user+mount namespace without creating a new process.
It is required by pkg/unshare in containers/common.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r-- | pkg/rootless/rootless_linux.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index 193c788c0..041a161dc 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -266,6 +266,8 @@ static void __attribute__((constructor)) init() char path[PATH_MAX]; const char *const suffix = "/libpod/pause.pid"; char *cwd = getcwd (NULL, 0); + char uid_fmt[16]; + char gid_fmt[16]; if (cwd == NULL) { @@ -324,6 +326,13 @@ static void __attribute__((constructor)) init() exit (EXIT_FAILURE); } + sprintf (uid_fmt, "%d", uid); + sprintf (gid_fmt, "%d", gid); + + setenv ("_CONTAINERS_USERNS_CONFIGURED", "init", 1); + setenv ("_CONTAINERS_ROOTLESS_UID", uid_fmt, 1); + setenv ("_CONTAINERS_ROOTLESS_GID", gid_fmt, 1); + r = setns (fd, 0); if (r < 0) { |