diff --git a/criu/tty.c b/criu/tty.c index ec29e0a94..3eda28192 100644 --- a/criu/tty.c +++ b/criu/tty.c @@ -838,6 +838,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); } @@ -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.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 f77243a46..739a4ffed 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 {