[PATCH] Small cleanups from older branches

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Feb 26 13:24:02 UTC 2019


Hi!

Review appreciated!

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: 0551-370000-0, mailto:kontakt at sernet.de
Gesch.F.: Dr. Johannes Loxen und Reinhild Jung
AG Göttingen: HR-B 2816 - http://www.sernet.de
-------------- next part --------------
From a1794b05226a8cdee1a07c7258509de8d0ff06c6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 3 Jan 2018 16:25:41 +0100
Subject: [PATCH 01/12] addns: Remove some unused defines

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/addns/dnsquery.c | 50 --------------------------------------------------
 1 file changed, 50 deletions(-)

diff --git a/lib/addns/dnsquery.c b/lib/addns/dnsquery.c
index e5600367c4b..87ae97e3d0b 100644
--- a/lib/addns/dnsquery.c
+++ b/lib/addns/dnsquery.c
@@ -26,56 +26,6 @@
 #include "lib/util/tevent_ntstatus.h"
 #include "dnsquery.h"
 
-/* AIX resolv.h uses 'class' in struct ns_rr */
-
-#if defined(AIX)
-#  if defined(class)
-#    undef class
-#  endif
-#endif	/* AIX */
-
-/* resolver headers */
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
-#include <netdb.h>
-
-#define MAX_DNS_PACKET_SIZE 0xffff
-
-#ifdef NS_HFIXEDSZ	/* Bind 8/9 interface */
-#if !defined(C_IN)	/* AIX 5.3 already defines C_IN */
-#  define C_IN		ns_c_in
-#endif
-#if !defined(T_A)	/* AIX 5.3 already defines T_A */
-#  define T_A   	ns_t_a
-#endif
-
-#if defined(HAVE_IPV6)
-#if !defined(T_AAAA)
-#  define T_AAAA	ns_t_aaaa
-#endif
-#endif
-
-#  define T_SRV 	ns_t_srv
-#if !defined(T_NS)	/* AIX 5.3 already defines T_NS */
-#  define T_NS 		ns_t_ns
-#endif
-#else
-#  ifdef HFIXEDSZ
-#    define NS_HFIXEDSZ HFIXEDSZ
-#  else
-#    define NS_HFIXEDSZ sizeof(HEADER)
-#  endif	/* HFIXEDSZ */
-#  ifdef PACKETSZ
-#    define NS_PACKETSZ	PACKETSZ
-#  else	/* 512 is usually the default */
-#    define NS_PACKETSZ	512
-#  endif	/* PACKETSZ */
-#  define T_SRV 	33
-#endif
-
 /*********************************************************************
  Sort SRV record list based on weight and priority.  See RFC 2782.
 *********************************************************************/
-- 
2.11.0


From 63dd4e3cd18a163057051be6ca48c7176a6b959f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 10 Jan 2019 21:04:33 +0100
Subject: [PATCH 02/12] pdbtest: Use dom_sid_str_buf

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/torture/pdbtest.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
index 64bc45e6a7c..fdf72187b6c 100644
--- a/source3/torture/pdbtest.c
+++ b/source3/torture/pdbtest.c
@@ -358,9 +358,11 @@ static bool test_auth(TALLOC_CTX *mem_ctx, struct samu *pdb_entry)
 	}
 
 	if (!dom_sid_equal(info3_sam->base.domain_sid, info3_auth->base.domain_sid)) {
+		struct dom_sid_buf buf1, buf2;
 		DEBUG(0, ("domain_sid in SAM info3 %s does not match domain_sid in AUTH info3 %s\n", 
-			  dom_sid_string(NULL, info3_sam->base.domain_sid),
-			  dom_sid_string(NULL, info3_auth->base.domain_sid)));
+			  dom_sid_str_buf(info3_sam->base.domain_sid, &buf1),
+			  dom_sid_str_buf(info3_auth->base.domain_sid,
+					  &buf2)));
 		return False;
 	}
 	
