Browse Source

Add the ptm device to pty(4). By opening /dev/ptm and using the PTMGET

ioctl(2), an unprivileged process may allocate a pty and have its owner
and mode set appropriately.  This means that programs such as xterm and
screen no longer need to be setuid.  Programs using the openpty()
function require zero changes and will "just work".
Designed by beck@ and deraadt@; changes by beck@ with cleanup (and
a rewrite of the vnode bits) by art@ and tweaks/bugfixes by me.
Tested by many.
OPENBSD_3_5
millert 21 years ago
parent
commit
440a67a653
29 changed files with 173 additions and 40 deletions
  1. +4
    -1
      src/etc/MAKEDEV.mi
  2. +6
    -1
      src/etc/etc.alpha/MAKEDEV
  3. +2
    -1
      src/etc/etc.alpha/MAKEDEV.md
  4. +2
    -1
      src/etc/etc.cats/MAKEDEV.md
  5. +6
    -1
      src/etc/etc.hp300/MAKEDEV
  6. +2
    -1
      src/etc/etc.hp300/MAKEDEV.md
  7. +8
    -3
      src/etc/etc.hppa/MAKEDEV
  8. +2
    -1
      src/etc/etc.hppa/MAKEDEV.md
  9. +7
    -2
      src/etc/etc.i386/MAKEDEV
  10. +2
    -1
      src/etc/etc.i386/MAKEDEV.md
  11. +7
    -2
      src/etc/etc.mac68k/MAKEDEV
  12. +2
    -1
      src/etc/etc.mac68k/MAKEDEV.md
  13. +6
    -1
      src/etc/etc.macppc/MAKEDEV
  14. +2
    -1
      src/etc/etc.macppc/MAKEDEV.md
  15. +6
    -1
      src/etc/etc.mvme68k/MAKEDEV
  16. +2
    -1
      src/etc/etc.mvme68k/MAKEDEV.md
  17. +6
    -1
      src/etc/etc.mvme88k/MAKEDEV
  18. +2
    -1
      src/etc/etc.mvme88k/MAKEDEV.md
  19. +2
    -1
      src/etc/etc.mvmeppc/MAKEDEV.md
  20. +6
    -1
      src/etc/etc.pegasos/MAKEDEV
  21. +2
    -1
      src/etc/etc.pegasos/MAKEDEV.md
  22. +8
    -3
      src/etc/etc.sparc/MAKEDEV
  23. +2
    -1
      src/etc/etc.sparc/MAKEDEV.md
  24. +7
    -2
      src/etc/etc.sparc64/MAKEDEV
  25. +2
    -1
      src/etc/etc.sparc64/MAKEDEV.md
  26. +8
    -3
      src/etc/etc.vax/MAKEDEV
  27. +2
    -1
      src/etc/etc.vax/MAKEDEV.md
  28. +23
    -2
      src/lib/libutil/openpty.3
  29. +37
    -2
      src/lib/libutil/pty.c

+ 4
- 1
src/etc/MAKEDEV.mi View File

