1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Tue, 13 Aug 2019 13:57:22 +0200
4 Subject: [PATCH] PVE: [Config] attach: always use getent
6 In debian buster, some libnss plugins (if installed) can
7 cause getpwent to segfault instead of erroring out cleanly.
8 To avoid this, stick to always using getent.
10 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
12 src/lxc/attach.c | 28 ++--------------------------
13 1 file changed, 2 insertions(+), 26 deletions(-)
15 diff --git a/src/lxc/attach.c b/src/lxc/attach.c
16 index befa1580e..7a325f5b1 100644
17 --- a/src/lxc/attach.c
18 +++ b/src/lxc/attach.c
19 @@ -1444,12 +1444,8 @@ int lxc_attach_run_command(void *payload)
21 int lxc_attach_run_shell(void* payload)
23 - __do_free char *buf = NULL;
25 - struct passwd pwent;
26 - struct passwd *pwentp = NULL;
31 /* Ignore payload parameter. */
32 @@ -1457,32 +1453,13 @@ int lxc_attach_run_shell(void* payload)
36 - bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
40 - buf = malloc(bufsize);
42 - ret = getpwuid_r(uid, &pwent, buf, bufsize, &pwentp);
45 - WARN("Could not find matched password record");
47 - WARN("Failed to get password record - %u", uid);
51 /* This probably happens because of incompatible nss implementations in
52 * host and container (remember, this code is still using the host's
53 * glibc but our mount namespace is in the container) we may try to get
54 * the information by spawning a [getent passwd uid] process and parsing
58 - user_shell = lxc_attach_getpwshell(uid);
60 - user_shell = pwent.pw_shell;
62 + user_shell = lxc_attach_getpwshell(uid);
64 execlp(user_shell, user_shell, (char *)NULL);
66 @@ -1492,8 +1469,7 @@ int lxc_attach_run_shell(void* payload)
67 execlp("/bin/sh", "/bin/sh", (char *)NULL);
69 SYSERROR("Failed to execute shell");