Commit 9fb384f9 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: Make tty_get_sid_pgrp() to use parasite code

We need to use namespace local sid/pgid parameters
assigned on tty link, thus use parasite helper.

Otherwise we might fail on restoring controlling
terminal inside namespace (though everything else
will work even without this patch).
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9ee6f877
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/tty.pb-c.h" #include "protobuf/tty.pb-c.h"
#include "protobuf/creds.pb-c.h"
#include "parasite-syscall.h"
#include "parasite.h"
#include "pstree.h" #include "pstree.h"
#include "tty.h" #include "tty.h"
...@@ -309,36 +313,24 @@ static int lock_pty(int fd) ...@@ -309,36 +313,24 @@ static int lock_pty(int fd)
return 0; return 0;
} }
static int tty_get_sid_pgrp(int fd, int *sid, int *pgrp, bool *hangup) static int tty_get_sid_pgrp(const struct fd_parms *p, int major,
int *sid, int *pgrp, bool *hangup)
{ {
struct parasite_dump_tty *args = parasite_args(p->ctl, sizeof(*args));
int ret; int ret;
ret = ioctl(fd, TIOCGSID, sid); *args = (struct parasite_dump_tty) {
if (ret < 0) { .fd = p->fd,
if (errno != ENOTTY) };
goto err;
*sid = 0;
}
ret = ioctl(fd, TIOCGPGRP, pgrp);
if (ret < 0) {
if (errno != ENOTTY)
goto err;
*pgrp = 0;
}
*hangup = false;
return 0;
err: ret = parasite_dump_tty(p->ctl);
if (errno != EIO) { if (ret)
pr_perror("Can't get sid/pgrp on %d", fd);
return -1; return -1;
}
/* kernel reports EIO for get ioctls on pair-less ptys */ *sid = args->sid;
*sid = *pgrp = 0; *pgrp = args->pgrp;
*hangup = true; *hangup = args->hangup;
return 0; return 0;
} }
...@@ -932,7 +924,7 @@ static int dump_pty_info(int lfd, u32 id, const struct fd_parms *p, int major, i ...@@ -932,7 +924,7 @@ static int dump_pty_info(int lfd, u32 id, const struct fd_parms *p, int major, i
BUILD_BUG_ON(sizeof(termios.c_cc) != sizeof(void *)); BUILD_BUG_ON(sizeof(termios.c_cc) != sizeof(void *));
BUILD_BUG_ON((sizeof(termios.c_cc) * TERMIOS_NCC) < sizeof(t.c_cc)); BUILD_BUG_ON((sizeof(termios.c_cc) * TERMIOS_NCC) < sizeof(t.c_cc));
if (tty_get_sid_pgrp(lfd, &sid, &pgrp, &hangup)) if (tty_get_sid_pgrp(p, major, &sid, &pgrp, &hangup))
return -1; return -1;
info.id = id; info.id = id;
......
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