@ -1,6 +1,6 @@
include(MAKEDEV.sub)dnl
dnl
vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.67 2004/02/05 22:22:15 todd Exp $-})dnl
vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.68 2004/02/10 01:31:20 millert Exp $-})dnl
dnl
divert(1)dnl
{-#-}
@ -186,6 +186,7 @@ target(all, ppi, 0)dnl
target(all, view0, 0, 1, 2, 3, 4, 5)dnl
target(all, local)dnl
target(all, gpr, 0)dnl
target(all, ptm)dnl
dnl
_mkdev(all, {-all-}, {-dnl
show_target(all)dnl
@ -405,6 +406,8 @@ __devitem(wsmouse, wsmouse*, wscons mice)dnl
_mkdev(wsmouse, wsmouse*, {-M wsmouse$U c major_wsmouse_c $U 600-})dnl
__devitem(quad, quadmouse, "quadrature mouse")dnl
__devtitle(pty, Pseudo terminals)dnl
__devitem(ptm, ptm, pty master device)dnl
_mkdev(ptm, ptm, {-M ptm c major_ptm_c 0 666-})dnl
__devitem(tty, tty*, set of 16 slave psuedo terminals)dnl
__devitem(pty, pty*, set of 16 master pseudo terminals)dnl
_mkdev(pty, pty*, {-if [ $U -gt 15 ]; then


+ 6
- 1
src/etc/etc.alpha/MAKEDEV View File

@ -52,6 +52,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# lpt* IEEE 1284 centronics printer
# lpa* interruptless lp
@ -382,6 +383,10 @@ lpt*|lpa*)
M $n$U c 31 $(($U+$f)) 600
;;
ptm)
M ptm c 55 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -501,7 +506,7 @@ all)
R cd0 cd1 rd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 fd1 fd1B fd1C fd1D
R fd1E fd1F fd1G fd1H fd0 fd0B fd0C fd0D fd0E fd0F fd0G fd0H
R xfs0 ss0 ss1 ch0 wscons pci iop0 iop1 usbs rmidi0 rmidi1
R xfs0 ss0 ss1 ch0 ptm wscons pci iop0 iop1 usbs rmidi0 rmidi1
R rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 music0 speaker
R audio0 uk0 random lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 mmclock lkm
R tty00 tty01 tty02 tty03 ttyc0 ttyc1 ttyc2 ttyc3 ttyc4 ttyc5


+ 2
- 1
src/etc/etc.alpha/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.17 2004/01/12 22:18:24 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.18 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -46,6 +46,7 @@ _DEV(wsmouse, 30)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 55)
_TITLE(prn)
_DEV(lpt, 31)
_DEV(lpa)


+ 2
- 1
src/etc/etc.cats/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.1 2004/02/01 05:26:50 drahn Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.2 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001 Todd T. Fries <todd@OpenBSD.org>
@ -83,6 +83,7 @@ _DEV(systrace, 50)
_DEV(bktr, 75)
_DEV(tuner, 75)
_DEV(radio, 97)
_DEV(ptm, 98)
dnl
divert(7)dnl
dnl


+ 6
- 1
src/etc/etc.hp300/MAKEDEV View File

@ -44,6 +44,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# ppi* HP-IB plotters
# Call units:
@ -343,6 +344,10 @@ fd)
MKlist="$MKlist;chmod 555 fd"
;;
ptm)
M ptm c 52 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -402,7 +407,7 @@ all)
R ite0 ct0 ct1 hd0 hd1 hd2 dcm0 dcm1 dcm2 dcm3 dca0 dca1 st0
R st1 hil grf0 ccd0 ccd1 ccd2 ccd3 vnd0 vnd1 vnd2 vnd3 sd0 sd1
R sd2 sd3 sd4 rd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 xfs0 local ppi0
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 xfs0 ptm local ppi0
R apci0 random lkm pf systrace std fd
;;


+ 2
- 1
src/etc/etc.hp300/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.14 2004/01/13 15:13:14 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.15 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -66,6 +66,7 @@ _DEV(apci)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 52)
_TITLE(prn)
_DEV(ppi, 11)
_TITLE(call)


+ 8
- 3
src/etc/etc.hppa/MAKEDEV View File

@ -41,6 +41,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# lpt* IEEE 1284 centronics printer
# Console ports:
@ -340,6 +341,10 @@ lpt*|lpa*)
M $n$U c 30 $(($U+$f)) 600
;;
ptm)
M ptm c 38 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -425,9 +430,9 @@ all)
R cd0 cd1 rd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 fd1 fd1B fd1C fd1D
R fd1E fd1F fd1G fd1H fd0 fd0B fd0C fd0D fd0E fd0F fd0G fd0H
R xfs0 ss0 ss1 ch0 ses0 wscons pci audio0 uk0 random lpa0 lpa1
R lpa2 lpt0 lpt1 lpt2 lkm tty00 tty01 tty02 tty03 crypto pf
R systrace std st0 st1 fd
R xfs0 ss0 ss1 ch0 ses0 ptm wscons pci audio0 uk0 random lpa0
R lpa1 lpa2 lpt0 lpt1 lpt2 lkm tty00 tty01 tty02 tty03 crypto
R pf systrace std st0 st1 fd
;;
sd*|ccd*)


+ 2
- 1
src/etc/etc.hppa/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.16 2003/12/09 04:27:51 mickey Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.17 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -35,6 +35,7 @@ _DEV(com, 23)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 38)
_TITLE(prn)
_DEV(lpt, 30)
_TITLE(cons)


