From 2f85acbe87cc794db02b1617c049b5f0950b0cb9 Mon Sep 17 00:00:00 2001 From: edp Date: Sun, 24 Sep 2006 18:22:18 -0700 Subject: 6474418 opens of linux pts devices are broken for non-root users --- usr/src/lib/brand/lx/lx_brand/common/ioctl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'usr/src') diff --git a/usr/src/lib/brand/lx/lx_brand/common/ioctl.c b/usr/src/lib/brand/lx/lx_brand/common/ioctl.c index c80bf162ab..b6a6b79ad1 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/ioctl.c +++ b/usr/src/lib/brand/lx/lx_brand/common/ioctl.c @@ -1189,6 +1189,7 @@ static int ict_gptn(int fd, struct stat *stat, int cmd, char *cmd_str, intptr_t arg) { int ptyno, *ptynop = (int *)arg; + pt_own_t pto; assert(cmd == LX_TIOCGPTN); assert(getmajor(stat->st_rdev) == ioc_translator_ptm.idt_major); @@ -1196,6 +1197,18 @@ ict_gptn(int fd, struct stat *stat, int cmd, char *cmd_str, intptr_t arg) /* This operation is only valid for the lx_ptm device. */ ptyno = LX_PTM_DEV_TO_PTS(stat->st_rdev); + /* + * We'd like to just use grantpt() directly, but we can't since + * it assumes the fd node that's passed to it is a ptm node, + * and in our case it's an lx_ptm node. It also relies on + * naming services to get the current process group name. + * Hence we have to invoke the PT_OWNER ioctl directly here. + */ + pto.pto_ruid = getuid(); + pto.pto_rgid = getgid(); + if (ioctl_istr(fd, PT_OWNER, "PT_OWNER", &pto, sizeof (pto)) != 0) + return (-EACCES); + /* Copy out the data. */ if (uucopy(&ptyno, ptynop, sizeof (ptyno)) != 0) return (-errno); -- cgit v1.2.3