1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Use suser() to check for super user rather than examining cr_uid directly.

Use TTYDEF_SPEED rather than 9600 a couple of places.

Reviewed by:	bde, with a few grumbles.
This commit is contained in:
Poul-Henning Kamp 1999-01-30 12:17:38 +00:00
parent 871f5df0ef
commit 4e2d2aa1cd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43425
28 changed files with 77 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $Id: promcons.c,v 1.2 1998/07/05 11:59:44 dfr Exp $ */
/* $Id: promcons.c,v 1.3 1998/07/12 16:15:02 dfr Exp $ */
/* $NetBSD: promcons.c,v 1.13 1998/03/21 22:52:59 mycroft Exp $ */
/*
@ -112,11 +112,12 @@ promopen(dev, flag, mode, p)
tp->t_oflag = TTYDEF_OFLAG;
tp->t_cflag = TTYDEF_CFLAG|CLOCAL;
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = 9600;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
ttsetwater(tp);
setuptimeout = 1;
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) {
} else if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
splx(s);
return EBUSY;
}

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: zs_tlsb.c,v 1.5 1998/07/31 09:20:01 dfr Exp $
* $Id: zs_tlsb.c,v 1.6 1998/11/15 18:25:16 dfr Exp $
*/
/*
* This driver is a hopeless hack to get the SimOS console working. A real
@ -266,9 +266,10 @@ zsopen(dev_t dev, int flag, int mode, struct proc *p)
tp->t_oflag = TTYDEF_OFLAG;
tp->t_cflag = TTYDEF_CFLAG|CLOCAL;
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = 9600;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
ttsetwater(tp);
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) {
} else if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
splx(s);
return EBUSY;
}

View File

@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: cy.c,v 1.83 1999/01/08 19:17:46 bde Exp $
* $Id: cy.c,v 1.84 1999/01/28 01:59:53 dillon Exp $
*/
#include "opt_compat.h"
@ -728,7 +728,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: cy.c,v 1.83 1999/01/08 19:17:46 bde Exp $
* $Id: cy.c,v 1.84 1999/01/28 01:59:53 dillon Exp $
*/
#include "opt_compat.h"
@ -728,7 +728,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -1,5 +1,5 @@
/*-
* dgb.c $Id: dgb.c,v 1.40 1998/08/23 08:26:39 bde Exp $
* dgb.c $Id: dgb.c,v 1.41 1998/12/07 21:58:17 archie Exp $
*
* Digiboard driver.
*
@ -1032,7 +1032,8 @@ dgbopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -1,5 +1,5 @@
/*-
* $Id: dgm.c,v 1.5 1998/08/23 08:26:40 bde Exp $
* $Id: dgm.c,v 1.6 1998/12/07 21:58:18 archie Exp $
*
* This driver and the associated header files support the ISA PC/Xem
* Digiboards. Its evolutionary roots are described below.
@ -833,7 +833,8 @@ dgmopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -766,7 +766,8 @@ rcopen(dev, flag, mode, p)
goto again;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -1346,7 +1346,8 @@ rpopen(dev, flag, mode, p)
goto open_top;
}
}
if(tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if(tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
splx(oldspl);
return(EBUSY);
}

View File

@ -30,7 +30,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE AUTHORS BE LIABLE.
*
* $Id: si.c,v 1.77 1998/08/23 10:12:12 bde Exp $
* $Id: si.c,v 1.78 1999/01/12 00:36:35 eivind Exp $
*/
#ifndef lint
@ -1205,7 +1205,8 @@ siopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
DPRINT((pp, DBG_OPEN|DBG_FAIL,
"already open and EXCLUSIVE set\n"));
error = EBUSY;

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sio.c,v 1.219 1998/12/13 23:12:54 steve Exp $
* $Id: sio.c,v 1.220 1999/01/19 00:21:47 peter Exp $
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* from: i386/isa sio.c,v 1.215
*/
@ -1205,7 +1205,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.295 1999/01/28 01:59:48 dillon Exp $
* $Id: syscons.c,v 1.296 1999/01/28 17:31:58 dillon Exp $
*/
#include "sc.h"
@ -707,7 +707,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
mouse_level = 0; /* XXX */
}
else
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
if (tp->t_state & TS_XCLUDE && suser(p->p_ucred, &p->p_acflag))
return(EBUSY);
if (minor(dev) < MAXCONS && !console[minor(dev)]) {
console[minor(dev)] = alloc_scp();

View File

@ -1,5 +1,5 @@
/*-
* dgb.c $Id: dgb.c,v 1.40 1998/08/23 08:26:39 bde Exp $
* dgb.c $Id: dgb.c,v 1.41 1998/12/07 21:58:17 archie Exp $
*
* Digiboard driver.
*
@ -1032,7 +1032,8 @@ dgbopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -1,5 +1,5 @@
/*-
* $Id: dgm.c,v 1.5 1998/08/23 08:26:40 bde Exp $
* $Id: dgm.c,v 1.6 1998/12/07 21:58:18 archie Exp $
*
* This driver and the associated header files support the ISA PC/Xem
* Digiboards. Its evolutionary roots are described below.
@ -833,7 +833,8 @@ dgmopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -153,7 +153,7 @@ int cxopen (dev_t dev, int flag, int mode, struct proc *p)
tp = c->ttyp;
tp->t_dev = dev;
if ((tp->t_state & TS_ISOPEN) && (tp->t_state & TS_XCLUDE) &&
p->p_ucred->cr_uid != 0)
suser(p->p_ucred, &p->p_acflag))
return (EBUSY);
if (! (tp->t_state & TS_ISOPEN)) {
ttychars (tp);

View File

@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: cy.c,v 1.83 1999/01/08 19:17:46 bde Exp $
* $Id: cy.c,v 1.84 1999/01/28 01:59:53 dillon Exp $
*/
#include "opt_compat.h"
@ -728,7 +728,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: istallion.c,v 1.22 1998/08/23 09:57:09 bde Exp $
* $Id: istallion.c,v 1.23 1999/01/12 01:17:01 eivind Exp $
*/
/*****************************************************************************/
@ -129,7 +129,7 @@
#define STL_MEMDEV 0x07000000
#define STL_DEFSPEED 9600
#define STL_DEFSPEED TTYDEF_SPEED
#define STL_DEFCFLAG (CS8 | CREAD | HUPCL)
/*****************************************************************************/
@ -1009,7 +1009,8 @@ STATIC int stliopen(dev_t dev, int flag, int mode, struct proc *p)
goto stliopen_restart;
}
}
if ((tp->t_state & TS_XCLUDE) && (p->p_ucred->cr_uid != 0)) {
if ((tp->t_state & TS_XCLUDE) &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto stliopen_end;
}

View File

@ -517,7 +517,7 @@ pcopen(Dev_t dev, int flag, int mode, struct proc *p)
(*linesw[tp->t_line].l_modem)(tp, 1); /* fake connection */
winsz = 1; /* set winsize later */
}
else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
else if (tp->t_state & TS_XCLUDE && suser(p->p_ucred, &p->p_acflag))
return (EBUSY);
#if PCVT_NETBSD || (PCVT_FREEBSD >= 200)