+ 7
- 2
src/etc/etc.i386/MAKEDEV View File

@ -54,6 +54,7 @@
# tty[0-7][0-9a-f] NS16x50 serial ports
# ttyc* Cyclades serial ports
# Pseudo terminals:
# ptm pty master device
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# Printers:
@ -457,6 +458,10 @@ pty*)
done
;;
ptm)
M ptm c 81 0 666
;;
tty[0-7][0-9a-f])
U=${i#tty*}
o=$(h2d $U)
@ -575,8 +580,8 @@ all)
R sd3 sd4 cd0 cd1 rd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3
R bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 fd1 fd1B fd1C
R fd1D fd1E fd1F fd1G fd1H fd0 fd0B fd0C fd0D fd0E fd0F fd0G
R fd0H xfs0 ss0 ss1 ch0 ses0 gpr0 wscons pci iop0 iop1 usbs
R rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7
R fd0H xfs0 ss0 ss1 ch0 ses0 ptm gpr0 wscons pci iop0 iop1
R usbs rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7
R tuner0 radio0 music0 speaker audio0 wdt0 wt0 uk0 random joy0
R joy1 lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 lkm tty00 tty01 tty02
R tty03 ttyc0 ttyc1 ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 apm


+ 2
- 1
src/etc/etc.i386/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.18 2004/01/12 22:18:24 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.19 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -48,6 +48,7 @@ _TITLE(term)
_DEV(com, 8)
_DEV(ttyc, 38)
_TITLE(pty)
_DEV(ptm, 81)
_DEV(tty, 5)
_DEV(pty, 6)
_TITLE(prn)


+ 7
- 2
src/etc/etc.mac68k/MAKEDEV View File

@ -42,6 +42,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Graphics devices:
# grf* custom chip (grf0), Retina Z2/Z3 (grf1/grf2),
# Cirrus boards (grf3), A2410 (grf4) video or
@ -298,6 +299,10 @@ bpf*)
M bpf$U c 22 $U 600
;;
ptm)
M ptm c 52 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -362,8 +367,8 @@ all)
R ttye0 ccd0 ccd1 ccd2 ccd3 cd0 cd1 rd0 tun0 tun1 tun2 tun3
R bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1
R pty2 xfs0 ss0 ss1 ch0 vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3
R sd4 local grf0 grf1 grf2 grf3 adb asc0 uk0 random lkm tty00
R tty01 pf systrace std st0 st1 fd
R sd4 ptm local grf0 grf1 grf2 grf3 adb asc0 uk0 random lkm
R tty00 tty01 pf systrace std st0 st1 fd
;;
sd*|ccd*)


+ 2
- 1
src/etc/etc.mac68k/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.12 2004/01/13 15:13:14 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.13 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -40,6 +40,7 @@ _DEV(mac_tty0)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 52)
_TITLE(graph)
_DEV(grf_mac, 10)
_TITLE(spec)


+ 6
- 1
src/etc/etc.macppc/MAKEDEV View File

@ -51,6 +51,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# USB devices:
# usb* Bus control devices used by usbd for attach/detach
# uhid* Generic HID devices
@ -353,6 +354,10 @@ usb*)
M usb$u c 61 $U 660
;;
ptm)
M ptm c 77 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -457,7 +462,7 @@ fd)
all)
R ccd0 ccd1 ccd2 ccd3 vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4
R cd0 cd1 rd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 xfs0 ss0 ss1 ch0
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 xfs0 ss0 ss1 ch0 ptm
R local wscons pci iop0 iop1 usbs tuner0 radio0 audio0 uk0
R random lkm tty00 tty01 tty02 tty03 apm crypto pf systrace
R wd0 wd1 wd2 wd3 raid0 raid1 raid2 raid3 std st0 st1 fd


+ 2
- 1
src/etc/etc.macppc/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.13 2004/01/13 13:38:21 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.14 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -45,6 +45,7 @@ _DEV(com, 7)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 77)
_TITLE(usb)
_DEV(usb, 61)
_DEV(uhid, 62)


+ 6
- 1
src/etc/etc.mvme68k/MAKEDEV View File

