Skip to content

Commit

Permalink
Merge pull request #974 from truenas/add-kernel-dosmode-support
Browse files Browse the repository at this point in the history
NAS-109678 / 12.0 / s3:smbd:open - add support for kernel dosmodes
  • Loading branch information
william-gr committed Mar 4, 2021
2 parents 9e65a57 + ed70612 commit 3128112
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 8 deletions.
2 changes: 1 addition & 1 deletion net/samba/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

PORTNAME= ${SAMBA4_BASENAME}
PORTVERSION= ${SAMBA4_VERSION}
PORTREVISION= 6
PORTREVISION= 7
CATEGORIES?= net
MASTER_SITES= SAMBA/samba/stable SAMBA/samba/rc
DISTNAME= ${SAMBA4_DISTNAME}
Expand Down
5 changes: 3 additions & 2 deletions net/samba/files/0001-add-ix-custom-vfs-modules.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2126,10 +2126,10 @@ index 00000000000..801553403c7
+#endif /* !__SMB_LIBZFS_H */
diff --git a/source3/modules/vfs_ixnas.c b/source3/modules/vfs_ixnas.c
new file mode 100644
index 00000000000..8e3f6073269
index 00000000000..fbfc2391fdc
--- /dev/null
+++ b/source3/modules/vfs_ixnas.c
@@ -0,0 +1,2577 @@
@@ -0,0 +1,2578 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * A dumping ground for FreeBSD-specific VFS functions. For testing case
Expand Down Expand Up @@ -4640,6 +4640,7 @@ index 00000000000..8e3f6073269
+ lp_do_parameter(SNUM(handle->conn), "store dos attributes",
+ "no");
+ }
+ lp_do_parameter(SNUM(handle->conn), "kernel dosmodes", "yes");
+ }
+
+ ok = set_acl_parameters(handle, config);
Expand Down
33 changes: 30 additions & 3 deletions net/samba/files/0001-add-parameters-for-ha-configuration.patch
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ index 00000000000..ee113b12ea7
+<value type="default">yes</value>
+<value type="example">no</value>
+</samba:parameter>
diff --git a/docs-xml/smbdotconf/filename/kerneldosmodes.xml b/docs-xml/smbdotconf/filename/kerneldosmodes.xml
new file mode 100644
index 00000000000..b0808a436c5
--- /dev/null
+++ b/docs-xml/smbdotconf/filename/kerneldosmodes.xml
@@ -0,0 +1,13 @@
+<samba:parameter name="kernel dosmodes"
+ context="S"
+ type="boolean"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+ <para>
+ This parameter is set to indicate that server supports kernel dosmodes.
+ In case they are enabled, normal dosmode storage in xattr / posix mode are bypassed
+ in favor of direct call to relevant SET/FSET_DOS_ATTRIBUTES vfs function.
+ </para>
+</description>
+<value type="default">no</value>
+</samba:parameter>
diff --git a/docs-xml/smbdotconf/winbind/winbindnetbiosaliasspn.xml b/docs-xml/smbdotconf/winbind/winbindnetbiosaliasspn.xml
new file mode 100644
index 00000000000..6979955a101
Expand Down Expand Up @@ -151,18 +170,26 @@ index a087587bba7..bdca3030f19 100644
for (addl_hostnames = lp_additional_dns_hostnames();
addl_hostnames != NULL && *addl_hostnames != NULL;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index d3d81f6ece5..2b13e37d3eb 100644
index d3d81f6ece5..31ce1f1f37d 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -690,6 +690,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
@@ -194,6 +194,7 @@ static const struct loadparm_service _sDefault =
.map_hidden = false,
.map_archive = true,
.store_dos_attributes = true,
+ .kernel_dosmodes = false,
.dmapi_support = false,
.locking = true,
.strict_locking = Auto,
@@ -690,6 +691,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
#endif
Globals.time_server = false;
Globals.bind_interfaces_only = false;
+ Globals.enable_web_service_discovery = false;
Globals.unix_password_sync = false;
Globals.pam_password_change = false;
Globals.passwd_chat_debug = false;
@@ -721,6 +722,11 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
@@ -721,6 +723,11 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
Globals.log_writeable_files_on_exit = false;
Globals.create_krb5_conf = true;
Globals.include_system_krb5_conf = true;
Expand Down
42 changes: 40 additions & 2 deletions net/samba/files/smbd-core-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ index 5bcf0503b4c..04b0ec11b25 100644
#ifdef USE_DMAPI
struct smbd_dmapi_context;
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 4a31b822646..561baf9906d 100644
index 4a31b822646..3992cff5ce6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -641,6 +641,7 @@ static int non_widelink_open(struct connection_struct *conn,
Expand All @@ -823,6 +823,22 @@ index 4a31b822646..561baf9906d 100644

/*
* Only follow symlinks within a share
@@ -2978,13 +2981,13 @@ static bool open_match_attributes(connection_struct *conn,
(unsigned int)*returned_unx_mode ));

/* If we're mapping SYSTEM and HIDDEN ensure they match. */
- if (lp_map_system(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn))) {
+ if (lp_map_system(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn)) || lp_kernel_dosmodes(SNUM(conn))) {
if ((old_dos_attr & FILE_ATTRIBUTE_SYSTEM) &&
!(new_dos_attr & FILE_ATTRIBUTE_SYSTEM)) {
return False;
}
}
- if (lp_map_hidden(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn))) {
+ if (lp_map_hidden(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn)) || lp_kernel_dosmodes(SNUM(conn))) {
if ((old_dos_attr & FILE_ATTRIBUTE_HIDDEN) &&
!(new_dos_attr & FILE_ATTRIBUTE_HIDDEN)) {
return False;
@@ -3670,10 +3673,24 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
/*
* Ensure we pay attention to default ACLs on directories if required.
Expand Down Expand Up @@ -852,6 +868,28 @@ index 4a31b822646..561baf9906d 100644
}

DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o, "
@@ -4040,6 +4057,10 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
}
}
}
+ else if (lp_kernel_dosmodes(SNUM(conn)) && !posix_open) {
+ SMB_VFS_SET_DOS_ATTRIBUTES(conn, smb_fname,
+ new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE);
+ }
}

/* Determine sparse flag. */
@@ -4199,6 +4220,10 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
parent_dir, true);
}
}
+ else if (lp_kernel_dosmodes(SNUM(conn)) && !posix_open) {
+ SMB_VFS_SET_DOS_ATTRIBUTES(conn, smb_dname,
+ file_attributes | FILE_ATTRIBUTE_DIRECTORY);
+ }

if (lp_inherit_permissions(SNUM(conn))) {
inherit_access_posix_acl(conn, parent_dir,
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index ac021ad93fe..20f90634a6e 100644
--- a/source3/smbd/proto.h
Expand Down Expand Up @@ -1224,7 +1262,7 @@ index 5162ec06ea9..a49b934720a 100644
}
DEBUG(10,("stat_cache_delete: deleting name [%s] -> %s\n",
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 339dd36b6af..70f95f97935 100644
index 339dd36b6af..02bd92c6b01 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -258,9 +258,22 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx,
Expand Down

0 comments on commit 3128112

Please sign in to comment.