ptyget — allocate a pty
ptyget allocates a new pty, makes the master side available as fd 4 (non-blocking), makes the slave side available as fd 5, and runs
TTY environment variable giving the name of the pty slave.
On current systems, ptyget is setuid
root and setgid
It changes the ownership of the pty slave to the user, so that the user can open it, and makes it mode
600, so that nobody else can open it.
It also puts the pty slave under group
It will refuse to run if these protections fail.
ptyget does not make any provisions to clean up when the user finishes using the pty.
On systems with the POSIX 2001 compliant posix_openpt(3), ptsname(3), grantpt(3), and unlockpt(3), functions, ptyget doesn't know nor care where the master or slave actually are. It uses the library functions to do most of the work.
On other pty/tty-based systems (e.g., BSD 4.4), the slave is
xy are two characters.
ptyget searches through masters starting from a random point (with a random increment to avoid secondary clustering).
ptyget relies for security on the kernel's revoke(3) function.
On other ptmx/pts-based systems (e.g., Solaris), the slave is
N is a nonnegative integer.
ptyget does not invoke /usr/lib/pt_chmod.
ptyget relies for security on the kernel's built-in slave locking.