@ -44,6 +44,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# par0 Printer port
# Special purpose devices:
@ -293,6 +294,10 @@ lp*)
esac
;;
ptm)
M ptm c 52 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -402,7 +407,7 @@ all)
R vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 cd0 cd1 rd0 tun0 tun1 tun2
R tun3 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0
R pty1 pty2 xfs0 ss0 ss1 ch0 vmel0 vmes0 flash0 nvram0 sram0
R uk0 random lkm pf systrace std st0 st1 fd
R ptm uk0 random lkm pf systrace std st0 st1 fd
;;
sd*|ccd*)


+ 2
- 1
src/etc/etc.mvme68k/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.9 2003/09/26 06:58:02 miod Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.10 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -143,6 +143,7 @@ _DEV(ttyw, 30)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 52)
_TITLE(prn)
_DEV(lp, 28)
_TITLE(spec)


+ 6
- 1
src/etc/etc.mvme88k/MAKEDEV View File

@ -43,6 +43,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Special purpose devices:
# uk* SCSI Unknown device
# ss* SCSI scanners
@ -277,6 +278,10 @@ uk*)
M uk$U c 41 $U 640 operator
;;
ptm)
M ptm c 52 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -370,7 +375,7 @@ all)
R ccd3 vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 cd0 cd1 rd0
R tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7
R bpf8 bpf9 pty0 pty1 pty2 xfs0 ss0 ch0 vmel0 vmes0 nvram0
R sram0 uk0 random lkm pf systrace std st0 st1 fd
R sram0 ptm uk0 random lkm pf systrace std st0 st1 fd
;;
sd*|ccd*)


+ 2
- 1
src/etc/etc.mvme88k/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.10 2004/01/05 20:11:56 miod Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.11 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -117,6 +117,7 @@ _DEV(vx, 15)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 52)
_TITLE(spec)
_DEV(uk, 41)
_DEV(ss, 42)


+ 2
- 1
src/etc/etc.mvmeppc/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.12 2004/01/12 22:18:24 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.13 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -42,6 +42,7 @@ _DEV(wsmouse, 69)
_TITLE(pty)
_DEV(tty)
_DEV(pty)
_DEV(ptm, 55)
_TITLE(graphics)
_DEV(mac_grf)
_TTILE(usb)


+ 6
- 1
src/etc/etc.pegasos/MAKEDEV View File

@ -52,6 +52,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# USB devices:
# usb* Bus control devices used by usbd for attach/detach
# uhid* Generic HID devices
@ -361,6 +362,10 @@ usb*)
M usb$u c 61 $U 660
;;
ptm)
M ptm c 77 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -465,7 +470,7 @@ fd)
all)
R ccd0 ccd1 ccd2 ccd3 vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4
R cd0 cd1 rd0 tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 xfs0 ss0 ss1 ch0
R bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1 pty2 xfs0 ss0 ss1 ch0 ptm
R local wscons pci iop0 iop1 usbs tuner0 radio0 audio0 uk0
R random lkm tty00 tty01 tty02 tty03 apm crypto pf systrace
R wd0 wd1 wd2 wd3 raid0 raid1 raid2 raid3 std st0 st1 fd


+ 2
- 1
src/etc/etc.pegasos/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.2 2004/01/12 23:32:24 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.3 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001 Todd T. Fries <todd@OpenBSD.org>
@ -54,6 +54,7 @@ _DEV(com, 7)
_TITLE(pty)
_DEV(tty, 4)
_DEV(pty, 5)
_DEV(ptm, 77)
_TITLE(usb)
_DEV(usb, 61)
_DEV(uhid, 62)


+ 8
- 3
src/etc/etc.sparc/MAKEDEV View File

@ -45,6 +45,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# Console ports:
# ttyC0 wscons screen 0
@ -392,6 +393,10 @@ wscons)
R ttyC4 ttyC5 ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb
;;
ptm)
M ptm c 125 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -487,9 +492,9 @@ all)
R tun3 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0
R pty1 pty2 fd1 fd1B fd1C fd1D fd1E fd1F fd1G fd1H fd0 fd0B
R fd0C fd0D fd0E fd0F fd0G fd0H xfs0 ss0 ss1 ch0 ses0 cuaa
R cuab cuac cuad ttya ttyb ttyc ttyd wscons audio0 uk0 random
R lkm pf systrace xd0 xd1 xd2 xd3 raid0 raid1 raid2 raid3 std
R st0 st1 fd
R cuab cuac cuad ttya ttyb ttyc ttyd ptm wscons audio0 uk0
R random lkm pf systrace xd0 xd1 xd2 xd3 raid0 raid1 raid2
R raid3 std st0 st1 fd
;;
presto*|xd*|xy*|sd*|raid*|ccd*)