@@ -429,9 +431,12 @@ static bool test_auth(TALLOC_CTX *mem_ctx, struct samu *pdb_entry)
 		}
 
 		if (!dom_sid_equal(info3_sam->base.domain_sid, info6_wbc->base.domain_sid)) {
+			struct dom_sid_buf buf1, buf2;
 			DEBUG(0, ("domain_sid in SAM info3 %s does not match domain_sid in AUTH info3 %s\n",
-				  dom_sid_string(NULL, info3_sam->base.domain_sid),
-				  dom_sid_string(NULL, info6_wbc->base.domain_sid)));
+				  dom_sid_str_buf(info3_sam->base.domain_sid,
+						  &buf1),
+				  dom_sid_str_buf(info6_wbc->base.domain_sid,
+						  &buf2)));
 			return false;
 		}
 	}
-- 
2.11.0


From 939119ed47e8b7fed4dc3668f797171b50c979ba Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 9 Nov 2018 21:12:51 +0100
Subject: [PATCH 03/12] libads: Use dom_sid_str_buf

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/libads/ldap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 6b5f271272a..ae23245fb14 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -2264,12 +2264,12 @@ static void dump_sid(ADS_STRUCT *ads, const char *field, struct berval **values)
 	int i;
 	for (i=0; values[i]; i++) {
 		struct dom_sid sid;
-		fstring tmp;
+		struct dom_sid_buf tmp;
 		if (!sid_parse((const uint8_t *)values[i]->bv_val,
 			       values[i]->bv_len, &sid)) {
 			return;
 		}
-		printf("%s: %s\n", field, sid_to_fstring(tmp, &sid));
+		printf("%s: %s\n", field, dom_sid_str_buf(&sid, &tmp));
 	}
 }
 
-- 
2.11.0


From 025e5553d112030c1d2dc9f1a8ddd7da4f3a3bf8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 12 Jan 2019 14:59:58 +0100
Subject: [PATCH 04/12] libads: Align integer types

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/libads/ldap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index ae23245fb14..728c821f32d 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -2229,8 +2229,9 @@ done:
 */
 static void dump_binary(ADS_STRUCT *ads, const char *field, struct berval **values)
 {
-	int i, j;
+	size_t i;
 	for (i=0; values[i]; i++) {
+		ber_len_t j;
 		printf("%s: ", field);
 		for (j=0; j<values[i]->bv_len; j++) {
 			printf("%02X", (unsigned char)values[i]->bv_val[j]);
@@ -2540,8 +2541,7 @@ int ads_count_replies(ADS_STRUCT *ads, void *res)
 {
 	char **values;
 	char **ret = NULL;
-	int i;
-	size_t converted_size;
+	size_t i, converted_size;
 
 	values = ldap_get_values(ads->ldap.ld, msg, field);
 	if (!values)
-- 
2.11.0


From 04eb8d02cebff803b679c615ecb9d33ebe348f34 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 30 Oct 2018 14:55:35 +0100
Subject: [PATCH 05/12] winbindd: Fix typos

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/winbindd_cm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 22d3dcaa92b..49dafb60b9e 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -1166,7 +1166,7 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
 		  nt_errstr(result)));
 
 	/*
-	 * If we are not going to validiate the conneciton
+	 * If we are not going to validate the connection
 	 * with SMB signing, then allow us to fall back to
 	 * anonymous
 	 */
@@ -1219,7 +1219,7 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
 		  nt_errstr(result)));
 
 	/*
-	 * If we are not going to validiate the conneciton
+	 * If we are not going to validate the connection
 	 * with SMB signing, then allow us to fall back to
 	 * anonymous
 	 */
-- 
2.11.0


