From: Jeffrey Altman Date: Wed, 16 May 2007 16:55:16 +0000 (+0000) Subject: DEVEL15-windows-afsd-list-acl-only-dir-20070516 X-Git-Tag: openafs-devel-1_5_20~16 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c17699da4532d2e8c9ed9ea3a129356d833c39e2;p=packages%2Fo%2Fopenafs.git DEVEL15-windows-afsd-list-acl-only-dir-20070516 FIXES 60258 Do not return access denied when applying directory patches if the user does not have read permission. This is the case we want to fake the directory entries for. Also, make sure we set the directory attribute on non-files so that the path can be accessed via the Explorer Shell. (cherry picked from commit 03e3b77553bed4d395393a53d81069c71d67dbea) --- diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 6c91b5d0c..2eae3a3f6 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -3655,15 +3655,20 @@ smb_ApplyV3DirListPatches(cm_scache_t *dscp, smb_dirListPatch_t *patchp; smb_dirListPatch_t *npatchp; afs_uint32 rights; + afs_int32 mustFake = 0; code = cm_FindACLCache(dscp, userp, &rights); if (code == 0 && !(rights & PRSFS_READ)) - code = CM_ERROR_NOACCESS; + mustFake = 1; else if (code == -1) { lock_ObtainMutex(&dscp->mx); code = cm_SyncOp(dscp, NULL, userp, reqp, PRSFS_READ, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); lock_ReleaseMutex(&dscp->mx); + if (code == CM_ERROR_NOACCESS) { + mustFake = 1; + code = 0; + } } if (code) return code; @@ -3675,11 +3680,11 @@ smb_ApplyV3DirListPatches(cm_scache_t *dscp, continue; lock_ObtainMutex(&scp->mx); - code = cm_SyncOp(scp, NULL, userp, reqp, 0, - CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); - if (code) { + if (mustFake == 0) + code = cm_SyncOp(scp, NULL, userp, reqp, 0, + CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); + if (mustFake || code) { lock_ReleaseMutex(&scp->mx); - cm_ReleaseSCache(scp); dptr = patchp->dptr; @@ -3706,9 +3711,20 @@ smb_ApplyV3DirListPatches(cm_scache_t *dscp, *((FILETIME *)dptr) = ft; dptr += 24; + switch (scp->fileType) { + case CM_SCACHETYPE_DIRECTORY: + case CM_SCACHETYPE_MOUNTPOINT: + case CM_SCACHETYPE_SYMLINK: + case CM_SCACHETYPE_INVALID: + *((u_long *)dptr) = SMB_ATTR_DIRECTORY; + break; + default: + *((u_long *)dptr) = SMB_ATTR_NORMAL; + + } /* merge in hidden attribute */ if ( patchp->flags & SMB_DIRLISTPATCH_DOTFILE ) { - *((u_long *)dptr) = SMB_ATTR_HIDDEN; + *((u_long *)dptr) |= SMB_ATTR_HIDDEN; } dptr += 4; } else { @@ -3745,13 +3761,25 @@ smb_ApplyV3DirListPatches(cm_scache_t *dscp, *((u_short *)dptr) = shortTemp; dptr += 10; + /* set the attribute */ + switch (scp->fileType) { + case CM_SCACHETYPE_DIRECTORY: + case CM_SCACHETYPE_MOUNTPOINT: + case CM_SCACHETYPE_SYMLINK: + case CM_SCACHETYPE_INVALID: + attr = SMB_ATTR_DIRECTORY; + default: + attr = SMB_ATTR_NORMAL; + } /* merge in hidden (dot file) attribute */ if ( patchp->flags & SMB_DIRLISTPATCH_DOTFILE ) { - attr = SMB_ATTR_HIDDEN; - *dptr++ = attr & 0xff; - *dptr++ = (attr >> 8) & 0xff; + attr |= SMB_ATTR_HIDDEN; } + *dptr++ = attr & 0xff; + *dptr++ = (attr >> 8) & 0xff; } + + cm_ReleaseSCache(scp); continue; }