[v2,17/36] ns: Set pointer to root_user_ns in ns_ids

Submitted by Kirill Tkhai on Feb. 3, 2017, 4:14 p.m.

Details

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

Commit Message

Kirill Tkhai Feb. 3, 2017, 4:14 p.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 761de62e5..e93c74065 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -1667,6 +1667,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;
@@ -1675,8 +1676,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)