summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-27 20:23:18 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-27 20:28:48 +0100
commit613b411c947635136637f8cdd66b94512f761eab (patch)
tree5e0713345af39de99409d2193be93ae9e760e1d2 /src/machine
parentdf41776d66b5b7467a5cf9c719b97b66d6534c8c (diff)
service: add the ability for units to join other unit's PrivateNetwork= and PrivateTmp= namespaces
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machinectl.c10
1 files changed, 3 insertions, 7 deletions
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)