+ 2
- 1
src/etc/etc.sparc/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.19 2003/06/18 18:08:59 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.20 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -71,6 +71,7 @@ _DEV(presto, 25, 26)
_TITLE(pty)
_DEV(tty, 20)
_DEV(pty, 21)
_DEV(ptm, 125)
_TITLE(prn)
_TITLE(cons)
_DEV(wscons)


+ 7
- 2
src/etc/etc.sparc64/MAKEDEV View File

@ -57,6 +57,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# lpt* IEEE 1284 centronics printer
# lpa* interruptless lp
@ -420,6 +421,10 @@ lpt*|lpa*)
M $n$U c 37 $(($U+$f)) 600
;;
ptm)
M ptm c 123 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -576,8 +581,8 @@ all)
R bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9 pty0 pty1
R pty2 fd1 fd1B fd1C fd1D fd1E fd1F fd1G fd1H fd0 fd0B fd0C
R fd0D fd0E fd0F fd0G fd0H xfs0 ss0 ss1 ch0 ses0 ccd0 ccd1
R ccd2 ccd3 wscons pci usbs audio0 uk0 random lpa0 lpa1 lpa2
R lpt0 lpt1 lpt2 lkm tty00 tty01 tty02 tty03 ttyh0 ttyh1
R ccd2 ccd3 ptm wscons pci usbs audio0 uk0 random lpa0 lpa1
R lpa2 lpt0 lpt1 lpt2 lkm tty00 tty01 tty02 tty03 ttyh0 ttyh1
R crypto pf systrace wd0 wd1 wd2 wd3 raid0 raid1 raid2 raid3
R std st0 st1 fd
;;


+ 2
- 1
src/etc/etc.sparc64/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.28 2004/01/12 22:18:24 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.29 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -76,6 +76,7 @@ _DEV(tth, 77)
_TITLE(pty)
_DEV(tty, 20)
_DEV(pty, 21)
_DEV(ptm, 123)
_TITLE(prn)
_DEV(lpt, 37)
_DEV(lpa)


+ 8
- 3
src/etc/etc.vax/MAKEDEV View File

@ -56,6 +56,7 @@
# Pseudo terminals:
# tty* set of 16 slave psuedo terminals
# pty* set of 16 master pseudo terminals
# ptm pty master device
# Printers:
# Terminal ports:
# dhu* unibus dhu11
@ -418,6 +419,10 @@ dl*)
fi
;;
ptm)
M ptm c 75 0 666
;;
pty*)
if [ $U -gt 15 ]; then
echo bad unit for pty in: $i
@ -510,9 +515,9 @@ local)
all)
R vt0 dl0 dz0 dhu0 ts0 ts1 mt0 mt1 hd0 hd1 hd2 ccd0 vnd0 sd0
R sd1 sd2 sd3 cd0 tun0 tun1 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6
R bpf7 pty0 pty1 ss0 uk0 random lkm pf systrace rx0 rx1 ra0
R ra1 ra2 ra3 hp0 hp1 hp2 hp3 raid0 raid1 raid2 raid3 std st0
R st1 fd
R bpf7 pty0 pty1 ss0 ptm uk0 random lkm pf systrace rx0 rx1
R ra0 ra1 ra2 ra3 hp0 hp1 hp2 hp3 raid0 raid1 raid2 raid3 std
R st0 st1 fd
;;
up*|sd*|rx*|rl*|rb*|raid*|ra*|hp*|hk*|hd*|ccd*)


+ 2
- 1
src/etc/etc.vax/MAKEDEV.md View File

