[BACK]Return to ufs_vnops.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/ufs/ufs/ufs_vnops.c between version 1.139 and 1.139.4.4

version 1.139, 2006/03/01 12:38:33 version 1.139.4.4, 2006/03/11 16:45:26
Line 78  __KERNEL_RCSID(0, "$NetBSD$");
Line 78  __KERNEL_RCSID(0, "$NetBSD$");
   
 #include <uvm/uvm.h>  #include <uvm/uvm.h>
   
 static int ufs_chmod(struct vnode *, int, struct ucred *, struct proc *);  static int ufs_chmod(struct vnode *, int, kauth_cred_t, struct proc *);
 static int ufs_chown(struct vnode *, uid_t, gid_t, struct ucred *,  static int ufs_chown(struct vnode *, uid_t, gid_t, kauth_cred_t,
     struct proc *);      struct proc *);
   
 /*  /*
Line 185  ufs_open(void *v)
Line 185  ufs_open(void *v)
         struct vop_open_args /* {          struct vop_open_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 int             a_mode;                  int             a_mode;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
   
Line 210  ufs_close(void *v)
Line 210  ufs_close(void *v)
         struct vop_close_args /* {          struct vop_close_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 int             a_fflag;                  int             a_fflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct vnode    *vp;          struct vnode    *vp;
Line 231  ufs_access(void *v)
Line 231  ufs_access(void *v)
         struct vop_access_args /* {          struct vop_access_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 int             a_mode;                  int             a_mode;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct vnode    *vp;          struct vnode    *vp;
Line 287  ufs_getattr(void *v)
Line 287  ufs_getattr(void *v)
         struct vop_getattr_args /* {          struct vop_getattr_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct vattr    *a_vap;                  struct vattr    *a_vap;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct vnode    *vp;          struct vnode    *vp;
Line 358  ufs_setattr(void *v)
Line 358  ufs_setattr(void *v)
         struct vop_setattr_args /* {          struct vop_setattr_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct vattr    *a_vap;                  struct vattr    *a_vap;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct vattr    *vap;          struct vattr    *vap;
         struct vnode    *vp;          struct vnode    *vp;
         struct inode    *ip;          struct inode    *ip;
         struct ucred    *cred;          kauth_cred_t    cred;
         struct lwp      *l;          struct lwp      *l;
         int             error;          int             error;
   
Line 386  ufs_setattr(void *v)
Line 386  ufs_setattr(void *v)
         if (vap->va_flags != VNOVAL) {          if (vap->va_flags != VNOVAL) {
                 if (vp->v_mount->mnt_flag & MNT_RDONLY)                  if (vp->v_mount->mnt_flag & MNT_RDONLY)
                         return (EROFS);                          return (EROFS);
                 if (cred->cr_uid != ip->i_uid &&                  if (kauth_cred_geteuid(cred) != ip->i_uid &&
                     (error = suser(cred, &l->l_proc->p_acflag)))                      (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
                                                  &l->l_proc->p_acflag)))
                         return (error);                          return (error);
                 if (cred->cr_uid == 0) {                  if (kauth_cred_geteuid(cred) == 0) {
                         if ((ip->i_flags & (SF_IMMUTABLE | SF_APPEND)) &&                          if ((ip->i_flags & (SF_IMMUTABLE | SF_APPEND)) &&
                             securelevel > 0)                              securelevel > 0)
                                 return (EPERM);                                  return (EPERM);
Line 459  ufs_setattr(void *v)
Line 460  ufs_setattr(void *v)
                         return (EROFS);                          return (EROFS);
                 if ((ip->i_flags & SF_SNAPSHOT) != 0)                  if ((ip->i_flags & SF_SNAPSHOT) != 0)
                         return (EPERM);                          return (EPERM);
                 if (cred->cr_uid != ip->i_uid &&                  if (kauth_cred_geteuid(cred) != ip->i_uid &&
                     (error = suser(cred, &l->l_proc->p_acflag)) &&                      (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
                                                  &l->l_proc->p_acflag)) &&
                     ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||                      ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
                     (error = VOP_ACCESS(vp, VWRITE, cred, l))))                      (error = VOP_ACCESS(vp, VWRITE, cred, l))))
                         return (error);                          return (error);
Line 497  ufs_setattr(void *v)
Line 499  ufs_setattr(void *v)
  * Inode must be locked before calling.   * Inode must be locked before calling.
  */   */
 static int  static int
 ufs_chmod(struct vnode *vp, int mode, struct ucred *cred, struct proc *p)  ufs_chmod(struct vnode *vp, int mode, kauth_cred_t cred, struct proc *p)
 {  {
         struct inode    *ip;          struct inode    *ip;
         int             error;          int             error, ismember = 0;
   
         ip = VTOI(vp);          ip = VTOI(vp);
         if (cred->cr_uid != ip->i_uid &&          if (kauth_cred_geteuid(cred) != ip->i_uid &&
             (error = suser(cred, &p->p_acflag)))              (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
                                          &p->p_acflag)))
                 return (error);                  return (error);
         if (cred->cr_uid) {          if (kauth_cred_geteuid(cred)) {
                 if (vp->v_type != VDIR && (mode & S_ISTXT))                  if (vp->v_type != VDIR && (mode & S_ISTXT))
                         return (EFTYPE);                          return (EFTYPE);
                 if (!groupmember(ip->i_gid, cred) && (mode & ISGID))                  if ((kauth_cred_ismember_gid(cred, ip->i_gid, &ismember) != 0 ||
                       !ismember) && (mode & ISGID))
                         return (EPERM);                          return (EPERM);
         }          }
         ip->i_mode &= ~ALLPERMS;          ip->i_mode &= ~ALLPERMS;
Line 524  ufs_chmod(struct vnode *vp, int mode, st
Line 528  ufs_chmod(struct vnode *vp, int mode, st
  * inode must be locked prior to call.   * inode must be locked prior to call.
  */   */
 static int  static int
 ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred,  ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, kauth_cred_t cred,
         struct proc *p)          struct proc *p)
 {  {
         struct inode    *ip;          struct inode    *ip;
         int             error;          int             error, ismember = 0;
 #ifdef QUOTA  #ifdef QUOTA
         uid_t           ouid;          uid_t           ouid;
         gid_t           ogid;          gid_t           ogid;
Line 548  ufs_chown(struct vnode *vp, uid_t uid, g
Line 552  ufs_chown(struct vnode *vp, uid_t uid, g
          * the caller's credentials must imply super-user privilege           * the caller's credentials must imply super-user privilege
          * or the call fails.           * or the call fails.
          */           */
         if ((cred->cr_uid != ip->i_uid || uid != ip->i_uid ||          if ((kauth_cred_geteuid(cred) != ip->i_uid || uid != ip->i_uid ||
             (gid != ip->i_gid &&              (gid != ip->i_gid &&
              !(cred->cr_gid == gid || groupmember((gid_t)gid, cred)))) &&               !(kauth_cred_getegid(cred) == gid ||
             ((error = suser(cred, &p->p_acflag)) != 0))                (kauth_cred_ismember_gid(cred, gid, &ismember) == 0 &&
                 ismember)))) &&
               ((error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER,
                                           &p->p_acflag)) != 0))
                 return (error);                  return (error);
   
 #ifdef QUOTA  #ifdef QUOTA
Line 1071  ufs_rename(void *v)
Line 1078  ufs_rename(void *v)
                  * otherwise the destination may not be changed (except by                   * otherwise the destination may not be changed (except by
                  * root). This implements append-only directories.                   * root). This implements append-only directories.
                  */                   */
                 if ((dp->i_mode & S_ISTXT) && tcnp->cn_cred->cr_uid != 0 &&                  if ((dp->i_mode & S_ISTXT) && kauth_cred_geteuid(tcnp->cn_cred) != 0 &&
                     tcnp->cn_cred->cr_uid != dp->i_uid &&                      kauth_cred_geteuid(tcnp->cn_cred) != dp->i_uid &&
                     xp->i_uid != tcnp->cn_cred->cr_uid) {                      xp->i_uid != kauth_cred_geteuid(tcnp->cn_cred)) {
                         error = EPERM;                          error = EPERM;
                         goto bad;                          goto bad;
                 }                  }
Line 1263  ufs_mkdir(void *v)
Line 1270  ufs_mkdir(void *v)
                 goto out;                  goto out;
         tvp = *ap->a_vpp;          tvp = *ap->a_vpp;
         ip = VTOI(tvp);          ip = VTOI(tvp);
         ip->i_uid = cnp->cn_cred->cr_uid;          ip->i_uid = kauth_cred_geteuid(cnp->cn_cred);
         DIP_ASSIGN(ip, uid, ip->i_uid);          DIP_ASSIGN(ip, uid, ip->i_uid);
         ip->i_gid = dp->i_gid;          ip->i_gid = dp->i_gid;
         DIP_ASSIGN(ip, gid, ip->i_gid);          DIP_ASSIGN(ip, gid, ip->i_gid);
Line 1565  ufs_readdir(void *v)
Line 1572  ufs_readdir(void *v)
         struct vop_readdir_args /* {          struct vop_readdir_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct uio      *a_uio;                  struct uio      *a_uio;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 int             *a_eofflag;                  int             *a_eofflag;
                 off_t           **a_cookies;                  off_t           **a_cookies;
                 int             *ncookies;                  int             *ncookies;
Line 1690  ufs_readlink(void *v)
Line 1697  ufs_readlink(void *v)
         struct vop_readlink_args /* {          struct vop_readlink_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct uio      *a_uio;                  struct uio      *a_uio;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
         } */ *ap = v;          } */ *ap = v;
         struct vnode    *vp = ap->a_vp;          struct vnode    *vp = ap->a_vp;
         struct inode    *ip = VTOI(vp);          struct inode    *ip = VTOI(vp);
Line 1787  ufsspec_read(void *v)
Line 1794  ufsspec_read(void *v)
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct uio      *a_uio;                  struct uio      *a_uio;
                 int             a_ioflag;                  int             a_ioflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
         } */ *ap = v;          } */ *ap = v;
   
         /*          /*
Line 1808  ufsspec_write(void *v)
Line 1815  ufsspec_write(void *v)
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct uio      *a_uio;                  struct uio      *a_uio;
                 int             a_ioflag;                  int             a_ioflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
         } */ *ap = v;          } */ *ap = v;
   
         /*          /*
Line 1830  ufsspec_close(void *v)
Line 1837  ufsspec_close(void *v)
         struct vop_close_args /* {          struct vop_close_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 int             a_fflag;                  int             a_fflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct vnode    *vp;          struct vnode    *vp;
Line 1855  ufsfifo_read(void *v)
Line 1862  ufsfifo_read(void *v)
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct uio      *a_uio;                  struct uio      *a_uio;
                 int             a_ioflag;                  int             a_ioflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
         } */ *ap = v;          } */ *ap = v;
   
         /*          /*
Line 1875  ufsfifo_write(void *v)
Line 1882  ufsfifo_write(void *v)
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 struct uio      *a_uio;                  struct uio      *a_uio;
                 int             a_ioflag;                  int             a_ioflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
         } */ *ap = v;          } */ *ap = v;
   
         /*          /*
Line 1896  ufsfifo_close(void *v)
Line 1903  ufsfifo_close(void *v)
         struct vop_close_args /* {          struct vop_close_args /* {
                 struct vnode    *a_vp;                  struct vnode    *a_vp;
                 int             a_fflag;                  int             a_fflag;
                 struct ucred    *a_cred;                  kauth_cred_t    a_cred;
                 struct lwp      *a_l;                  struct lwp      *a_l;
         } */ *ap = v;          } */ *ap = v;
         struct vnode    *vp;          struct vnode    *vp;
Line 2050  ufs_makeinode(int mode, struct vnode *dv
Line 2057  ufs_makeinode(int mode, struct vnode *dv
         struct inode    *ip, *pdir;          struct inode    *ip, *pdir;
         struct direct   *newdir;          struct direct   *newdir;
         struct vnode    *tvp;          struct vnode    *tvp;
         int             error;          int             error, ismember = 0;
   
         pdir = VTOI(dvp);          pdir = VTOI(dvp);
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
Line 2069  ufs_makeinode(int mode, struct vnode *dv
Line 2076  ufs_makeinode(int mode, struct vnode *dv
         ip = VTOI(tvp);          ip = VTOI(tvp);
         ip->i_gid = pdir->i_gid;          ip->i_gid = pdir->i_gid;
         DIP_ASSIGN(ip, gid, ip->i_gid);          DIP_ASSIGN(ip, gid, ip->i_gid);
         ip->i_uid = cnp->cn_cred->cr_uid;          ip->i_uid = kauth_cred_geteuid(cnp->cn_cred);
         DIP_ASSIGN(ip, uid, ip->i_uid);          DIP_ASSIGN(ip, uid, ip->i_uid);
 #ifdef QUOTA  #ifdef QUOTA
         if ((error = getinoquota(ip)) ||          if ((error = getinoquota(ip)) ||
Line 2090  ufs_makeinode(int mode, struct vnode *dv
Line 2097  ufs_makeinode(int mode, struct vnode *dv
         DIP_ASSIGN(ip, nlink, 1);          DIP_ASSIGN(ip, nlink, 1);
         if (DOINGSOFTDEP(tvp))          if (DOINGSOFTDEP(tvp))
                 softdep_change_linkcnt(ip);                  softdep_change_linkcnt(ip);
         if ((ip->i_mode & ISGID) &&          if ((ip->i_mode & ISGID) && (kauth_cred_ismember_gid(cnp->cn_cred,
                 !groupmember(ip->i_gid, cnp->cn_cred) &&              ip->i_gid, &ismember) != 0 || !ismember) &&
             suser(cnp->cn_cred, NULL)) {              kauth_authorize_generic(cnp->cn_cred, KAUTH_GENERIC_ISSUSER, NULL)) {
                 ip->i_mode &= ~ISGID;                  ip->i_mode &= ~ISGID;
                 DIP_ASSIGN(ip, mode, ip->i_mode);                  DIP_ASSIGN(ip, mode, ip->i_mode);
         }          }
Line 2146  ufs_makeinode(int mode, struct vnode *dv
Line 2153  ufs_makeinode(int mode, struct vnode *dv
  */   */
 int  int
 ufs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags,  ufs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags,
     struct ucred *cred)      kauth_cred_t cred)
 {  {
         struct inode *ip = VTOI(vp);          struct inode *ip = VTOI(vp);
         int error, delta, bshift, bsize;          int error, delta, bshift, bsize;

Legend:
Removed from v.1.139  
changed lines
  Added in v.1.139.4.4

CVSweb <webmaster@jp.NetBSD.org>