[CRIU] [PATCH v3 09/33] user_ns: Make host_id() working with any mapping and rename it
Kirill Tkhai
ktkhai at virtuozzo.com
Thu Feb 16 04:07:55 PST 2017
Make possible to convert uid and gid from a user_ns to its
representation in its (grand) parent user_ns.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/namespaces.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 8ee2ef47d..352c4f36d 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -765,7 +765,7 @@ static unsigned int userns_id(unsigned int id, UidGidExtent **map, int n)
return INVALID_ID;
}
-static unsigned int host_id(unsigned int id, UidGidExtent **map, int n)
+static unsigned int parent_userns_id(unsigned int id, UidGidExtent **map, int n)
{
int i;
@@ -781,16 +781,14 @@ static unsigned int host_id(unsigned int id, UidGidExtent **map, int n)
return INVALID_ID;
}
-static uid_t host_uid(uid_t uid)
+static uid_t parent_userns_uid(UsernsEntry *e, uid_t uid)
{
- UsernsEntry *e = userns_entry;
- return host_id(uid, e->uid_map, e->n_uid_map);
+ return parent_userns_id(uid, e->uid_map, e->n_uid_map);
}
-static gid_t host_gid(gid_t gid)
+static gid_t parent_userns_gid(UsernsEntry *e, gid_t gid)
{
- UsernsEntry *e = userns_entry;
- return host_id(gid, e->gid_map, e->n_gid_map);
+ return parent_userns_id(gid, e->gid_map, e->n_gid_map);
}
uid_t userns_uid(uid_t uid)
@@ -930,6 +928,7 @@ static int collect_ns_hierarhy(bool for_dump)
static int check_user_ns(struct ns_id *ns)
{
+ UsernsEntry *e = ns->user.e;
pid_t pid = ns->ns_pid;
int status;
pid_t chld;
@@ -947,8 +946,8 @@ static int check_user_ns(struct ns_id *ns)
gid_t gid;
int i;
- uid = host_uid(0);
- gid = host_gid(0);
+ uid = parent_userns_uid(e, 0);
+ gid = parent_userns_gid(e, 0);
if (uid == INVALID_ID || gid == INVALID_ID) {
pr_err("Unable to convert uid or gid\n");
return -1;
More information about the CRIU
mailing list