Update samba48 port to 4.8.5 version

Sponsored by:	my wife
This commit is contained in:
Timur I. Bakeyev 2018-09-02 22:36:09 +00:00
parent a1c342c6f1
commit 1ad8b026b7
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=478825
11 changed files with 36 additions and 1468 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= ${SAMBA4_BASENAME}48
PORTVERSION= ${SAMBA4_VERSION}
PORTREVISION= 1
PORTREVISION= 0
CATEGORIES?= net
MASTER_SITES= SAMBA/samba/stable SAMBA/samba/rc
DISTNAME= ${SAMBA4_DISTNAME}
@ -21,17 +21,12 @@ CONFLICTS_INSTALL?= samba4-4.0.* samba4[1-79]-4.* p5-Parse-Pidl-4.*
EXTRA_PATCHES+= ${PATCHDIR}/0001-Zfs-provision-1.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-Freenas-master-mdns-fixes-22.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-audit.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-ctdb.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-bug-13175.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-bug-13351.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-bug-13441.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-bug-13451.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-bug-13537.patch:-p1
EXTRA_PATCHES+= ${PATCHDIR}/0001-bug-228462.patch:-p1
SAMBA4_BASENAME= samba
SAMBA4_PORTNAME= ${SAMBA4_BASENAME}4
SAMBA4_VERSION= 4.8.4
SAMBA4_VERSION= 4.8.5
SAMBA4_DISTNAME= ${SAMBA4_BASENAME}-${SAMBA4_VERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|}
WRKSRC?= ${WRKDIR}/${DISTNAME}
@ -165,8 +160,8 @@ RUN_DEPENDS+= libarchive>=3.1.2:archivers/libarchive
#SAMBA4_BUNDLED_TALLOC?= no
#SAMBA4_BUNDLED_TEVENT?= no
#SAMBA4_BUNDLED_TDB?= no
SAMBA4_BUNDLED_LDB?= yes
SAMBA4_LDB= 13
#SAMBA4_BUNDLED_LDB?= yes
#SAMBA4_LDB= 13
# cmocka
.if defined(SAMBA4_BUNDLED_CMOCKA)
SAMBA4_BUNDLED_LIBS+= cmocka
@ -228,8 +223,8 @@ PLIST_SUB+= SAMBA4_BUNDLED_LDB=""
SUB_LIST+= SAMBA4_BUNDLED_LDB=""
.else
. if ${SAMBA4_LDB} == 13
BUILD_DEPENDS+= ldb13>=1.3.4:databases/ldb13
RUN_DEPENDS+= ldb13>=1.3.4:databases/ldb13
BUILD_DEPENDS+= ldb13>=1.3.6:databases/ldb13
RUN_DEPENDS+= ldb13>=1.3.6:databases/ldb13
. elif ${SAMBA4_LDB} == 12
BUILD_DEPENDS+= ldb12>=1.2.3:databases/ldb12
RUN_DEPENDS+= ldb12>=1.2.3:databases/ldb12
@ -483,7 +478,8 @@ CONFIGURE_ARGS+= --accel-aes=none
.endif
.if ${PORT_OPTIONS:MGSSAPI_MIT}
PLIST_FILES+= lib/samba4/winbind-krb5-localauth.so
PLIST_FILES+= lib/shared-modules/krb5/winbind_krb5_localauth.so \
man/man8/winbind_krb5_localauth.8.gz
. if ${PORT_OPTIONS:MAD_DC}
PLIST_FILES+= lib/samba4/krb5/plugins/kdb/samba.so
. endif

View file

@ -1,3 +1,3 @@
TIMESTAMP = 1534251663
SHA256 (samba-4.8.4.tar.gz) = f5044d149e01894a08b1d114b8b69aed78171a7bb19608bd1fd771453b9a5406
SIZE (samba-4.8.4.tar.gz) = 17700008
TIMESTAMP = 1535201844
SHA256 (samba-4.8.5.tar.gz) = e58ee6b1262d4128b8932ceee59d5f0b0a9bbe00547eb3cc4c41552de1a65155
SIZE (samba-4.8.5.tar.gz) = 17715401

View file

