[CRIU] [PATCH] tty: Restore peers uid, gid
Cyrill Gorcunov
gorcunov at openvz.org
Mon Aug 29 15:33:10 PDT 2016
Currently when we create peers we don't consider
if they were owned by someone else. Lest carry
uid/gid into image and restore then.
https://github.com/xemul/criu/issues/198
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/tty.c | 15 +++++++++++++++
images/tty.proto | 3 +++
2 files changed, 18 insertions(+)
diff --git a/criu/tty.c b/criu/tty.c
index 7705c5ffac5c..e6e790a10e9a 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -837,6 +837,16 @@ static int restore_tty_params(int fd, struct tty_info *info)
winsize_copy(&p.w, info->tie->winsize);
}
+ if (info->tie->has_uid && info->tie->has_gid) {
+ if (fchown(fd, info->tie->uid, info->tie->gid)) {
+ pr_perror("Can't setup uid %d gid %d on %x\n",
+ (int)info->tie->uid,
+ (int)info->tie->gid,
+ info->tfe->id);
+ return -1;
+ }
+ }
+
return userns_call(do_restore_tty_parms, UNS_ASYNC, &p, sizeof(p), fd);
}
@@ -1707,6 +1717,11 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_d
info.exclusive = pti->st_excl;
info.packet_mode = pti->st_pckt;
+ info.has_uid = true;
+ info.uid = userns_uid(p->stat.st_uid);
+ info.has_gid = true;
+ info.gid = userns_gid(p->stat.st_gid);
+
info.type = driver->type;
if (info.type == TTY_TYPE__PTY) {
info.pty = &pty;
diff --git a/images/tty.proto b/images/tty.proto
index f77243a464c2..739a4ffedfff 100644
--- a/images/tty.proto
+++ b/images/tty.proto
@@ -70,6 +70,9 @@ message tty_info_entry {
*/
optional tty_pty_entry pty = 12;
optional uint32 dev = 13;
+
+ optional uint32 uid = 14;
+ optional uint32 gid = 15;
};
message tty_file_entry {
--
2.7.4
More information about the CRIU
mailing list