Re: ptsname() support (new ptys)

H. Peter Anvin (hpa@transmeta.com)
Thu, 15 Jan 1998 01:54:30 -0800 (PST)


> So the first open of a pty slave would set its uid/gid to that of the
> opening process (mode rw user), and a close would reset it? [a crash could
> leave the pty unusable to all but one user, but we'll let that pass]. We
> don't have to worry about pty master permissions, because the kernel only
> allows one open on them anyway.

Correct, except that you don't really want the gid set (normally you
want gid tty). My proposal is to use the already existing
setgid-directory mechanism to remedy that problem:

drwxr-sr-x root tty /dev/pts

And have the kernel create the new entries with mode (0620 & ~umask).

> If this is what you want, there's no need to resort to disk accesses. Why
> not add a UID field in the pty slave information structure, and disallow
> opens on an already-open device unless the UIDs match. Why touch the
> disk?

Because it's legal for chown() and chmod() to happen after the fact --
especially chmod().

> I'll add this support if people really want it -- Peter is right, it's
> trivial -- but it's entirely separate from the /dev/ptmx code.

Actually, my idea was for the kernel to mknod() the devices in
/dev/pts/* as well. Yes, it is separate in some ways, but the SysV
naming scheme makes this a helluva lot more reasonable. It would also
solve the crash problem quite simply, since it would be perfectly
reasonable to do an unlink() before doing these things.

I would normally propose having a daemon do these things, but since it
is so simple, we might as well do it right in the kernel.

-hpa