cvs commit: src/lib/libutil pty.c

John Baldwin jhb at freebsd.org
Thu Dec 20 13:21:54 PST 2007


On Thursday 20 December 2007 04:10:06 pm John Baldwin wrote:
> jhb         2007-12-20 21:10:06 UTC
> 
>   FreeBSD src repository
> 
>   Modified files:
>     lib/libutil          pty.c 
>   Log:
>   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

For a cute demonstration do something like this:

1) ssh foo in one window
2) ssh foo in another window
   note that pty in this window is /dev/pts/1 or some such
   end the ssh session

3) cat /dev/pts/1 in the first window (it should still be owned by your user)
4) ssh foo again in second window
5) note that the 'cat' didn't terminate.. now when you type in chars to your
   second window they will go to one of the two windows (seems to roughly
   ping-pong)
6) logout from window two, and the 'cat' in window one will die with ENXIO
   (presumbly due to a revoke(2) being done in sshd when the pty is closed)

With this fix, the 'cat' in 3) gets terminated with ENXIO during 4).

Note that the pty(4) case already gets this correct (which is what <= 7.x 
use).

(In general cat on a slave pty you are already using in another window is a 
bit of an odd experience.)

-- 
John Baldwin


More information about the cvs-src mailing list