@ -1,50 +0,0 @@
From 1598b78bf791b5a2b8ff52745563ebfcc2a5a0cb Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 22 Mar 2018 08:03:58 +0100
Subject: [PATCH] s3: smbd: always set vuid in check_user_ok()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
A SMB session reauth will have invalidated conn->vuid via
conn_clear_vuid_caches().
Ensure conn->vuid always has the vuid of the current user in
check_user_ok().
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13351
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Mar 22 18:26:04 CET 2018 on sn-devel-144
(cherry picked from commit 42d6dd2f30b6c3b3176bd1f378422a2eb62b1008)
---
source3/smbd/uid.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index 6eb53920abf..b24ae3cc3b0 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -202,6 +202,7 @@ static bool check_user_ok(connection_struct *conn,
conn->session_info = ent->session_info;
conn->read_only = ent->read_only;
conn->share_access = ent->share_access;
+ conn->vuid = ent->vuid;
return(True);
}
}
@@ -250,6 +251,7 @@ static bool check_user_ok(connection_struct *conn,
ent->share_access = share_access;
free_conn_session_info_if_unused(conn);
conn->session_info = ent->session_info;
+ conn->vuid = ent->vuid;
if (vuid == UID_FIELD_INVALID) {
/*
* Not strictly needed, just make it really
--
2.13.6

View file

@ -1,374 +0,0 @@
From 1aa2785b7549205c4187c2afcd171ea1ade96ba9 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sat, 19 May 2018 01:36:21 +0200
Subject: [PATCH 1/3] s4:torture/vfs/fruit: decrease large resource fork size
in test from 1 GB to 64 MB
64 MB is a more realistic value and lets the test pass on FreeBSD with
fruit:resource=stream and vfs_streams_xattr.
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 2729b4329af0ad0b6a8bd188450b8abd76670d8a)
---
source4/torture/vfs/fruit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 4564047e0fb..543b1c5d969 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -1594,11 +1594,11 @@ static bool test_write_atalk_rfork_io(struct torture_context *tctx,
ret &= write_stream(tree, __location__, tctx, mem_ctx,
fname, AFPRESOURCE_STREAM_NAME,
- (off_t)1<<32, 10, rfork_content);
+ (off_t)64*1024*1024, 10, rfork_content);
ret &= check_stream(tree, __location__, tctx, mem_ctx,
fname, AFPRESOURCE_STREAM_NAME,
- (off_t)1<<32, 10, 0, 10, rfork_content);
+ (off_t)64*1024*1024, 10, 0, 10, rfork_content);
/* Truncate back to size of 1 byte */
--
2.13.6
From 928b66f9b798497bb694434e08384bb75d029913 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 17 May 2018 16:43:49 +0200
Subject: [PATCH 2/3] s4:torture: test setting EOF of a stream to 0 with
enabled AAPL extensions
macOS SMB server uses xattrs as storage backend for streams, directly
exposing xattr get/set characteristics. Setting EOF on a stream to 0
just deletes the xattr as macOS doesn't support 0-byte sized xattrs.
Note that this does not apply to the AFP_AfpInfo and AFP_Resource
streams, they have even stranger semantics and we have other tests
for those.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13441
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit cf5d471544f0cb0d072e4af1ee36798580d32897)
---
selftest/knownfail.d/samba3.vfs.fruit | 3 +
source4/torture/vfs/fruit.c | 197 ++++++++++++++++++++++++++++++++++
2 files changed, 200 insertions(+)
diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit
index 8df25bccb79..5931c471086 100644
--- a/selftest/knownfail.d/samba3.vfs.fruit
+++ b/selftest/knownfail.d/samba3.vfs.fruit
@@ -1 +1,4 @@
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
+^samba3.vfs.fruit metadata_netatalk.setinfo eof stream\(nt4_dc\)
+^samba3.vfs.fruit metadata_stream.setinfo eof stream\(nt4_dc\)
+^samba3.vfs.fruit streams_depot.setinfo eof stream\(nt4_dc\)
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 543b1c5d969..1202adb2cbf 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -4578,6 +4578,202 @@ static bool test_nfs_aces(struct torture_context *tctx,
return ret;
}
+static bool test_setinfo_stream_eof(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_create create;
+ union smb_setfileinfo sfinfo;
+ union smb_fileinfo finfo;
+ struct smb2_handle h1;
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ const char *fname = BASEDIR "\\file";
+ const char *sname = BASEDIR "\\file:foo";
+
+ torture_assert_goto(tctx, mem_ctx != NULL, ret, done,
+ "talloc_new failed\n");
+
+ torture_comment(tctx, "Test setting EOF on a stream\n");
+
+ smb2_deltree(tree, BASEDIR);
+ status = torture_smb2_testdir(tree, BASEDIR, &h1);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testdir\n");
+ smb2_util_close(tree, h1);
+
+ status = torture_smb2_testfile(tree, fname, &h1);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+ smb2_util_close(tree, h1);
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ status = smb2_util_write(tree, h1, "1234567890", 0, 10);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_util_write failed\n");
+ smb2_util_close(tree, h1);
+
+ /*
+ * Test setting EOF to 21
+ */
+
+ torture_comment(tctx, "Setting stream EOF to 21\n");
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(sfinfo);
+ sfinfo.generic.in.file.handle = h1;
+ sfinfo.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
+ sfinfo.position_information.in.position = 21;
+ status = smb2_setinfo_file(tree, &sfinfo);
+ torture_assert_ntstatus_ok_goto(tctx, status,
+ ret, done, "set EOF 21 failed\n");
+
+ smb2_util_close(tree, h1);
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_STANDARD_INFORMATION;
+ finfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree, mem_ctx, &finfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_getinfo_file failed");
+
+ smb2_util_close(tree, h1);
+
+ torture_assert_goto(tctx, finfo.standard_info.out.size == 21,
+ ret, done, "size != 21\n");
+
+ /*
+ * Test setting EOF to 0
+ */
+
+ torture_comment(tctx, "Setting stream EOF to 0\n");
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(sfinfo);
+ sfinfo.generic.in.file.handle = h1;
+ sfinfo.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
+ sfinfo.position_information.in.position = 0;
+ status = smb2_setinfo_file(tree, &sfinfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "set eof 0 failed\n");
+
+ smb2_util_close(tree, h1);
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_STANDARD_INFORMATION;
+ finfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree, mem_ctx, &finfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_getinfo_file failed\n");
+
+ smb2_util_close(tree, h1);
+
+ torture_assert_goto(tctx, finfo.standard_info.out.size == 0,
+ ret, done, "size != 0\n");
+
+ /*
+ * Test setinfo end-of-file info to 1
+ */
+
+ torture_comment(tctx, "Setting stream EOF to 1\n");
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(sfinfo);
+ sfinfo.generic.in.file.handle = h1;
+ sfinfo.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
+ sfinfo.position_information.in.position = 1;
+ status = smb2_setinfo_file(tree, &sfinfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "set EOF 1 failed\n");
+
+ smb2_util_close(tree, h1);
+
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_STANDARD_INFORMATION;
+ finfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree, mem_ctx, &finfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_getinfo_file failed\n");
+
+ smb2_util_close(tree, h1);
+
+ torture_assert_goto(tctx, finfo.standard_info.out.size == 1,
+ ret, done, "size != 1\n");
+
+ /*
+ * Test setting EOF to 0 with AAPL enabled, should delete stream
+ */
+
+ torture_comment(tctx, "Enabling AAPL extensions\n");
+
+ ret = enable_aapl(tctx, tree);
+ torture_assert(tctx, ret == true, "enable_aapl failed\n");
+
+ torture_comment(tctx, "Setting stream EOF to 0\n");
+ status = torture_smb2_testfile_access(tree, sname, &h1,
+ SEC_FILE_WRITE_DATA);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testfile failed\n");
+
+ ZERO_STRUCT(sfinfo);
+ sfinfo.generic.in.file.handle = h1;
+ sfinfo.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
+ sfinfo.position_information.in.position = 0;
+ status = smb2_setinfo_file(tree, &sfinfo);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "set eof 0 failed\n");
+
+ smb2_util_close(tree, h1);
+
+ ZERO_STRUCT(create);
+ create.in.desired_access = SEC_FILE_READ_ATTRIBUTE;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.fname = sname;
+
+ status = smb2_create(tree, tctx, &create);
+ torture_assert_ntstatus_equal_goto(
+ tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done,
+ "Unexpected status\n");
+
+done:
+ smb2_util_unlink(tree, fname);
+ smb2_util_rmdir(tree, BASEDIR);
+ return ret;
+}
+
/*
* Note: This test depends on "vfs objects = catia fruit streams_xattr". For
* some tests torture must be run on the host it tests and takes an additional
@@ -4610,6 +4806,7 @@ struct torture_suite *torture_vfs_fruit(TALLOC_CTX *ctx)
torture_suite_add_1smb2_test(suite, "create delete-on-close AFP_AfpResource", test_create_delete_on_close_resource);
torture_suite_add_1smb2_test(suite, "setinfo delete-on-close AFP_AfpResource", test_setinfo_delete_on_close_resource);
torture_suite_add_1smb2_test(suite, "setinfo eof AFP_AfpResource", test_setinfo_eof_resource);
+ torture_suite_add_1smb2_test(suite, "setinfo eof stream", test_setinfo_stream_eof);
torture_suite_add_1smb2_test(suite, "null afpinfo", test_null_afpinfo);
torture_suite_add_1smb2_test(suite, "delete", test_delete_file_with_rfork);
torture_suite_add_1smb2_test(suite, "read open rsrc after rename", test_rename_and_read_rsrc);
--
2.13.6
From d85666f4c4062af68606790df2c5e1fdba135906 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Thu, 17 May 2018 16:48:09 +0200
Subject: [PATCH 3/3] vfs_fruit: delete 0 byte size streams if AAPL is enabled
macOS SMB server uses xattrs as storage backend for streams, directly
exposing xattr get/set characteristics. Setting EOF on a stream to 0
just deletes the xattr as macOS doesn't support 0-byte sized xattrs.
Note that this does not apply to the AFP_AfpInfo and AFP_Resource
streams, they have even stranger semantics and we have other tests
for those.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13441
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed May 30 02:34:29 CEST 2018 on sn-devel-144
(cherry picked from commit 46d127865f3fb14041797d395db3b3234ed3bd6c)
---
selftest/knownfail.d/samba3.vfs.fruit | 3 ---
source3/modules/vfs_fruit.c | 3 +++
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit
index 5931c471086..8df25bccb79 100644
--- a/selftest/knownfail.d/samba3.vfs.fruit
+++ b/selftest/knownfail.d/samba3.vfs.fruit
@@ -1,4 +1 @@
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
-^samba3.vfs.fruit metadata_netatalk.setinfo eof stream\(nt4_dc\)
-^samba3.vfs.fruit metadata_stream.setinfo eof stream\(nt4_dc\)
-^samba3.vfs.fruit streams_depot.setinfo eof stream\(nt4_dc\)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 1a05d0bae34..013dec0186a 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -5537,6 +5537,9 @@ static int fruit_ftruncate(struct vfs_handle_struct *handle,
(intmax_t)offset);
if (fio == NULL) {
+ if (offset == 0 && global_fruit_config.nego_aapl) {
+ return SMB_VFS_NEXT_UNLINK(handle, fsp->fsp_name);
+ }
return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
}
--
2.13.6
From 6253a3865e1185f0d0907dadef38167d4ede1845 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl@samba.org>
Date: Tue, 7 Aug 2018 15:10:31 +0200
Subject: [PATCH] vfs_fruit: Don't unlink the main file
Follow-up to
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13441
Signed-off-by: Volker Lendecke <vl@samba.org>
---
source3/modules/vfs_fruit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index ebf0f9842f0..9635116e0ba 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -5570,7 +5570,9 @@ static int fruit_ftruncate(struct vfs_handle_struct *handle,
(intmax_t)offset);
if (fio == NULL) {
- if (offset == 0 && global_fruit_config.nego_aapl) {
+ if (offset == 0 &&
+ global_fruit_config.nego_aapl &&
+ fsp->fsp_name->stream_name != NULL) {
return SMB_VFS_NEXT_UNLINK(handle, fsp->fsp_name);
}
return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
--
2.11.0

View file

@ -1,461 +0,0 @@
From 7bf82ece36c384784b1ba672667c5461fd0d7c29 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sat, 26 May 2018 16:30:47 +0200
Subject: [PATCH 1/6] selftest: run smb2.streams tests against a share with
vfs_streams_xattr
The tests are currently only run against streams_depot, where stream IO
is handle based, compared to streams_xattr which is path
based. vfs_streams_xattr is also used much more in real world setups, so
we should run our tests against it.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(backported from commit aa096ab70a466388a9947f73a525b2dcbb9821e5)
---
selftest/knownfail | 3 +++
source3/selftest/tests.py | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/selftest/knownfail b/selftest/knownfail
index eaddaece25c..ba16fd72290 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -177,6 +177,9 @@
^samba3.smb2.streams.rename
^samba3.smb2.streams.rename2
^samba3.smb2.streams.attributes
+^samba3.smb2.streams streams_xattr.rename\(nt4_dc\)
+^samba3.smb2.streams streams_xattr.rename2\(nt4_dc\)
+^samba3.smb2.streams streams_xattr.attributes\(nt4_dc\)
^samba3.smb2.getinfo.complex
^samba3.smb2.getinfo.fsinfo # quotas don't work yet
^samba3.smb2.setinfo.setinfo
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index f43d2b14d3a..9092c1776c8 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -559,6 +559,10 @@ tests= base + raw + smb2 + rpc + unix + local + rap + nbt + libsmbclient + idmap
elif t == "rpc.samba3.netlogon" or t == "rpc.samba3.sessionkey":
plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest')
plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest')
+ elif t == "smb2.streams":
+ plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
+ plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
+ plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/streams_xattr -U$USERNAME%$PASSWORD', 'streams_xattr')
else:
plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD')
plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
--
2.13.6
From 495303b80c7cc87a5b2c6a8b6c6d545db7b48d8b Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sat, 26 May 2018 16:07:14 +0200
Subject: [PATCH 2/6] s4:torture/smb2/streams: try to rename basefile while is
has open streams
This tests the following:
- create a file with a stream
- open the the stream and keep it open
- on a second connection, try to rename the basefile, this should fail
with NT_STATUS_ACCESS_DENIED
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 00d19bdab15102083b8ba395ede161824c898be1)
---
selftest/knownfail.d/samba3.smb2.streams | 2 +
source4/torture/smb2/streams.c | 82 ++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 selftest/knownfail.d/samba3.smb2.streams
diff --git a/selftest/knownfail.d/samba3.smb2.streams b/selftest/knownfail.d/samba3.smb2.streams
new file mode 100644
index 00000000000..26d40a67bda
--- /dev/null
+++ b/selftest/knownfail.d/samba3.smb2.streams
@@ -0,0 +1,2 @@
+samba3.smb2.streams.basefile-rename-with-open-stream\(.*\)
+samba3.smb2.streams streams_xattr.basefile-rename-with-open-stream\(nt4_dc\)
diff --git a/source4/torture/smb2/streams.c b/source4/torture/smb2/streams.c
index d302bf923c9..b39d96d4924 100644
--- a/source4/torture/smb2/streams.c
+++ b/source4/torture/smb2/streams.c
@@ -1830,6 +1830,86 @@ static bool test_stream_attributes(struct torture_context *tctx,
return ret;
}
+static bool test_basefile_rename_with_open_stream(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_tree *tree2 = NULL;
+ struct smb2_create create, create2;
+ struct smb2_handle h1 = {{0}}, h2 = {{0}};
+ const char *fname = "test_rename_openfile";
+ const char *sname = "test_rename_openfile:foo";
+ const char *fname_renamed = "test_rename_openfile_renamed";
+ union smb_setfileinfo sinfo;
+ const char *data = "test data";
+
+ ret = torture_smb2_connection(tctx, &tree2);
+ torture_assert_goto(tctx, ret == true, ret, done,
+ "torture_smb2_connection failed\n");
+
+ torture_comment(tctx, "Creating file with stream\n");
+
+ ZERO_STRUCT(create);
+ create.in.desired_access = SEC_FILE_ALL;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+ create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ create.in.impersonation_level = SMB2_IMPERSONATION_IMPERSONATION;
+ create.in.fname = sname;
+
+ status = smb2_create(tree, tctx, &create);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+
+ h1 = create.out.file.handle;
+
+ torture_comment(tctx, "Writing to stream\n");
+
+ status = smb2_util_write(tree, h1, data, 0, strlen(data));
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_util_write failed\n");
+
+ torture_comment(tctx, "Renaming base file\n");
+
+ ZERO_STRUCT(create2);
+ create2.in.desired_access = SEC_FILE_ALL;
+ create2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ create2.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
+ create2.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create2.in.impersonation_level = SMB2_IMPERSONATION_IMPERSONATION;
+ create2.in.fname = fname;
+
+ status = smb2_create(tree2, tctx, &create2);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_create failed\n");
+
+ h2 = create2.out.file.handle;
+
+ ZERO_STRUCT(sinfo);
+ sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION;
+ sinfo.rename_information.in.file.handle = h2;
+ sinfo.rename_information.in.new_name = fname_renamed;
+
+ status = smb2_setinfo_file(tree2, &sinfo);
+ torture_assert_ntstatus_equal_goto(
+ tctx, status, NT_STATUS_ACCESS_DENIED, ret, done,
+ "smb2_setinfo_file didn't return NT_STATUS_ACCESS_DENIED\n");
+
+ smb2_util_close(tree2, h2);
+
+done:
+ if (!smb2_util_handle_empty(h1)) {
+ smb2_util_close(tree, h1);
+ }
+ if (!smb2_util_handle_empty(h2)) {
+ smb2_util_close(tree2, h2);
+ }
+ smb2_util_unlink(tree, fname);
+ smb2_util_unlink(tree, fname_renamed);
+
+ return ret;
+}
/*
basic testing of streams calls SMB2
@@ -1850,6 +1930,8 @@ struct torture_suite *torture_smb2_streams_init(TALLOC_CTX *ctx)
torture_suite_add_1smb2_test(suite, "attributes", test_stream_attributes);
torture_suite_add_1smb2_test(suite, "delete", test_stream_delete);
torture_suite_add_1smb2_test(suite, "zero-byte", test_zero_byte_stream);
+ torture_suite_add_1smb2_test(suite, "basefile-rename-with-open-stream",
+ test_basefile_rename_with_open_stream);
suite->description = talloc_strdup(suite, "SMB2-STREAM tests");
--
2.13.6
From fbdb42c19526ff2ddeab378f384526156da161b0 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sat, 26 May 2018 18:33:00 +0200
Subject: [PATCH 3/6] s4:torture/vfs/fruit: adjust test testing basefile rename
to expect failure
Renaming a basefile that has open streams must fail with
NT_STATUS_ACCESS_DENIED.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit f166207fc0344b51879d863857055ab7ff36a09b)
---
selftest/knownfail.d/samba3.vfs.fruit | 3 +++
source4/torture/vfs/fruit.c | 25 ++++---------------------
2 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit
index 8df25bccb79..bf97dbc5822 100644
--- a/selftest/knownfail.d/samba3.vfs.fruit
+++ b/selftest/knownfail.d/samba3.vfs.fruit
@@ -1 +1,4 @@
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
+^samba3.vfs.fruit metadata_netatalk.read open rsrc after rename\(nt4_dc\)
+^samba3.vfs.fruit metadata_stream.read open rsrc after rename\(nt4_dc\)
+^samba3.vfs.fruit streams_depot.read open rsrc after rename\(nt4_dc\)
diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index 65109cc1934..4564047e0fb 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -3897,7 +3897,6 @@ static bool test_rename_and_read_rsrc(struct torture_context *tctx,
const char *fname_renamed = "test_rename_openfile_renamed";
const char *data = "1234567890";
union smb_setfileinfo sinfo;
- struct smb2_read r;
ret = enable_aapl(tctx, tree);
torture_assert_goto(tctx, ret == true, ret, done, "enable_aapl failed");
@@ -3949,28 +3948,12 @@ static bool test_rename_and_read_rsrc(struct torture_context *tctx,
sinfo.rename_information.in.new_name = fname_renamed;
status = smb2_setinfo_file(tree, &sinfo);
- torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_setinfo_file failed");
-
- smb2_util_close(tree, h2);
-
- ZERO_STRUCT(r);
- r.in.file.handle = h1;
- r.in.length = 10;
- r.in.offset = 0;
-
- torture_comment(tctx, "Read resource fork of renamed file\n");
-
- status = smb2_read(tree, tree, &r);
- torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_read failed");
+ torture_assert_ntstatus_equal_goto(
+ tctx, status, NT_STATUS_ACCESS_DENIED, ret, done,
+ "smb2_setinfo_file failed");
smb2_util_close(tree, h1);
-
- torture_assert_goto(tctx, r.out.data.length == 10, ret, done,
- talloc_asprintf(tctx, "smb2_read returned %jd bytes, expected 10\n",
- (intmax_t)r.out.data.length));
-
- torture_assert_goto(tctx, memcmp(r.out.data.data, data, 10) == 0, ret, done,
- talloc_asprintf(tctx, "Bad data in stream\n"));
+ smb2_util_close(tree, h2);
done:
smb2_util_unlink(tree, fname);
--
2.13.6
From 33e52b7e4e7d54b3488a54e2620f5e07b3042b9c Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sun, 27 May 2018 13:01:50 +0200
Subject: [PATCH 4/6] s3:smbd: add private option
NTCREATEX_OPTIONS_PRIVATE_STREAM_BASEOPEN
This will be used to mark basefile opens of streams opens. This is
needed to later implement a function that can determine if a file has
stream opens.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 37e7ff05ab9443c0330e68f5c701ffecedf2d738)
---
source3/include/smb.h | 3 +++
source3/smbd/open.c | 7 ++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 3316f09d94f..5e83ee90afe 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -419,6 +419,9 @@ Offset Data length.
/* Private options for printer support */
#define NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE 0x0008
+/* Private option for streams support */
+#define NTCREATEX_OPTIONS_PRIVATE_STREAM_BASEOPEN 0x0010
+
/* Flag for NT transact rename call. */
#define RENAME_REPLACE_IF_EXISTS 1
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 3708bdd10fa..8a9288dbdb4 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -5091,6 +5091,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
&& (!(private_flags & NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE))) {
uint32_t base_create_disposition;
struct smb_filename *smb_fname_base = NULL;
+ uint32_t base_privflags;
if (create_options & FILE_DIRECTORY_FILE) {
status = NT_STATUS_NOT_A_DIRECTORY;
@@ -5141,13 +5142,17 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
}
}
+ base_privflags = NTCREATEX_OPTIONS_PRIVATE_STREAM_BASEOPEN;
+
/* Open the base file. */
status = create_file_unixpath(conn, NULL, smb_fname_base, 0,
FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE,
base_create_disposition,
- 0, 0, 0, NULL, 0, 0, NULL, NULL,
+ 0, 0, 0, NULL, 0,
+ base_privflags,
+ NULL, NULL,
&base_fsp, NULL);
TALLOC_FREE(smb_fname_base);
--
2.13.6
From f2f02d9b9f2d6c38b2813757ee942b8910985839 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sun, 27 May 2018 13:03:25 +0200
Subject: [PATCH 5/6] s3:locking: add file_has_open_streams()
This can be used to check if a file opened by fsp also has stream opens.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit dd8cf54c79fe8536e34cde15801d60931cd47b8b)
---
source3/locking/locking.c | 31 +++++++++++++++++++++++++++++++
source3/locking/proto.h | 1 +
2 files changed, 32 insertions(+)
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 4e9f1bbc681..f71cd176029 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1318,3 +1318,34 @@ struct timespec get_share_mode_write_time(struct share_mode_lock *lck)
}
return d->old_write_time;
}
+
+bool file_has_open_streams(files_struct *fsp)
+{
+ struct share_mode_lock *lock = NULL;
+ struct share_mode_data *d = NULL;
+ uint32_t i;
+
+ lock = get_existing_share_mode_lock(talloc_tos(), fsp->file_id);
+ if (lock == NULL) {
+ return false;
+ }
+ d = lock->data;
+
+ for (i = 0; i < d->num_share_modes; i++) {
+ struct share_mode_entry *e = &d->share_modes[i];
+
+ if (share_mode_stale_pid(d, i)) {
+ continue;
+ }
+
+ if (e->private_options &
+ NTCREATEX_OPTIONS_PRIVATE_STREAM_BASEOPEN)
+ {
+ TALLOC_FREE(lock);
+ return true;
+ }
+ }
+
+ TALLOC_FREE(lock);
+ return false;
+}
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index 33184e0fa0a..4cd38091f3c 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -205,6 +205,7 @@ bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
bool set_write_time(struct file_id fileid, struct timespec write_time);
struct timespec get_share_mode_write_time(struct share_mode_lock *lck);
+bool file_has_open_streams(files_struct *fsp);
int share_mode_forall(int (*fn)(struct file_id fid,
const struct share_mode_data *data,
void *private_data),
--
2.13.6
From 809c3b9f13d5d22847a94fcfdec27b022fdb099d Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow@samba.org>
Date: Sat, 26 May 2018 18:32:21 +0200
Subject: [PATCH 6/6] s3:smbd: don't allow renaming basefile if streams are
open
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 465b7d07e5db787c3d6330371e5e42ecbb1b57b9)
---
selftest/knownfail.d/samba3.smb2.streams | 2 --
selftest/knownfail.d/samba3.vfs.fruit | 3 ---
source3/smbd/reply.c | 4 ++++
3 files changed, 4 insertions(+), 5 deletions(-)
delete mode 100644 selftest/knownfail.d/samba3.smb2.streams
diff --git a/selftest/knownfail.d/samba3.smb2.streams b/selftest/knownfail.d/samba3.smb2.streams
deleted file mode 100644
index 26d40a67bda..00000000000
--- a/selftest/knownfail.d/samba3.smb2.streams
+++ /dev/null
@@ -1,2 +0,0 @@
-samba3.smb2.streams.basefile-rename-with-open-stream\(.*\)
-samba3.smb2.streams streams_xattr.basefile-rename-with-open-stream\(nt4_dc\)
diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit
index bf97dbc5822..8df25bccb79 100644
--- a/selftest/knownfail.d/samba3.vfs.fruit
+++ b/selftest/knownfail.d/samba3.vfs.fruit
@@ -1,4 +1 @@
^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\)
-^samba3.vfs.fruit metadata_netatalk.read open rsrc after rename\(nt4_dc\)
-^samba3.vfs.fruit metadata_stream.read open rsrc after rename\(nt4_dc\)
-^samba3.vfs.fruit streams_depot.read open rsrc after rename\(nt4_dc\)
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 623f83b1250..2b5bb8f1ed6 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -6642,6 +6642,10 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
return status;
}
+ if (file_has_open_streams(fsp)) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
/* Make a copy of the dst smb_fname structs */
smb_fname_dst = cp_smb_filename(ctx, smb_fname_dst_in);
--
2.13.6

