[v4,13/31] ns: Set pointer to root_user_ns in ns_ids

Submitted by Kirill Tkhai on Feb. 22, 2017, 11:32 a.m.

Details

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

Commit Message

Kirill Tkhai Feb. 22, 2017, 11:32 a.m.
Old type images do not have pointer to user_ns.
Set them manually.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/namespaces.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/namespaces.c b/criu/namespaces.c
index a3e5dfce1..7e7a430b6 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -1681,6 +1681,7 @@  static int do_read_old_user_ns_img(struct ns_id *ns, void *arg)
 static int read_old_user_ns_img(void)
 {
 	int ret, count = 0;
+	struct ns_id *ns;
 
 	if (!(root_ns_mask & CLONE_NEWUSER))
 		return 0;
@@ -1689,8 +1690,13 @@  static int read_old_user_ns_img(void)
 		return 0;
 	/* Old format img is only for root_user_ns. More or less is error */
 	ret = walk_namespaces(&user_ns_desc, do_read_old_user_ns_img, &count);
+	if (ret < 0)
+		return -1;
 
-	return ret;
+	for (ns = ns_ids; ns != NULL; ns = ns->next)
+		if (ns->nd != &user_ns_desc)
+			ns->user_ns = root_user_ns;
+	return 0;
 }
 
 int prepare_userns(struct pstree_item *item)