summaryrefslogtreecommitdiffstats
path: root/lib/libutil/pty.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-12-20 21:10:06 +0000
committerjhb <jhb@FreeBSD.org>2007-12-20 21:10:06 +0000
commit03594bb79f9a6545f49ca5bb2829c5aea7b39011 (patch)
tree1cfec13fa90b42599aa31ca935614f34eeaa6797 /lib/libutil/pty.c
parentb72597c775e788f824117ee8c75316497df3b5a3 (diff)
downloadFreeBSD-src-03594bb79f9a6545f49ca5bb2829c5aea7b39011.zip
FreeBSD-src-03594bb79f9a6545f49ca5bb2829c5aea7b39011.tar.gz
Invoke revoke(2) on the slave pty in the pts(4) case (new_openpty()) to
kick off any other users on the device line before using it since openpty(3) is documented to do this. Note that grantpt(3) does not call revoke(2), it only adjusts permissions and ownership. MFC after: 3 days
Diffstat (limited to 'lib/libutil/pty.c')
-rw-r--r--lib/libutil/pty.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c
index c94ce99..1fe8be2 100644
--- a/lib/libutil/pty.c
+++ b/lib/libutil/pty.c
@@ -55,6 +55,7 @@ static int
new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
{
+ const char *slavename;
int master, slave;
master = posix_openpt(O_RDWR);
@@ -66,7 +67,18 @@ new_openpty(int *amaster, int *aslave, char *name, struct termios *termp,
return (-1);
}
- slave = open(ptsname(master), O_RDWR);
+ slavename = ptsname(master);
+ if (slavename == NULL) {
+ close(master);
+ return (-1);
+ }
+
+ if (revoke(slavename) == -1) {
+ close(master);
+ return (-1);
+ }
+
+ slave = open(slavename, O_RDWR);
if (slave == -1) {
close(master);
return (-1);
OpenPOWER on IntegriCloud