]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn()
authorJeremy Allison <jra@samba.org>
Wed, 17 Aug 2022 18:43:47 +0000 (11:43 -0700)
committerNoel Power <npower@samba.org>
Thu, 18 Aug 2022 14:10:18 +0000 (14:10 +0000)
Allows close_file_in_loop() to differentiate between SHUTDOWN_CLOSE
(previously it only used this close type) and ERROR_CLOSE - called
on error from smbXsrv_tcon_disconnect() in the error path. In that
case we want to close the fd, but not run any delete-on-close actions.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reivewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Thu Aug 18 14:10:18 UTC 2022 on sn-devel-184

source3/smbd/files.c

index fb9454b015d01aeee7d6c38b86e895a75796ed60..b494a8b789ae4e082dfbd4b63063772fc89d57c6 100644 (file)
@@ -1258,7 +1258,8 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
-static bool close_file_in_loop(struct files_struct *fsp)
+static bool close_file_in_loop(struct files_struct *fsp,
+                              enum file_close_type close_type)
 {
        if (fsp_is_alternate_stream(fsp)) {
                /*
@@ -1276,7 +1277,7 @@ static bool close_file_in_loop(struct files_struct *fsp)
                fsp->base_fsp->stream_fsp = NULL;
                fsp->base_fsp = NULL;
 
-               close_file_free(NULL, &fsp, SHUTDOWN_CLOSE);
+               close_file_free(NULL, &fsp, close_type);
                return NULL;
        }
 
@@ -1300,7 +1301,7 @@ static bool close_file_in_loop(struct files_struct *fsp)
                return false;
        }
 
-       close_file_free(NULL, &fsp, SHUTDOWN_CLOSE);
+       close_file_free(NULL, &fsp, close_type);
        return true;
 }
 
@@ -1310,6 +1311,7 @@ static bool close_file_in_loop(struct files_struct *fsp)
 
 struct file_close_conn_state {
        struct connection_struct *conn;
+       enum file_close_type close_type;
        bool fsp_left_behind;
 };
 
@@ -1331,7 +1333,7 @@ static struct files_struct *file_close_conn_fn(
                fsp->op->global->durable = false;
        }
 
-       did_close = close_file_in_loop(fsp);
+       did_close = close_file_in_loop(fsp, state->close_type);
        if (!did_close) {
                state->fsp_left_behind = true;
        }
@@ -1341,7 +1343,8 @@ static struct files_struct *file_close_conn_fn(
 
 void file_close_conn(connection_struct *conn, enum file_close_type close_type)
 {
-       struct file_close_conn_state state = { .conn = conn };
+       struct file_close_conn_state state = { .conn = conn,
+                                              .close_type = close_type };
 
        files_forall(conn->sconn, file_close_conn_fn, &state);
 
@@ -1427,7 +1430,7 @@ static struct files_struct *file_close_user_fn(
                return NULL;
        }
 
-       did_close = close_file_in_loop(fsp);
+       did_close = close_file_in_loop(fsp, SHUTDOWN_CLOSE);
        if (!did_close) {
                state->fsp_left_behind = true;
        }