From 1dcf105abe0fdd2f2c9b88aa52cc181a49c4abdd Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 9 Nov 2018 21:17:57 +0100
Subject: [PATCH 06/12] winbind: Align integer types

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/winbindd_ads.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c
index 4076f8227cb..4b5966dc237 100644
--- a/source3/winbindd/winbindd_ads.c
+++ b/source3/winbindd/winbindd_ads.c
@@ -718,7 +718,7 @@ static NTSTATUS lookup_usergroups_memberof(struct winbindd_domain *domain,
 	const char *attrs[] = {"memberOf", NULL};
 	uint32_t num_groups = 0;
 	struct dom_sid *group_sids = NULL;
-	int i;
+	size_t i;
 	char **strings = NULL;
 	size_t num_strings = 0, num_sids = 0;
 
@@ -1080,7 +1080,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
 	NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
 	char *sidbinstr;
 	char **members = NULL;
-	int i;
+	size_t i;
 	size_t num_members = 0;
 	ads_control args;
 	struct dom_sid *sid_mem_nocache = NULL;
@@ -1390,7 +1390,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
 {
 	NTSTATUS 		result = NT_STATUS_UNSUCCESSFUL;
 	WERROR werr;
-	int			i;
+	uint32_t		i;
 	uint32_t		flags;
 	struct rpc_pipe_client *cli;
 	int ret_count;
-- 
2.11.0


From f044f2f3f7ed8b9c6fd2e2436e468b4e48eabff7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 15 Oct 2018 08:32:33 +0200
Subject: [PATCH 07/12] winbind: Fix an error path memleak

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/wb_dsgetdcname.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/source3/winbindd/wb_dsgetdcname.c b/source3/winbindd/wb_dsgetdcname.c
index d2aaa8068ea..95a75a9cbc5 100644
--- a/source3/winbindd/wb_dsgetdcname.c
+++ b/source3/winbindd/wb_dsgetdcname.c
@@ -196,6 +196,7 @@ static void dcinfo_parser(const struct gencache_timeout *timeout,
 	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 		DBG_ERR("ndr_pull_struct_blob failed\n");
 		state->status = ndr_map_error2ntstatus(ndr_err);
+		TALLOC_FREE(state->dcinfo);
 		return;
 	}
 
-- 
2.11.0


From 68659be2681b546686d9457fd5aa1be3dc2782c8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Nov 2018 12:54:58 +0100
Subject: [PATCH 08/12] winbind: Avoid a "==False"

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/winbindd_cm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 49dafb60b9e..b9a1c1eda7b 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -2149,7 +2149,7 @@ static bool connection_ok(struct winbindd_domain *domain)
 		return False;
 	}
 
-	if (domain->online == False) {
+	if (!domain->online) {
 		DEBUG(3, ("connection_ok: Domain %s is offline\n", domain->name));
 		return False;
 	}
-- 
2.11.0


From 4185a2e906f060f3dc5d2bd84f8bf34ba7b635ca Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 8 Jan 2019 09:47:40 +0100
Subject: [PATCH 09/12] audit_log: Use dom_sid_str_buf

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/audit_log.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/source4/dsdb/samdb/ldb_modules/audit_log.c b/source4/dsdb/samdb/ldb_modules/audit_log.c
index 28d824acfff..931147efc72 100644
--- a/source4/dsdb/samdb/ldb_modules/audit_log.c
+++ b/source4/dsdb/samdb/ldb_modules/audit_log.c
@@ -778,7 +778,7 @@ static char *password_change_human_readable(
 	struct ldb_context *ldb = NULL;
 	const char *remote_host = NULL;
 	const struct dom_sid *sid = NULL;
-	const char *user_sid = NULL;
+	struct dom_sid_buf user_sid;
 	const char *timestamp = NULL;
 	char *log_entry = NULL;
 	const char *action = NULL;
@@ -790,7 +790,6 @@ static char *password_change_human_readable(
 
 	remote_host = dsdb_audit_get_remote_host(ldb, ctx);
 	sid = dsdb_audit_get_user_sid(module);
-	user_sid = dom_sid_string(ctx, sid);
 	timestamp = audit_get_timestamp(ctx);
 	action = get_password_action(request, reply);
 	dn = dsdb_audit_get_primary_dn(request);
@@ -803,7 +802,7 @@ static char *password_change_human_readable(
 		timestamp,
 		ldb_strerror(reply->error),
 		remote_host,
-		user_sid,
+		dom_sid_str_buf(sid, &user_sid),
 		dn);
 	TALLOC_FREE(ctx);
 	return log_entry;
@@ -930,7 +929,7 @@ static char *operation_human_readable(
 	struct ldb_context *ldb = NULL;
 	const char *remote_host = NULL;
 	const struct dom_sid *sid = NULL;
-	const char *user_sid = NULL;
+	struct dom_sid_buf user_sid;
 	const char *timestamp = NULL;
 	const char *op_name = NULL;
 	char *log_entry = NULL;
@@ -948,7 +947,6 @@ static char *operation_human_readable(
 	} else {
 		sid = dsdb_audit_get_user_sid(module);
 	}
-	user_sid = dom_sid_string(ctx, sid);
 	timestamp = audit_get_timestamp(ctx);
 	op_name = dsdb_audit_get_operation_name(request);
 	dn = dsdb_audit_get_primary_dn(request);
@@ -964,7 +962,7 @@ static char *operation_human_readable(
 		timestamp,
 		ldb_strerror(reply->error),
 		remote_host,
-		user_sid,
+		dom_sid_str_buf(sid, &user_sid),
 		dn);
 	if (new_dn != NULL) {
 		log_entry = talloc_asprintf_append_buffer(
-- 
2.11.0


From dc1d6023b379e10ae453bbb452a42ba3b2aa2994 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 25 Oct 2018 21:29:29 +0200
Subject: [PATCH 10/12] dsdb: Align integer types

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/dsdb/samdb/ldb_modules/audit_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/dsdb/samdb/ldb_modules/audit_util.c b/source4/dsdb/samdb/ldb_modules/audit_util.c
index edf3c5e4b46..f25102585f8 100644
--- a/source4/dsdb/samdb/ldb_modules/audit_util.c
+++ b/source4/dsdb/samdb/ldb_modules/audit_util.c
@@ -586,7 +586,7 @@ struct json_object dsdb_audit_attributes_json(
 	const struct ldb_message* message)
 {
 
-	int i, j;
+	unsigned int i, j;
 	struct json_object attributes = json_new_object();
 
 	if (json_is_invalid(&attributes)) {
-- 
2.11.0


From 3752294451606b527e95c868c37fbe238ad7e882 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 7 Jan 2019 21:03:06 +0100
Subject: [PATCH 11/12] libnet: Use dom_sid_str_buf

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/libnet/libnet_samsync_ldb.c | 40 +++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c
index 3171138886c..68e9cd110a6 100644
--- a/source4/libnet/libnet_samsync_ldb.c
+++ b/source4/libnet/libnet_samsync_ldb.c
@@ -259,6 +259,7 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
 	char *cn_name;
 	int cn_name_len;
 	const struct dom_sid *user_sid;
+	struct dom_sid_buf buf;
 	struct ldb_message *msg;
 	struct ldb_message **msgs;
 	struct ldb_message **remote_msgs = NULL;
@@ -288,15 +289,19 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
 			   ldap_encode_ndr_dom_sid(mem_ctx, user_sid));
 
 	if (ret == -1) {
-		*error_string = talloc_asprintf(mem_ctx, "LDB for user %s failed: %s", 
-						dom_sid_string(mem_ctx, user_sid),
-						ldb_errstring(state->sam_ldb));
+		*error_string = talloc_asprintf(
+			mem_ctx,
+			"LDB for user %s failed: %s",
+			dom_sid_str_buf(user_sid, &buf),
+			ldb_errstring(state->sam_ldb));
 		return NT_STATUS_INTERNAL_DB_CORRUPTION;
 	} else if (ret == 0) {
 		add = true;
 	} else if (ret > 1) {
-		*error_string = talloc_asprintf(mem_ctx, "More than one user with SID: %s in local LDB", 
-						dom_sid_string(mem_ctx, user_sid));
+		*error_string = talloc_asprintf(
+			mem_ctx,
+			"More than one user with SID: %s in local LDB",
+			dom_sid_str_buf(user_sid, &buf));
 		return NT_STATUS_INTERNAL_DB_CORRUPTION;
 	} else {
 		msg->dn = msgs[0]->dn;
@@ -310,18 +315,27 @@ static NTSTATUS samsync_ldb_handle_user(TALLOC_CTX *mem_ctx,
 				   ldap_encode_ndr_dom_sid(mem_ctx, user_sid));
 		
 		if (ret == -1) {
-			*error_string = talloc_asprintf(mem_ctx, "remote LDAP for user %s failed: %s", 
-							dom_sid_string(mem_ctx, user_sid),
-							ldb_errstring(state->remote_ldb));
+			*error_string = talloc_asprintf(
+				mem_ctx,
+				"remote LDAP for user %s failed: %s",
+				dom_sid_str_buf(user_sid, &buf),
+				ldb_errstring(state->remote_ldb));
 			return NT_STATUS_INTERNAL_DB_CORRUPTION;
 		} else if (ret == 0) {
-			*error_string = talloc_asprintf(mem_ctx, "User exists in samsync but not in remote LDAP domain! (base: %s, SID: %s)", 
-							ldb_dn_get_linearized(state->base_dn[database]),
-							dom_sid_string(mem_ctx, user_sid));
+			*error_string = talloc_asprintf(
+				mem_ctx,
+				"User exists in samsync but not in remote "
+				"LDAP domain! (base: %s, SID: %s)",
+				ldb_dn_get_linearized(
+					state->base_dn[database]),
+				dom_sid_str_buf(user_sid, &buf));
 			return NT_STATUS_NO_SUCH_USER;
 		} else if (ret > 1) {
-			*error_string = talloc_asprintf(mem_ctx, "More than one user in remote LDAP domain with SID: %s", 
-							dom_sid_string(mem_ctx, user_sid));
+			*error_string = talloc_asprintf(
+				mem_ctx,
+				"More than one user in remote LDAP domain "
+				"with SID: %s",
+				dom_sid_str_buf(user_sid, &buf));
 			return NT_STATUS_INTERNAL_DB_CORRUPTION;
 			
 			/* Try to put things in the same location as the remote server */
-- 
2.11.0


From ae7701817241e1f0c734942d7e1af692952266d2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 10 Jan 2019 21:13:36 +0100
Subject: [PATCH 12/12] rpc_server: Use dom_sid_str_buf

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source4/rpc_server/handles.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c
index 91bfaf9c62c..15d0c3d6e09 100644
--- a/source4/rpc_server/handles.c
+++ b/source4/rpc_server/handles.c
@@ -116,9 +116,10 @@ struct dcesrv_handle *dcesrv_handle_lookup(struct dcesrv_call_state *call,
 				return NULL;
 			}
 			if (!dom_sid_equal(h->sid, sid)) {
-				DEBUG(0,(__location__ ": Attempt to use invalid sid %s - %s\n",
-					 dom_sid_string(context, h->sid),
-					 dom_sid_string(context, sid)));
+				struct dom_sid_buf buf1, buf2;
+				DBG_ERR("Attempt to use invalid sid %s - %s\n",
+					dom_sid_str_buf(h->sid, &buf1),
+					dom_sid_str_buf(sid, &buf2));
 				return NULL;
 			}
 			if (call->auth_state->auth_level < h->min_auth_level) {
-- 
2.11.0



More information about the samba-technical mailing list