From 3138aaba25fc93ec0ef38cd1cf61100b86990e80 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 24 Nov 2009 18:08:55 -0500 Subject: [PATCH] Windows: Fix test for setting FILE_ATTR_READONLY When checking whether or not to enforce the unix mode bits as if they were the Windows FILE_ATTR_READONLY flag the mask 0200 is used. Make sure that the same mask is used when publishing the FILE_ATTR_READONLY flag to the smb client. LICENSE MIT Change-Id: Ia68bd17ad80341f1c14f3c0caaec8f09a0a2f3c5 Reviewed-on: http://gerrit.openafs.org/868 Reviewed-by: Derrick Brashear Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- src/WINNT/afsd/smb.c | 8 ++++---- src/WINNT/afsd/smb3.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index cc402f8ed..6af4eb61c 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -482,10 +482,10 @@ unsigned int smb_Attributes(cm_scache_t *scp) * turns out to be impolitic in NT. See defect 10007. */ #ifdef notdef - if ((scp->unixModeBits & 0222) == 0 || (scp->flags & CM_SCACHEFLAG_RO)) + if ((scp->unixModeBits & 0200) == 0 || (scp->flags & CM_SCACHEFLAG_RO)) attrs |= SMB_ATTR_READONLY; /* turn on read-only flag */ #else - if ((scp->unixModeBits & 0222) == 0) + if ((scp->unixModeBits & 0200) == 0) attrs |= SMB_ATTR_READONLY; /* turn on read-only flag */ #endif @@ -5417,12 +5417,12 @@ long smb_ReceiveCoreSetFileAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_pack attr.mask |= CM_ATTRMASK_CLIENTMODTIME; smb_UnixTimeFromDosUTime(&attr.clientModTime, dosTime); } - if ((newScp->unixModeBits & 0222) && (attribute & SMB_ATTR_READONLY) != 0) { + if ((newScp->unixModeBits & 0200) && (attribute & SMB_ATTR_READONLY) != 0) { /* we're told to make a writable file read-only */ attr.unixModeBits = newScp->unixModeBits & ~0222; attr.mask |= CM_ATTRMASK_UNIXMODEBITS; } - else if ((newScp->unixModeBits & 0222) == 0 && (attribute & SMB_ATTR_READONLY) == 0) { + else if ((newScp->unixModeBits & 0200) == 0 && (attribute & SMB_ATTR_READONLY) == 0) { /* we're told to make a read-only file writable */ attr.unixModeBits = newScp->unixModeBits | 0222; attr.mask |= CM_ATTRMASK_UNIXMODEBITS; diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index cb185df4e..3440e9467 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -115,10 +115,10 @@ unsigned long smb_ExtAttributes(cm_scache_t *scp) * turns out to be impolitic in NT. See defect 10007. */ #ifdef notdef - if ((scp->unixModeBits & 0222) == 0 || (scp->flags & CM_SCACHEFLAG_RO)) + if ((scp->unixModeBits & 0200) == 0 || (scp->flags & CM_SCACHEFLAG_RO)) attrs |= SMB_ATTR_READONLY; /* Read-only */ #else - if ((scp->unixModeBits & 0222) == 0) + if ((scp->unixModeBits & 0200) == 0) attrs |= SMB_ATTR_READONLY; /* Read-only */ #endif @@ -3644,13 +3644,13 @@ long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet } if (spi->u.QPstandardInfo.attributes != 0) { - if ((scp->unixModeBits & 0222) + if ((scp->unixModeBits & 0200) && (spi->u.QPstandardInfo.attributes & SMB_ATTR_READONLY) != 0) { /* make a writable file read-only */ attr.mask |= CM_ATTRMASK_UNIXMODEBITS; attr.unixModeBits = scp->unixModeBits & ~0222; } - else if ((scp->unixModeBits & 0222) == 0 + else if ((scp->unixModeBits & 0200) == 0 && (spi->u.QPstandardInfo.attributes & SMB_ATTR_READONLY) == 0) { /* make a read-only file writable */ attr.mask |= CM_ATTRMASK_UNIXMODEBITS; @@ -3981,13 +3981,13 @@ long smb_ReceiveTran2SetFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet attribute = sfi->u.QFbasicInfo.attributes; if (attribute != 0) { - if ((scp->unixModeBits & 0222) + if ((scp->unixModeBits & 0200) && (attribute & SMB_ATTR_READONLY) != 0) { /* make a writable file read-only */ attr.mask |= CM_ATTRMASK_UNIXMODEBITS; attr.unixModeBits = scp->unixModeBits & ~0222; } - else if ((scp->unixModeBits & 0222) == 0 + else if ((scp->unixModeBits & 0200) == 0 && (attribute & SMB_ATTR_READONLY) == 0) { /* make a read-only file writable */ attr.mask |= CM_ATTRMASK_UNIXMODEBITS; -- 2.39.5