The branch, master has been updated
via fe96aa111cd s4:smbtorture: Fix samba3.smb.dir on btrfs
via 38b8a4f2232 s4:torture: Fix samba3.smb2.name-mangling on btrfs
from bb92c70f0ee libcli/auth: let netlogon_creds_copy() make use of
ndr_deepcopy_struct()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit fe96aa111cdcc0f753075cccb8f1fd44791abaab
Author: Andreas Schneider <[email protected]>
Date: Fri Nov 29 07:37:54 2024 +0100
s4:smbtorture: Fix samba3.smb.dir on btrfs
"If a file is removed from or added to the directory after the most recent
call
to opendir() or rewinddir(), whether a subsequent call to readdir() returns
an entry for that file is unspecified."
https://pubs.opengroup.org/onlinepubs/009604599/functions/readdir.html
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
Autobuild-User(master): Andreas Schneider <[email protected]>
Autobuild-Date(master): Fri Nov 29 15:10:13 UTC 2024 on atb-devel-224
commit 38b8a4f2232ca3e8dc4596c080df770f07fa49a8
Author: Andreas Schneider <[email protected]>
Date: Thu Nov 28 15:52:03 2024 +0100
s4:torture: Fix samba3.smb2.name-mangling on btrfs
If a file is removed from or added to the directory after the most recent
call
to opendir() or rewinddir(), whether a subsequent call to readdir() returns
an entry for that file is unspecified."
https://pubs.opengroup.org/onlinepubs/009604599/functions/readdir.html
As it is unspecified, the different filesystems on Linux implement this
differently:
ext4:
./a.out
opendir(foo)
creat(foo/bar)
readdir() loop
readdir entry: bar
readdir entry: ..
readdir entry: .
readdir() detected the newly created file `foo`
btrfs:
./a.out
opendir(foo)
creat(foo/bar)
readdir() loop
readdir entry: .
readdir entry: ..
readdir() did not detect the newly created file `foo`
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Alexander Bokovoy <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
source4/torture/smb2/dir.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
source4/torture/smb2/mangle.c | 8 ++++++
2 files changed, 64 insertions(+), 1 deletion(-)
Changeset truncated at 500 lines:
diff --git a/source4/torture/smb2/dir.c b/source4/torture/smb2/dir.c
index 4020e6b8672..c495f09d861 100644
--- a/source4/torture/smb2/dir.c
+++ b/source4/torture/smb2/dir.c
@@ -53,6 +53,7 @@ static NTSTATUS populate_tree(struct torture_context *tctx,
struct smb2_handle *h_out)
{
struct smb2_create create;
+ struct smb2_handle dirh;
char **strs = NULL;
NTSTATUS status;
bool ret = true;
@@ -72,7 +73,7 @@ static NTSTATUS populate_tree(struct torture_context *tctx,
status = smb2_create(tree, mem_ctx, &create);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
- *h_out = create.out.file.handle;
+ dirh = create.out.file.handle;
ZERO_STRUCT(create);
create.in.desired_access = SEC_RIGHTS_FILE_ALL;
@@ -93,6 +94,29 @@ static NTSTATUS populate_tree(struct torture_context *tctx,
files[i].create_time = create.out.create_time;
smb2_util_close(tree, create.out.file.handle);
}
+ /* Close the dir handle */
+ smb2_util_close(tree, dirh);
+
+ /*
+ * Reopen the directory handle that the readdir() in smbd will see the
+ * created files.
+ */
+ ZERO_STRUCT(create);
+ create.in.desired_access = SEC_RIGHTS_DIR_ALL;
+ create.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ create.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.fname = DNAME;
+
+ status = smb2_create(tree, mem_ctx, &create);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
+ dirh = create.out.file.handle;
+
+ *h_out = dirh;
+
done:
if (!ret) {
return status;
@@ -1204,6 +1228,16 @@ static bool test_file_index(struct torture_context *tctx,
smb2_util_close(tree, create.out.file.handle);
}
+ /* Close the dir handle */
+ smb2_util_close(tree, h);
+
+ /*
+ * Reopen the directory handle, that the readdir() in smbd will see the
+ * created files.
+ */
+ status = torture_smb2_testdir(tree, DNAME, &h);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
+
ZERO_STRUCT(result);
result.tctx = tctx;
@@ -1342,6 +1376,27 @@ static bool test_large_files(struct torture_context
*tctx,
smb2_util_close(tree, create.out.file.handle);
}
+ /* Close dir handle */
+ smb2_util_close(tree, h);
+
+ /*
+ * Reopen the directory handle that the readdir() in smbd will see the
+ * created files.
+ */
+ ZERO_STRUCT(create);
+ create.in.desired_access = SEC_RIGHTS_DIR_ALL;
+ create.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ create.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ create.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ create.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create.in.fname = DNAME;
+
+ status = smb2_create(tree, mem_ctx, &create);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "");
+ h = create.out.file.handle;
+
ZERO_STRUCT(f);
f.in.file.handle = h;
f.in.pattern = "*";
diff --git a/source4/torture/smb2/mangle.c b/source4/torture/smb2/mangle.c
index 09097ee6d78..09eddd26556 100644
--- a/source4/torture/smb2/mangle.c
+++ b/source4/torture/smb2/mangle.c
@@ -264,6 +264,7 @@ static bool test_mangled_mask(struct torture_context *tctx,
smb2_deltree(tree, dname);
+ /* Create dname and fname */
status = torture_smb2_testdir(tree, dname, &dh);
torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
"torture_smb2_testdir failed");
@@ -271,6 +272,13 @@ static bool test_mangled_mask(struct torture_context *tctx,
status = torture_smb2_testfile(tree, fname, &fh);
smb2_util_close(tree, fh);
+ smb2_util_close(tree, dh);
+
+ /* Update the directory handle, that readdir() can see the testfile */
+ status = torture_smb2_testdir(tree, dname, &dh);
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "torture_smb2_testdir failed");
+
ZERO_STRUCT(f);
f.in.file.handle = dh;
f.in.pattern = "*";
--
Samba Shared Repository