[RESEND,v1,44/55] ns: Always start usernsd

Submitted by Kirill Tkhai on March 24, 2017, 3:15 p.m.

Details

Message ID 149036855712.23093.8527449853017438040.stgit@localhost.localdomain
State New
Series "Nested pid namespaces support"
Headers show

Commit Message

Kirill Tkhai March 24, 2017, 3:15 p.m.
We need a parent for pid_ns helpers. This can't be criu task,
as this introduces circular dependencies. So choose usernsd
for that, as we create it almost always.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/namespaces.c |    4 ++--
 criu/net.c        |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 9ed5ff7d..a2e6b82c 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -1414,7 +1414,7 @@  struct unsc_msg {
 	char c[CMSG_SPACE(sizeof(struct ucred)) + CMSG_SPACE(sizeof(int))];
 };
 
-static int usernsd_pid;
+int usernsd_pid;
 
 static inline void unsc_msg_init(struct unsc_msg *m, uns_call_t *c,
 		int *x, void *arg, size_t asize, int fd)
@@ -1642,7 +1642,7 @@  static int start_usernsd(void)
 	int sk[2];
 	int one = 1;
 
-	if (!(root_ns_mask & CLONE_NEWUSER))
+	if (!(root_ns_mask & (CLONE_NEWUSER|CLONE_NEWPID)))
 		return 0;
 
 	/*
diff --git a/criu/net.c b/criu/net.c
index 977a9091..5c781704 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -1106,7 +1106,7 @@  static int userns_restore_one_link(void *arg, int fd, pid_t pid)
 	struct newlink_req *req = arg;
 	int ns_fd = get_service_fd(NS_FD_OFF), rst = -1;
 
-	if (!(root_ns_mask & CLONE_NEWUSER)) {
+	if (ns_fd > 0) {
 		if (switch_ns_by_fd(ns_fd, &net_ns_desc, &rst))
 			return -1;
 	}