Session management

David Barts davidb at Pacer.UUCP
Wed Aug 29 03:30:50 AEST 1990


In article <105387 at convex.convex.com>, tchrist at convex.COM (Tom Christiansen) writes:
> :
> :
> I'd like to solve at least these problems:
> 
>     1. getting the pty name right (varies system to system)
>     2. race condition between choosing a name and trying the open
> . . .

I thought master pty's only allowed one open at a time (at least that's
what the HP-UX docs say).  So choosing a name is easy -- just read
through the /dev directory (or wherever the ptys are).  For each name
that matches the naming convention of a master pty, try to open it.  If
the open succeeds, you have your pty pair.  (You can't open a closed
master pty whose slave is still open, because that will fail also.)

The only possible problem that I see is if some other unwanted process
opens your slave pty.  But this can be solved by keeping all the ptys
owned by root and not world read- or writable (to limit use of ptys to
trusted programs that follow this opening protocol).  So I can see
where the need for suid programs and chown()ing comes in, but I can't
see the race condition, since choosing the name and trying the open are
the same step.

Am I missing something here?  (I looked in the man pages for our
Solbourne system, and couldn't find anything as detailed as the rules
laid out in the HP man pages for when a master pty will open.) Is this
behavior of master pty's unique to HP-UX?

The one time I wrote a program that used ptys, I used the above
approach and it seemed to work just fine.
-- 
David Barts			Pacer Corporation, Bothell, WA
davidb at pacer.uucp		...!uunet!pilchuck!pacer!davidb



More information about the Comp.unix.wizards mailing list