summaryrefslogtreecommitdiff
path: root/source3/libsmb/cli_smb2_fnum.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2017-07-17 10:37:15 -0700
committerJeremy Allison <jra@samba.org>2017-07-18 09:49:17 +0200
commitf1cc79a46d56bda99c392d491d88479cd6427a32 (patch)
treedf01c38bcc8d16462f08cb4dc8e8f726669077e3 /source3/libsmb/cli_smb2_fnum.c
parent59f89515051c1b68f2de6dc76cfcf126c71d1db0 (diff)
downloadsamba-f1cc79a46d56bda99c392d491d88479cd6427a32.tar.gz
s3: libsmb: Reverse sense of 'clear all attributes', ignore attribute change in SMB2 to match SMB1.
SMB1 uses attr == 0 to clear all attributes on a file (end up with FILE_ATTRIBUTE_NORMAL), and attr == FILE_ATTRIBUTE_NORMAL to mean ignore request attribute change. SMB2 uses exactly the reverse. Unfortunately as the cli_setatr() ABI is exposed inside libsmbclient, we must make the SMB2 cli_smb2_setatr() call export the same ABI as the SMB1 cli_setatr() which calls it. This means reversing the sense of the requested attr argument if it's zero or FILE_ATTRIBUTE_NORMAL. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12899 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Diffstat (limited to 'source3/libsmb/cli_smb2_fnum.c')
-rw-r--r--source3/libsmb/cli_smb2_fnum.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 954f3fe3a7f..6967555797a 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1698,6 +1698,29 @@ NTSTATUS cli_smb2_setatr(struct cli_state *cli,
inbuf.length = sizeof(inbuf_store);
data_blob_clear(&inbuf);
+ /*
+ * SMB1 uses attr == 0 to clear all attributes
+ * on a file (end up with FILE_ATTRIBUTE_NORMAL),
+ * and attr == FILE_ATTRIBUTE_NORMAL to mean ignore
+ * request attribute change.
+ *
+ * SMB2 uses exactly the reverse. Unfortunately as the
+ * cli_setatr() ABI is exposed inside libsmbclient,
+ * we must make the SMB2 cli_smb2_setatr() call
+ * export the same ABI as the SMB1 cli_setatr()
+ * which calls it. This means reversing the sense
+ * of the requested attr argument if it's zero
+ * or FILE_ATTRIBUTE_NORMAL.
+ *
+ * See BUG: https://bugzilla.samba.org/show_bug.cgi?id=12899
+ */
+
+ if (attr == 0) {
+ attr = FILE_ATTRIBUTE_NORMAL;
+ } else if (attr == FILE_ATTRIBUTE_NORMAL) {
+ attr = 0;
+ }
+
SSVAL(inbuf.data, 32, attr);
if (mtime != 0) {
put_long_date((char *)inbuf.data + 16,mtime);