[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Apr 23 19:03:01 UTC 2024


The branch, master has been updated
       via  1cba9de1444 Fix a few "might be uninitialized" errors
       via  316579b5029 smbd: Slightly simplify notifyd_send_delete()
       via  190ae0796eb smbd: Simplify smb_set_file_unix_link()
       via  88921ac1774 smbd: Simplify smb_q_posix_symlink()
       via  e35b3af2e8b smbd: Simplify call_trans2qpathinfo()
      from  daf6d371f36 s3:rpc_client: implement bind time feature negotiation

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


- Log -----------------------------------------------------------------
commit 1cba9de14444933a51972b725e0f4852704d2a8c
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 22 21:33:05 2024 +0100

    Fix a few "might be uninitialized" errors
    
    I've seen them with clang
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Apr 23 19:02:10 UTC 2024 on atb-devel-224

commit 316579b5029823ba19eda2a131a3a2a5df7419a1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 27 15:32:59 2024 +0100

    smbd: Slightly simplify notifyd_send_delete()
    
    Call messaging_send_iov() instead of messaging_send_iov_from().
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 190ae0796ebaaf4f2fc2479f81637207d1fa8934
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Feb 12 10:26:28 2024 +0100

    smbd: Simplify smb_set_file_unix_link()
    
    Avoid a call to parent_pathref, use the dirfsp that already exists
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 88921ac177421c25827092df3f063baa80f9f4bf
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Feb 11 13:10:01 2024 +0100

    smbd: Simplify smb_q_posix_symlink()
    
    Use the dirfsp from call_trans2qpathinfo(), avoid a call to parent_pathref()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e35b3af2e8b82678b2d77ea39a132f6ecaca9991
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 10 14:26:55 2024 +0100

    smbd: Simplify call_trans2qpathinfo()
    
    These days filename_convert_dirfsp() always returns a full fsp.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 source3/libsmb/libsmb_file.c      |   2 +-
 source3/smbd/notifyd/notifyd.c    |  18 +++--
 source3/smbd/smb1_trans2.c        | 147 +++++++++++++-------------------------
 source4/auth/sam.c                |   2 +-
 source4/dsdb/common/rodc_helper.c |   2 +-
 5 files changed, 63 insertions(+), 108 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index ff18d569757..5861718d672 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -470,7 +470,7 @@ SMBC_getatr(SMBCCTX * context,
 	mode_t mode = S_IFREG;
 	struct cli_credentials *creds = NULL;
 	TALLOC_CTX *frame = talloc_stackframe();
-	NTSTATUS status;
+	NTSTATUS status = NT_STATUS_ACCESS_DENIED;
 
 	if (!context || !context->internal->initialized) {
 		TALLOC_FREE(frame);
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
index 4af62a9a1f9..64dd26a7e11 100644
--- a/source3/smbd/notifyd/notifyd.c
+++ b/source3/smbd/notifyd/notifyd.c
@@ -790,7 +790,7 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx,
 	};
 	uint8_t nul = 0;
 	struct iovec iov[3];
-	int ret;
+	NTSTATUS status;
 
 	/*
 	 * Send a rec_change to ourselves to delete a dead entry
@@ -802,13 +802,17 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx,
 	iov[1] = (struct iovec) { .iov_base = key.dptr, .iov_len = key.dsize };
 	iov[2] = (struct iovec) { .iov_base = &nul, .iov_len = sizeof(nul) };
 
-	ret = messaging_send_iov_from(
-		msg_ctx, instance->client, messaging_server_id(msg_ctx),
-		MSG_SMB_NOTIFY_REC_CHANGE, iov, ARRAY_SIZE(iov), NULL, 0);
+	status = messaging_send_iov(msg_ctx,
+				    instance->client,
+				    MSG_SMB_NOTIFY_REC_CHANGE,
+				    iov,
+				    ARRAY_SIZE(iov),
+				    NULL,
+				    0);
 
-	if (ret != 0) {
-		DBG_WARNING("messaging_send_iov_from returned %s\n",
-			    strerror(ret));
+	if (!NT_STATUS_IS_OK(status)) {
+		DBG_WARNING("messaging_send_iov failed: %s\n",
+			    nt_errstr(status));
 	}
 }
 
diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c
index ae5fee7e2ff..e31bdf02fe8 100644
--- a/source3/smbd/smb1_trans2.c
+++ b/source3/smbd/smb1_trans2.c
@@ -2529,16 +2529,14 @@ static NTSTATUS smb_q_posix_acl(
 static NTSTATUS smb_q_posix_symlink(
 	struct connection_struct *conn,
 	struct smb_request *req,
+	struct files_struct *dirfsp,
 	struct smb_filename *smb_fname,
 	char **ppdata,
 	int *ptotal_data)
 {
-	char buffer[PATH_MAX+1];
+	char *target = NULL;
 	size_t needed, len;
-	int link_len;
 	char *pdata = NULL;
-	struct smb_filename *parent_fname = NULL;
-	struct smb_filename *base_name = NULL;
 	NTSTATUS status;
 
 	DBG_DEBUG("SMB_QUERY_FILE_UNIX_LINK for file %s\n",
@@ -2548,40 +2546,39 @@ static NTSTATUS smb_q_posix_symlink(
 		return NT_STATUS_DOS(ERRSRV, ERRbadlink);
 	}
 
-	status = parent_pathref(
-		talloc_tos(),
-		conn->cwd_fsp,
-		smb_fname,
-		&parent_fname,
-		&base_name);
+	if (fsp_get_pathref_fd(smb_fname->fsp) != -1) {
+		/*
+		 * fsp is an O_PATH open, Linux does a "freadlink"
+		 * with an empty name argument to readlinkat
+		 */
+		status = readlink_talloc(talloc_tos(),
+					 smb_fname->fsp,
+					 NULL,
+					 &target);
+	} else {
+		struct smb_filename smb_fname_rel = *smb_fname;
+		char *slash = NULL;
 
-	if (!NT_STATUS_IS_OK(status)) {
-		DBG_DEBUG("parent_pathref failed: %s\n", nt_errstr(status));
-		return status;
+		slash = strrchr_m(smb_fname->base_name, '/');
+		if (slash != NULL) {
+			smb_fname_rel.base_name = slash + 1;
+		}
+		status = readlink_talloc(talloc_tos(),
+					 dirfsp,
+					 &smb_fname_rel,
+					 &target);
 	}
 
-	link_len = SMB_VFS_READLINKAT(
-		conn,
-		parent_fname->fsp,
-		base_name,
-		buffer,
-		sizeof(buffer)-1);
-	TALLOC_FREE(parent_fname);
-
-	if (link_len == -1) {
-		status = map_nt_error_from_unix(errno);
-		DBG_DEBUG("READLINKAT failed: %s\n", nt_errstr(status));
+	if (!NT_STATUS_IS_OK(status)) {
+		DBG_DEBUG("readlink_talloc() failed: %s\n", nt_errstr(status));
 		return status;
 	}
-	if (link_len >= sizeof(buffer)) {
-		return NT_STATUS_INTERNAL_ERROR;
-	}
-	buffer[link_len] = 0;
 
-	needed = (link_len+1)*2;
+	needed = talloc_get_size(target) * 2;
 
 	*ppdata = SMB_REALLOC(*ppdata, needed);
 	if (*ppdata == NULL) {
+		TALLOC_FREE(target);
 		return NT_STATUS_NO_MEMORY;
 	}
 	pdata = *ppdata;
@@ -2590,10 +2587,11 @@ static NTSTATUS smb_q_posix_symlink(
 		pdata,
 		req->flags2,
 		pdata,
-		buffer,
+		target,
 		needed,
 		STR_TERMINATE,
 		&len);
+	TALLOC_FREE(target);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
@@ -2618,14 +2616,11 @@ static void call_trans2qpathinfo(
 	struct timespec write_time_ts = { .tv_sec = 0, };
 	struct files_struct *dirfsp = NULL;
 	files_struct *fsp = NULL;
-	struct file_id fileid;
-	uint32_t name_hash;
 	char *fname = NULL;
 	uint32_t ucf_flags = ucf_flags_from_smb_request(req);
 	NTTIME twrp = 0;
 	bool info_level_handled;
 	NTSTATUS status = NT_STATUS_OK;
-	int ret;
 
 	if (!params) {
 		reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2718,65 +2713,24 @@ static void call_trans2qpathinfo(
 	fsp = smb_fname->fsp;
 
 	/* If this is a stream, check if there is a delete_pending. */
-	if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
-	    && is_ntfs_stream_smb_fname(smb_fname)) {
-		struct smb_filename *smb_fname_base;
-
-		/* Create an smb_filename with stream_name == NULL. */
-		smb_fname_base = synthetic_smb_fname(
-			talloc_tos(),
-			smb_fname->base_name,
-			NULL,
-			NULL,
-			smb_fname->twrp,
-			smb_fname->flags);
-		if (smb_fname_base == NULL) {
-			reply_nterror(req, NT_STATUS_NO_MEMORY);
-			return;
-		}
+	if (fsp_is_alternate_stream(fsp)) {
 
-		ret = vfs_stat(conn, smb_fname_base);
-		if (ret != 0) {
-			DBG_NOTICE("vfs_stat of %s failed "
-				   "(%s)\n",
-				   smb_fname_str_dbg(smb_fname_base),
-				   strerror(errno));
-			TALLOC_FREE(smb_fname_base);
-			reply_nterror(req,
-				      map_nt_error_from_unix(errno));
-			return;
-		}
-
-		status = file_name_hash(conn,
-					smb_fname_str_dbg(smb_fname_base),
-					&name_hash);
-		if (!NT_STATUS_IS_OK(status)) {
-			TALLOC_FREE(smb_fname_base);
-			reply_nterror(req, status);
-			return;
-		}
+		struct files_struct *base_fsp = fsp->base_fsp;
 
-		fileid = vfs_file_id_from_sbuf(conn,
-					       &smb_fname_base->st);
-		TALLOC_FREE(smb_fname_base);
-		get_file_infos(fileid, name_hash, &delete_pending, NULL);
+		get_file_infos(base_fsp->file_id,
+			       base_fsp->name_hash,
+			       &delete_pending,
+			       NULL);
 		if (delete_pending) {
 			reply_nterror(req, NT_STATUS_DELETE_PENDING);
 			return;
 		}
 	}
 
-	status = file_name_hash(conn,
-				smb_fname_str_dbg(smb_fname),
-				&name_hash);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		return;
-	}
-
 	if (fsp_getinfo_ask_sharemode(fsp)) {
-		fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
-		get_file_infos(fileid, name_hash, &delete_pending,
+		get_file_infos(fsp->file_id,
+			       fsp->name_hash,
+			       &delete_pending,
 			       &write_time_ts);
 	}
 
@@ -2827,6 +2781,7 @@ static void call_trans2qpathinfo(
 		status = smb_q_posix_symlink(
 			conn,
 			req,
+			dirfsp,
 			smb_fname,
 			ppdata,
 			&total_data);
@@ -3720,15 +3675,16 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
 				       struct smb_request *req,
 				       const char *pdata,
 				       int total_data,
+				       struct files_struct *dirfsp,
 				       struct smb_filename *new_smb_fname)
 {
 	char *link_target = NULL;
 	struct smb_filename target_fname;
 	TALLOC_CTX *ctx = talloc_tos();
+	struct smb_filename new_smb_fname_rel = {};
+	char *slash = NULL;
 	NTSTATUS status;
 	int ret;
-	struct smb_filename *parent_fname = NULL;
-	struct smb_filename *base_name = NULL;
 
 	if (!CAN_WRITE(conn)) {
 		return NT_STATUS_DOS(ERRSRV, ERRaccess);
@@ -3765,25 +3721,20 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
 	DBG_DEBUG("SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
 		  new_smb_fname->base_name, link_target);
 
-	status = parent_pathref(talloc_tos(),
-				conn->cwd_fsp,
-				new_smb_fname,
-				&parent_fname,
-				&base_name);
-	if (!NT_STATUS_IS_OK(status)) {
-		return status;
+	new_smb_fname_rel = *new_smb_fname;
+	slash = strrchr_m(new_smb_fname_rel.base_name, '/');
+	if (slash != NULL) {
+		new_smb_fname_rel.base_name = slash + 1;
 	}
 
 	ret = SMB_VFS_SYMLINKAT(conn,
-			&target_fname,
-			parent_fname->fsp,
-			base_name);
+				&target_fname,
+				dirfsp,
+				&new_smb_fname_rel);
 	if (ret != 0) {
-		TALLOC_FREE(parent_fname);
 		return map_nt_error_from_unix(errno);
 	}
 
-	TALLOC_FREE(parent_fname);
 	return NT_STATUS_OK;
 }
 
@@ -4583,7 +4534,7 @@ static void call_trans2setpathinfo(
 
 	case SMB_SET_FILE_UNIX_LINK:
 		status = smb_set_file_unix_link(
-			conn, req, *ppdata, total_data, smb_fname);
+			conn, req, *ppdata, total_data, dirfsp, smb_fname);
 		break;
 
 	case SMB_SET_FILE_UNIX_HLINK:
diff --git a/source4/auth/sam.c b/source4/auth/sam.c
index 1445adf2261..bd8219d7335 100644
--- a/source4/auth/sam.c
+++ b/source4/auth/sam.c
@@ -1581,7 +1581,7 @@ NTSTATUS authsam_logon_success_accounting(struct ldb_context *sam_ctx,
 	NTTIME sync_interval_nt = 0;
 	bool am_rodc = false;
 	bool txn_active = false;
-	bool need_db_reread;
+	bool need_db_reread = false;
 
 	mem_ctx = talloc_new(msg);
 	if (mem_ctx == NULL) {
diff --git a/source4/dsdb/common/rodc_helper.c b/source4/dsdb/common/rodc_helper.c
index b4982aee9ed..5ed60e0af43 100644
--- a/source4/dsdb/common/rodc_helper.c
+++ b/source4/dsdb/common/rodc_helper.c
@@ -243,7 +243,7 @@ WERROR samdb_confirm_rodc_allowed_to_repl_to(struct ldb_context *sam_ctx,
 {
 	TALLOC_CTX *frame = talloc_stackframe();
 	WERROR werr;
-	uint32_t num_token_sids;
+	uint32_t num_token_sids = 0;
 	struct dom_sid *token_sids;
 	const struct dom_sid *object_sid = NULL;
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list