Adapt MD code to KAUTH_DEVICE_TTY_OPEN, batch #2 from Matt Fleming, thanks!

Also, add forgotten splx() calls in some places.
This commit is contained in:
elad 2006-10-01 19:28:43 +00:00
parent 7be862b0db
commit bdc51baebb
26 changed files with 118 additions and 148 deletions

View File

@ -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 <sys/cdefs.h> /* 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 <sys/param.h>
#include <sys/systm.h>
@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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);

View File

@ -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 <sys/cdefs.h>
__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;

View File

@ -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 <sys/cdefs.h>
__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));

View File

@ -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 <sys/cdefs.h>
__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();

View File

@ -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 <sys/cdefs.h>
__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);

View File

@ -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 <sys/cdefs.h>
__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));

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/user.h>
@ -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);

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/conf.h>
@ -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();

View File

@ -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 <sys/cdefs.h>
__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;
/*

View File

@ -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 <sys/cdefs.h>
__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();

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/ioctl.h>
@ -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();
}

View File

@ -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 <sys/cdefs.h>
__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();

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/proc.h>
@ -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();

View File

@ -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 <sys/cdefs.h>
__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();

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/conf.h>
@ -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)) {

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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();

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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));
}

View File

@ -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 <sys/cdefs.h>
__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();

View File

@ -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 <sys/cdefs.h>
__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();
}

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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();

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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();

View File

@ -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 <sys/cdefs.h>
__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));