2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

tty: Make sure the controlling terminal is restored by session leader

The controling terminal should be sestored by a session leader,
thus we need to test if the SID we've found in process tree
is a leader.

Otherwise we might have pretty interesting situation: the user
passed -j on dump, ie telling us to inherit shell jobs and on
restore procedure the SID get inherited from the crtools but
session leader for this sid doesn't belong to our peocess tree
and thus we should not try to restore controlling terminal
but inherit it as well.

Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov
2012-11-20 21:05:17 +04:00
committed by Pavel Emelyanov
parent ed5f540c99
commit 4cff708663

7
tty.c
View File

@@ -733,8 +733,13 @@ static int tty_find_restoring_task(struct tty_info *info)
return 0;
}
/*
* Find out the task which is session leader
* and it can restore the controlling terminal
* for us.
*/
item = find_first_sid(info->tie->sid);
if (item) {
if (item && item->pid.virt == item->sid) {
pr_info("Set a control terminal %x to %d\n",
info->tfe->id, info->tie->sid);
return prepare_ctl_tty(item->pid.virt,