get the suser check in the correct places
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 10 May 1989 14:42:24 +0000 (06:42 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 10 May 1989 14:42:24 +0000 (06:42 -0800)
SCCS-vsn: sys/ufs/ffs/ffs_vnops.c 7.9
SCCS-vsn: sys/ufs/ffs/ufs_vnops.c 7.9
SCCS-vsn: sys/ufs/lfs/lfs_vnops.c 7.9
SCCS-vsn: sys/ufs/ufs/ufs_vnops.c 7.9

usr/src/sys/ufs/ffs/ffs_vnops.c
usr/src/sys/ufs/ffs/ufs_vnops.c
usr/src/sys/ufs/lfs/lfs_vnops.c
usr/src/sys/ufs/ufs/ufs_vnops.c

index 823c504..e3b8c7c 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)ffs_vnops.c 7.8 (Berkeley) %G%
+ *     @(#)ffs_vnops.c 7.9 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -275,13 +275,10 @@ ufs_setattr(vp, vap, cred)
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
-       /*
-        * Check whether the following attributes can be changed.
-        */
-       if (cred->cr_uid != ip->i_uid &&
-           (error = suser(cred, &u.u_acflag)))
-               return (error);
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
+               if (cred->cr_uid != ip->i_uid &&
+                   (error = suser(cred, &u.u_acflag)))
+                       return (error);
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
@@ -305,7 +302,11 @@ chmod1(vp, mode, cred)
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
+       int error;
 
 
+       if (cred->cr_uid != ip->i_uid &&
+           (error = suser(cred, &u.u_acflag)))
+               return (error);
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
index b3e22c6..1fb7a86 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)ufs_vnops.c 7.8 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.9 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -275,13 +275,10 @@ ufs_setattr(vp, vap, cred)
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
-       /*
-        * Check whether the following attributes can be changed.
-        */
-       if (cred->cr_uid != ip->i_uid &&
-           (error = suser(cred, &u.u_acflag)))
-               return (error);
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
+               if (cred->cr_uid != ip->i_uid &&
+                   (error = suser(cred, &u.u_acflag)))
+                       return (error);
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
@@ -305,7 +302,11 @@ chmod1(vp, mode, cred)
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
+       int error;
 
 
+       if (cred->cr_uid != ip->i_uid &&
+           (error = suser(cred, &u.u_acflag)))
+               return (error);
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
index 8350227..b2e9447 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)lfs_vnops.c 7.8 (Berkeley) %G%
+ *     @(#)lfs_vnops.c 7.9 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -275,13 +275,10 @@ ufs_setattr(vp, vap, cred)
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
-       /*
-        * Check whether the following attributes can be changed.
-        */
-       if (cred->cr_uid != ip->i_uid &&
-           (error = suser(cred, &u.u_acflag)))
-               return (error);
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
+               if (cred->cr_uid != ip->i_uid &&
+                   (error = suser(cred, &u.u_acflag)))
+                       return (error);
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
@@ -305,7 +302,11 @@ chmod1(vp, mode, cred)
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
+       int error;
 
 
+       if (cred->cr_uid != ip->i_uid &&
+           (error = suser(cred, &u.u_acflag)))
+               return (error);
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
index b3e22c6..1fb7a86 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)ufs_vnops.c 7.8 (Berkeley) %G%
+ *     @(#)ufs_vnops.c 7.9 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -275,13 +275,10 @@ ufs_setattr(vp, vap, cred)
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
                if (error = itrunc(ip, vap->va_size))
                        return (error);
        }
-       /*
-        * Check whether the following attributes can be changed.
-        */
-       if (cred->cr_uid != ip->i_uid &&
-           (error = suser(cred, &u.u_acflag)))
-               return (error);
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
        if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
+               if (cred->cr_uid != ip->i_uid &&
+                   (error = suser(cred, &u.u_acflag)))
+                       return (error);
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
                if (vap->va_atime.tv_sec != VNOVAL)
                        ip->i_flag |= IACC;
                if (vap->va_mtime.tv_sec != VNOVAL)
@@ -305,7 +302,11 @@ chmod1(vp, mode, cred)
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
        struct ucred *cred;
 {
        register struct inode *ip = VTOI(vp);
+       int error;
 
 
+       if (cred->cr_uid != ip->i_uid &&
+           (error = suser(cred, &u.u_acflag)))
+               return (error);
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)
        ip->i_mode &= ~07777;
        if (cred->cr_uid) {
                if (vp->v_type != VDIR)