Print this page
12306 XPG4v2 slave pty behaviour should generally be disabled
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Change-ID: I7ccd399c22866f34dd20c6bb9d28e77ba4e24c67

*** 22,36 **** /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - #pragma ident "%Z%%M% %I% %E% SMI" - #pragma weak _ptsname = ptsname #pragma weak _grantpt = grantpt #pragma weak _unlockpt = unlockpt #include "lint.h" --- 22,38 ---- /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + */ + /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #pragma weak _ptsname = ptsname #pragma weak _grantpt = grantpt #pragma weak _unlockpt = unlockpt #include "lint.h"
*** 131,140 **** --- 133,181 ---- return (-1); return (0); } + /* + * XPG4v2 requires that open of a slave pseudo terminal device + * provides the process with an interface that is identical to + * the terminal interface. + * + * To satisfy this, in strict XPG4v2 mode, this routine also sends + * a message down the stream that sets a flag in the kernel module + * so that additional actions are performed when opening an + * associated slave PTY device. When this happens, modules are + * automatically pushed onto the stream to provide terminal + * semantics and those modules are then informed that they should + * behave in strict XPG4v2 mode which modifies their behaviour. In + * particular, in strict XPG4v2 mode, empty blocks will be sent up + * the master side of the stream rather than being suppressed. + * + * Most applications do not expect this behaviour so it is only + * enabled for programs compiled in strict XPG4v2 mode (see + * stdlib.h). + */ + int + __unlockpt_xpg4(int fd) + { + int ret; + + if ((ret = unlockpt(fd)) == 0) { + struct strioctl istr; + + istr.ic_cmd = PTSSTTY; + istr.ic_len = 0; + istr.ic_timout = 0; + istr.ic_dp = NULL; + + if (ioctl(fd, I_STR, &istr) < 0) + ret = -1; + } + + return (ret); + } + int grantpt(int fd) { struct strioctl istr; pt_own_t pto;