summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authoredp <none@none>2006-09-24 18:22:18 -0700
committeredp <none@none>2006-09-24 18:22:18 -0700
commit2f85acbe87cc794db02b1617c049b5f0950b0cb9 (patch)
tree9e7016c0534b2d1dce29c586e0ba86bbfc1db560 /usr/src
parent468f746cc700b507592bdf4849bdcc9d7ada0bd2 (diff)
downloadillumos-gate-2f85acbe87cc794db02b1617c049b5f0950b0cb9.tar.gz
6474418 opens of linux pts devices are broken for non-root users
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/ioctl.c13
1 files changed, 13 insertions, 0 deletions
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);