]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: let smbd_dirptr_lanman2_entry return smb_fname
authorRalph Boehme <slow@samba.org>
Thu, 15 Mar 2018 18:03:59 +0000 (19:03 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 27 Jul 2018 11:07:15 +0000 (13:07 +0200)
Note that smb_fname is relative to fsp, not conn!

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/globals.h
source3/smbd/smb2_query_directory.c
source3/smbd/trans2.c

index d151d33b968a3f897869a85ae08b28db80aaa83a..6ae571844178f530393d6bc48de19e38b773fbf5 100644 (file)
@@ -210,6 +210,7 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               char *base_data,
                               char *end_data,
                               int space_remaining,
+                              struct smb_filename **smb_fname,
                               bool *got_exact_match,
                               int *_last_entry_off,
                               struct ea_list *name_list,
index 3c241f2e04a01e05847d8013925ff44799a78591..aeba134810fa521a2168ac38b15b1486f3499a6b 100644 (file)
@@ -531,6 +531,7 @@ static bool smb2_query_directory_next_entry(struct tevent_req *req)
 {
        struct smbd_smb2_query_directory_state *state = tevent_req_data(
                req, struct smbd_smb2_query_directory_state);
+       struct smb_filename *smb_fname = NULL; /* relative to fsp !! */
        bool got_exact_match = false;
        int off = state->out_output_buffer.length;
        int space_remaining = state->in_output_buffer_length - off;
@@ -557,6 +558,7 @@ static bool smb2_query_directory_next_entry(struct tevent_req *req)
                                           state->base_data,
                                           state->end_data,
                                           space_remaining,
+                                          &smb_fname,
                                           &got_exact_match,
                                           &state->last_entry_off,
                                           NULL,
@@ -603,6 +605,8 @@ static bool smb2_query_directory_next_entry(struct tevent_req *req)
                state->async_sharemode_count++;
        }
 
+       TALLOC_FREE(smb_fname);
+
        state->num++;
        state->out_output_buffer.length = off;
 
index 005f55f77b7868e9328608e933b53505efa232ab..b4a481fbf865223c7281ef535a7e9271b15e51b6 100644 (file)
@@ -2458,6 +2458,7 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               char *base_data,
                               char *end_data,
                               int space_remaining,
+                              struct smb_filename **_smb_fname,
                               bool *got_exact_match,
                               int *_last_entry_off,
                               struct ea_list *name_list,
@@ -2548,15 +2549,29 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                *file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st);
        }
 
-       TALLOC_FREE(fname);
-       TALLOC_FREE(smb_fname);
-
        if (!NT_STATUS_IS_OK(status) &&
            !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES))
        {
+               TALLOC_FREE(smb_fname);
+               TALLOC_FREE(fname);
                return status;
        }
 
+       if (_smb_fname != NULL) {
+               struct smb_filename *name = NULL;
+
+               name = synthetic_smb_fname(ctx, fname, NULL, &smb_fname->st, 0);
+               if (name == NULL) {
+                       TALLOC_FREE(smb_fname);
+                       TALLOC_FREE(fname);
+                       return NT_STATUS_NO_MEMORY;
+               }
+               *_smb_fname = name;
+       }
+
+       TALLOC_FREE(smb_fname);
+       TALLOC_FREE(fname);
+
        if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
                dptr_SeekDir(dirptr, prev_dirpos);
                return status;
@@ -2598,6 +2613,7 @@ static NTSTATUS get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                         true, align, do_pad,
                                         ppdata, base_data, end_data,
                                         space_remaining,
+                                        NULL,
                                         got_exact_match,
                                         last_entry_off, name_list, NULL);
 }