Commit 4f99370c authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: Restore peers uid, gid

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/198Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent e9261d2d
...@@ -838,6 +838,16 @@ static int restore_tty_params(int fd, struct tty_info *info) ...@@ -838,6 +838,16 @@ static int restore_tty_params(int fd, struct tty_info *info)
winsize_copy(&p.w, info->tie->winsize); 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); return userns_call(do_restore_tty_parms, UNS_ASYNC, &p, sizeof(p), fd);
} }
...@@ -1714,6 +1724,11 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_d ...@@ -1714,6 +1724,11 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, struct tty_d
info.exclusive = pti->st_excl; info.exclusive = pti->st_excl;
info.packet_mode = pti->st_pckt; 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; info.type = driver->type;
if (info.type == TTY_TYPE__PTY) { if (info.type == TTY_TYPE__PTY) {
info.pty = &pty; info.pty = &pty;
......
...@@ -70,6 +70,9 @@ message tty_info_entry { ...@@ -70,6 +70,9 @@ message tty_info_entry {
*/ */
optional tty_pty_entry pty = 12; optional tty_pty_entry pty = 12;
optional uint32 dev = 13; optional uint32 dev = 13;
optional uint32 uid = 14;
optional uint32 gid = 15;
}; };
message tty_file_entry { message tty_file_entry {
......
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