Commit 30711b10 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

userns: save uid-s from a target userns (v2)

We are going to support user namespaces and uid-s will be converted
accoding with userns mappings.

v2: conver id-s for sockets too
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 71a9cd06
...@@ -324,8 +324,8 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st, dev_t phys_de ...@@ -324,8 +324,8 @@ static int dump_ghost_file(int _fd, u32 id, const struct stat *st, dev_t phys_de
if (img < 0) if (img < 0)
return -1; return -1;
gfe.uid = st->st_uid; gfe.uid = userns_uid(st->st_uid);
gfe.gid = st->st_gid; gfe.gid = userns_gid(st->st_gid);
gfe.mode = st->st_mode; gfe.mode = st->st_mode;
gfe.has_dev = gfe.has_ino = true; gfe.has_dev = gfe.has_ino = true;
......
...@@ -63,4 +63,7 @@ extern struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, struct ns_desc *n ...@@ -63,4 +63,7 @@ extern struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, struct ns_desc *n
extern int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd); extern int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd);
extern struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd); extern struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd);
extern int userns_uid(int uid);
extern int userns_gid(int gid);
#endif /* __CR_NS_H__ */ #endif /* __CR_NS_H__ */
...@@ -477,6 +477,21 @@ int dump_task_ns_ids(struct pstree_item *item) ...@@ -477,6 +477,21 @@ int dump_task_ns_ids(struct pstree_item *item)
return 0; return 0;
} }
static int userns_id(int id)
{
return id;
}
int userns_uid(int uid)
{
return userns_id(uid);
}
int userns_gid(int gid)
{
return userns_id(gid);
}
static int dump_user_ns(pid_t pid, int ns_id) static int dump_user_ns(pid_t pid, int ns_id)
{ {
pr_err("User namesapces are not supported yet\n"); pr_err("User namesapces are not supported yet\n");
......
...@@ -209,8 +209,8 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p) ...@@ -209,8 +209,8 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
ue->file_perms = perms; ue->file_perms = perms;
perms->mode = sk->mode; perms->mode = sk->mode;
perms->uid = sk->uid; perms->uid = userns_uid(sk->uid);
perms->gid = sk->gid; perms->gid = userns_gid(sk->gid);
} }
sk_encode_shutdown(ue, sk->shutdown); sk_encode_shutdown(ue, sk->shutdown);
......
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