diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-04-20 17:48:31 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-04-20 17:48:31 +0000 |
commit | d6ebd360288d294ae750a4db56ce1d439a9dcd08 (patch) | |
tree | a55b6a5876ddf7a6f9a7cf25f972be4fdb1c938a /lib/libutil/openpty.3 | |
parent | 202ebe010de214b98ca6dd7a8af50db3f27998e1 (diff) |
Add getptmfd(), fdopenpty(), fdforkpty() functions. These allow programs
to separate the open(/dev/ptm) from the ioctl(PTMGET) for privilege
separation or pledge().
Based on a diff from reyk@.
ok deraadt millert
Diffstat (limited to 'lib/libutil/openpty.3')
-rw-r--r-- | lib/libutil/openpty.3 | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/lib/libutil/openpty.3 b/lib/libutil/openpty.3 index a49e533a82f..3d89cbc55d3 100644 --- a/lib/libutil/openpty.3 +++ b/lib/libutil/openpty.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: openpty.3,v 1.17 2015/08/28 19:54:06 kettenis Exp $ +.\" $OpenBSD: openpty.3,v 1.18 2017/04/20 17:48:30 nicm Exp $ .\" Copyright (c) 1995 .\" The Regents of the University of California. All rights reserved. .\" @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: August 28 2015 $ +.Dd $Mdocdate: April 20 2017 $ .Dt OPENPTY 3 .Os .Sh NAME @@ -42,11 +42,17 @@ .In termios.h .In util.h .Ft int +.Fn getptmfd "void" +.Ft int .Fn openpty "int *amaster" "int *aslave" "char *name" "struct termios *termp" "struct winsize *winp" .Ft int +.Fn fdopenpty "int ptmfd" "int *amaster" "int *aslave" "char *name" "struct termios *termp" "struct winsize *winp" +.Ft int .Fn login_tty "int fd" .Ft pid_t .Fn forkpty "int *amaster" "char *name" "struct termios *termp" "struct winsize *winp" +.Ft pid_t +.Fn fdforkpty "int ptmfd" "int *amaster" "char *name" "struct termios *termp" "struct winsize *winp" .Sh DESCRIPTION The .Fn openpty , @@ -90,6 +96,22 @@ uses of that device are revoked (see for details). .Pp The +.Fn fdopenpty +and +.Fn fdforkpty +functions work like +.Fn openpty +and +.Fn forkpty +but expect a +.Pa /dev/ptm +file descriptor +.Fa ptmfd +obtained from the +.Fn getptmfd +function. +.Pp +The .Fn login_tty function prepares for a login on the tty .Fa fd @@ -151,25 +173,42 @@ slave pseudo terminals pseudo terminal management device .El .Sh ERRORS +.Fn getptmfd +may fail and set +.Va errno +for any of the errors specified for the routine +.Xr open 2 . +.Pp .Fn openpty +and +.Fn fdopenpty will fail if: .Bl -tag -width Er .It Bq Er ENOENT There are no available ttys. .El .Pp -.Fn login_tty +.Fn fdopenpty +and +.Fn fdforkpty will fail if -.Fn ioctl -fails to set -.Fa fd -to the controlling terminal of the current process. +.Fn getptmfd +fails. .Fn forkpty +and +.Fn fdforkpty will fail if either .Fn openpty or .Fn fork fails. +.Pp +.Fn login_tty +will fail if +.Fn ioctl +fails to set +.Fa fd +to the controlling terminal of the current process. .Sh SEE ALSO .Xr fork 2 , .Xr revoke 2 , |