From 613b411c947635136637f8cdd66b94512f761eab Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 27 Nov 2013 20:23:18 +0100 Subject: service: add the ability for units to join other unit's PrivateNetwork= and PrivateTmp= namespaces --- src/machine/machinectl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/machine') diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index a1890aa855..61fb81381c 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -399,7 +399,6 @@ static int terminate_machine(sd_bus *bus, char **args, unsigned n) { static int openpt_in_namespace(pid_t pid, int flags) { _cleanup_close_ int nsfd = -1, rootfd = -1; - _cleanup_free_ char *ns = NULL, *root = NULL; _cleanup_close_pipe_ int sock[2] = { -1, -1 }; union { struct cmsghdr cmsghdr; @@ -411,20 +410,17 @@ static int openpt_in_namespace(pid_t pid, int flags) { }; struct cmsghdr *cmsg; int master = -1, r; + char *ns, *root; pid_t child; siginfo_t si; - r = asprintf(&ns, "/proc/%lu/ns/mnt", (unsigned long) pid); - if (r < 0) - return -ENOMEM; + ns = procfs_file_alloca(pid, "ns/mnt"); nsfd = open(ns, O_RDONLY|O_NOCTTY|O_CLOEXEC); if (nsfd < 0) return -errno; - r = asprintf(&root, "/proc/%lu/root", (unsigned long) pid); - if (r < 0) - return -ENOMEM; + root = procfs_file_alloca(pid, "root"); rootfd = open(root, O_RDONLY|O_NOCTTY|O_CLOEXEC|O_DIRECTORY); if (rootfd < 0) -- cgit v1.2.3-54-g00ecf