mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
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: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
b7375b1265
commit
a47d2917a5
@ -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 prepare_userns(struct pstree_item *item);
|
||||
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 void free_userns_maps(void);
|
||||
|
||||
|
@ -507,8 +507,9 @@ int dump_task_ns_ids(struct pstree_item *item)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -521,7 +522,7 @@ static int userns_id(int id, UidGidExtent **map, int n)
|
||||
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)
|
||||
@ -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 -1;
|
||||
return INVALID_ID;
|
||||
}
|
||||
|
||||
static uid_t host_uid(uid_t uid)
|
||||
@ -552,13 +553,13 @@ static gid_t host_gid(gid_t gid)
|
||||
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;
|
||||
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;
|
||||
return userns_id(gid, e->gid_map, e->n_gid_map);
|
||||
@ -672,7 +673,7 @@ static int check_user_ns(int pid)
|
||||
|
||||
uid = host_uid(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");
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user