summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McDonald <danmcd@mnx.io>2022-11-28 14:50:33 -0500
committerDan McDonald <danmcd@mnx.io>2022-11-28 14:50:33 -0500
commit35f42fdf7487ef44e1f0b46c0351b669371b8c46 (patch)
tree249b63ab1ee8b68bda33cb5b75ed585cbfdc92bc
parent645aadb185fb668ad7958d093e51645170df5af1 (diff)
parent0cab3dcd1eb7944361370218fd81d56d85907ed1 (diff)
downloadillumos-joyent-35f42fdf7487ef44e1f0b46c0351b669371b8c46.tar.gz
[illumos-gate merge]
commit 0cab3dcd1eb7944361370218fd81d56d85907ed1 15158 WPTS FSA FileInfo_Set_FileBasicInformation_Dir_Negative commit 6e7e68d69a0c906a89a14afbb5663a30d0f202f0 15157 WPTS FSA FileInfo_Query_FilePositionInformation commit 36d5d64dcecbec1dfcdcf7b4b57d1917c18a7e6f 15156 WPTS FSA FileInfo_Query_FileModeInformation
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c24
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c5
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c17
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_common_open.c7
4 files changed, 45 insertions, 8 deletions
diff --git a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c
index dcfd771baa..6f70a8d74b 100644
--- a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c
+++ b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c
@@ -482,17 +482,35 @@ smb2_qif_position(smb_request_t *sr, smb_queryinfo_t *qi)
/*
* FileModeInformation [MS-FSA 2.4.24]
- * XXX: These mode flags are supposed to be on the open handle,
- * XXX: or I think so. Not yet... (just put zero for now)
*/
static uint32_t
smb2_qif_mode(smb_request_t *sr, smb_queryinfo_t *qi)
{
_NOTE(ARGUNUSED(qi))
+ smb_ofile_t *of = sr->fid_ofile;
+ uint32_t mode;
int rc;
+ /*
+ * See MS-FSA description of Open.Mode
+ * For now, we have these in...
+ */
+ mode = of->f_create_options &
+ (FILE_WRITE_THROUGH | FILE_SEQUENTIAL_ONLY |
+ FILE_NO_INTERMEDIATE_BUFFERING | FILE_DELETE_ON_CLOSE);
+
+ /*
+ * The ofile level DoC flag is currently in of->f_flags
+ * (SMB_OFLAGS_SET_DELETE_ON_CLOSE) though probably it
+ * should be in f_create_options (and perhaps rename
+ * that field to f_mode or something closer to the
+ * Open.Mode terminology used in MS-FSA).
+ */
+ if (of->f_flags & SMB_OFLAGS_SET_DELETE_ON_CLOSE)
+ mode |= FILE_DELETE_ON_CLOSE;
+
rc = smb_mbc_encodef(
- &sr->raw_data, "l", 0);
+ &sr->raw_data, "l", mode);
if (rc != 0)
return (NT_STATUS_BUFFER_OVERFLOW);
diff --git a/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c b/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c
index bbb9f2877b..28b1177158 100644
--- a/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c
+++ b/usr/src/uts/common/fs/smbsrv/smb2_setinfo_file.c
@@ -11,6 +11,7 @@
/*
* Copyright 2019 Nexenta by DDN, Inc. All rights reserved.
+ * Copyright 2022 RackTop Systems, Inc.
*/
/*
@@ -179,7 +180,7 @@ smb2_setf_seek(smb_request_t *sr, smb_setinfo_t *si)
uint64_t newoff;
if (smb_mbc_decodef(&si->si_data, "q", &newoff) != 0)
- return (NT_STATUS_INVALID_PARAMETER);
+ return (NT_STATUS_INFO_LENGTH_MISMATCH);
ASSERT(of->f_magic == SMB_OFILE_MAGIC);
mutex_enter(&of->f_mutex);
@@ -214,7 +215,7 @@ smb2_setf_mode(smb_request_t *sr, smb_setinfo_t *si)
uint32_t Mode;
if (smb_mbc_decodef(&si->si_data, "l", &Mode) != 0)
- return (NT_STATUS_INVALID_PARAMETER);
+ return (NT_STATUS_INFO_LENGTH_MISMATCH);
#if 0 /* XXX - todo */
if (Mode & FILE_WRITE_THROUGH) {
diff --git a/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c b/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c
index 304eb93a39..1b9ed07060 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_cmn_setfile.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2020 Tintri by DDN, Inc. All rights reserved.
+ * Copyright 2022 RackTop Systems, Inc.
*/
/*
@@ -62,9 +63,19 @@ smb_set_basic_info(smb_request_t *sr, smb_setinfo_t *si)
&crtime, &atime, &mtime, &ctime, &attributes) != 0)
return (NT_STATUS_INFO_LENGTH_MISMATCH);
- if ((attributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (!smb_node_is_dir(node)))
- return (NT_STATUS_INVALID_PARAMETER);
+ /*
+ * MS-FSA 2.1.5.14.2 FileBasicInformation
+ * Return STATUS_INVALID_PARAMETER if:
+ * FILE_ATTRIBUTE_TEMPORARY on a directory,
+ * FILE_ATTRIBUTE_DIRECTORY on a non-directory.
+ */
+ if (smb_node_is_dir(node)) {
+ if ((attributes & FILE_ATTRIBUTE_TEMPORARY) != 0)
+ return (NT_STATUS_INVALID_PARAMETER);
+ } else {
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ return (NT_STATUS_INVALID_PARAMETER);
+ }
bzero(attr, sizeof (*attr));
if (atime != 0 && atime != (uint64_t)-1) {
diff --git a/usr/src/uts/common/fs/smbsrv/smb_common_open.c b/usr/src/uts/common/fs/smbsrv/smb_common_open.c
index 2fe367e4c3..cf8ed57a8d 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_common_open.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_common_open.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2020 Tintri by DDN, Inc. All rights reserved.
+ * Copyright 2022 RackTop Systems, Inc.
*/
/*
@@ -938,6 +939,12 @@ create:
goto errout;
}
+ if (is_dir != 0 &&
+ (op->dattr & FILE_ATTRIBUTE_TEMPORARY) != 0) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto errout;
+ }
+
if ((op->desired_access & ACCESS_SYSTEM_SECURITY) != 0 &&
!smb_user_has_security_priv(sr->uid_user, sr->user_cr)) {
status = NT_STATUS_ACCESS_DENIED;