Commit a47d2917 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

userns: use a correct type for uid and gid

Currently we use int for them, but uid_t and gid_t is unsigned int.
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent b7375b12
...@@ -94,8 +94,10 @@ extern struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd); ...@@ -94,8 +94,10 @@ extern struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd);
extern int collect_user_namespaces(bool for_dump); extern int collect_user_namespaces(bool for_dump);
extern int prepare_userns(struct pstree_item *item); extern int prepare_userns(struct pstree_item *item);
extern int stop_usernsd(void); extern int stop_usernsd(void);
extern int userns_uid(int uid);
extern int userns_gid(int gid); extern uid_t userns_uid(uid_t uid);
extern gid_t userns_gid(gid_t gid);
extern int dump_user_ns(pid_t pid, int ns_id); extern int dump_user_ns(pid_t pid, int ns_id);
extern void free_userns_maps(void); extern void free_userns_maps(void);
......
...@@ -507,8 +507,9 @@ int dump_task_ns_ids(struct pstree_item *item) ...@@ -507,8 +507,9 @@ int dump_task_ns_ids(struct pstree_item *item)
} }
static UsernsEntry userns_entry = USERNS_ENTRY__INIT; static UsernsEntry userns_entry = USERNS_ENTRY__INIT;
#define INVALID_ID (~0U)
static int userns_id(int id, UidGidExtent **map, int n) static unsigned int userns_id(unsigned int id, UidGidExtent **map, int n)
{ {
int i; int i;
...@@ -521,7 +522,7 @@ static int userns_id(int id, UidGidExtent **map, int n) ...@@ -521,7 +522,7 @@ static int userns_id(int id, UidGidExtent **map, int n)
return map[i]->first + (id - map[i]->lower_first); return map[i]->first + (id - map[i]->lower_first);
} }
return -1; return INVALID_ID;
} }
static unsigned int host_id(unsigned int id, UidGidExtent **map, int n) static unsigned int host_id(unsigned int id, UidGidExtent **map, int n)
...@@ -537,7 +538,7 @@ static unsigned int host_id(unsigned int id, UidGidExtent **map, int n) ...@@ -537,7 +538,7 @@ static unsigned int host_id(unsigned int id, UidGidExtent **map, int n)
return map[i]->lower_first + (id - map[i]->first); return map[i]->lower_first + (id - map[i]->first);
} }
return -1; return INVALID_ID;
} }
static uid_t host_uid(uid_t uid) static uid_t host_uid(uid_t uid)
...@@ -552,13 +553,13 @@ static gid_t host_gid(gid_t gid) ...@@ -552,13 +553,13 @@ static gid_t host_gid(gid_t gid)
return host_id(gid, e->gid_map, e->n_gid_map); return host_id(gid, e->gid_map, e->n_gid_map);
} }
int userns_uid(int uid) uid_t userns_uid(uid_t uid)
{ {
UsernsEntry *e = &userns_entry; UsernsEntry *e = &userns_entry;
return userns_id(uid, e->uid_map, e->n_uid_map); return userns_id(uid, e->uid_map, e->n_uid_map);
} }
int userns_gid(int gid) gid_t userns_gid(gid_t gid)
{ {
UsernsEntry *e = &userns_entry; UsernsEntry *e = &userns_entry;
return userns_id(gid, e->gid_map, e->n_gid_map); return userns_id(gid, e->gid_map, e->n_gid_map);
...@@ -672,7 +673,7 @@ static int check_user_ns(int pid) ...@@ -672,7 +673,7 @@ static int check_user_ns(int pid)
uid = host_uid(0); uid = host_uid(0);
gid = host_gid(0); gid = host_gid(0);
if (uid == -1 || gid == -1) { if (uid == INVALID_ID || gid == INVALID_ID) {
pr_err("Unable to convert uid or gid\n"); pr_err("Unable to convert uid or gid\n");
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment