]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfs_search.c
xnu-792.6.76.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_search.c
index 0d013ced4d78a9662c5912aefedf47599b15b74a..1432a7c69058d3072cfade3dc2a4b71674130be9 100644 (file)
@@ -99,7 +99,7 @@ static int CheckCriteria(     ExtendedVCB *vcb,
                                                        searchinfospec_t *searchInfo2,
                                                        Boolean lookForDup );
 
-static int CheckAccess(ExtendedVCB *vcb, u_long searchBits, CatalogKey *key, struct proc *p);
+static int CheckAccess(ExtendedVCB *vcb, u_long searchBits, CatalogKey *key, struct vfs_context *ctx);
 
 static int InsertMatch(struct hfsmount *hfsmp, uio_t a_uio, CatalogRecord *rec,
                        CatalogKey *key, struct attrlist *returnAttrList,
@@ -206,7 +206,7 @@ hfs_vnop_search(ap)
                attrs = ap->a_searchattrs->commonattr | ap->a_returnattrs->commonattr;
                if (attrs & (ATTR_CMN_NAME | ATTR_CMN_PAROBJID))
                        return (EINVAL);
-               if ((err = suser(kauth_cred_get(), 0)))
+               if ((err = vfs_context_suser(ap->a_context)))
                        return (err);
        }
 
@@ -307,7 +307,7 @@ hfs_vnop_search(ap)
                                hfs_systemfile_unlock(hfsmp, lockflags);
                                if (CheckCriteria(vcb, ap->a_options, ap->a_searchattrs, &rec,
                                                                  keyp, &searchInfo1, &searchInfo2, false) &&
-                                       CheckAccess(vcb, ap->a_options, keyp, p)) {
+                                       CheckAccess(vcb, ap->a_options, keyp, ap->a_context)) {
                
                                        result = InsertMatch(hfsmp, ap->a_uio, &rec, 
                                                                          keyp, ap->a_returnattrs,
@@ -365,7 +365,7 @@ hfs_vnop_search(ap)
                }
                if (CheckCriteria( vcb, ap->a_options, ap->a_searchattrs, myCurrentDataPtr,
                                myCurrentKeyPtr, &searchInfo1, &searchInfo2, true )
-               &&  CheckAccess(vcb, ap->a_options, myCurrentKeyPtr, p)) {
+               &&  CheckAccess(vcb, ap->a_options, myCurrentKeyPtr, ap->a_context)) {
                        err = InsertMatch(hfsmp, ap->a_uio, myCurrentDataPtr, 
                                        myCurrentKeyPtr, ap->a_returnattrs,
                                        attributesBuffer, variableBuffer, ap->a_nummatches);
@@ -537,7 +537,7 @@ is_inappropriate_name(char *name, int len)
  */
 
 static int
-CheckAccess(ExtendedVCB *theVCBPtr, u_long searchBits, CatalogKey *theKeyPtr, struct proc *theProcPtr)
+CheckAccess(ExtendedVCB *theVCBPtr, u_long searchBits, CatalogKey *theKeyPtr, struct vfs_context *ctx)
 {
        Boolean                         isHFSPlus;
        int                                     myErr;
@@ -546,13 +546,10 @@ CheckAccess(ExtendedVCB *theVCBPtr, u_long searchBits, CatalogKey *theKeyPtr, st
        hfsmount_t *            hfsmp;
        struct FndrDirInfo      *finfop;
        struct vnode *          vp = NULL;
-       struct vfs_context      my_context;
 
        myResult = 0;   /* default to "no access" */
-       my_context.vc_proc = theProcPtr;
-       my_context.vc_ucred = kauth_cred_get();
                
-       if (!proc_suser(theProcPtr)) {
+       if (!vfs_context_suser(ctx))  {
                myResult = 1;   /* allow access */
                goto ExitThisRoutine; /* root always has access */
        }
@@ -602,9 +599,9 @@ CheckAccess(ExtendedVCB *theVCBPtr, u_long searchBits, CatalogKey *theKeyPtr, st
                myNodeID = cp->c_parentcnid;    /* move up the hierarchy */
                hfs_unlock(VTOC(vp));
                if (vp->v_type == VDIR) {
-                   myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH | KAUTH_VNODE_LIST_DIRECTORY), &my_context);
+                   myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH | KAUTH_VNODE_LIST_DIRECTORY), ctx);
                } else {
-                   myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH), &my_context);
+                   myErr = vnode_authorize(vp, NULL, (KAUTH_VNODE_SEARCH), ctx);
                }
                vnode_put(vp);
                vp = NULL;