Avoid checking for privileges if there is no need to.
Discussed with: rwatson
This commit is contained in:
parent
62de975b4d
commit
9558665f1e
@ -596,7 +596,7 @@ ext2_chown(vp, uid, gid, cred, td)
|
||||
ip->i_gid = gid;
|
||||
ip->i_uid = uid;
|
||||
ip->i_flag |= IN_CHANGE;
|
||||
if (ouid != uid || ogid != gid) {
|
||||
if ((ip->i_mode & (ISUID | ISGID)) && (ouid != uid || ogid != gid)) {
|
||||
if (priv_check_cred(cred, PRIV_VFS_CLEARSUGID,
|
||||
SUSER_ALLOWJAIL) != 0)
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
|
@ -788,11 +788,13 @@ ffs_write(ap)
|
||||
* we clear the setuid and setgid bits as a precaution against
|
||||
* tampering.
|
||||
*/
|
||||
if (resid > uio->uio_resid && ap->a_cred &&
|
||||
priv_check_cred(ap->a_cred, PRIV_VFS_CLEARSUGID,
|
||||
SUSER_ALLOWJAIL)) {
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
DIP_SET(ip, i_mode, ip->i_mode);
|
||||
if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid &&
|
||||
ap->a_cred) {
|
||||
if (priv_check_cred(ap->a_cred, PRIV_VFS_CLEARSUGID,
|
||||
SUSER_ALLOWJAIL)) {
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
DIP_SET(ip, i_mode, ip->i_mode);
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
if (ioflag & IO_UNIT) {
|
||||
@ -1115,10 +1117,12 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *ucred)
|
||||
* we clear the setuid and setgid bits as a precaution against
|
||||
* tampering.
|
||||
*/
|
||||
if (resid > uio->uio_resid && ucred &&
|
||||
priv_check_cred(ucred, PRIV_VFS_CLEARSUGID, SUSER_ALLOWJAIL)) {
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
dp->di_mode = ip->i_mode;
|
||||
if ((ip->i_mode & (ISUID | ISGID)) && resid > uio->uio_resid && ucred) {
|
||||
if (priv_check_cred(ap->a_cred, PRIV_VFS_CLEARSUGID,
|
||||
SUSER_ALLOWJAIL)) {
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
dp->di_mode = ip->i_mode;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
if (ioflag & IO_UNIT) {
|
||||
|
@ -786,10 +786,11 @@ good:
|
||||
panic("ufs_chown: lost quota");
|
||||
#endif /* QUOTA */
|
||||
ip->i_flag |= IN_CHANGE;
|
||||
if (priv_check_cred(cred, PRIV_VFS_CLEARSUGID, SUSER_ALLOWJAIL) &&
|
||||
(ouid != uid || ogid != gid)) {
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
DIP_SET(ip, i_mode, ip->i_mode);
|
||||
if ((ip->i_mode & (ISUID | ISGID)) && (ouid != uid || ogid != gid)) {
|
||||
if (priv_check_cred(cred, PRIV_VFS_CLEARSUGID, SUSER_ALLOWJAIL)) {
|
||||
ip->i_mode &= ~(ISUID | ISGID);
|
||||
DIP_SET(ip, i_mode, ip->i_mode);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user