s3: smbd: Allow "smbd async dosmode = yes" to return valid DOS attributes again.
authorJeremy Allison <jra@samba.org>
Wed, 14 Jul 2021 22:00:13 +0000 (15:00 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 15 Jul 2021 05:02:30 +0000 (05:02 +0000)
We already have a valid smb_fname->fsp, don't drop
it when returning from smbd_dirptr_lanman2_entry()
to allow it to be reused inside dos_mode_at_send().

Remove knownfail.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14758

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
selftest/knownfail.d/smb2_list_dir_async [deleted file]
source3/smbd/trans2.c

diff --git a/selftest/knownfail.d/smb2_list_dir_async b/selftest/knownfail.d/smb2_list_dir_async
deleted file mode 100644 (file)
index bc38582..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smbtorture_s3.plain.SMB2-LIST-DIR-ASYNC.smbtorture\(simpleserver\)
index c69e48a4a56f3e73ff00ce8e93a3893ad13d28b5..b9e2786eda649771235c26b6efd4cb4523048d52 100644 (file)
@@ -2551,23 +2551,27 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
        }
 
        if (_smb_fname != NULL) {
-               struct smb_filename *name = NULL;
-
-               name = synthetic_smb_fname(ctx,
-                                          fname,
-                                          NULL,
-                                          &smb_fname->st,
-                                          smb_fname->twrp,
-                                          0);
-               if (name == NULL) {
+               /*
+                * smb_fname is already talloc'ed off ctx.
+                * We just need to make sure we don't return
+                * any stream_name, and replace base_name
+                * with fname in case base_name got mangled.
+                * This allows us to preserve any smb_fname->fsp
+                * for asynchronous handle lookups.
+                */
+               TALLOC_FREE(smb_fname->stream_name);
+               TALLOC_FREE(smb_fname->base_name);
+               smb_fname->base_name = talloc_strdup(smb_fname, fname);
+
+               if (smb_fname->base_name == NULL) {
                        TALLOC_FREE(smb_fname);
                        TALLOC_FREE(fname);
                        return NT_STATUS_NO_MEMORY;
                }
-               *_smb_fname = name;
+               *_smb_fname = smb_fname;
+       } else {
+               TALLOC_FREE(smb_fname);
        }
-
-       TALLOC_FREE(smb_fname);
        TALLOC_FREE(fname);
 
        if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {