From bdc51baebbd18bab76a0e6f70739f02625099c3c Mon Sep 17 00:00:00 2001 From: elad Date: Sun, 1 Oct 2006 19:28:43 +0000 Subject: [PATCH] Adapt MD code to KAUTH_DEVICE_TTY_OPEN, batch #2 from Matt Fleming, thanks! Also, add forgotten splx() calls in some places. --- sys/arch/alpha/alpha/promcons.c | 8 +++++--- sys/arch/amiga/dev/mfc.c | 8 +++++--- sys/arch/hpcmips/tx/txcom.c | 5 ++--- sys/arch/vax/vax/gencons.c | 13 +++++++------ sys/arch/x68k/dev/com.c | 9 +++------ sys/arch/x68k/dev/ite.c | 8 +++----- sys/arch/xen/xen/xencons.c | 12 ++++++------ sys/dev/arcbios/arcbios_tty.c | 15 ++++++++------- sys/dev/dec/dz.c | 12 ++++++------ sys/dev/hpc/biconsdev.c | 12 ++++++------ sys/dev/ic/cd18xx.c | 11 +++-------- sys/dev/ic/clmpcc.c | 9 +++------ sys/dev/ic/com.c | 9 +++------ sys/dev/ic/cy.c | 11 +++++------ sys/dev/ic/z8530tty.c | 9 +++------ sys/dev/ir/irframe_tty.c | 8 ++++---- sys/dev/marvell/gtmpsc.c | 9 +++------ sys/dev/ofw/ofcons.c | 11 +++++------ sys/dev/pci/cz.c | 9 +++------ sys/dev/qbus/dhu.c | 13 +++++++------ sys/dev/qbus/dl.c | 12 ++++++------ sys/dev/sbus/magma.c | 9 +++------ sys/dev/sbus/spif.c | 12 +++++------- sys/dev/usb/ucom.c | 9 +++------ sys/dev/usb/ucycom.c | 9 +++------ sys/dev/wscons/wsdisplay.c | 14 ++++++++------ 26 files changed, 118 insertions(+), 148 deletions(-) diff --git a/sys/arch/alpha/alpha/promcons.c b/sys/arch/alpha/alpha/promcons.c index c941153fcf16..64c1ef9c89a7 100644 --- a/sys/arch/alpha/alpha/promcons.c +++ b/sys/arch/alpha/alpha/promcons.c @@ -1,4 +1,4 @@ -/* $NetBSD: promcons.c,v 1.29 2006/10/01 18:56:21 elad Exp $ */ +/* $NetBSD: promcons.c,v 1.30 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -29,7 +29,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: promcons.c,v 1.29 2006/10/01 18:56:21 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: promcons.c,v 1.30 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -102,8 +102,10 @@ promopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_param = promparam; tp->t_dev = dev; - if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) { + splx(s); return (EBUSY); + } if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; diff --git a/sys/arch/amiga/dev/mfc.c b/sys/arch/amiga/dev/mfc.c index 3213a3984915..93f6de5362a1 100644 --- a/sys/arch/amiga/dev/mfc.c +++ b/sys/arch/amiga/dev/mfc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mfc.c,v 1.42 2006/10/01 18:56:21 elad Exp $ */ +/* $NetBSD: mfc.c,v 1.43 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 1982, 1990 The Regents of the University of California. @@ -58,7 +58,7 @@ #include "opt_kgdb.h" #include -__KERNEL_RCSID(0, "$NetBSD: mfc.c,v 1.42 2006/10/01 18:56:21 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mfc.c,v 1.43 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -505,8 +505,10 @@ mfcsopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_dev = dev; tp->t_hwiflow = mfcshwiflow; - if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) { + splx(s); return (EBUSY); + } if ((tp->t_state & TS_ISOPEN) == 0 && tp->t_wopen == 0) { ttychars(tp); diff --git a/sys/arch/hpcmips/tx/txcom.c b/sys/arch/hpcmips/tx/txcom.c index 3b43470b5450..d72e517a5061 100644 --- a/sys/arch/hpcmips/tx/txcom.c +++ b/sys/arch/hpcmips/tx/txcom.c @@ -1,4 +1,4 @@ -/* $NetBSD: txcom.c,v 1.32 2006/10/01 18:56:22 elad Exp $ */ +/* $NetBSD: txcom.c,v 1.33 2006/10/01 19:28:43 elad Exp $ */ /*- * Copyright (c) 1999, 2000, 2004 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: txcom.c,v 1.32 2006/10/01 18:56:22 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: txcom.c,v 1.33 2006/10/01 19:28:43 elad Exp $"); #include "opt_tx39uart_debug.h" @@ -787,7 +787,6 @@ txcomopen(dev_t dev, int flag, int mode, struct lwp *l) struct txcom_chip *chip; struct tty *tp; int s, err = ENXIO; -; if (!sc) return err; diff --git a/sys/arch/vax/vax/gencons.c b/sys/arch/vax/vax/gencons.c index 6f724721a54a..ba12ab6a768c 100644 --- a/sys/arch/vax/vax/gencons.c +++ b/sys/arch/vax/vax/gencons.c @@ -1,4 +1,4 @@ -/* $NetBSD: gencons.c,v 1.44 2006/07/23 22:06:07 ad Exp $ */ +/* $NetBSD: gencons.c,v 1.45 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -36,7 +36,7 @@ /* All bugs are subject to removal without further notice */ #include -__KERNEL_RCSID(0, "$NetBSD: gencons.c,v 1.44 2006/07/23 22:06:07 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gencons.c,v 1.45 2006/10/01 19:28:43 elad Exp $"); #include "opt_ddb.h" #include "opt_cputype.h" @@ -113,6 +113,10 @@ gencnopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_oproc = gencnstart; tp->t_param = gencnparam; tp->t_dev = dev; + + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if ((tp->t_state & TS_ISOPEN) == 0) { ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; @@ -122,10 +126,7 @@ gencnopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; gencnparam(tp, &tp->t_termios); ttsetwater(tp); - } else if (tp->t_state & TS_XCLUDE && - kauth_authorize_generic(l->l_cred, - KAUTH_GENERIC_ISSUSER, &l->l_acflag) != 0) - return EBUSY; + } tp->t_state |= TS_CARR_ON; return ((*tp->t_linesw->l_open)(dev, tp)); diff --git a/sys/arch/x68k/dev/com.c b/sys/arch/x68k/dev/com.c index 3c4fb0170f5c..a45e9913d69f 100644 --- a/sys/arch/x68k/dev/com.c +++ b/sys/arch/x68k/dev/com.c @@ -1,4 +1,4 @@ -/* $NetBSD: com.c,v 1.40 2006/07/23 22:06:08 ad Exp $ */ +/* $NetBSD: com.c,v 1.41 2006/10/01 19:28:43 elad Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.40 2006/07/23 22:06:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.41 2006/10/01 19:28:43 elad Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -413,10 +413,7 @@ comopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_param = comparam; tp->t_dev = dev; - if ((tp->t_state & TS_ISOPEN) && - (tp->t_state & TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/arch/x68k/dev/ite.c b/sys/arch/x68k/dev/ite.c index 63d203dbc9a1..c7d2f208504a 100644 --- a/sys/arch/x68k/dev/ite.c +++ b/sys/arch/x68k/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.46 2006/07/23 22:06:08 ad Exp $ */ +/* $NetBSD: ite.c,v 1.47 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -83,7 +83,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.46 2006/07/23 22:06:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.47 2006/10/01 19:28:43 elad Exp $"); #include "ite.h" #if NITE > 0 @@ -393,9 +393,7 @@ iteopen(dev_t dev, int mode, int devtype, struct lwp *l) tty_attach(tp); } else tp = ite_tty[unit]; - if ((tp->t_state&(TS_ISOPEN|TS_XCLUDE)) == (TS_ISOPEN|TS_XCLUDE) - && kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); if ((ip->flags & ITE_ACTIVE) == 0) { error = iteon(dev, 0); diff --git a/sys/arch/xen/xen/xencons.c b/sys/arch/xen/xen/xencons.c index 2ed9bdd57017..4cf16afc2085 100644 --- a/sys/arch/xen/xen/xencons.c +++ b/sys/arch/xen/xen/xencons.c @@ -1,4 +1,4 @@ -/* $NetBSD: xencons.c,v 1.18 2006/07/23 22:06:08 ad Exp $ */ +/* $NetBSD: xencons.c,v 1.19 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -63,7 +63,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.18 2006/07/23 22:06:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.19 2006/10/01 19:28:43 elad Exp $"); #include "opt_xen.h" @@ -250,6 +250,9 @@ xencons_open(dev_t dev, int flag, int mode, struct lwp *l) tp = sc->sc_tty; + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if ((tp->t_state & TS_ISOPEN) == 0 && tp->t_wopen == 0) { tp->t_dev = dev; ttychars(tp); @@ -260,10 +263,7 @@ xencons_open(dev_t dev, int flag, int mode, struct lwp *l) tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; xencons_param(tp, &tp->t_termios); ttsetwater(tp); - } else if (tp->t_state&TS_XCLUDE && - kauth_authorize_generic(l->l_cred, - KAUTH_GENERIC_ISSUSER, &l->l_acflag) != 0) - return (EBUSY); + } tp->t_state |= TS_CARR_ON; return ((*tp->t_linesw->l_open)(dev, tp)); diff --git a/sys/dev/arcbios/arcbios_tty.c b/sys/dev/arcbios/arcbios_tty.c index a25a303480c5..cb5def8d0e72 100644 --- a/sys/dev/arcbios/arcbios_tty.c +++ b/sys/dev/arcbios/arcbios_tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: arcbios_tty.c,v 1.14 2006/07/21 16:48:48 ad Exp $ */ +/* $NetBSD: arcbios_tty.c,v 1.15 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arcbios_tty.c,v 1.14 2006/07/21 16:48:48 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arcbios_tty.c,v 1.15 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -91,6 +91,12 @@ arcbios_ttyopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_oproc = arcbios_tty_start; tp->t_param = arcbios_tty_param; tp->t_dev = dev; + + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) { + splx(s); + return (EBUSY); + } + if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_CARR_ON; ttychars(tp); @@ -102,11 +108,6 @@ arcbios_ttyopen(dev_t dev, int flag, int mode, struct lwp *l) ttsetwater(tp); setuptimeout = 1; - } else if (tp->t_state & TS_XCLUDE && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) { - splx(s); - return (EBUSY); } splx(s); diff --git a/sys/dev/dec/dz.c b/sys/dev/dec/dz.c index 81a459181ef2..d5e62c9d62f5 100644 --- a/sys/dev/dec/dz.c +++ b/sys/dev/dec/dz.c @@ -1,4 +1,4 @@ -/* $NetBSD: dz.c,v 1.22 2006/07/29 18:48:14 ad Exp $ */ +/* $NetBSD: dz.c,v 1.23 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.22 2006/07/29 18:48:14 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dz.c,v 1.23 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -347,6 +347,10 @@ dzopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_oproc = dzstart; tp->t_param = dzparam; tp->t_dev = dev; + + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if ((tp->t_state & TS_ISOPEN) == 0) { ttychars(tp); if (tp->t_ispeed == 0) { @@ -358,10 +362,6 @@ dzopen(dev_t dev, int flag, int mode, struct lwp *l) } (void) dzparam(tp, &tp->t_termios); ttsetwater(tp); - } else if ((tp->t_state & TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) - return (EBUSY); /* Use DMBIS and *not* DMSET or else we clobber incoming bits */ if (dzmctl(sc, line, DML_DTR, DMBIS) & DML_DCD) tp->t_state |= TS_CARR_ON; diff --git a/sys/dev/hpc/biconsdev.c b/sys/dev/hpc/biconsdev.c index ebea6f25be99..42f100537259 100644 --- a/sys/dev/hpc/biconsdev.c +++ b/sys/dev/hpc/biconsdev.c @@ -1,4 +1,4 @@ -/* $NetBSD: biconsdev.c,v 1.16 2006/07/21 16:48:48 ad Exp $ */ +/* $NetBSD: biconsdev.c,v 1.17 2006/10/01 19:28:43 elad Exp $ */ /*- * Copyright (c) 1999-2001 @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: biconsdev.c,v 1.16 2006/07/21 16:48:48 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: biconsdev.c,v 1.17 2006/10/01 19:28:43 elad Exp $"); #include "biconsdev.h" #include @@ -170,6 +170,9 @@ biconsdevopen(dev_t dev, int flag, int mode, struct lwp *l) struct tty *tp = &biconsdev_tty[0]; int status; + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if ((tp->t_state & TS_ISOPEN) == 0) { /* * Leave baud rate alone! @@ -182,10 +185,7 @@ biconsdevopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_state = TS_ISOPEN | TS_CARR_ON; (void)(*tp->t_param)(tp, &tp->t_termios); ttsetwater(tp); - } else if (tp->t_state & TS_XCLUDE && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) - return (EBUSY); + } status = (*tp->t_linesw->l_open)(dev, tp); return status; diff --git a/sys/dev/ic/cd18xx.c b/sys/dev/ic/cd18xx.c index 6bdd5e376218..6d71ffd6ca2a 100644 --- a/sys/dev/ic/cd18xx.c +++ b/sys/dev/ic/cd18xx.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd18xx.c,v 1.16 2006/07/21 16:48:48 ad Exp $ */ +/* $NetBSD: cd18xx.c,v 1.17 2006/10/01 19:28:43 elad Exp $ */ /* XXXad does this even compile? */ @@ -103,7 +103,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd18xx.c,v 1.16 2006/07/21 16:48:48 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd18xx.c,v 1.17 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -431,12 +431,7 @@ cdttyopen(dev, flag, mode, p) tp = port->p_tty; - /* enforce exclude */ - if (tp == NULL || - (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0)) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/ic/clmpcc.c b/sys/dev/ic/clmpcc.c index 31ff76807049..16df50ada890 100644 --- a/sys/dev/ic/clmpcc.c +++ b/sys/dev/ic/clmpcc.c @@ -1,4 +1,4 @@ -/* $NetBSD: clmpcc.c,v 1.29 2006/07/21 16:48:48 ad Exp $ */ +/* $NetBSD: clmpcc.c,v 1.30 2006/10/01 19:28:43 elad Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: clmpcc.c,v 1.29 2006/07/21 16:48:48 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clmpcc.c,v 1.30 2006/10/01 19:28:43 elad Exp $"); #include "opt_ddb.h" @@ -523,10 +523,7 @@ clmpccopen(dev, flag, mode, l) tp = ch->ch_tty; - if ( ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0 ) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return EBUSY; /* diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index b1ddf92f2ae0..d742190c18a8 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $NetBSD: com.c,v 1.252 2006/09/24 03:53:08 jmcneill Exp $ */ +/* $NetBSD: com.c,v 1.253 2006/10/01 19:28:43 elad Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.252 2006/09/24 03:53:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.253 2006/10/01 19:28:43 elad Exp $"); #include "opt_com.h" #include "opt_ddb.h" @@ -795,10 +795,7 @@ comopen(dev_t dev, int flag, int mode, struct lwp *l) tp = sc->sc_tty; - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c index 664de1a14089..3fa0d92ad026 100644 --- a/sys/dev/ic/cy.c +++ b/sys/dev/ic/cy.c @@ -1,4 +1,4 @@ -/* $NetBSD: cy.c,v 1.44 2006/07/21 16:48:49 ad Exp $ */ +/* $NetBSD: cy.c,v 1.45 2006/10/01 19:28:43 elad Exp $ */ /* * cy.c @@ -16,7 +16,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cy.c,v 1.44 2006/07/21 16:48:49 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cy.c,v 1.45 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -294,6 +294,9 @@ cyopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_param = cyparam; tp->t_dev = dev; + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) { ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; @@ -365,10 +368,6 @@ cyopen(dev_t dev, int flag, int mode, struct lwp *l) SET(tp->t_state, TS_CARR_ON); else CLR(tp->t_state, TS_CARR_ON); - } else if (ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) { - return EBUSY; } else { s = spltty(); } diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index bea2e269b39f..8abde1b9b137 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: z8530tty.c,v 1.110 2006/07/22 15:09:09 martin Exp $ */ +/* $NetBSD: z8530tty.c,v 1.111 2006/10/01 19:28:43 elad Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -137,7 +137,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.110 2006/07/22 15:09:09 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.111 2006/10/01 19:28:43 elad Exp $"); #include "opt_kgdb.h" #include "opt_ntp.h" @@ -587,10 +587,7 @@ zsopen(dev, flags, mode, l) if (tp == NULL) return (EBUSY); - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/ir/irframe_tty.c b/sys/dev/ir/irframe_tty.c index b30ff26947b6..d59ab3e0e906 100644 --- a/sys/dev/ir/irframe_tty.c +++ b/sys/dev/ir/irframe_tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: irframe_tty.c,v 1.36 2006/07/21 16:48:51 ad Exp $ */ +/* $NetBSD: irframe_tty.c,v 1.37 2006/10/01 19:28:43 elad Exp $ */ /* * TODO @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.36 2006/07/21 16:48:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.37 2006/10/01 19:28:43 elad Exp $"); #include #include @@ -223,8 +223,8 @@ irframetopen(dev_t dev, struct tty *tp) DPRINTF(("%s\n", __FUNCTION__)); - if ((error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag)) != 0) + if ((error = kauth_authorize_device_tty(l->l_cred, + KAUTH_DEVICE_TTY_OPEN, tp))) return (error); s = spltty(); diff --git a/sys/dev/marvell/gtmpsc.c b/sys/dev/marvell/gtmpsc.c index 7931de7547cb..717cb970657a 100644 --- a/sys/dev/marvell/gtmpsc.c +++ b/sys/dev/marvell/gtmpsc.c @@ -1,4 +1,4 @@ -/* $NetBSD: gtmpsc.c,v 1.20 2006/07/21 16:48:51 ad Exp $ */ +/* $NetBSD: gtmpsc.c,v 1.21 2006/10/01 19:28:43 elad Exp $ */ /* * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc. @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gtmpsc.c,v 1.20 2006/07/21 16:48:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gtmpsc.c,v 1.21 2006/10/01 19:28:43 elad Exp $"); #include "opt_kgdb.h" @@ -610,10 +610,7 @@ gtmpscopen(dev_t dev, int flag, int mode, struct lwp *l) return (EBUSY); #endif tp = sc->gtmpsc_tty; - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, - KAUTH_GENERIC_ISSUSER, &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/ofw/ofcons.c b/sys/dev/ofw/ofcons.c index 439590c4412b..c531c60425b4 100644 --- a/sys/dev/ofw/ofcons.c +++ b/sys/dev/ofw/ofcons.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofcons.c,v 1.28 2006/07/21 16:48:51 ad Exp $ */ +/* $NetBSD: ofcons.c,v 1.29 2006/10/01 19:28:44 elad Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ofcons.c,v 1.28 2006/07/21 16:48:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofcons.c,v 1.29 2006/10/01 19:28:44 elad Exp $"); #include #include @@ -137,6 +137,8 @@ ofcons_open(dev, flag, mode, l) tp->t_oproc = ofcons_start; tp->t_param = ofcons_param; tp->t_dev = dev; + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); if (!(tp->t_state & TS_ISOPEN)) { ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; @@ -146,10 +148,7 @@ ofcons_open(dev, flag, mode, l) tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; ofcons_param(tp, &tp->t_termios); ttsetwater(tp); - } else if ((tp->t_state&TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag)) - return EBUSY; + } tp->t_state |= TS_CARR_ON; if (!(sc->of_flags & OFPOLL)) { diff --git a/sys/dev/pci/cz.c b/sys/dev/pci/cz.c index c94bb947b706..41cab4462a66 100644 --- a/sys/dev/pci/cz.c +++ b/sys/dev/pci/cz.c @@ -1,4 +1,4 @@ -/* $NetBSD: cz.c,v 1.38 2006/07/21 16:48:51 ad Exp $ */ +/* $NetBSD: cz.c,v 1.39 2006/10/01 19:28:44 elad Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cz.c,v 1.38 2006/07/21 16:48:51 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cz.c,v 1.39 2006/10/01 19:28:44 elad Exp $"); #include #include @@ -960,10 +960,7 @@ czttyopen(dev_t dev, int flags, int mode, struct lwp *l) cz = CZTTY_CZ(sc); tp = sc->sc_tty; - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/qbus/dhu.c b/sys/dev/qbus/dhu.c index 442a4b9718db..c4e50b03817b 100644 --- a/sys/dev/qbus/dhu.c +++ b/sys/dev/qbus/dhu.c @@ -1,4 +1,4 @@ -/* $NetBSD: dhu.c,v 1.45 2006/07/21 16:48:52 ad Exp $ */ +/* $NetBSD: dhu.c,v 1.46 2006/10/01 19:28:44 elad Exp $ */ /* * Copyright (c) 2003, Hugh Graham. * Copyright (c) 1992, 1993 @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.45 2006/07/21 16:48:52 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dhu.c,v 1.46 2006/10/01 19:28:44 elad Exp $"); #include #include @@ -456,6 +456,10 @@ dhuopen(dev, flag, mode, l) tp->t_param = dhuparam; tp->t_hwiflow = dhuiflow; tp->t_dev = dev; + + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if ((tp->t_state & TS_ISOPEN) == 0) { ttychars(tp); if (tp->t_ispeed == 0) { @@ -467,10 +471,7 @@ dhuopen(dev, flag, mode, l) } (void) dhuparam(tp, &tp->t_termios); ttsetwater(tp); - } else if ((tp->t_state & TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) - return (EBUSY); + } /* Use DMBIS and *not* DMSET or else we clobber incoming bits */ if (dhumctl(sc, line, DML_DTR|DML_RTS, DMBIS) & DML_DCD) tp->t_state |= TS_CARR_ON; diff --git a/sys/dev/qbus/dl.c b/sys/dev/qbus/dl.c index 27a883575cb2..b24926d8e286 100644 --- a/sys/dev/qbus/dl.c +++ b/sys/dev/qbus/dl.c @@ -1,4 +1,4 @@ -/* $NetBSD: dl.c,v 1.35 2006/07/21 16:48:52 ad Exp $ */ +/* $NetBSD: dl.c,v 1.36 2006/10/01 19:28:44 elad Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -111,7 +111,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dl.c,v 1.35 2006/07/21 16:48:52 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dl.c,v 1.36 2006/10/01 19:28:44 elad Exp $"); #include #include @@ -343,6 +343,9 @@ dlopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_param = dlparam; tp->t_dev = dev; + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if (!(tp->t_state & TS_ISOPEN)) { ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; @@ -355,10 +358,7 @@ dlopen(dev_t dev, int flag, int mode, struct lwp *l) dlparam(tp, &tp->t_termios); ttsetwater(tp); - } else if ((tp->t_state & TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) - return EBUSY; + } return ((*tp->t_linesw->l_open)(dev, tp)); } diff --git a/sys/dev/sbus/magma.c b/sys/dev/sbus/magma.c index 72431da79767..ff4b50df1e49 100644 --- a/sys/dev/sbus/magma.c +++ b/sys/dev/sbus/magma.c @@ -1,4 +1,4 @@ -/* $NetBSD: magma.c,v 1.36 2006/09/23 04:45:49 jmcneill Exp $ */ +/* $NetBSD: magma.c,v 1.37 2006/10/01 19:28:44 elad Exp $ */ /* * magma.c * @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: magma.c,v 1.36 2006/09/23 04:45:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: magma.c,v 1.37 2006/10/01 19:28:44 elad Exp $"); #if 0 #define MAGMA_DEBUG @@ -923,10 +923,7 @@ mttyopen(dev, flags, mode, l) tp = mp->mp_tty; tp->t_dev = dev; - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/sbus/spif.c b/sys/dev/sbus/spif.c index 4dd22f4c3c28..4b54ee41dfbf 100644 --- a/sys/dev/sbus/spif.c +++ b/sys/dev/sbus/spif.c @@ -1,4 +1,4 @@ -/* $NetBSD: spif.c,v 1.7 2006/07/21 16:48:52 ad Exp $ */ +/* $NetBSD: spif.c,v 1.8 2006/10/01 19:28:44 elad Exp $ */ /* $OpenBSD: spif.c,v 1.12 2003/10/03 16:44:51 miod Exp $ */ /* @@ -41,7 +41,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: spif.c,v 1.7 2006/07/21 16:48:52 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spif.c,v 1.8 2006/10/01 19:28:44 elad Exp $"); #include "spif.h" #if NSPIF > 0 @@ -352,6 +352,9 @@ stty_open(dev, flags, mode, l) tp = sp->sp_tty; tp->t_dev = dev; + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) { ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; @@ -384,11 +387,6 @@ stty_open(dev, flags, mode, l) SET(tp->t_state, TS_CARR_ON); else CLR(tp->t_state, TS_CARR_ON); - } - else if (ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) { - return (EBUSY); } else { s = spltty(); } diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 4078c725ee6d..a2bb2649b1d0 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -1,4 +1,4 @@ -/* $NetBSD: ucom.c,v 1.65 2006/07/21 16:48:53 ad Exp $ */ +/* $NetBSD: ucom.c,v 1.66 2006/10/01 19:28:44 elad Exp $ */ /* * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.65 2006/07/21 16:48:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.66 2006/10/01 19:28:44 elad Exp $"); #include #include @@ -326,10 +326,7 @@ ucomopen(dev_t dev, int flag, int mode, struct lwp *l) DPRINTF(("ucomopen: unit=%d, tp=%p\n", unit, tp)); - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c index a3362c2330e4..6cadf0cd37f7 100644 --- a/sys/dev/usb/ucycom.c +++ b/sys/dev/usb/ucycom.c @@ -1,4 +1,4 @@ -/* $NetBSD: ucycom.c,v 1.11 2006/07/21 16:48:53 ad Exp $ */ +/* $NetBSD: ucycom.c,v 1.12 2006/10/01 19:28:44 elad Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include -__RCSID("$NetBSD: ucycom.c,v 1.11 2006/07/21 16:48:53 ad Exp $"); +__RCSID("$NetBSD: ucycom.c,v 1.12 2006/10/01 19:28:44 elad Exp $"); #include #include @@ -332,10 +332,7 @@ ucycomopen(dev_t dev, int flag, int mode, struct lwp *l) DPRINTF(("ucycomopen: tp=%p\n", tp)); - if (ISSET(tp->t_state, TS_ISOPEN) && - ISSET(tp->t_state, TS_XCLUDE) && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) + if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp)) return (EBUSY); s = spltty(); diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index c211d7952f7a..9bfce05d0660 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay.c,v 1.100 2006/07/21 16:48:53 ad Exp $ */ +/* $NetBSD: wsdisplay.c,v 1.101 2006/10/01 19:28:44 elad Exp $ */ /* * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.100 2006/07/21 16:48:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wsdisplay.c,v 1.101 2006/10/01 19:28:44 elad Exp $"); #include "opt_wsdisplay_compat.h" #include "opt_wsmsgattrs.h" @@ -747,6 +747,11 @@ wsdisplayopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_param = wsdisplayparam; tp->t_dev = dev; newopen = (tp->t_state & TS_ISOPEN) == 0; + + if (kauth_authorize_device_tty(l->l_cred, + KAUTH_DEVICE_TTY_OPEN, tp)) + return (EBUSY); + if (newopen) { ttychars(tp); tp->t_iflag = TTYDEF_IFLAG; @@ -756,10 +761,7 @@ wsdisplayopen(dev_t dev, int flag, int mode, struct lwp *l) tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; wsdisplayparam(tp, &tp->t_termios); ttsetwater(tp); - } else if ((tp->t_state & TS_XCLUDE) != 0 && - kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER, - &l->l_acflag) != 0) - return EBUSY; + } tp->t_state |= TS_CARR_ON; error = ((*tp->t_linesw->l_open)(dev, tp));