[SCM] Samba Shared Repository - branch master updated

Noel Power npower at samba.org
Thu Aug 18 14:11:01 UTC 2022


The branch, master has been updated
       via  cf5f7b14899 s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn()
       via  7005a6354df s3: smbd: Add "enum file_close_type close_type" parameter to file_close_conn().
       via  9203d17106c s3: smbd: Add "enum file_close_type close_type" parameter to close_cnum().
      from  e4371a4c3b8 release-script: Fix shellcheck errors

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit cf5f7b1489930f6d64c3e3512f116ccf286d4605
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 11:43:47 2022 -0700

    s3: smbd: Plumb close_type parameter through close_file_in_loop(), file_close_conn()
    
    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 at samba.org>
    Reivewed-by: Noel Power <npower at samba.org>
    
    Autobuild-User(master): Noel Power <npower at samba.org>
    Autobuild-Date(master): Thu Aug 18 14:10:18 UTC 2022 on sn-devel-184

commit 7005a6354df5522d9f665fb30052c458dfc93124
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 11:39:36 2022 -0700

    s3: smbd: Add "enum file_close_type close_type" parameter to file_close_conn().
    
    Not yet used.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15128
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 9203d17106c0e55a30813ff1ed76869c7581a343
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Aug 17 11:35:29 2022 -0700

    s3: smbd: Add "enum file_close_type close_type" parameter to close_cnum().
    
    Not yet used, but needed so we can differentiate between
    SHUTDOWN_CLOSE and ERROR_CLOSE in smbXsrv_tcon_disconnect()
    if we fail to chdir. 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 at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/files.c        | 17 ++++++++++-------
 source3/smbd/proto.h        |  6 ++++--
 source3/smbd/smb2_service.c |  6 ++++--
 source3/smbd/smbXsrv_tcon.c |  4 ++--
 4 files changed, 20 insertions(+), 13 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index a6c41f2b928..b494a8b789a 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -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;
 	}
@@ -1339,9 +1341,10 @@ static struct files_struct *file_close_conn_fn(
 	return NULL;
 }
 
-void file_close_conn(connection_struct *conn)
+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;
 	}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 5ac0f713958..c4a33014515 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -383,7 +383,7 @@ void fsp_set_gen_id(files_struct *fsp);
 NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 		  files_struct **result);
 NTSTATUS fsp_bind_smb(struct files_struct *fsp, struct smb_request *req);
-void file_close_conn(connection_struct *conn);
+void file_close_conn(connection_struct *conn, enum file_close_type close_type);
 bool file_init_global(void);
 bool file_init(struct smbd_server_connection *sconn);
 void file_close_user(struct smbd_server_connection *sconn, uint64_t vuid);
@@ -1053,7 +1053,9 @@ NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn,
 			      int snum,
 			      struct smbXsrv_session *session,
 			      const char *pdev);
-void close_cnum(connection_struct *conn, uint64_t vuid);
+void close_cnum(connection_struct *conn,
+		uint64_t vuid,
+		enum file_close_type close_type);
 
 /* The following definitions come from smbd/session.c  */
 struct sessionid;
diff --git a/source3/smbd/smb2_service.c b/source3/smbd/smb2_service.c
index e7a38241515..5affea6b3e4 100644
--- a/source3/smbd/smb2_service.c
+++ b/source3/smbd/smb2_service.c
@@ -932,14 +932,16 @@ connection_struct *make_connection_smb2(struct smbd_smb2_request *req,
  Close a cnum.
 ****************************************************************************/
 
-void close_cnum(connection_struct *conn, uint64_t vuid)
+void close_cnum(connection_struct *conn,
+		uint64_t vuid,
+		enum file_close_type close_type)
 {
 	char rootpath[2] = { '/', '\0'};
 	struct smb_filename root_fname = { .base_name = rootpath };
 	const struct loadparm_substitution *lp_sub =
 		loadparm_s3_global_substitution();
 
-	file_close_conn(conn);
+	file_close_conn(conn, close_type);
 
 	change_to_root_user();
 
diff --git a/source3/smbd/smbXsrv_tcon.c b/source3/smbd/smbXsrv_tcon.c
index b515b19e88f..8707082edd6 100644
--- a/source3/smbd/smbXsrv_tcon.c
+++ b/source3/smbd/smbXsrv_tcon.c
@@ -921,12 +921,12 @@ NTSTATUS smbXsrv_tcon_disconnect(struct smbXsrv_tcon *tcon, uint64_t vuid)
 			 * removed from the linked list
 			 * conn->sconn->connections.
 			 */
-			close_cnum(tcon->compat, vuid);
+			close_cnum(tcon->compat, vuid, ERROR_CLOSE);
 			tcon->compat = NULL;
 			return status;
 		}
 
-		close_cnum(tcon->compat, vuid);
+		close_cnum(tcon->compat, vuid, SHUTDOWN_CLOSE);
 		tcon->compat = NULL;
 	}
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list