View File

@ -766,7 +766,8 @@ rcopen(dev, flag, mode, p)
goto again;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -1346,7 +1346,8 @@ rpopen(dev, flag, mode, p)
goto open_top;
}
}
if(tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if(tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
splx(oldspl);
return(EBUSY);
}

View File

@ -30,7 +30,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE AUTHORS BE LIABLE.
*
* $Id: si.c,v 1.77 1998/08/23 10:12:12 bde Exp $
* $Id: si.c,v 1.78 1999/01/12 00:36:35 eivind Exp $
*/
#ifndef lint
@ -1205,7 +1205,8 @@ siopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
DPRINT((pp, DBG_OPEN|DBG_FAIL,
"already open and EXCLUSIVE set\n"));
error = EBUSY;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* $Id: sio.c,v 1.224 1999/01/19 00:21:41 peter Exp $
* $Id: sio.c,v 1.225 1999/01/26 04:02:54 steve Exp $
*/
#include "opt_comconsole.h"
@ -1154,7 +1154,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: stallion.c,v 1.23 1998/10/22 05:58:40 bde Exp $
* $Id: stallion.c,v 1.24 1999/01/12 00:36:36 eivind Exp $
*/
/*****************************************************************************/
@ -119,7 +119,7 @@ static unsigned int stl_irqshared = 0;
#define STL_MEMDEV 0x07000000
#define STL_DEFSPEED 9600
#define STL_DEFSPEED TTYDEF_SPEED
#define STL_DEFCFLAG (CS8 | CREAD | HUPCL)
/*
@ -825,7 +825,8 @@ STATIC int stlopen(dev_t dev, int flag, int mode, struct proc *p)
goto stlopen_restart;
}
}
if ((tp->t_state & TS_XCLUDE) && (p->p_ucred->cr_uid != 0)) {
if ((tp->t_state & TS_XCLUDE) &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto stlopen_end;
}

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sio.c,v 1.219 1998/12/13 23:12:54 steve Exp $
* $Id: sio.c,v 1.220 1999/01/19 00:21:47 peter Exp $
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* from: i386/isa sio.c,v 1.215
*/
@ -1205,7 +1205,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
* $Id: tty.c,v 1.111 1999/01/08 17:31:12 eivind Exp $
* $Id: tty.c,v 1.112 1999/01/28 17:32:00 dillon Exp $
*/
/*-
@ -981,9 +981,9 @@ ttioctl(tp, cmd, data, flag)
splx(s);
break;
case TIOCSTI: /* simulate terminal input */
if (p->p_ucred->cr_uid && (flag & FREAD) == 0)
if ((flag & FREAD) == 0 && suser(p->p_ucred, &p->p_acflag))
return (EPERM);
if (p->p_ucred->cr_uid && !isctty(p, tp))
if (!isctty(p, tp) && suser(p->p_ucred, &p->p_acflag))
return (EACCES);
s = spltty();
(*linesw[tp->t_line].l_rint)(*(u_char *)data, tp);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
* $Id: tty_pty.c,v 1.53 1998/07/15 12:18:30 bde Exp $
* $Id: tty_pty.c,v 1.54 1998/08/23 08:26:42 bde Exp $
*/
/*
@ -183,7 +183,7 @@ ptsopen(dev, flag, devtype, p)
tp->t_lflag = TTYDEF_LFLAG;
tp->t_cflag = TTYDEF_CFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
} else if (tp->t_state & TS_XCLUDE && suser(p->p_ucred, &p->p_acflag))
return (EBUSY);
if (tp->t_oproc) /* Ctrlr still around. */
(void)(*linesw[tp->t_line].l_modem)(tp, 1);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* $Id: sio.c,v 1.77 1999/01/27 08:26:16 kato Exp $
* $Id: sio.c,v 1.78 1999/01/28 11:24:36 kato Exp $
*/
#include "opt_comconsole.h"
@ -1912,7 +1912,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
* $Id: sio.c,v 1.77 1999/01/27 08:26:16 kato Exp $
* $Id: sio.c,v 1.78 1999/01/28 11:24:36 kato Exp $
*/
#include "opt_comconsole.h"
@ -1912,7 +1912,8 @@ sioopen(dev, flag, mode, p)
goto open_top;
}
}
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
if (tp->t_state & TS_XCLUDE &&
suser(p->p_ucred, &p->p_acflag)) {
error = EBUSY;
goto out;
}

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.109 1999/01/19 12:41:26 kato Exp $
* $Id: syscons.c,v 1.110 1999/01/27 08:22:08 kato Exp $
*/
#include "sc.h"
@ -753,7 +753,7 @@ scopen(dev_t dev, int flag, int mode, struct proc *p)
}
}
else
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
if (tp->t_state & TS_XCLUDE && suser(p->p_ucred, &p->p_acflag))
return(EBUSY);
if (minor(dev) < MAXCONS && !console[minor(dev)]) {
console[minor(dev)] = alloc_scp();