View file

@ -1,539 +0,0 @@
From f0ed4f0930673ee044f187085e8972b8be104ebd Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Wed, 18 Jul 2018 13:32:49 -0700
Subject: [PATCH 1/5] s3: smbd: Fix Linux sendfile() for SMB2. Ensure we don't
spin on EAGAIN.
For SMB2 the socket is set non-blocking. Ensure sendfile()
calls complete by saving the socket state, setting it blocking,
doing the sendfile until completion and then restoring the socket
state.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13537
Signed-off-by: Jeremy Allison <jra@samba.org>
---
source3/lib/sendfile.c | 54 ++++++++++++++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 7 deletions(-)
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index 3d457bd6f13..a578a66e7de 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -24,6 +24,7 @@
*/
#include "includes.h"
+#include "system/filesys.h"
#if defined(LINUX_SENDFILE_API)
@@ -36,8 +37,23 @@
ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset, size_t count)
{
size_t total=0;
- ssize_t ret;
+ ssize_t ret = -1;
size_t hdr_len = 0;
+ int saved_errno = 0;
+ int old_flags = 0;
+
+ /*
+ * Sendfile must complete before we can
+ * send any other outgoing data on the socket.
+ * Ensure socket is in blocking mode.
+ * For SMB2 by default the socket is in non-blocking
+ * mode.
+ */
+ old_flags = fcntl(tofd, F_GETFL, 0);
+ ret = set_blocking(tofd, true);
+ if (ret == -1) {
+ goto out;
+ }
/*
* Send the header first.
@@ -48,8 +64,9 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
hdr_len = header->length;
while (total < hdr_len) {
ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE);
- if (ret == -1)
- return -1;
+ if (ret == -1) {
+ goto out;
+ }
total += ret;
}
}
@@ -59,7 +76,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
ssize_t nwritten;
do {
nwritten = sendfile(tofd, fromfd, &offset, total);
- } while (nwritten == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
+ } while (nwritten == -1 && errno == EINTR);
if (nwritten == -1) {
if (errno == ENOSYS || errno == EINVAL) {
/* Ok - we're in a world of pain here. We just sent
@@ -72,17 +89,40 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
*/
errno = EINTR; /* Normally we can never return this. */
}
- return -1;
+ ret = -1;
+ goto out;
}
if (nwritten == 0) {
/*
* EOF, return a short read
*/
- return hdr_len + (count - total);
+ ret = hdr_len + (count - total);
+ goto out;
}
total -= nwritten;
}
- return count + hdr_len;
+
+ ret = count + hdr_len;
+
+ out:
+
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+
+ {
+ /* Restore the blocking state of the socket. */
+ int err = fcntl(tofd, F_SETFL, old_flags);
+ if (err == -1) {
+ return -1;
+ }
+ }
+
+ if (ret == -1) {
+ errno = saved_errno;
+ }
+
+ return ret;
}
#elif defined(SOLARIS_SENDFILE_API)
--
2.18.0.203.gfac676dfb9-goog
From abc681420b88a2d795adc44808c7e52eb2775cf6 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Wed, 18 Jul 2018 15:29:37 -0700
Subject: [PATCH 2/5] s3: smbd: Fix Solaris sendfile() for SMB2. Ensure we
don't spin on EAGAIN.
For SMB2 the socket is set non-blocking. Ensure sendfile()
calls complete by saving the socket state, setting it blocking,
doing the sendfile until completion and then restoring the socket
state.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13537
Signed-off-by: Jeremy Allison <jra@samba.org>
---
source3/lib/sendfile.c | 52 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 46 insertions(+), 6 deletions(-)
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index a578a66e7de..6c323213830 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -139,6 +139,9 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
size_t total, xferred;
struct sendfilevec vec[2];
ssize_t hdr_len = 0;
+ int saved_errno = 0;
+ int old_flags = 0;
+ ssize_t ret = -1;
if (header) {
sfvcnt = 2;
@@ -164,6 +167,19 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
total = count + hdr_len;
+ /*
+ * Sendfile must complete before we can
+ * send any other outgoing data on the socket.
+ * Ensure socket is in blocking mode.
+ * For SMB2 by default the socket is in non-blocking
+ * mode.
+ */
+ old_flags = fcntl(tofd, F_GETFL, 0);
+ ret = set_blocking(tofd, true);
+ if (ret == -1) {
+ goto out;
+ }
+
while (total) {
ssize_t nwritten;
@@ -175,17 +191,21 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
xferred = 0;
nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
- if (nwritten == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) {
+ if (nwritten == -1 && errno == EINTR) {
if (xferred == 0)
continue; /* Nothing written yet. */
else
nwritten = xferred;
}
- if (nwritten == -1)
- return -1;
- if (nwritten == 0)
- return -1; /* I think we're at EOF here... */
+ if (nwritten == -1) {
+ ret = -1;
+ goto out;
+ }
+ if (nwritten == 0) {
+ ret = -1;
+ goto out; /* I think we're at EOF here... */
+ }
/*
* If this was a short (signal interrupted) write we may need
@@ -207,7 +227,27 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
}
total -= nwritten;
}
- return count + hdr_len;
+ ret = count + hdr_len;
+
+ out:
+
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+
+ {
+ /* Restore the blocking state of the socket. */
+ int err = fcntl(tofd, F_SETFL, old_flags);
+ if (err == -1) {
+ return -1;
+ }
+ }
+
+ if (ret == -1) {
+ errno = saved_errno;
+ }
+
+ return ret;
}
#elif defined(HPUX_SENDFILE_API)
--
2.18.0.203.gfac676dfb9-goog
From 0068f7d136da89d96d50dced5eda8738c28e2938 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Wed, 18 Jul 2018 15:36:47 -0700
Subject: [PATCH 3/5] s3: smbd: Fix HPUX sendfile() for SMB2. Ensure we don't
spin on EAGAIN.
For SMB2 the socket is set non-blocking. Ensure sendfile()
calls complete by saving the socket state, setting it blocking,
doing the sendfile until completion and then restoring the socket
state.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13537
Signed-off-by: Jeremy Allison <jra@samba.org>
---
source3/lib/sendfile.c | 53 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 47 insertions(+), 6 deletions(-)
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index 6c323213830..63f50d1946f 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -260,6 +260,9 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
size_t total=0;
struct iovec hdtrl[2];
size_t hdr_len = 0;
+ int saved_errno = 0;
+ int old_flags = 0;
+ ssize_t ret = -1;
if (header) {
/* Set up the header/trailer iovec. */
@@ -273,6 +276,20 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
hdtrl[1].iov_len = 0;
total = count;
+
+ /*
+ * Sendfile must complete before we can
+ * send any other outgoing data on the socket.
+ * Ensure socket is in blocking mode.
+ * For SMB2 by default the socket is in non-blocking
+ * mode.
+ */
+ old_flags = fcntl(tofd, F_GETFL, 0);
+ ret = set_blocking(tofd, true);
+ if (ret == -1) {
+ goto out;
+ }
+
while (total + hdtrl[0].iov_len) {
ssize_t nwritten;
@@ -285,11 +302,15 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
do {
nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
- } while (nwritten == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
- if (nwritten == -1)
- return -1;
- if (nwritten == 0)
- return -1; /* I think we're at EOF here... */
+ } while (nwritten == -1 && errno == EINTR);
+ if (nwritten == -1) {
+ ret = -1;
+ goto out;
+ }
+ if (nwritten == 0) {
+ ret = -1; /* I think we're at EOF here... */
+ goto out;
+ }
/*
* If this was a short (signal interrupted) write we may need
@@ -313,7 +334,27 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
total -= nwritten;
offset += nwritten;
}
- return count + hdr_len;
+ ret = count + hdr_len;
+
+ out:
+
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+
+ {
+ /* Restore the blocking state of the socket. */
+ int err = fcntl(tofd, F_SETFL, old_flags);
+ if (err == -1) {
+ return -1;
+ }
+ }
+
+ if (ret == -1) {
+ errno = saved_errno;
+ }
+
+ return ret;
}
#elif defined(FREEBSD_SENDFILE_API) || defined(DARWIN_SENDFILE_API)
--
2.18.0.203.gfac676dfb9-goog
From 8df7360c2198098a2cb757910974110e33e4d4cf Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Wed, 18 Jul 2018 15:44:34 -0700
Subject: [PATCH 4/5] s3: smbd: Fix FreeBSD sendfile() for SMB2. Ensure we
don't spin on EAGAIN.
For SMB2 the socket is set non-blocking. Ensure sendfile()
calls complete by saving the socket state, setting it blocking,
doing the sendfile until completion and then restoring the socket
state.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13537
Signed-off-by: Jeremy Allison <jra@samba.org>
---
source3/lib/sendfile.c | 44 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index 63f50d1946f..575428deb15 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -368,9 +368,11 @@ ssize_t sys_sendfile(int tofd, int fromfd,
{
struct sf_hdtr sf_header = {0};
struct iovec io_header = {0};
+ int saved_errno = 0;
+ int old_flags = 0;
off_t nwritten;
- int ret;
+ ssize_t ret = -1;
if (header) {
sf_header.headers = &io_header;
@@ -381,6 +383,19 @@ ssize_t sys_sendfile(int tofd, int fromfd,
sf_header.trl_cnt = 0;
}
+ /*
+ * Sendfile must complete before we can
+ * send any other outgoing data on the socket.
+ * Ensure socket is in blocking mode.
+ * For SMB2 by default the socket is in non-blocking
+ * mode.
+ */
+ old_flags = fcntl(tofd, F_GETFL, 0);
+ ret = set_blocking(tofd, true);
+ if (ret == -1) {
+ goto out;
+ }
+
while (count != 0) {
nwritten = count;
@@ -391,9 +406,10 @@ ssize_t sys_sendfile(int tofd, int fromfd,
#else
ret = sendfile(fromfd, tofd, offset, count, &sf_header, &nwritten, 0);
#endif
- if (ret == -1 && errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) {
+ if (ret == -1 && errno != EINTR) {
/* Send failed, we are toast. */
- return -1;
+ ret = -1;
+ goto out;
}
if (nwritten == 0) {
@@ -420,7 +436,27 @@ ssize_t sys_sendfile(int tofd, int fromfd,
count -= nwritten;
}
- return nwritten;
+ ret = nwritten;
+
+ out:
+
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+
+ {
+ /* Restore the blocking state of the socket. */
+ int err = fcntl(tofd, F_SETFL, old_flags);
+ if (err == -1) {
+ return -1;
+ }
+ }
+
+ if (ret == -1) {
+ errno = saved_errno;
+ }
+
+ return ret;
}
#elif defined(AIX_SENDFILE_API)
--
2.18.0.203.gfac676dfb9-goog
From 019c677b42184d5f45931bdb549b22aad25ee2e9 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Wed, 18 Jul 2018 15:49:29 -0700
Subject: [PATCH 5/5] s3: smbd: Fix AIX sendfile() for SMB2. Ensure we don't
spin on EAGAIN.
For SMB2 the socket is set non-blocking. Ensure sendfile()
calls complete by saving the socket state, setting it blocking,
doing the sendfile until completion and then restoring the socket
state.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13537
Signed-off-by: Jeremy Allison <jra@samba.org>
---
source3/lib/sendfile.c | 45 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index 575428deb15..a28102b5bf9 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -469,6 +469,9 @@ ssize_t sys_sendfile(int tofd, int fromfd,
ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset, size_t count)
{
struct sf_parms hdtrl;
+ int saved_errno = 0;
+ int old_flags = 0;
+ ssize_t ret = -1;
/* Set up the header/trailer struct params. */
if (header) {
@@ -485,9 +488,20 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
hdtrl.file_offset = offset;
hdtrl.file_bytes = count;
- while ( hdtrl.file_bytes + hdtrl.header_length ) {
- ssize_t ret;
+ /*
+ * Sendfile must complete before we can
+ * send any other outgoing data on the socket.
+ * Ensure socket is in blocking mode.
+ * For SMB2 by default the socket is in non-blocking
+ * mode.
+ */
+ old_flags = fcntl(tofd, F_GETFL, 0);
+ ret = set_blocking(tofd, true);
+ if (ret == -1) {
+ goto out;
+ }
+ while ( hdtrl.file_bytes + hdtrl.header_length ) {
/*
Return Value
@@ -505,12 +519,33 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset
*/
do {
ret = send_file(&tofd, &hdtrl, 0);
- } while ((ret == 1) || (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)));
- if ( ret == -1 )
+ } while ((ret == 1) || (ret == -1 && errno == EINTR));
+ if ( ret == -1 ) {
+ goto out;
+ }
+ }
+
+ ret = count + header->length;
+
+ out:
+
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+
+ {
+ /* Restore the blocking state of the socket. */
+ int err = fcntl(tofd, F_SETFL, old_flags);
+ if (err == -1) {
return -1;
+ }
}
- return count + header->length;
+ if (ret == -1) {
+ errno = saved_errno;
+ }
+
+ return ret;
}
/* END AIX SEND_FILE */
--
2.18.0.203.gfac676dfb9-goog

View file

@ -1,11 +0,0 @@
--- ctdb/common/ctdb_util.c.orig 2018-06-28 15:36:39 UTC
+++ ctdb/common/ctdb_util.c
@@ -390,7 +390,7 @@ void ctdb_canonicalize_ip(const ctdb_soc
} else {
cip->ip6.sin6_family = AF_INET6;
#ifdef HAVE_SOCK_SIN_LEN
- cip->ip6.sin_len = sizeof(ctdb_sock_addr);
+ cip->ip6.sin6_len = sizeof(ctdb_sock_addr);
#endif
cip->ip6.sin6_port = ip->ip6.sin6_port;
memcpy(&cip->ip6.sin6_addr,

View file

@ -1,6 +1,6 @@
--- ctdb/wscript.orig 2018-03-13 13:18:01 UTC
--- ctdb/wscript.orig 2018-08-24 11:58:20 UTC
+++ ctdb/wscript
@@ -86,6 +86,9 @@ def set_options(opt):
@@ -90,6 +90,9 @@ def set_options(opt):
opt.add_option('--enable-ceph-reclock',
help=("Enable Ceph CTDB recovery lock helper (default=no)"),
action="store_true", dest='ctdb_ceph_reclock', default=False)
@ -10,22 +10,20 @@
opt.add_option('--with-logdir',
help=("Path to log directory"),
@@ -219,7 +222,7 @@ def configure(conf):
@@ -231,7 +234,7 @@ def configure(conf):
conf.env['LIBPATH_CEPH-COMMON'] = conf.env['LIBPATH_RADOS'] + '/ceph'
if Options.options.ctdb_ceph_reclock:
if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
- conf.CHECK_LIB('rados', shlib=True)):
+ conf.CHECK_LIB('rados', shlib=True)):
+ conf.CHECK_LIB('rados', shlib=True)):
conf.CHECK_LIB('ceph-common', shlib=True)
Logs.info('Building with Ceph librados recovery lock support')
conf.define('HAVE_LIBRADOS', 1)
else:
@@ -255,9 +258,15 @@ def configure(conf):
@@ -268,9 +271,15 @@ def configure(conf):
conf.env.CTDB_VARDIR,
conf.env.CTDB_RUNDIR))
- conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
- 'share/ctdb/tests')
- conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
+ if Options.options.ctdb_no_tests:
+ conf.env.ctdb_tests = False
+ else:
@ -33,25 +31,26 @@
+
+ if conf.env.ctdb_tests:
+ conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
+ 'share/ctdb/tests')
'share/ctdb/tests')
- conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
+ conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
# Allow unified compilation and separate compilation of utilities
# to find includes
@@ -592,9 +601,9 @@ def build(bld):
@@ -605,9 +614,9 @@ def build(bld):
if bld.env.HAVE_LIBRADOS:
bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
- deps='talloc tevent rados',
- deps='talloc tevent rados ceph-common',
- includes='include',
- install_path='${CTDB_HELPER_BINDIR}')
+ deps='talloc tevent rados',
+ deps='talloc tevent rados ceph-common',
+ includes='include',
+ install_path='${CTDB_HELPER_BINDIR}')
sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
@@ -737,6 +746,9 @@ def build(bld):
@@ -750,6 +759,9 @@ def build(bld):
bld.install_dir(bld.env.CTDB_RUNDIR)
bld.install_dir(bld.env.CTDB_VARDIR)

