Blame cloud-init-19.4-utils-use-SystemRandom-when-generating-random-passwo.patch
|
|
34fecf9 |
From 3e2f7356effc9e9cccc5ae945846279804eedc46 Mon Sep 17 00:00:00 2001
|
|
|
34fecf9 |
From: Dimitri John Ledkov <xnox@ubuntu.com>
|
|
|
34fecf9 |
Date: Tue, 18 Feb 2020 17:03:24 +0000
|
|
|
34fecf9 |
Subject: [PATCH] utils: use SystemRandom when generating random password.
|
|
|
34fecf9 |
(#204)
|
|
|
34fecf9 |
|
|
|
34fecf9 |
As noticed by Seth Arnold, non-deterministic SystemRandom should be
|
|
|
34fecf9 |
used when creating security sensitive random strings.
|
|
|
34fecf9 |
---
|
|
|
34fecf9 |
cloudinit/util.py | 3 ++-
|
|
|
34fecf9 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
34fecf9 |
|
|
|
34fecf9 |
diff --git a/cloudinit/util.py b/cloudinit/util.py
|
|
|
34fecf9 |
index d99e82fa..c02b3d9a 100644
|
|
|
34fecf9 |
--- a/cloudinit/util.py
|
|
|
34fecf9 |
+++ b/cloudinit/util.py
|
|
|
34fecf9 |
@@ -397,9 +397,10 @@ def translate_bool(val, addons=None):
|
|
|
34fecf9 |
|
|
|
34fecf9 |
|
|
|
34fecf9 |
def rand_str(strlen=32, select_from=None):
|
|
|
34fecf9 |
+ r = random.SystemRandom()
|
|
|
34fecf9 |
if not select_from:
|
|
|
34fecf9 |
select_from = string.ascii_letters + string.digits
|
|
|
34fecf9 |
- return "".join([random.choice(select_from) for _x in range(0, strlen)])
|
|
|
34fecf9 |
+ return "".join([r.choice(select_from) for _x in range(0, strlen)])
|
|
|
34fecf9 |
|
|
|
34fecf9 |
|
|
|
34fecf9 |
def rand_dict_key(dictionary, postfix=None):
|
|
|
34fecf9 |
--
|
|
|
34fecf9 |
2.18.1
|
|
|
34fecf9 |
|