diff options
author | flouthoc <flouthoc.git@gmail.com> | 2021-05-27 11:22:02 +0530 |
---|---|---|
committer | flouthoc <flouthoc.git@gmail.com> | 2021-05-29 15:16:26 +0530 |
commit | 2addc0f90d7134158f52124fc8d0ae75691d947b (patch) | |
tree | d36ed889cf42696f62f6866bb78c518e95a1ef5a | |
parent | 083746112f80b4a6164c1fdcdef54da155cfb855 (diff) | |
download | podman-2addc0f90d7134158f52124fc8d0ae75691d947b.tar.gz podman-2addc0f90d7134158f52124fc8d0ae75691d947b.tar.bz2 podman-2addc0f90d7134158f52124fc8d0ae75691d947b.zip |
rootless: fix SIGSEGV ,make LISTEN_FDNAMES optional [Closes #10435].
[NO TESTS NEEDED]
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
-rw-r--r-- | pkg/rootless/rootless_linux.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c index 918b9a7e6..0d1d6e93e 100644 --- a/pkg/rootless/rootless_linux.c +++ b/pkg/rootless/rootless_linux.c @@ -311,10 +311,10 @@ static void __attribute__((constructor)) init() do_socket_activation = true; saved_systemd_listen_pid = strdup(listen_pid); saved_systemd_listen_fds = strdup(listen_fds); - saved_systemd_listen_fdnames = strdup(listen_fdnames); + if (listen_fdnames != NULL) + saved_systemd_listen_fdnames = strdup(listen_fdnames); if (saved_systemd_listen_pid == NULL - || saved_systemd_listen_fds == NULL - || saved_systemd_listen_fdnames == NULL) + || saved_systemd_listen_fds == NULL) { fprintf (stderr, "save socket listen environments error: %s\n", strerror (errno)); _exit (EXIT_FAILURE); @@ -700,7 +700,9 @@ reexec_userns_join (int pid_to_join, char *pause_pid_file_path) sprintf (s, "%d", getpid()); setenv ("LISTEN_PID", s, true); setenv ("LISTEN_FDS", saved_systemd_listen_fds, true); - setenv ("LISTEN_FDNAMES", saved_systemd_listen_fdnames, true); + // Setting fdnames is optional for systemd_socket_activation + if (saved_systemd_listen_fdnames != NULL) + setenv ("LISTEN_FDNAMES", saved_systemd_listen_fdnames, true); } setenv ("_CONTAINERS_USERNS_CONFIGURED", "init", 1); @@ -896,7 +898,9 @@ reexec_in_user_namespace (int ready, char *pause_pid_file_path, char *file_to_re sprintf (s, "%d", getpid()); setenv ("LISTEN_PID", s, true); setenv ("LISTEN_FDS", saved_systemd_listen_fds, true); - setenv ("LISTEN_FDNAMES", saved_systemd_listen_fdnames, true); + // Setting fdnames is optional for systemd_socket_activation + if (saved_systemd_listen_fdnames != NULL) + setenv ("LISTEN_FDNAMES", saved_systemd_listen_fdnames, true); } setenv ("_CONTAINERS_USERNS_CONFIGURED", "init", 1); |