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

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: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ed5f540c
......@@ -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,
......
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