Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
This commit is contained in:
parent
a4a49508b4
commit
44731cab3b
@ -123,7 +123,7 @@ promopen(dev, flag, mode, td)
|
||||
ttsetwater(tp);
|
||||
|
||||
setuptimeout = 1;
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) {
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td)) {
|
||||
splx(s);
|
||||
return EBUSY;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ alpha_sethae(struct thread *td, char *args)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
error = suser(td->td_proc);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
|
@ -1062,7 +1062,7 @@ osf1_setuid(td, uap)
|
||||
uid = SCARG(uap, uid);
|
||||
oldcred = p->p_ucred;
|
||||
|
||||
if ((error = suser_xxx(p->p_ucred, NULL, PRISON_ROOT)) != 0 &&
|
||||
if ((error = suser_cred(p->p_ucred, PRISON_ROOT)) != 0 &&
|
||||
uid != oldcred->cr_ruid && uid != oldcred->cr_svuid)
|
||||
return (error);
|
||||
|
||||
@ -1108,7 +1108,7 @@ osf1_setgid(td, uap)
|
||||
gid = SCARG(uap, gid);
|
||||
oldcred = p->p_ucred;
|
||||
|
||||
if (((error = suser_xxx(p->p_ucred, NULL, PRISON_ROOT)) != 0 ) &&
|
||||
if (((error = suser_cred(p->p_ucred, PRISON_ROOT)) != 0 ) &&
|
||||
gid != oldcred->cr_rgid && gid != oldcred->cr_svgid)
|
||||
return (error);
|
||||
|
||||
|
@ -290,7 +290,7 @@ zsopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
|
||||
ttsetwater(tp);
|
||||
setuptimeout = 1;
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) {
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td)) {
|
||||
splx(s);
|
||||
return EBUSY;
|
||||
}
|
||||
|
@ -2140,7 +2140,7 @@ set_dbregs(struct thread *td, struct dbreg *dbregs)
|
||||
* from within kernel mode?
|
||||
*/
|
||||
|
||||
if (suser_td(td) != 0) {
|
||||
if (suser(td) != 0) {
|
||||
if (dbregs->dr7 & 0x3) {
|
||||
/* dr0 is enabled */
|
||||
if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
|
||||
|
@ -122,7 +122,7 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
|
@ -183,7 +183,7 @@ i386_set_ioperm(td, args)
|
||||
if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
|
||||
return (error);
|
||||
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
||||
return (error);
|
||||
|
@ -980,7 +980,7 @@ linux_setgroups(struct thread *td, struct linux_setgroups_args *args)
|
||||
* Keep cr_groups[0] unchanged to prevent that.
|
||||
*/
|
||||
|
||||
if ((error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
if ((error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
return (error);
|
||||
|
||||
if (ngrp >= NGROUPS)
|
||||
|
@ -108,7 +108,7 @@ linux_setgroups16(struct thread *td, struct linux_setgroups16_args *args)
|
||||
* Keep cr_groups[0] unchanged to prevent that.
|
||||
*/
|
||||
|
||||
if ((error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
if ((error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
return (error);
|
||||
|
||||
if (ngrp >= NGROUPS)
|
||||
|
@ -264,7 +264,7 @@ fd_revoke(td, fd)
|
||||
goto out;
|
||||
|
||||
if (td->td_ucred->cr_uid != vattr.va_uid &&
|
||||
(error = suser_td(td)) != 0)
|
||||
(error = suser(td)) != 0)
|
||||
goto out;
|
||||
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
|
@ -607,7 +607,7 @@ svr4_sys_fchroot(td, uap)
|
||||
struct file *fp;
|
||||
int error;
|
||||
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return error;
|
||||
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
|
||||
return error;
|
||||
|
@ -559,13 +559,13 @@ svr4_sys_systeminfo(td, uap)
|
||||
break;
|
||||
#if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
|
||||
case SVR4_SI_SET_HOSTNAME:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return error;
|
||||
name = KERN_HOSTNAME;
|
||||
return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, td);
|
||||
|
||||
case SVR4_SI_SET_SRPC_DOMAIN:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return error;
|
||||
name = KERN_NISDOMAINNAME;
|
||||
return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, td);
|
||||
|
@ -1266,7 +1266,7 @@ an_ioctl(ifp, command, data)
|
||||
int i;
|
||||
struct an_softc *sc;
|
||||
struct ifreq *ifr;
|
||||
struct proc *p = curproc;
|
||||
struct thread *td = curthread;
|
||||
struct ieee80211req *ireq;
|
||||
u_int8_t tmpstr[IEEE80211_NWID_LEN*2];
|
||||
u_int8_t *tmpptr;
|
||||
@ -1353,7 +1353,7 @@ an_ioctl(ifp, command, data)
|
||||
error = copyout(&sc->areq, ifr->ifr_data, sizeof(sc->areq));
|
||||
break;
|
||||
case SIOCSAIRONET:
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
|
||||
if (error != 0)
|
||||
@ -1361,7 +1361,7 @@ an_ioctl(ifp, command, data)
|
||||
an_setdef(sc, &sc->areq);
|
||||
break;
|
||||
case SIOCGPRIVATE_0: /* used by Cisco client utility */
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
|
||||
mode = l_ioctl.command;
|
||||
@ -1381,7 +1381,7 @@ an_ioctl(ifp, command, data)
|
||||
|
||||
break;
|
||||
case SIOCGPRIVATE_1: /* used by Cisco client utility */
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
|
||||
l_ioctl.command = 0;
|
||||
@ -1614,7 +1614,7 @@ an_ioctl(ifp, command, data)
|
||||
}
|
||||
break;
|
||||
case SIOCS80211:
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
sc->areq.an_len = sizeof(sc->areq);
|
||||
/*
|
||||
|
@ -3879,7 +3879,7 @@ asr_open(
|
||||
s = splcam ();
|
||||
if (ASR_ctlr_held) {
|
||||
error = EBUSY;
|
||||
} else if ((error = suser(td->td_proc)) == 0) {
|
||||
} else if ((error = suser(td)) == 0) {
|
||||
++ASR_ctlr_held;
|
||||
}
|
||||
splx(s);
|
||||
|
@ -573,7 +573,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
|
||||
break;
|
||||
|
||||
case CDIOCRESET:
|
||||
error = suser(td->td_proc);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
break;
|
||||
error = atapi_test_ready(cdp->device);
|
||||
|
@ -521,7 +521,11 @@ awi_ioctl(ifp, cmd, data)
|
||||
break;
|
||||
case SIOCS80211NWID:
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ >= 5
|
||||
error = suser(curthread);
|
||||
#else
|
||||
error = suser(curproc);
|
||||
#endif
|
||||
if (error)
|
||||
break;
|
||||
#endif
|
||||
@ -555,7 +559,11 @@ awi_ioctl(ifp, cmd, data)
|
||||
break;
|
||||
case SIOCS80211NWKEY:
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ >= 5
|
||||
error = suser(curthread);
|
||||
#else
|
||||
error = suser(curproc);
|
||||
#endif
|
||||
if (error)
|
||||
break;
|
||||
#endif
|
||||
@ -613,7 +621,11 @@ awi_ioctl(ifp, cmd, data)
|
||||
error = awi_wep_getkey(sc, ireq->i_val, tmpstr, &len);
|
||||
if(error)
|
||||
break;
|
||||
#if __FreeBSD__ >= 5
|
||||
if(!suser(curthread))
|
||||
#else
|
||||
if(!suser(curproc))
|
||||
#endif
|
||||
bzero(tmpstr, len);
|
||||
ireq->i_len = len;
|
||||
error = copyout(tmpstr, ireq->i_data, len);
|
||||
@ -650,7 +662,11 @@ awi_ioctl(ifp, cmd, data)
|
||||
}
|
||||
break;
|
||||
case SIOCS80211:
|
||||
#if __FreeBSD__ >= 5
|
||||
error = suser(curthread);
|
||||
#else
|
||||
error = suser(curproc);
|
||||
#endif
|
||||
if(error)
|
||||
break;
|
||||
switch(ireq->i_type) {
|
||||
|
@ -189,7 +189,11 @@ awi_wep_getnwkey(sc, nwkey)
|
||||
nwkey->i_defkid = sc->sc_wep_defkid + 1;
|
||||
/* do not show any keys to non-root user */
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ >= 5
|
||||
suerr = suser(curthread);
|
||||
#else
|
||||
suerr = suser(curproc);
|
||||
#endif
|
||||
#else
|
||||
suerr = suser(curproc->p_ucred, &curproc->p_acflag);
|
||||
#endif
|
||||
|
@ -108,7 +108,11 @@ awi_wicfg(ifp, cmd, data)
|
||||
break;
|
||||
case SIOCSWAVELAN:
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ >= 5
|
||||
error = suser(curthread);
|
||||
#else
|
||||
error = suser(curproc);
|
||||
#endif
|
||||
#else
|
||||
error = suser(curproc->p_ucred, &curproc->p_acflag);
|
||||
#endif
|
||||
@ -272,7 +276,11 @@ awi_cfgget(ifp, cmd, data)
|
||||
keys = (struct wi_ltv_keys *)&wreq;
|
||||
/* do not show keys to non-root user */
|
||||
#ifdef __FreeBSD__
|
||||
#if __FreeBSD__ >= 5
|
||||
error = suser(curthread);
|
||||
#else
|
||||
error = suser(curproc);
|
||||
#endif
|
||||
#else
|
||||
error = suser(curproc->p_ucred, &curproc->p_acflag);
|
||||
#endif
|
||||
|
@ -1239,7 +1239,11 @@ cnw_ioctl(ifp, cmd, data)
|
||||
#endif
|
||||
struct ifreq *ifr = (struct ifreq *)data;
|
||||
int s, error = 0;
|
||||
struct proc *p = curproc; /*XXX*/
|
||||
#if __FreeBSD__ >= 5
|
||||
struct thread *td = curthread; /* XXX */
|
||||
#else
|
||||
struct proc *td = curproc; /*XXX*/
|
||||
#endif
|
||||
|
||||
s = splnet();
|
||||
|
||||
@ -1331,7 +1335,7 @@ cnw_ioctl(ifp, cmd, data)
|
||||
#if !defined(__FreeBSD__)
|
||||
error = suser(p->p_ucred, &p->p_acflag);
|
||||
#else
|
||||
error = suser(p);
|
||||
error = suser(td);
|
||||
#endif
|
||||
if (error)
|
||||
break;
|
||||
@ -1342,7 +1346,7 @@ cnw_ioctl(ifp, cmd, data)
|
||||
#if !defined(__FreeBSD__)
|
||||
error = suser(p->p_ucred, &p->p_acflag);
|
||||
#else
|
||||
error = suser(p);
|
||||
error = suser(td);
|
||||
#endif
|
||||
if (error)
|
||||
break;
|
||||
@ -1353,7 +1357,7 @@ cnw_ioctl(ifp, cmd, data)
|
||||
#if !defined(__FreeBSD__)
|
||||
error = suser(p->p_ucred, &p->p_acflag);
|
||||
#else
|
||||
error = suser(p);
|
||||
error = suser(td);
|
||||
#endif
|
||||
if (error)
|
||||
break;
|
||||
|
@ -718,7 +718,7 @@ sioopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1637,7 +1637,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1736,7 +1736,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
/* must be root since the wait applies to following logins */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -718,7 +718,7 @@ sioopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1637,7 +1637,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1736,7 +1736,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
/* must be root since the wait applies to following logins */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -1050,7 +1050,7 @@ dgbopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1548,7 +1548,7 @@ dgbioctl(dev, cmd, data, flag, td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1770,7 +1770,7 @@ dgbioctl(dev, cmd, data, flag, td)
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
/* must be root since the wait applies to following logins */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -783,7 +783,7 @@ digiopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
goto open_top;
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE && suser(td->td_proc) != 0) {
|
||||
if (tp->t_state & TS_XCLUDE && suser(td) != 0) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1146,7 +1146,7 @@ digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1317,7 +1317,7 @@ digiioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
*(int *)data = digimctl(port, 0, DMGET);
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -2644,7 +2644,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
* Set density definition permanently. Only
|
||||
* allow for superuser.
|
||||
*/
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
fd->fts[type] = *(struct fd_type *)addr;
|
||||
}
|
||||
@ -2669,7 +2669,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
#endif
|
||||
|
||||
case FD_CLRERR:
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
fd->fdc->fdc_errs = 0;
|
||||
return (0);
|
||||
@ -2751,7 +2751,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
|
||||
case FD_STYPE: /* set drive type */
|
||||
/* this is considered harmful; only allow for superuser */
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
*fd->ft = *(struct fd_type *)addr;
|
||||
break;
|
||||
@ -2775,7 +2775,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
#endif
|
||||
|
||||
case FD_CLRERR:
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
fd->fdc->fdc_errs = 0;
|
||||
break;
|
||||
|
@ -209,7 +209,7 @@ nmdmopen(dev_t dev, int flag, int devtype, struct thread *td)
|
||||
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 && suser_td(td)) {
|
||||
} else if (tp->t_state & TS_XCLUDE && suser(td)) {
|
||||
return (EBUSY);
|
||||
} else if (pti->pt_prison != td->td_ucred->cr_prison) {
|
||||
return (EBUSY);
|
||||
|
@ -99,7 +99,7 @@ null_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
|
||||
|
||||
if (cmd != DIOCGKERNELDUMP)
|
||||
return (noioctl(dev, cmd, data, fflag, td));
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
return (set_dumper(NULL));
|
||||
|
@ -123,7 +123,7 @@ ofw_dev_open(dev_t dev, int flag, int mode, struct thread *td)
|
||||
ttsetwater(tp);
|
||||
|
||||
setuptimeout = 1;
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser_td(td)) {
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td)) {
|
||||
return (EBUSY);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ random_open(dev_t dev __unused, int flags, int fmt __unused, struct thread *td)
|
||||
int error;
|
||||
|
||||
if (flags & FWRITE) {
|
||||
error = suser(td->td_proc);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
@ -162,7 +162,7 @@ static int
|
||||
random_close(dev_t dev __unused, int flags, int fmt __unused, struct thread *td)
|
||||
{
|
||||
if (flags & FWRITE) {
|
||||
if (!(suser(td->td_proc) ||
|
||||
if (!(suser(td) ||
|
||||
securelevel_gt(td->td_ucred, 0)))
|
||||
random_reseed();
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ rcopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1118,7 +1118,7 @@ struct thread *td;
|
||||
break;
|
||||
|
||||
case TIOCMSDTRWAIT:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -1010,7 +1010,7 @@ rpopen(dev, flag, mode, td)
|
||||
goto open_top;
|
||||
}
|
||||
}
|
||||
if(tp->t_state & TS_XCLUDE && suser_td(td) != 0) {
|
||||
if(tp->t_state & TS_XCLUDE && suser(td) != 0) {
|
||||
splx(oldspl);
|
||||
error = EBUSY;
|
||||
goto out2;
|
||||
@ -1271,7 +1271,7 @@ rpioctl(dev, cmd, data, flag, td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if(error != 0)
|
||||
return(error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1416,7 +1416,7 @@ rpioctl(dev, cmd, data, flag, td)
|
||||
*(int *)data = result;
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if(error != 0) {
|
||||
splx(oldspl);
|
||||
return(error);
|
||||
|
@ -1042,6 +1042,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
{
|
||||
struct sbni_softc *sc;
|
||||
struct ifreq *ifr;
|
||||
struct thread *td;
|
||||
struct proc *p;
|
||||
struct sbni_in_stats *in_stats;
|
||||
struct sbni_flags flags;
|
||||
@ -1049,7 +1050,8 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
|
||||
sc = ifp->if_softc;
|
||||
ifr = (struct ifreq *)data;
|
||||
p = curproc;
|
||||
td = curthread;
|
||||
p = td->td_proc;
|
||||
error = 0;
|
||||
|
||||
s = splimp();
|
||||
@ -1114,7 +1116,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
|
||||
case SIOCSHWFLAGS: /* set flags */
|
||||
/* root only */
|
||||
error = suser(p);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
break;
|
||||
flags = *(struct sbni_flags*)&ifr->ifr_data;
|
||||
@ -1136,7 +1138,7 @@ sbni_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
||||
break;
|
||||
|
||||
case SIOCRINSTATS:
|
||||
if (!(error = suser(p))) /* root only */
|
||||
if (!(error = suser(td))) /* root only */
|
||||
bzero(&sc->in_stats, sizeof(struct sbni_in_stats));
|
||||
break;
|
||||
|
||||
|
@ -607,7 +607,7 @@ siopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
|
||||
/* quickly let in /dev/si_control */
|
||||
if (IS_CONTROLDEV(mynor)) {
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
return(error);
|
||||
return(0);
|
||||
}
|
||||
@ -686,7 +686,7 @@ siopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
DPRINT((pp, DBG_OPEN|DBG_FAIL,
|
||||
"already open and EXCLUSIVE set\n"));
|
||||
error = EBUSY;
|
||||
@ -951,7 +951,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1064,7 +1064,7 @@ siioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
/* must be root since the wait applies to following logins */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error == 0)
|
||||
pp->sp_dtr_wait = *(int *)data * hz / 100;
|
||||
break;
|
||||
@ -1117,7 +1117,7 @@ si_Sioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
|
||||
ip = (int *)data;
|
||||
|
||||
#define SUCHECK if ((error = suser_td(td))) goto out
|
||||
#define SUCHECK if ((error = suser(td))) goto out
|
||||
|
||||
switch (cmd) {
|
||||
case TCSIPORTS:
|
||||
|
@ -1206,7 +1206,7 @@ sioopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1980,7 +1980,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -2071,7 +2071,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
/* must be root since the wait applies to following logins */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -479,7 +479,7 @@ scopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
(*linesw[tp->t_line].l_modem)(tp, 1);
|
||||
}
|
||||
else
|
||||
if (tp->t_state & TS_XCLUDE && suser_td(td))
|
||||
if (tp->t_state & TS_XCLUDE && suser(td))
|
||||
return(EBUSY);
|
||||
|
||||
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
||||
@ -976,7 +976,7 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
return 0;
|
||||
|
||||
case KDENABIO: /* allow io operations */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return error;
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
|
@ -99,7 +99,7 @@ smopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
|
||||
smparam(tp, &tp->t_termios);
|
||||
(*linesw[tp->t_line].l_modem)(tp, 1);
|
||||
} else if (tp->t_state & TS_XCLUDE && suser_td(td)) {
|
||||
} else if (tp->t_state & TS_XCLUDE && suser(td)) {
|
||||
return EBUSY;
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ ucomopen(dev_t dev, int flag, int mode, usb_proc_ptr p)
|
||||
|
||||
if (ISSET(tp->t_state, TS_ISOPEN) &&
|
||||
ISSET(tp->t_state, TS_XCLUDE) &&
|
||||
suser_td(p))
|
||||
suser(p))
|
||||
return (EBUSY);
|
||||
|
||||
/*
|
||||
|
@ -593,7 +593,7 @@ umodemopen(dev_t dev, int flag, int mode, usb_proc_ptr p)
|
||||
|
||||
if (ISSET(tp->t_state, TS_ISOPEN) &&
|
||||
ISSET(tp->t_state, TS_XCLUDE) &&
|
||||
suser_td(p))
|
||||
suser(p))
|
||||
return (EBUSY);
|
||||
|
||||
/*
|
||||
|
@ -375,7 +375,7 @@ vinumopen(dev_t dev,
|
||||
}
|
||||
|
||||
case VINUM_SUPERDEV_TYPE:
|
||||
error = suser_td(td); /* are we root? */
|
||||
error = suser(td); /* are we root? */
|
||||
if (error == 0) { /* yes, can do */
|
||||
if (devminor == VINUM_DAEMON_DEV) /* daemon device */
|
||||
vinum_conf.flags |= VF_DAEMONOPEN; /* we're open */
|
||||
|
@ -1672,7 +1672,7 @@ wi_ioctl(ifp, command, data)
|
||||
struct wi_req wreq;
|
||||
struct ifreq *ifr;
|
||||
struct ieee80211req *ireq;
|
||||
struct proc *p = curproc;
|
||||
struct thread *td = curthread;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
WI_LOCK(sc);
|
||||
@ -1724,7 +1724,7 @@ wi_ioctl(ifp, command, data)
|
||||
if (error)
|
||||
break;
|
||||
/* Don't show WEP keys to non-root users. */
|
||||
if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS && suser(p))
|
||||
if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS && suser(td))
|
||||
break;
|
||||
if (wreq.wi_type == WI_RID_IFACE_STATS) {
|
||||
bcopy((char *)&sc->wi_stats, (char *)&wreq.wi_val,
|
||||
@ -1768,7 +1768,7 @@ wi_ioctl(ifp, command, data)
|
||||
error = copyout(&wreq, ifr->ifr_data, sizeof(wreq));
|
||||
break;
|
||||
case SIOCSWAVELAN:
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
|
||||
if (error)
|
||||
@ -1809,7 +1809,7 @@ wi_ioctl(ifp, command, data)
|
||||
error = copyout(&wreq, ifr->ifr_data, sizeof(wreq));
|
||||
break;
|
||||
case SIOCSPRISM2DEBUG:
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
|
||||
if (error)
|
||||
@ -1858,7 +1858,7 @@ wi_ioctl(ifp, command, data)
|
||||
break;
|
||||
}
|
||||
len = sc->wi_keys.wi_keys[ireq->i_val].wi_keylen;
|
||||
if (suser(p))
|
||||
if (suser(td))
|
||||
bcopy(sc->wi_keys.wi_keys[ireq->i_val].wi_keydat,
|
||||
tmpkey, len);
|
||||
else
|
||||
@ -1911,7 +1911,7 @@ wi_ioctl(ifp, command, data)
|
||||
}
|
||||
break;
|
||||
case SIOCS80211:
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
goto out;
|
||||
switch(ireq->i_type) {
|
||||
case IEEE80211_IOC_SSID:
|
||||
|
@ -1214,7 +1214,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
/* pointer to buffer in user space */
|
||||
up = (void *)ifr->ifr_data;
|
||||
/* work out if they're root */
|
||||
isroot = (suser_td(td) == 0);
|
||||
isroot = (suser(td) == 0);
|
||||
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
/* don't hand the DES key out to non-root users */
|
||||
@ -1229,7 +1229,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
/* copy the PSA in from the caller; we only copy _some_ values */
|
||||
case SIOCSWLPSA:
|
||||
/* root only */
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
break;
|
||||
error = EINVAL; /* assume the worst */
|
||||
/* pointer to buffer in user space containing data */
|
||||
@ -1283,7 +1283,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
*/
|
||||
case SIOCSWLCNWID:
|
||||
/* root only */
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
break;
|
||||
if (!(ifp->if_flags & IFF_UP)) {
|
||||
error = EIO; /* only allowed while up */
|
||||
@ -1301,7 +1301,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
/* copy the EEPROM in 2.4 Gz WaveMODEM out to the caller */
|
||||
case SIOCGWLEEPROM:
|
||||
/* root only */
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
break;
|
||||
/* pointer to buffer in user space */
|
||||
up = (void *)ifr->ifr_data;
|
||||
@ -1324,7 +1324,7 @@ wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
/* zero (Delete) the wl cache */
|
||||
case SIOCDWLCACHE:
|
||||
/* root only */
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
break;
|
||||
wl_cache_zero(unit);
|
||||
break;
|
||||
|
@ -238,7 +238,7 @@ cd9660_mount(mp, path, data, ndp, td)
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
|
||||
if (error)
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
|
@ -718,8 +718,7 @@ devfs_setattr(ap)
|
||||
if (uid != de->de_uid || gid != de->de_gid) {
|
||||
if (((ap->a_cred->cr_uid != de->de_uid) || uid != de->de_uid ||
|
||||
(gid != de->de_gid && !groupmember(gid, ap->a_cred))) &&
|
||||
(error = suser_xxx(NULL, ap->a_td->td_proc,
|
||||
PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT)) != 0)
|
||||
return (error);
|
||||
de->de_uid = uid;
|
||||
de->de_gid = gid;
|
||||
@ -736,21 +735,21 @@ devfs_setattr(ap)
|
||||
|
||||
if (vap->va_mode != (mode_t)VNOVAL) {
|
||||
if ((ap->a_cred->cr_uid != de->de_uid) &&
|
||||
(error = suser_xxx(NULL, ap->a_td->td_proc, PRISON_ROOT)))
|
||||
(error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT)))
|
||||
return (error);
|
||||
de->de_mode = vap->va_mode;
|
||||
c = 1;
|
||||
}
|
||||
if (vap->va_atime.tv_sec != VNOVAL) {
|
||||
if ((ap->a_cred->cr_uid != de->de_uid) &&
|
||||
(error = suser_xxx(NULL, ap->a_td->td_proc, PRISON_ROOT)))
|
||||
(error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT)))
|
||||
return (error);
|
||||
de->de_atime = vap->va_atime;
|
||||
c = 1;
|
||||
}
|
||||
if (vap->va_mtime.tv_sec != VNOVAL) {
|
||||
if ((ap->a_cred->cr_uid != de->de_uid) &&
|
||||
(error = suser_xxx(NULL, ap->a_td->td_proc, PRISON_ROOT)))
|
||||
(error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT)))
|
||||
return (error);
|
||||
de->de_mtime = vap->va_mtime;
|
||||
c = 1;
|
||||
@ -776,7 +775,7 @@ devfs_symlink(ap)
|
||||
struct devfs_dirent *de;
|
||||
struct devfs_mount *dmp;
|
||||
|
||||
error = suser(ap->a_cnp->cn_thread->td_proc);
|
||||
error = suser(ap->a_cnp->cn_thread);
|
||||
if (error)
|
||||
return(error);
|
||||
dmp = VFSTODEVFS(ap->a_dvp->v_mount);
|
||||
|
@ -529,7 +529,7 @@ hpfs_setattr(ap)
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != hp->h_uid &&
|
||||
(error = suser_xxx(cred, td->td_proc, PRISON_ROOT)) &&
|
||||
(error = suser_cred(cred, PRISON_ROOT)) &&
|
||||
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
|
||||
(error = VOP_ACCESS(vp, VWRITE, cred, td))))
|
||||
return (error);
|
||||
|
@ -194,7 +194,7 @@ msdosfs_mount(mp, path, data, ndp, td)
|
||||
* If upgrade to read-write by non-root, then verify
|
||||
* that user has necessary permissions on the device.
|
||||
*/
|
||||
if (suser_td(td)) {
|
||||
if (suser(td)) {
|
||||
devvp = pmp->pm_devvp;
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
error = VOP_ACCESS(devvp, VREAD | VWRITE,
|
||||
@ -241,7 +241,7 @@ msdosfs_mount(mp, path, data, ndp, td)
|
||||
* If mount by non-root, then verify that user has necessary
|
||||
* permissions on the device.
|
||||
*/
|
||||
if (suser_td(td)) {
|
||||
if (suser(td)) {
|
||||
accessmode = VREAD;
|
||||
if ((mp->mnt_flag & MNT_RDONLY) == 0)
|
||||
accessmode |= VWRITE;
|
||||
|
@ -376,7 +376,7 @@ msdosfs_setattr(ap)
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != pmp->pm_uid &&
|
||||
(error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT)))
|
||||
(error = suser_cred(cred, PRISON_ROOT)))
|
||||
return (error);
|
||||
/*
|
||||
* We are very inconsistent about handling unsupported
|
||||
@ -390,7 +390,7 @@ msdosfs_setattr(ap)
|
||||
* set ATTR_ARCHIVE for directories `cp -pr' from a more
|
||||
* sensible file system attempts it a lot.
|
||||
*/
|
||||
if (suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT)) {
|
||||
if (suser_cred(cred, PRISON_ROOT)) {
|
||||
if (vap->va_flags & SF_SETTABLE)
|
||||
return EPERM;
|
||||
}
|
||||
@ -417,7 +417,7 @@ msdosfs_setattr(ap)
|
||||
gid = pmp->pm_gid;
|
||||
if ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid ||
|
||||
(gid != pmp->pm_gid && !groupmember(gid, cred))) &&
|
||||
(error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT)))
|
||||
(error = suser_cred(cred, PRISON_ROOT)))
|
||||
return error;
|
||||
if (uid != pmp->pm_uid || gid != pmp->pm_gid)
|
||||
return EINVAL;
|
||||
@ -449,7 +449,7 @@ msdosfs_setattr(ap)
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != pmp->pm_uid &&
|
||||
(error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT)) &&
|
||||
(error = suser_cred(cred, PRISON_ROOT)) &&
|
||||
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
|
||||
(error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_td))))
|
||||
return (error);
|
||||
@ -472,7 +472,7 @@ msdosfs_setattr(ap)
|
||||
if (vp->v_mount->mnt_flag & MNT_RDONLY)
|
||||
return (EROFS);
|
||||
if (cred->cr_uid != pmp->pm_uid &&
|
||||
(error = suser_xxx(cred, ap->a_td->td_proc, PRISON_ROOT)))
|
||||
(error = suser_cred(cred, PRISON_ROOT)))
|
||||
return (error);
|
||||
if (vp->v_type != VDIR) {
|
||||
/* We ignore the read and execute bits. */
|
||||
|
@ -59,7 +59,7 @@ procfs_ioctl(PFS_IOCTL_ARGS)
|
||||
break;
|
||||
case PIOCSFL:
|
||||
flags = *(unsigned int *)data;
|
||||
if (flags & PF_ISUGID && (error = suser(td->td_proc)) != 0)
|
||||
if (flags & PF_ISUGID && (error = suser(td)) != 0)
|
||||
break;
|
||||
p->p_pfsflags = flags;
|
||||
break;
|
||||
|
@ -105,7 +105,7 @@ umapfs_mount(mp, path, data, ndp, td)
|
||||
/*
|
||||
* Only for root
|
||||
*/
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -233,7 +233,7 @@ ext2_mount(mp, path, data, ndp, td)
|
||||
* If upgrade to read-write by non-root, then verify
|
||||
* that user has necessary permissions on the device.
|
||||
*/
|
||||
if (suser_td(td)) {
|
||||
if (suser(td)) {
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
if ((error = VOP_ACCESS(devvp, VREAD | VWRITE,
|
||||
td->td_ucred, td)) != 0) {
|
||||
@ -286,7 +286,7 @@ ext2_mount(mp, path, data, ndp, td)
|
||||
* If mount by non-root, then verify that user has necessary
|
||||
* permissions on the device.
|
||||
*/
|
||||
if (suser_td(td)) {
|
||||
if (suser(td)) {
|
||||
accessmode = VREAD;
|
||||
if ((mp->mnt_flag & MNT_RDONLY) == 0)
|
||||
accessmode |= VWRITE;
|
||||
|
@ -1153,7 +1153,7 @@ ext2_makeinode(mode, dvp, vpp, cnp)
|
||||
tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */
|
||||
ip->i_nlink = 1;
|
||||
if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) &&
|
||||
suser_xxx(cnp->cn_cred, 0, PRISON_ROOT))
|
||||
suser_cred(cnp->cn_cred, PRISON_ROOT))
|
||||
ip->i_mode &= ~ISGID;
|
||||
|
||||
if (cnp->cn_flags & ISWHITEOUT)
|
||||
|
@ -233,7 +233,7 @@ ext2_mount(mp, path, data, ndp, td)
|
||||
* If upgrade to read-write by non-root, then verify
|
||||
* that user has necessary permissions on the device.
|
||||
*/
|
||||
if (suser_td(td)) {
|
||||
if (suser(td)) {
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
if ((error = VOP_ACCESS(devvp, VREAD | VWRITE,
|
||||
td->td_ucred, td)) != 0) {
|
||||
@ -286,7 +286,7 @@ ext2_mount(mp, path, data, ndp, td)
|
||||
* If mount by non-root, then verify that user has necessary
|
||||
* permissions on the device.
|
||||
*/
|
||||
if (suser_td(td)) {
|
||||
if (suser(td)) {
|
||||
accessmode = VREAD;
|
||||
if ((mp->mnt_flag & MNT_RDONLY) == 0)
|
||||
accessmode |= VWRITE;
|
||||
|
@ -1153,7 +1153,7 @@ ext2_makeinode(mode, dvp, vpp, cnp)
|
||||
tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */
|
||||
ip->i_nlink = 1;
|
||||
if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) &&
|
||||
suser_xxx(cnp->cn_cred, 0, PRISON_ROOT))
|
||||
suser_cred(cnp->cn_cred, PRISON_ROOT))
|
||||
ip->i_mode &= ~ISGID;
|
||||
|
||||
if (cnp->cn_flags & ISWHITEOUT)
|
||||
|
@ -2140,7 +2140,7 @@ set_dbregs(struct thread *td, struct dbreg *dbregs)
|
||||
* from within kernel mode?
|
||||
*/
|
||||
|
||||
if (suser_td(td) != 0) {
|
||||
if (suser(td) != 0) {
|
||||
if (dbregs->dr7 & 0x3) {
|
||||
/* dr0 is enabled */
|
||||
if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
|
||||
|
@ -122,7 +122,7 @@ mmopen(dev_t dev, int flags, int fmt, struct thread *td)
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
|
@ -183,7 +183,7 @@ i386_set_ioperm(td, args)
|
||||
if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
|
||||
return (error);
|
||||
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
||||
return (error);
|
||||
|
@ -659,7 +659,6 @@ vm86_sysarch(td, args)
|
||||
struct thread *td;
|
||||
char *args;
|
||||
{
|
||||
struct proc *p = td->td_proc;
|
||||
int error = 0;
|
||||
struct i386_vm86_args ua;
|
||||
struct vm86_kernel *vm86;
|
||||
@ -716,7 +715,7 @@ vm86_sysarch(td, args)
|
||||
case VM86_INTCALL: {
|
||||
struct vm86_intcall_args sa;
|
||||
|
||||
if ((error = suser(p)))
|
||||
if ((error = suser(td)))
|
||||
return (error);
|
||||
if ((error = copyin(ua.sub_args, &sa, sizeof(sa))))
|
||||
return (error);
|
||||
|
@ -1013,7 +1013,7 @@ ibcs2_plock(td, uap)
|
||||
#define IBCS2_DATALOCK 4
|
||||
|
||||
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return EPERM;
|
||||
switch(SCARG(uap, cmd)) {
|
||||
case IBCS2_UNLOCK:
|
||||
@ -1048,7 +1048,7 @@ ibcs2_uadmin(td, uap)
|
||||
#define SCO_AD_GETBMAJ 0
|
||||
#define SCO_AD_GETCMAJ 1
|
||||
|
||||
if (suser_td(td))
|
||||
if (suser(td))
|
||||
return EPERM;
|
||||
|
||||
switch(SCARG(uap, cmd)) {
|
||||
|
@ -173,7 +173,7 @@ ibcs2_setipdomainname(td, uap)
|
||||
char hname[MAXHOSTNAMELEN], *ptr;
|
||||
int error, sctl[2], hlen;
|
||||
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
return (error);
|
||||
|
||||
/* W/out a hostname a domain-name is nonsense */
|
||||
|
@ -73,7 +73,7 @@ ibcs2_sysi86(struct thread *td, struct ibcs2_sysi86_args *args)
|
||||
int name[2];
|
||||
int error;
|
||||
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
return (error);
|
||||
name[0] = CTL_KERN;
|
||||
name[1] = KERN_HOSTNAME;
|
||||
|
@ -162,7 +162,7 @@ int cxopen (dev_t dev, int flag, int mode, struct thread *td)
|
||||
tp = c->ttyp;
|
||||
tp->t_dev = dev;
|
||||
if ((tp->t_state & TS_ISOPEN) && (tp->t_state & TS_XCLUDE) &&
|
||||
suser_td(td))
|
||||
suser(td))
|
||||
return (EBUSY);
|
||||
if (! (tp->t_state & TS_ISOPEN)) {
|
||||
ttychars (tp);
|
||||
|
@ -718,7 +718,7 @@ sioopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1637,7 +1637,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
}
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
*ct = *(struct termios *)data;
|
||||
@ -1736,7 +1736,7 @@ sioioctl(dev, cmd, data, flag, td)
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
/* must be root since the wait applies to following logins */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -1010,7 +1010,7 @@ STATIC int stliopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
}
|
||||
if ((tp->t_state & TS_XCLUDE) &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto stliopen_end;
|
||||
}
|
||||
@ -1182,7 +1182,7 @@ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag,
|
||||
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
if ((error = suser_td(td)) == 0)
|
||||
if ((error = suser(td)) == 0)
|
||||
*localtios = *((struct termios *) data);
|
||||
break;
|
||||
case TIOCGETA:
|
||||
@ -1318,7 +1318,7 @@ STATIC int stliioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag,
|
||||
*((int *) data) = (portp->sigs | TIOCM_LE);
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
if ((error = suser_td(td)) == 0)
|
||||
if ((error = suser(td)) == 0)
|
||||
portp->dtrwait = *((int *) data) * hz / 100;
|
||||
break;
|
||||
case TIOCMGDTRWAIT:
|
||||
|
@ -316,7 +316,7 @@ pcvt_open(dev_t dev, int flag, int mode, struct thread *td)
|
||||
(*linesw[tp->t_line].l_modem)(tp, 1); /* fake connection */
|
||||
winsz = 1; /* set winsize later */
|
||||
}
|
||||
else if (tp->t_state & TS_XCLUDE && suser_td(td))
|
||||
else if (tp->t_state & TS_XCLUDE && suser(td))
|
||||
{
|
||||
return (EBUSY);
|
||||
}
|
||||
|
@ -2619,7 +2619,7 @@ usl_vt_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)
|
||||
{
|
||||
struct trapframe *fp = td->td_frame;
|
||||
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
|
@ -764,7 +764,7 @@ rcopen(dev, flag, mode, td)
|
||||
}
|
||||
}
|
||||
if (tp->t_state & TS_XCLUDE &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
@ -1118,7 +1118,7 @@ struct thread *td;
|
||||
break;
|
||||
|
||||
case TIOCMSDTRWAIT:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (error);
|
||||
|
@ -175,7 +175,7 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
|
||||
* require sufficient privilege soon and nothing much can be done
|
||||
* without them.
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return error;
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
@ -232,7 +232,7 @@ struct spigot_info *info;
|
||||
break;
|
||||
case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */
|
||||
#if !defined(SPIGOT_UNSECURE)
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error != 0)
|
||||
return error;
|
||||
error = securelevel_gt(td->td_ucred, 0);
|
||||
|
@ -832,7 +832,7 @@ STATIC int stlopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
}
|
||||
}
|
||||
if ((tp->t_state & TS_XCLUDE) &&
|
||||
suser_td(td)) {
|
||||
suser(td)) {
|
||||
error = EBUSY;
|
||||
goto stlopen_end;
|
||||
}
|
||||
@ -970,7 +970,7 @@ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag,
|
||||
|
||||
switch (cmd) {
|
||||
case TIOCSETA:
|
||||
if ((error = suser_td(td)) == 0)
|
||||
if ((error = suser(td)) == 0)
|
||||
*localtios = *((struct termios *) data);
|
||||
break;
|
||||
case TIOCGETA:
|
||||
@ -1088,7 +1088,7 @@ STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag,
|
||||
*((int *) data) = (stl_getsignals(portp) | TIOCM_LE);
|
||||
break;
|
||||
case TIOCMSDTRWAIT:
|
||||
if ((error = suser_td(td)) == 0)
|
||||
if ((error = suser(td)) == 0)
|
||||
portp->dtrwait = *((int *) data) * hz / 100;
|
||||
break;
|
||||
case TIOCMGDTRWAIT:
|
||||
|
@ -559,7 +559,7 @@ linux_iopl(struct thread *td, struct linux_iopl_args *args)
|
||||
|
||||
if (args->level < 0 || args->level > 3)
|
||||
return (EINVAL);
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
||||
return (error);
|
||||
|
@ -481,9 +481,9 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
#ifdef IPR_VJ
|
||||
case IPRIOCSMAXCID:
|
||||
{
|
||||
struct proc *p = curproc; /* XXX */
|
||||
struct thread *td = curthread; /* XXX */
|
||||
|
||||
if((error = suser(p)) != 0)
|
||||
if((error = suser(td)))
|
||||
return (error);
|
||||
sl_compress_setup(sc->sc_compr, *(int *)data);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ sscopen(dev_t dev, int flag, int mode, struct thread *td)
|
||||
ttsetwater(tp);
|
||||
|
||||
setuptimeout = 1;
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td->td_proc)) {
|
||||
} else if ((tp->t_state & TS_XCLUDE) && suser(td)) {
|
||||
splx(s);
|
||||
return EBUSY;
|
||||
}
|
||||
|
@ -2644,7 +2644,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
* Set density definition permanently. Only
|
||||
* allow for superuser.
|
||||
*/
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
fd->fts[type] = *(struct fd_type *)addr;
|
||||
}
|
||||
@ -2669,7 +2669,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
#endif
|
||||
|
||||
case FD_CLRERR:
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
fd->fdc->fdc_errs = 0;
|
||||
return (0);
|
||||
@ -2751,7 +2751,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
|
||||
case FD_STYPE: /* set drive type */
|
||||
/* this is considered harmful; only allow for superuser */
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
*fd->ft = *(struct fd_type *)addr;
|
||||
break;
|
||||
@ -2775,7 +2775,7 @@ fdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
|
||||
#endif
|
||||
|
||||
case FD_CLRERR:
|
||||
if (suser_td(td) != 0)
|
||||
if (suser(td) != 0)
|
||||
return (EPERM);
|
||||
fd->fdc->fdc_errs = 0;
|
||||
break;
|
||||
|
@ -238,7 +238,7 @@ cd9660_mount(mp, path, data, ndp, td)
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
|
||||
error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td);
|
||||
if (error)
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
|
@ -123,7 +123,7 @@ acct(td, uap)
|
||||
if (td != curthread)
|
||||
panic("acct"); /* XXXKSE DIAGNOSTIC */
|
||||
/* Make sure that the caller is root. */
|
||||
error = suser_xxx(td->td_proc->p_ucred, NULL, 0);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto done2;
|
||||
|
||||
|
@ -89,7 +89,7 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid,
|
||||
* a DAC entry that matches but has failed to allow access.
|
||||
*/
|
||||
#ifndef CAPABILITIES
|
||||
if (suser_xxx(cred, NULL, PRISON_ROOT) == 0)
|
||||
if (suser_cred(cred, PRISON_ROOT) == 0)
|
||||
cap_granted = (VEXEC | VREAD | VWRITE | VADMIN);
|
||||
else
|
||||
cap_granted = 0;
|
||||
|
@ -353,7 +353,7 @@ execve(td, uap)
|
||||
* we do not regain any tracing during a possible block.
|
||||
*/
|
||||
setsugid(p);
|
||||
if (p->p_tracep && suser_xxx(oldcred, NULL, PRISON_ROOT)) {
|
||||
if (p->p_tracep && suser_cred(oldcred, PRISON_ROOT)) {
|
||||
struct vnode *vtmp;
|
||||
|
||||
if ((vtmp = p->p_tracep) != NULL) {
|
||||
|
@ -87,7 +87,7 @@ jail(td, uap)
|
||||
pr->pr_ip = j.ip_number;
|
||||
PROC_LOCK(p);
|
||||
/* Implicitly fail if already in jail. */
|
||||
error = suser_xxx(p->p_ucred, NULL, 0);
|
||||
error = suser_cred(p->p_ucred, 0);
|
||||
if (error)
|
||||
goto badcred;
|
||||
oldcred = p->p_ucred;
|
||||
|
@ -594,7 +594,7 @@ ktrcanset(callp, targetp)
|
||||
{
|
||||
|
||||
if (targetp->p_traceflag & KTRFAC_ROOT &&
|
||||
suser_xxx(NULL, callp, PRISON_ROOT))
|
||||
suser_cred(callp->p_ucred, PRISON_ROOT))
|
||||
return (0);
|
||||
|
||||
if (p_candebug(callp, targetp) != 0)
|
||||
|
@ -703,7 +703,7 @@ kldload(struct thread *td, struct kldload_args *uap)
|
||||
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
||||
goto out;
|
||||
|
||||
if ((error = suser_xxx(td->td_ucred, NULL, 0)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
goto out;
|
||||
|
||||
pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
|
||||
@ -750,7 +750,7 @@ kldunload(struct thread *td, struct kldunload_args *uap)
|
||||
if ((error = securelevel_gt(td->td_ucred, 0)) != 0)
|
||||
goto out;
|
||||
|
||||
if ((error = suser_xxx(td->td_ucred, NULL, 0)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
goto out;
|
||||
|
||||
lf = linker_find_file_by_id(SCARG(uap, fileid));
|
||||
|
@ -300,7 +300,7 @@ ntp_adjtime(struct thread *td, struct ntp_adjtime_args *uap)
|
||||
mtx_lock(&Giant);
|
||||
modes = ntv.modes;
|
||||
if (modes)
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto done2;
|
||||
s = splclock();
|
||||
|
@ -555,7 +555,7 @@ setuid(struct thread *td, struct setuid_args *uap)
|
||||
#ifdef POSIX_APPENDIX_B_4_2_2 /* Use BSD-compat clause from B.4.2.2 */
|
||||
uid != oldcred->cr_uid && /* allow setuid(geteuid()) */
|
||||
#endif
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
|
||||
newcred = crdup(oldcred);
|
||||
@ -568,7 +568,7 @@ setuid(struct thread *td, struct setuid_args *uap)
|
||||
#ifdef POSIX_APPENDIX_B_4_2_2 /* Use the clause from B.4.2.2 */
|
||||
uid == oldcred->cr_uid ||
|
||||
#endif
|
||||
suser_xxx(oldcred, NULL, PRISON_ROOT) == 0) /* we are using privs */
|
||||
suser_cred(oldcred, PRISON_ROOT) == 0) /* we are using privs */
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
@ -629,7 +629,7 @@ seteuid(struct thread *td, struct seteuid_args *uap)
|
||||
oldcred = p->p_ucred;
|
||||
if (euid != oldcred->cr_ruid && /* allow seteuid(getuid()) */
|
||||
euid != oldcred->cr_svuid && /* allow seteuid(saved uid) */
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
/*
|
||||
* Everything's okay, do it. Copy credentials so other references do
|
||||
@ -687,7 +687,7 @@ setgid(struct thread *td, struct setgid_args *uap)
|
||||
#ifdef POSIX_APPENDIX_B_4_2_2 /* Use BSD-compat clause from B.4.2.2 */
|
||||
gid != oldcred->cr_groups[0] && /* allow setgid(getegid()) */
|
||||
#endif
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
|
||||
newcred = crdup(oldcred);
|
||||
@ -700,7 +700,7 @@ setgid(struct thread *td, struct setgid_args *uap)
|
||||
#ifdef POSIX_APPENDIX_B_4_2_2 /* use the clause from B.4.2.2 */
|
||||
gid == oldcred->cr_groups[0] ||
|
||||
#endif
|
||||
suser_xxx(oldcred, NULL, PRISON_ROOT) == 0) /* we are using privs */
|
||||
suser_cred(oldcred, PRISON_ROOT) == 0) /* we are using privs */
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
@ -760,7 +760,7 @@ setegid(struct thread *td, struct setegid_args *uap)
|
||||
oldcred = p->p_ucred;
|
||||
if (egid != oldcred->cr_rgid && /* allow setegid(getgid()) */
|
||||
egid != oldcred->cr_svgid && /* allow setegid(saved gid) */
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
newcred = crdup(oldcred);
|
||||
if (oldcred->cr_groups[0] != egid) {
|
||||
@ -795,7 +795,7 @@ setgroups(struct thread *td, struct setgroups_args *uap)
|
||||
ngrp = uap->gidsetsize;
|
||||
mtx_lock(&Giant);
|
||||
oldcred = p->p_ucred;
|
||||
if ((error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
if ((error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
if (ngrp > NGROUPS) {
|
||||
error = EINVAL;
|
||||
@ -857,7 +857,7 @@ setreuid(register struct thread *td, struct setreuid_args *uap)
|
||||
ruid != oldcred->cr_svuid) ||
|
||||
(euid != (uid_t)-1 && euid != oldcred->cr_uid &&
|
||||
euid != oldcred->cr_ruid && euid != oldcred->cr_svuid)) &&
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
newcred = crdup(oldcred);
|
||||
if (euid != (uid_t)-1 && oldcred->cr_uid != euid) {
|
||||
@ -907,7 +907,7 @@ setregid(register struct thread *td, struct setregid_args *uap)
|
||||
rgid != oldcred->cr_svgid) ||
|
||||
(egid != (gid_t)-1 && egid != oldcred->cr_groups[0] &&
|
||||
egid != oldcred->cr_rgid && egid != oldcred->cr_svgid)) &&
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
newcred = crdup(oldcred);
|
||||
if (egid != (gid_t)-1 && oldcred->cr_groups[0] != egid) {
|
||||
@ -968,7 +968,7 @@ setresuid(register struct thread *td, struct setresuid_args *uap)
|
||||
(suid != (uid_t)-1 && suid != oldcred->cr_ruid &&
|
||||
suid != oldcred->cr_svuid &&
|
||||
suid != oldcred->cr_uid)) &&
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
newcred = crdup(oldcred);
|
||||
if (euid != (uid_t)-1 && oldcred->cr_uid != euid) {
|
||||
@ -1029,7 +1029,7 @@ setresgid(register struct thread *td, struct setresgid_args *uap)
|
||||
(sgid != (gid_t)-1 && sgid != oldcred->cr_rgid &&
|
||||
sgid != oldcred->cr_svgid &&
|
||||
sgid != oldcred->cr_groups[0])) &&
|
||||
(error = suser_xxx(oldcred, NULL, PRISON_ROOT)) != 0)
|
||||
(error = suser_cred(oldcred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
newcred = crdup(oldcred);
|
||||
if (egid != (gid_t)-1 && oldcred->cr_groups[0] != egid) {
|
||||
@ -1209,47 +1209,15 @@ TUNABLE_INT("security.bsd.suser_enabled", &suser_enabled);
|
||||
|
||||
/*
|
||||
* Test whether the specified credentials imply "super-user" privilege.
|
||||
* Return 0 or EPERM.
|
||||
* Return 0 or EPERM. The flag argument is currently used only to
|
||||
* specify jail interaction.
|
||||
*/
|
||||
int
|
||||
suser(struct proc *p)
|
||||
suser_cred(struct ucred *cred, int flag)
|
||||
{
|
||||
|
||||
return (suser_xxx(0, p, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* version for when the thread pointer is available and not the proc.
|
||||
* (saves having to include proc.h into every file that needs to do the change.)
|
||||
*/
|
||||
int
|
||||
suser_td(struct thread *td)
|
||||
{
|
||||
return (suser_xxx(0, td->td_proc, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* wrapper to use if you have the thread on hand but not the proc.
|
||||
*
|
||||
* MPSAFE (cred must be held)
|
||||
*/
|
||||
int
|
||||
suser_xxx_td(struct ucred *cred, struct thread *td, int flag)
|
||||
{
|
||||
return(suser_xxx(cred, td->td_proc, flag));
|
||||
}
|
||||
|
||||
int
|
||||
suser_xxx(struct ucred *cred, struct proc *proc, int flag)
|
||||
{
|
||||
if (!suser_enabled)
|
||||
return (EPERM);
|
||||
if (!cred && !proc) {
|
||||
printf("suser_xxx(): THINK!\n");
|
||||
return (EPERM);
|
||||
}
|
||||
if (cred == NULL)
|
||||
cred = proc->p_ucred;
|
||||
if (cred->cr_uid != 0)
|
||||
return (EPERM);
|
||||
if (jailed(cred) && !(flag & PRISON_ROOT))
|
||||
@ -1257,6 +1225,17 @@ suser_xxx(struct ucred *cred, struct proc *proc, int flag)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortcut to hide contents of struct td and struct proc from the
|
||||
* caller, promoting binary compatibility.
|
||||
*/
|
||||
int
|
||||
suser(struct thread *td)
|
||||
{
|
||||
|
||||
return (suser_cred(td->td_ucred, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test the active securelevel against a given level. securelevel_gt()
|
||||
* implements (securelevel > level). securelevel_ge() implements
|
||||
@ -1328,7 +1307,7 @@ cr_seeotheruids(struct ucred *u1, struct ucred *u2)
|
||||
{
|
||||
|
||||
if (!see_other_uids && u1->cr_ruid != u2->cr_ruid) {
|
||||
if (suser_xxx(u1, NULL, PRISON_ROOT) != 0)
|
||||
if (suser_cred(u1, PRISON_ROOT) != 0)
|
||||
return (ESRCH);
|
||||
}
|
||||
return (0);
|
||||
@ -1416,7 +1395,7 @@ cr_cansignal(struct ucred *cred, struct proc *proc, int signum)
|
||||
break;
|
||||
default:
|
||||
/* Not permitted without privilege. */
|
||||
error = suser_xxx(cred, NULL, PRISON_ROOT);
|
||||
error = suser_cred(cred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -1431,7 +1410,7 @@ cr_cansignal(struct ucred *cred, struct proc *proc, int signum)
|
||||
cred->cr_uid != proc->p_ucred->cr_ruid &&
|
||||
cred->cr_uid != proc->p_ucred->cr_svuid) {
|
||||
/* Not permitted without privilege. */
|
||||
error = suser_xxx(cred, NULL, PRISON_ROOT);
|
||||
error = suser_cred(cred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -1489,7 +1468,7 @@ p_cansched(struct proc *p1, struct proc *p2)
|
||||
return (0);
|
||||
if (p1->p_ucred->cr_uid == p2->p_ucred->cr_ruid)
|
||||
return (0);
|
||||
if (suser_xxx(0, p1, PRISON_ROOT) == 0)
|
||||
if (suser_cred(p1->p_ucred, PRISON_ROOT) == 0)
|
||||
return (0);
|
||||
|
||||
#ifdef CAPABILITIES
|
||||
@ -1530,7 +1509,7 @@ p_candebug(struct proc *p1, struct proc *p2)
|
||||
int credentialchanged, error, grpsubset, i, uidsubset;
|
||||
|
||||
if (!unprivileged_proc_debug) {
|
||||
error = suser_xxx(NULL, p1, PRISON_ROOT);
|
||||
error = suser_cred(p1->p_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -1576,7 +1555,7 @@ p_candebug(struct proc *p1, struct proc *p2)
|
||||
* require CAP_SYS_PTRACE.
|
||||
*/
|
||||
if (!grpsubset || !uidsubset || credentialchanged) {
|
||||
error = suser_xxx(NULL, p1, PRISON_ROOT);
|
||||
error = suser_cred(p1->p_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -1828,7 +1807,7 @@ setlogin(struct thread *td, struct setlogin_args *uap)
|
||||
char logintmp[MAXLOGNAME];
|
||||
|
||||
mtx_lock(&Giant);
|
||||
if ((error = suser_xxx(0, p, PRISON_ROOT)) != 0)
|
||||
if ((error = suser_cred(td->td_ucred, PRISON_ROOT)) != 0)
|
||||
goto done2;
|
||||
error = copyinstr((caddr_t) uap->namebuf, (caddr_t) logintmp,
|
||||
sizeof(logintmp), (size_t *)0);
|
||||
|
@ -258,7 +258,7 @@ donice(curp, chgp, n)
|
||||
if (n < PRIO_MIN)
|
||||
n = PRIO_MIN;
|
||||
if (n < chgp->p_ksegrp.kg_nice /* XXXKSE */ &&
|
||||
suser_xxx(curp->p_ucred, NULL, 0))
|
||||
suser_cred(curp->p_ucred, 0))
|
||||
return (EACCES);
|
||||
chgp->p_ksegrp.kg_nice /* XXXKSE */ = n;
|
||||
(void)resetpriority(&chgp->p_ksegrp); /* XXXKSE */
|
||||
@ -320,7 +320,7 @@ rtprio(td, uap)
|
||||
(error = copyin(uap->rtp, &rtp, sizeof(struct rtprio))))
|
||||
break;
|
||||
/* disallow setting rtprio in most cases if not superuser */
|
||||
if (suser_xxx(curp->p_ucred, NULL, 0) != 0) {
|
||||
if (suser(td) != 0) {
|
||||
/* can't set someone else's */
|
||||
if (uap->pid) {
|
||||
error = EPERM;
|
||||
@ -521,7 +521,7 @@ dosetrlimit(td, which, limp)
|
||||
|
||||
if (limp->rlim_cur > alimp->rlim_max ||
|
||||
limp->rlim_max > alimp->rlim_max)
|
||||
if ((error = suser_xxx(0, p, PRISON_ROOT)))
|
||||
if ((error = suser_cred(td->td_ucred, PRISON_ROOT)))
|
||||
return (error);
|
||||
if (limp->rlim_cur > limp->rlim_max)
|
||||
limp->rlim_cur = limp->rlim_max;
|
||||
|
@ -148,7 +148,7 @@ reboot(struct thread *td, struct reboot_args *uap)
|
||||
int error;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
if ((error = suser_td(td)) == 0)
|
||||
if ((error = suser(td)) == 0)
|
||||
boot(uap->opt);
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
|
@ -463,7 +463,7 @@ sysctl_sysctl_debug(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = suser(req->td->td_proc);
|
||||
error = suser(req->td);
|
||||
if (error)
|
||||
return error;
|
||||
sysctl_sysctl_debug_dump_node(&sysctl__children, 0);
|
||||
@ -1084,7 +1084,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS)
|
||||
flags = PRISON_ROOT;
|
||||
else
|
||||
flags = 0;
|
||||
error = suser_xxx(NULL, req->td->td_proc, flags);
|
||||
error = suser_cred(req->td->td_ucred, flags);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ clock_settime(td, uap)
|
||||
int error;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
goto done2;
|
||||
if (SCARG(uap, clock_id) != CLOCK_REALTIME) {
|
||||
error = EINVAL;
|
||||
@ -370,7 +370,7 @@ settimeofday(td, uap)
|
||||
|
||||
mtx_lock(&Giant);
|
||||
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
goto done2;
|
||||
/* Verify all parameters before changing time. */
|
||||
if (uap->tv) {
|
||||
@ -421,7 +421,7 @@ adjtime(td, uap)
|
||||
|
||||
mtx_lock(&Giant);
|
||||
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
goto done2;
|
||||
error = copyin((caddr_t)uap->delta, (caddr_t)&atv,
|
||||
sizeof(struct timeval));
|
||||
|
@ -97,7 +97,7 @@ osethostname(td, uap)
|
||||
name[0] = CTL_KERN;
|
||||
name[1] = KERN_HOSTNAME;
|
||||
mtx_lock(&Giant);
|
||||
if ((error = suser_xxx(0, td->td_proc, PRISON_ROOT)) == 0) {
|
||||
if ((error = suser_cred(td->td_ucred, PRISON_ROOT)) == 0) {
|
||||
error = userland_sysctl(td, name, 2, 0, 0, 0,
|
||||
uap->hostname, uap->len, 0);
|
||||
}
|
||||
@ -143,7 +143,7 @@ osethostid(td, uap)
|
||||
int error;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
hostid = uap->hostid;
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
@ -298,7 +298,7 @@ setdomainname(td, uap)
|
||||
int error, domainnamelen;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
if ((error = suser_td(td)))
|
||||
if ((error = suser(td)))
|
||||
goto done2;
|
||||
if ((u_int)uap->len > sizeof (domainname) - 1) {
|
||||
error = EINVAL;
|
||||
|
@ -89,7 +89,7 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid,
|
||||
* a DAC entry that matches but has failed to allow access.
|
||||
*/
|
||||
#ifndef CAPABILITIES
|
||||
if (suser_xxx(cred, NULL, PRISON_ROOT) == 0)
|
||||
if (suser_cred(cred, PRISON_ROOT) == 0)
|
||||
cap_granted = (VEXEC | VREAD | VWRITE | VADMIN);
|
||||
else
|
||||
cap_granted = 0;
|
||||
|
@ -861,7 +861,7 @@ sysctl_kern_msgbuf(SYSCTL_HANDLER_ARGS)
|
||||
int error;
|
||||
|
||||
if (!unprivileged_read_msgbuf) {
|
||||
error = suser_td(req->td);
|
||||
error = suser(req->td);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ ipcperm(td, perm, mode)
|
||||
/* Check for user match. */
|
||||
if (cred->cr_uid != perm->cuid && cred->cr_uid != perm->uid) {
|
||||
if (mode & IPC_M)
|
||||
return (suser_td(td) == 0 ? 0 : EPERM);
|
||||
return (suser(td) == 0 ? 0 : EPERM);
|
||||
/* Check for group match. */
|
||||
mode >>= 3;
|
||||
if (!groupmember(perm->gid, cred) &&
|
||||
@ -93,5 +93,5 @@ ipcperm(td, perm, mode)
|
||||
if (mode & IPC_M)
|
||||
return (0);
|
||||
return ((mode & perm->mode) == mode ||
|
||||
suser_td(td) == 0 ? 0 : EACCES);
|
||||
suser(td) == 0 ? 0 : EACCES);
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ msgctl(td, uap)
|
||||
if ((error = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0)
|
||||
goto done2;
|
||||
if (msqbuf.msg_qbytes > msqptr->msg_qbytes) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto done2;
|
||||
}
|
||||
|
@ -730,9 +730,11 @@ ttioctl(tp, cmd, data, flag)
|
||||
void *data;
|
||||
{
|
||||
register struct proc *p;
|
||||
struct thread *td;
|
||||
int s, error;
|
||||
|
||||
p = curproc; /* XXX */
|
||||
td = curthread; /* XXX */
|
||||
p = td->td_proc;
|
||||
|
||||
/* If the ioctl involves modification, hang if in the background. */
|
||||
switch (cmd) {
|
||||
@ -851,7 +853,7 @@ ttioctl(tp, cmd, data, flag)
|
||||
ISSET(constty->t_state, TS_CONNECTED))
|
||||
return (EBUSY);
|
||||
#ifndef UCONSOLE
|
||||
if ((error = suser_xxx(p->p_ucred, NULL, 0)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
#endif
|
||||
constty = tp;
|
||||
@ -1023,9 +1025,9 @@ ttioctl(tp, cmd, data, flag)
|
||||
splx(s);
|
||||
break;
|
||||
case TIOCSTI: /* simulate terminal input */
|
||||
if ((flag & FREAD) == 0 && suser_xxx(p->p_ucred, NULL, 0))
|
||||
if ((flag & FREAD) == 0 && suser(td))
|
||||
return (EPERM);
|
||||
if (!isctty(p, tp) && suser_xxx(p->p_ucred, NULL, 0))
|
||||
if (!isctty(p, tp) && suser(td))
|
||||
return (EACCES);
|
||||
s = spltty();
|
||||
(*linesw[tp->t_line].l_rint)(*(u_char *)data, tp);
|
||||
@ -1099,7 +1101,7 @@ ttioctl(tp, cmd, data, flag)
|
||||
}
|
||||
break;
|
||||
case TIOCSDRAINWAIT:
|
||||
error = suser_xxx(p->p_ucred, NULL, 0);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
tp->t_timeout = *(int *)data * hz;
|
||||
|
@ -456,7 +456,7 @@ cnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
* output from the "virtual" console.
|
||||
*/
|
||||
if (cmd == TIOCCONS && constty) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
constty = NULL;
|
||||
|
@ -187,7 +187,7 @@ ptsopen(dev, flag, devtype, td)
|
||||
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 && suser_xxx(td->td_ucred, NULL, 0)) {
|
||||
} else if (tp->t_state & TS_XCLUDE && suser(td)) {
|
||||
return (EBUSY);
|
||||
} else if (pti->pt_prison != td->td_ucred->cr_prison) {
|
||||
return (EBUSY);
|
||||
|
@ -89,7 +89,7 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid,
|
||||
* a DAC entry that matches but has failed to allow access.
|
||||
*/
|
||||
#ifndef CAPABILITIES
|
||||
if (suser_xxx(cred, NULL, PRISON_ROOT) == 0)
|
||||
if (suser_cred(cred, PRISON_ROOT) == 0)
|
||||
cap_granted = (VEXEC | VREAD | VWRITE | VADMIN);
|
||||
else
|
||||
cap_granted = 0;
|
||||
|
@ -374,7 +374,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
}
|
||||
|
||||
if (usermount == 0) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto bad;
|
||||
}
|
||||
@ -382,14 +382,14 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
* Do not allow NFS export by non-root users.
|
||||
*/
|
||||
if (fsflags & MNT_EXPORTED) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* Silently enforce MNT_NOSUID and MNT_NODEV for non-root users.
|
||||
*/
|
||||
if (suser_xxx(td->td_ucred, NULL, 0) != 0)
|
||||
if (suser(td))
|
||||
fsflags |= MNT_NOSUID | MNT_NODEV;
|
||||
/*
|
||||
* Get vnode to be covered
|
||||
@ -423,7 +423,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
* permitted to update it.
|
||||
*/
|
||||
if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
goto bad;
|
||||
@ -460,7 +460,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
goto bad;
|
||||
}
|
||||
if (va.va_uid != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
goto bad;
|
||||
@ -480,7 +480,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
break;
|
||||
if (vfsp == NULL) {
|
||||
/* Only load modules for root (very important!). */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
goto bad;
|
||||
@ -722,7 +722,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
return (ENAMETOOLONG);
|
||||
|
||||
if (usermount == 0) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -730,14 +730,14 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
* Do not allow NFS export by non-root users.
|
||||
*/
|
||||
if (fsflags & MNT_EXPORTED) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
* Silently enforce MNT_NOSUID and MNT_NODEV for non-root users.
|
||||
*/
|
||||
if (suser_xxx(td->td_ucred, NULL, 0) != 0)
|
||||
if (suser(td))
|
||||
fsflags |= MNT_NOSUID | MNT_NODEV;
|
||||
/*
|
||||
* Get vnode to be covered
|
||||
@ -769,7 +769,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
* permitted to update it.
|
||||
*/
|
||||
if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -803,7 +803,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
return (error);
|
||||
}
|
||||
if (va.va_uid != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -822,7 +822,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
break;
|
||||
if (vfsp == NULL) {
|
||||
/* Only load modules for root (very important!). */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -1056,7 +1056,7 @@ unmount(td, uap)
|
||||
* permitted to unmount this filesystem.
|
||||
*/
|
||||
if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -1313,7 +1313,7 @@ statfs(td, uap)
|
||||
if (error)
|
||||
return (error);
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
if (suser_xxx(td->td_ucred, 0, 0)) {
|
||||
if (suser(td)) {
|
||||
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
|
||||
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
|
||||
sp = &sb;
|
||||
@ -1356,7 +1356,7 @@ fstatfs(td, uap)
|
||||
if (error)
|
||||
return (error);
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
if (suser_xxx(td->td_ucred, 0, 0)) {
|
||||
if (suser(td)) {
|
||||
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
|
||||
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
|
||||
sp = &sb;
|
||||
@ -1585,7 +1585,7 @@ chroot(td, uap)
|
||||
struct nameidata nd;
|
||||
struct vnode *vp;
|
||||
|
||||
error = suser_xxx(0, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
FILEDESC_LOCK(fdp);
|
||||
@ -1868,10 +1868,10 @@ mknod(td, uap)
|
||||
switch (SCARG(uap, mode) & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
break;
|
||||
default:
|
||||
error = suser_xxx(0, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
break;
|
||||
}
|
||||
if (error)
|
||||
@ -2831,7 +2831,7 @@ setfflags(td, vp, flags)
|
||||
* chown can't fail when done as root.
|
||||
*/
|
||||
if (vp->v_type == VCHR || vp->v_type == VBLK) {
|
||||
error = suser_xxx(td->td_ucred, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -4089,7 +4089,7 @@ revoke(td, uap)
|
||||
}
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
if (td->td_ucred->cr_uid != vattr.va_uid) {
|
||||
error = suser_xxx(0, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
goto out;
|
||||
}
|
||||
@ -4158,7 +4158,7 @@ getfh(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, td);
|
||||
@ -4214,7 +4214,7 @@ fhopen(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -4390,7 +4390,7 @@ fhstat(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -4437,7 +4437,7 @@ fhstatfs(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -4454,7 +4454,7 @@ fhstatfs(td, uap)
|
||||
if ((error = VFS_STATFS(mp, sp, td)) != 0)
|
||||
return (error);
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
if (suser_xxx(td->td_ucred, 0, 0)) {
|
||||
if (suser(td)) {
|
||||
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
|
||||
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
|
||||
sp = &sb;
|
||||
|
@ -3217,7 +3217,7 @@ vaccess(type, file_mode, file_uid, file_gid, acc_mode, cred, privused)
|
||||
return (0);
|
||||
|
||||
privcheck:
|
||||
if (!suser_xxx(cred, NULL, PRISON_ROOT)) {
|
||||
if (!suser_cred(cred, PRISON_ROOT)) {
|
||||
/* XXX audit: privilege used */
|
||||
if (privused != NULL)
|
||||
*privused = 1;
|
||||
|
@ -374,7 +374,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
}
|
||||
|
||||
if (usermount == 0) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto bad;
|
||||
}
|
||||
@ -382,14 +382,14 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
* Do not allow NFS export by non-root users.
|
||||
*/
|
||||
if (fsflags & MNT_EXPORTED) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
* Silently enforce MNT_NOSUID and MNT_NODEV for non-root users.
|
||||
*/
|
||||
if (suser_xxx(td->td_ucred, NULL, 0) != 0)
|
||||
if (suser(td))
|
||||
fsflags |= MNT_NOSUID | MNT_NODEV;
|
||||
/*
|
||||
* Get vnode to be covered
|
||||
@ -423,7 +423,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
* permitted to update it.
|
||||
*/
|
||||
if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
goto bad;
|
||||
@ -460,7 +460,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
goto bad;
|
||||
}
|
||||
if (va.va_uid != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
goto bad;
|
||||
@ -480,7 +480,7 @@ vfs_nmount(td, fsflags, fsoptions)
|
||||
break;
|
||||
if (vfsp == NULL) {
|
||||
/* Only load modules for root (very important!). */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
goto bad;
|
||||
@ -722,7 +722,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
return (ENAMETOOLONG);
|
||||
|
||||
if (usermount == 0) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -730,14 +730,14 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
* Do not allow NFS export by non-root users.
|
||||
*/
|
||||
if (fsflags & MNT_EXPORTED) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
* Silently enforce MNT_NOSUID and MNT_NODEV for non-root users.
|
||||
*/
|
||||
if (suser_xxx(td->td_ucred, NULL, 0) != 0)
|
||||
if (suser(td))
|
||||
fsflags |= MNT_NOSUID | MNT_NODEV;
|
||||
/*
|
||||
* Get vnode to be covered
|
||||
@ -769,7 +769,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
* permitted to update it.
|
||||
*/
|
||||
if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -803,7 +803,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
return (error);
|
||||
}
|
||||
if (va.va_uid != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -822,7 +822,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
|
||||
break;
|
||||
if (vfsp == NULL) {
|
||||
/* Only load modules for root (very important!). */
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -1056,7 +1056,7 @@ unmount(td, uap)
|
||||
* permitted to unmount this filesystem.
|
||||
*/
|
||||
if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error) {
|
||||
vput(vp);
|
||||
return (error);
|
||||
@ -1313,7 +1313,7 @@ statfs(td, uap)
|
||||
if (error)
|
||||
return (error);
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
if (suser_xxx(td->td_ucred, 0, 0)) {
|
||||
if (suser(td)) {
|
||||
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
|
||||
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
|
||||
sp = &sb;
|
||||
@ -1356,7 +1356,7 @@ fstatfs(td, uap)
|
||||
if (error)
|
||||
return (error);
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
if (suser_xxx(td->td_ucred, 0, 0)) {
|
||||
if (suser(td)) {
|
||||
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
|
||||
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
|
||||
sp = &sb;
|
||||
@ -1585,7 +1585,7 @@ chroot(td, uap)
|
||||
struct nameidata nd;
|
||||
struct vnode *vp;
|
||||
|
||||
error = suser_xxx(0, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
FILEDESC_LOCK(fdp);
|
||||
@ -1868,10 +1868,10 @@ mknod(td, uap)
|
||||
switch (SCARG(uap, mode) & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
break;
|
||||
default:
|
||||
error = suser_xxx(0, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
break;
|
||||
}
|
||||
if (error)
|
||||
@ -2831,7 +2831,7 @@ setfflags(td, vp, flags)
|
||||
* chown can't fail when done as root.
|
||||
*/
|
||||
if (vp->v_type == VCHR || vp->v_type == VBLK) {
|
||||
error = suser_xxx(td->td_ucred, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
@ -4089,7 +4089,7 @@ revoke(td, uap)
|
||||
}
|
||||
VOP_UNLOCK(vp, 0, td);
|
||||
if (td->td_ucred->cr_uid != vattr.va_uid) {
|
||||
error = suser_xxx(0, td->td_proc, PRISON_ROOT);
|
||||
error = suser_cred(td->td_ucred, PRISON_ROOT);
|
||||
if (error)
|
||||
goto out;
|
||||
}
|
||||
@ -4158,7 +4158,7 @@ getfh(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, td);
|
||||
@ -4214,7 +4214,7 @@ fhopen(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -4390,7 +4390,7 @@ fhstat(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -4437,7 +4437,7 @@ fhstatfs(td, uap)
|
||||
/*
|
||||
* Must be super user
|
||||
*/
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -4454,7 +4454,7 @@ fhstatfs(td, uap)
|
||||
if ((error = VFS_STATFS(mp, sp, td)) != 0)
|
||||
return (error);
|
||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||
if (suser_xxx(td->td_ucred, 0, 0)) {
|
||||
if (suser(td)) {
|
||||
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
|
||||
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
|
||||
sp = &sb;
|
||||
|
@ -638,7 +638,7 @@ vn_stat(vp, sb, td)
|
||||
}
|
||||
|
||||
sb->st_flags = vap->va_flags;
|
||||
if (suser_xxx(td->td_ucred, 0, 0))
|
||||
if (suser(td))
|
||||
sb->st_gen = 0;
|
||||
else
|
||||
sb->st_gen = vap->va_gen;
|
||||
|
18
sys/net/if.c
18
sys/net/if.c
@ -1230,7 +1230,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
break;
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
ifr->ifr_prevflags = ifp->if_flags;
|
||||
@ -1255,7 +1255,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
break;
|
||||
|
||||
case SIOCSIFCAP:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
if (ifr->ifr_reqcap & ~ifp->if_capabilities)
|
||||
@ -1264,7 +1264,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
break;
|
||||
|
||||
case SIOCSIFMETRIC:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
ifp->if_metric = ifr->ifr_metric;
|
||||
@ -1272,7 +1272,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
break;
|
||||
|
||||
case SIOCSIFPHYS:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return error;
|
||||
if (!ifp->if_ioctl)
|
||||
@ -1286,7 +1286,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
{
|
||||
u_long oldmtu = ifp->if_mtu;
|
||||
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
if (ifr->ifr_mtu < IF_MINMTU || ifr->ifr_mtu > IF_MAXMTU)
|
||||
@ -1311,7 +1311,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
@ -1341,7 +1341,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
case SIOCSLIFPHYADDR:
|
||||
case SIOCSIFMEDIA:
|
||||
case SIOCSIFGENERIC:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
if (ifp->if_ioctl == NULL)
|
||||
@ -1366,7 +1366,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
|
||||
break;
|
||||
|
||||
case SIOCSIFLLADDR:
|
||||
error = suser_td(td);
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return (error);
|
||||
error = if_setlladdr(ifp,
|
||||
@ -1405,7 +1405,7 @@ ifioctl(so, cmd, data, td)
|
||||
switch (cmd) {
|
||||
case SIOCIFCREATE:
|
||||
case SIOCIFDESTROY:
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
return ((cmd == SIOCIFCREATE) ?
|
||||
if_clone_create(ifr->ifr_name, sizeof(ifr->ifr_name)) :
|
||||
|
@ -376,7 +376,7 @@ pppioctl(sc, cmd, data, flag, td)
|
||||
break;
|
||||
|
||||
case PPPIOCSFLAGS:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
break;
|
||||
flags = *(int *)data & SC_MASK;
|
||||
s = splsoftnet();
|
||||
@ -390,7 +390,7 @@ pppioctl(sc, cmd, data, flag, td)
|
||||
break;
|
||||
|
||||
case PPPIOCSMRU:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
mru = *(int *)data;
|
||||
if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
|
||||
@ -403,7 +403,7 @@ pppioctl(sc, cmd, data, flag, td)
|
||||
|
||||
#ifdef VJC
|
||||
case PPPIOCSMAXCID:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
break;
|
||||
if (sc->sc_comp) {
|
||||
s = splsoftnet();
|
||||
@ -414,14 +414,14 @@ pppioctl(sc, cmd, data, flag, td)
|
||||
#endif
|
||||
|
||||
case PPPIOCXFERUNIT:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
break;
|
||||
sc->sc_xfer = p->p_pid;
|
||||
break;
|
||||
|
||||
#ifdef PPP_COMPRESS
|
||||
case PPPIOCSCOMPRESS:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
break;
|
||||
odp = (struct ppp_option_data *) data;
|
||||
nb = odp->length;
|
||||
@ -497,7 +497,7 @@ pppioctl(sc, cmd, data, flag, td)
|
||||
if (cmd == PPPIOCGNPMODE) {
|
||||
npi->mode = sc->sc_npmode[npx];
|
||||
} else {
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
break;
|
||||
if (npi->mode != sc->sc_npmode[npx]) {
|
||||
s = splsoftnet();
|
||||
@ -573,7 +573,7 @@ pppsioctl(ifp, cmd, data)
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
{
|
||||
struct proc *p = curproc; /* XXX */
|
||||
struct thread *td = curthread; /* XXX */
|
||||
register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
|
||||
register struct ifaddr *ifa = (struct ifaddr *)data;
|
||||
register struct ifreq *ifr = (struct ifreq *)data;
|
||||
@ -623,7 +623,7 @@ pppsioctl(ifp, cmd, data)
|
||||
break;
|
||||
|
||||
case SIOCSIFMTU:
|
||||
if ((error = suser(p)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
break;
|
||||
if (ifr->ifr_mtu > PPP_MAXMTU)
|
||||
error = EINVAL;
|
||||
|
@ -341,7 +341,7 @@ slopen(dev, tp)
|
||||
register struct sl_softc *sc;
|
||||
int s, error;
|
||||
|
||||
error = suser_td(curthread);
|
||||
error = suser(curthread);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
|
@ -399,7 +399,7 @@ tapopen(dev, flag, mode, td)
|
||||
int unit, error;
|
||||
struct resource *r = NULL;
|
||||
|
||||
if ((error = suser_td(td)) != 0)
|
||||
if ((error = suser(td)) != 0)
|
||||
return (error);
|
||||
|
||||
unit = dev2unit(dev) & TAPMAXUNIT;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user