02357b
From a503519533eb375a5ce1f7566bfc153aac980d87 Mon Sep 17 00:00:00 2001
02357b
From: Petr Mensik <pemensik@redhat.com>
02357b
Date: Fri, 9 Jul 2021 20:52:21 +0200
02357b
Subject: [PATCH] Use proper entropy to initialize tsig keyname
02357b
02357b
Random names used on GSS backed nsupdate can conflict in specific
02357b
situations. That might include starting a lot of machines from
02357b
containers, where they took all similar time to start. PID and timestamp
02357b
would be similar and therefore randomness is quite low. Use entropy to
02357b
generate more random identifier and reduce chance of conflict.
02357b
---
02357b
 bin/nsupdate/nsupdate.c | 4 +++-
02357b
 1 file changed, 3 insertions(+), 1 deletion(-)
02357b
02357b
diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c
02357b
index 458aa76..d9e5a2b 100644
02357b
--- a/bin/nsupdate/nsupdate.c
02357b
+++ b/bin/nsupdate/nsupdate.c
02357b
@@ -2941,7 +2941,9 @@ start_gssrequest(dns_name_t *master) {
02357b
 
02357b
 	keyname = dns_fixedname_initname(&fkname);
02357b
 
02357b
-	isc_random_get(&val;;
02357b
+	result = isc_entropy_getdata(entropy, &val, sizeof(val), NULL, 0);
02357b
+	if (result != ISC_R_SUCCESS)
02357b
+		isc_random_get(&val;;
02357b
 	result = isc_string_printf(mykeystr, sizeof(mykeystr), "%u.sig-%s",
02357b
 				   val, namestr);
02357b
 	if (result != ISC_R_SUCCESS)
02357b
-- 
02357b
2.31.1
02357b