diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-30 02:20:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-30 02:20:31 +0200 |
commit | 59236762eca31a20d886837698db58e259a21de5 (patch) | |
tree | f5944a89d3c44301ac6e2b4af21f484d7c17682c | |
parent | ffca97a01ee4edb58b079cb4d991d03fca976caa (diff) | |
parent | 2addc0f90d7134158f52124fc8d0ae75691d947b (diff) | |
download | podman-59236762eca31a20d886837698db58e259a21de5.tar.gz podman-59236762eca31a20d886837698db58e259a21de5.tar.bz2 podman-59236762eca31a20d886837698db58e259a21de5.zip |
Merge pull request #10481 from flouthoc/fix-sigsegv-rootless
rootless: fix SIGSEGV, Make `LISTEN_FDNAMES` optional
-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); |