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:
parent
e9261d2d36
commit
4f99370cb8
15
criu/tty.c
15
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);
|
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
|
|||||||
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 {
|
|||||||
*/
|
*/
|
||||||
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user