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
This commit is contained in:
John Baldwin 2007-12-20 21:10:06 +00:00
parent 0079ea2086
commit 889befc455
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174818

View File

@ -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);