View file

@ -1,5 +1,13 @@
--- source3/wscript_build.orig 2017-07-25 13:09:58 UTC
+++ source3/wscript_build
@@ -124,7 +124,6 @@ ldapsam_pdb_match = ['!priv2ld', '!smbldap_search_doma
'!get_attr_list']
private_pdb_match.append('!pdb_nds_*')
private_pdb_match.append('!pdb_ldapsam_init*')
-private_pdb_match.append('!pdb_*_init')
private_pdb_match = private_pdb_match + ldapsam_pdb_match
bld.SAMBA3_LIBRARY('samba-passdb',
@@ -221,11 +221,9 @@ bld.SAMBA3_SUBSYSTEM('SMBREGISTRY',
talloc
replace

View file

@ -1,5 +1,5 @@
--- source4/heimdal/lib/roken/rand.c.orig 2018-01-14 12:41:58.000000000 -0800
+++ source4/heimdal/lib/roken/rand.c 2018-08-22 22:11:26.937151714 -0700
--- source4/heimdal/lib/roken/rand.c.orig 2018-01-14 04:41:58 UTC
+++ source4/heimdal/lib/roken/rand.c
@@ -37,7 +37,6 @@
rk_random_init(void)
{

View file

@ -178,7 +178,6 @@ lib/samba4/libtevent-util.so
lib/samba4/libtevent-util.so.0
lib/samba4/libwbclient.so
lib/samba4/libwbclient.so.0
lib/samba4/winbind_krb5_locator.so
lib/nss_winbind.so.1
lib/nss_wins.so.1
lib/pam_winbind.so
@ -298,6 +297,7 @@ lib/samba4/private/libxattr-tdb-samba4.so
%%AD_DC%%lib/shared-modules/bind9/dlz_bind9_9.so
%%AD_DC%%lib/shared-modules/bind9/dlz_bind9.so
%%AD_DC%%lib/shared-modules/gensec/krb5.so
%%AD_DC%%lib/shared-modules/krb5/winbind_krb5_locator.so
%%AD_DC%%lib/shared-modules/ldb/acl.so
%%AD_DC%%lib/shared-modules/ldb/aclread.so
%%AD_DC%%lib/shared-modules/ldb/anr.so
@ -1140,7 +1140,6 @@ man/man7/libsmbclient.7.gz
man/man7/samba.7.gz
man/man7/traffic_learner.7.gz
man/man7/traffic_replay.7.gz
man/man7/winbind_krb5_locator.7.gz
man/man8/cifsdd.8.gz
man/man8/eventlogadm.8.gz
man/man8/idmap_ad.8.gz
@ -1207,6 +1206,7 @@ man/man8/vfs_virusfilter.8.gz
man/man8/vfs_worm.8.gz
man/man8/vfs_xattr_tdb.8.gz
man/man8/vfs_zfsacl.8.gz
man/man8/winbind_krb5_locator.8.gz
man/man8/winbindd.8.gz
@dir %%SAMBA4_RUNDIR%%
@dir %%SAMBA4_LOGDIR%%