@ -1,5 +1,5 @@
vers(__file__,
{-$OpenBSD: MAKEDEV.md,v 1.13 2003/06/18 18:08:59 todd Exp $-},
{-$OpenBSD: MAKEDEV.md,v 1.14 2004/02/10 01:31:20 millert Exp $-},
etc.MACHINE)dnl
dnl
dnl Copyright (c) 2001,2002,2003 Todd T. Fries <todd@OpenBSD.org>
@ -130,6 +130,7 @@ _DEV(ccd, 54, 17)
_TITLE(pty)
_DEV(tty, 20)
_DEV(pty, 21)
_DEV(ptm, 75)
_TITLE(prn)
_TITLE(term)
_DEV(dhu, 34)


+ 23
- 2
src/lib/libutil/openpty.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: openpty.3,v 1.11 2003/06/02 20:18:42 millert Exp $
.\" $OpenBSD: openpty.3,v 1.12 2004/02/10 01:31:20 millert Exp $
.\" Copyright (c) 1995
.\" The Regents of the University of California. All rights reserved.
.\"
@ -78,6 +78,24 @@ is non-null, the window size of the slave will be set to the values in
.Fa winp .
.Pp
The
.Fn openpty
function works in the following way:
first it attempts to allocate the pseudo-tty through the
.Pa /dev/ptm
device (see
.Xr pty 4
for details) and if that fails it searches for a free psuedo-tty by iterating
through all existing pseudo-tty devices in
.Pa /dev .
When a free pseudo-tty is found, its ownership is changed to
the UID of the caller, permissions are set to correct values,
and all earlier uses of that device are revoked (see
.Xr revoke 2
for details).
The first method can work for any user, the second method requires
super-user privileges in most cases.
.Pp
The
.Fn login_tty
function prepares for a login on the tty
.Fa fd
@ -132,6 +150,7 @@ returns the process ID of the child process.
.Sh FILES
.Bl -tag -width /dev/[pt]ty[pqrstuvwxyzPQRST][0123456789abcdef] -compact
.It Pa /dev/[pt]ty[pqrstuvwxyzPQRST][0123456789abcdef]
.It Pa /dev/ptm
.El
.Sh ERRORS
.Fn openpty
@ -154,4 +173,6 @@ or
.Fn fork
fails.
.Sh SEE ALSO
.Xr fork 2
.Xr fork 2 ,
.Xr revoke 2 ,
.Xr pty 4

+ 37
- 2
src/lib/libutil/pty.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: pty.c,v 1.10 2003/06/02 20:18:42 millert Exp $ */
/* $OpenBSD: pty.c,v 1.11 2004/02/10 01:31:20 millert Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; */
static const char rcsid[] = "$Id: pty.c,v 1.10 2003/06/02 20:18:42 millert Exp $";
static const char rcsid[] = "$Id: pty.c,v 1.11 2004/02/10 01:31:20 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
@ -44,6 +44,7 @@ static const char rcsid[] = "$Id: pty.c,v 1.10 2003/06/02 20:18:42 millert Exp $
#include <stdio.h>
#include <string.h>
#include <grp.h>
#include <sys/tty.h>
#include "util.h"
@ -60,7 +61,41 @@ openpty(amaster, aslave, name, termp, winp)
register const char *cp1, *cp2;
register int master, slave, ttygid;
struct group *gr;
struct ptmget ptm;
int fd;
/* Try to use /dev/ptm and the PTMGET ioctl to get a properly set up
* and owned pty/tty pair. If this fails, (because we might not have
* the ptm device, etc.) fall back to using the traditional method
* of walking through the pty entries in /dev for the moment, until
* there is less chance of people being seriously boned by running
* kernels without /dev/ptm in them.
*/
fd = open(PATH_PTMDEV, O_RDWR, 0);
if (fd == -1)
goto walkit;
if ((ioctl(fd, PTMGET, &ptm) == -1)) {
close(fd);
goto walkit;
}
close(fd);
master = ptm.cfd;
slave = ptm.sfd;
if (name) {
/*
* Manual page says "at least 16 characters".
*/
strlcpy(name, ptm.sn, 16);
}
*amaster = master;
*aslave = slave;
if (termp)
(void) tcsetattr(slave, TCSAFLUSH, termp);
if (winp)
(void) ioctl(slave, TIOCSWINSZ, (char *)winp);
return (0);
walkit:
if ((gr = getgrnam("tty")) != NULL)
ttygid = gr->gr_gid;
else


Loading…
Cancel
Save