[PATCH] Some patches for netsamlogon_cache_get

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Dec 12 03:47:32 MST 2014


Hi!

Review&push appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From d322ac343009a99842532f8cb3d14a6f289d46f2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 12 Dec 2014 11:39:25 +0100
Subject: [PATCH 1/3] libsmb: Fix removing invalid samlogon cache entries

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

diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index 1f1ab1d..0041a77 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -247,7 +247,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 
 	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 		DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n"));
-		tdb_delete(netsamlogon_tdb, data);
+		tdb_delete_bystring(netsamlogon_tdb, keystr);
 		TALLOC_FREE(info3);
 		goto done;
 	}
-- 
2.1.2


From fbcd7131ff6176f200fa23019ed07d50040bb71a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 12 Dec 2014 11:41:14 +0100
Subject: [PATCH 2/3] libsmb: Only print decoded netsamlogon cache entries

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

diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index 0041a77..9e194b5 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -241,10 +241,6 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 	ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r,
 				      (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry);
 
-	if (DEBUGLEVEL >= 10) {
-		NDR_PRINT_DEBUG(netsamlogoncache_entry, &r);
-	}
-
 	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 		DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n"));
 		tdb_delete_bystring(netsamlogon_tdb, keystr);
@@ -252,6 +248,10 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 		goto done;
 	}
 
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_DEBUG(netsamlogoncache_entry, &r);
+	}
+
 	info3 = (struct netr_SamInfo3 *)talloc_memdup(mem_ctx, &r.info3,
 						      sizeof(r.info3));
 
-- 
2.1.2


From e22691ad02e121978b40f1986aec4714f9787df6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 12 Dec 2014 11:44:06 +0100
Subject: [PATCH 3/3] libsmb: Simplify netsamlogon_cache_get

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

diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index 9e194b5..4e50c78 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -211,7 +211,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 {
 	struct netr_SamInfo3 *info3 = NULL;
 	TDB_DATA data;
-	fstring keystr, tmp;
+	fstring keystr;
 	enum ndr_err_code ndr_err;
 	DATA_BLOB blob;
 	struct netsamlogoncache_entry r;
@@ -223,7 +223,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 	}
 
 	/* Prepare key as DOMAIN-SID/USER-RID string */
-	slprintf(keystr, sizeof(keystr), "%s", sid_to_fstring(tmp, user_sid));
+	sid_to_fstring(keystr, user_sid);
 	DEBUG(10,("netsamlogon_cache_get: SID [%s]\n", keystr));
 	data = tdb_fetch_bystring( netsamlogon_tdb, keystr );
 
-- 
2.1.2



More information about the samba-technical mailing list