2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

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/198

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Cyrill Gorcunov 2016-08-30 01:33:00 +03:00 committed by Pavel Emelyanov
parent e9261d2d36
commit 4f99370cb8
2 changed files with 18 additions and 0 deletions

View File

@ -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;

View File

@ -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 {