]> git.proxmox.com Git - lxc.git/blame - debian/patches/pve/0002-PVE-Config-attach-always-use-getent.patch
bump version to 6.0.0-1
[lxc.git] / debian / patches / pve / 0002-PVE-Config-attach-always-use-getent.patch
CommitLineData
80fb84e7 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8a25e884
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Tue, 13 Aug 2019 13:57:22 +0200
ab6c7914 4Subject: [PATCH 2/2] PVE: [Config] attach: always use getent
8a25e884
WB
5
6In debian buster, some libnss plugins (if installed) can
7cause getpwent to segfault instead of erroring out cleanly.
8To avoid this, stick to always using getent.
9
10Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11---
01ed4313
WB
12 src/lxc/attach.c | 29 ++---------------------------
13 1 file changed, 2 insertions(+), 27 deletions(-)
8a25e884
WB
14
15diff --git a/src/lxc/attach.c b/src/lxc/attach.c
ab6c7914 16index 8f2f7a37c..a8684808c 100644
8a25e884
WB
17--- a/src/lxc/attach.c
18+++ b/src/lxc/attach.c
12c525f3 19@@ -1843,45 +1843,21 @@ int lxc_attach_run_command(void *payload)
0a134a36 20
8a25e884
WB
21 int lxc_attach_run_shell(void* payload)
22 {
0a134a36 23- __do_free char *buf = NULL;
8a25e884
WB
24 uid_t uid;
25- struct passwd pwent;
26- struct passwd *pwentp = NULL;
27 char *user_shell;
87c39e90 28- ssize_t bufsize;
01ed4313 29- int ret;
8a25e884
WB
30
31 /* Ignore payload parameter. */
01ed4313 32 (void)payload;
8a25e884
WB
33
34 uid = getuid();
35
36- bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
87c39e90 37- if (bufsize < 0)
8a25e884
WB
38- bufsize = 1024;
39-
40- buf = malloc(bufsize);
41- if (buf) {
42- ret = getpwuid_r(uid, &pwent, buf, bufsize, &pwentp);
43- if (!pwentp) {
44- if (ret == 0)
45- WARN("Could not find matched password record");
46-
47- WARN("Failed to get password record - %u", uid);
48- }
49- }
50-
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
55 * the result.
56 */
57- if (!pwentp)
58- user_shell = lxc_attach_getpwshell(uid);
59- else
60- user_shell = pwent.pw_shell;
61-
62+ user_shell = lxc_attach_getpwshell(uid);
63 if (user_shell)
64 execlp(user_shell, user_shell, (char *)NULL);
65
12c525f3 66@@ -1891,8 +1867,7 @@ int lxc_attach_run_shell(void* payload)
8a25e884
WB
67 execlp("/bin/sh", "/bin/sh", (char *)NULL);
68
69 SYSERROR("Failed to execute shell");
70- if (!pwentp)
71- free(user_shell);
72+ free(user_shell);
73
8a25e884
WB
74 return -1;
75 }
12c525f3 76--
ab6c7914 772.39.2
12c525f3 78