|
|
5b08af |
From cdb5f116c3a43ff2a5943cdadd0562ec03054a5b Mon Sep 17 00:00:00 2001
|
|
|
5b08af |
From: jmaloy <jmaloy@redhat.com>
|
|
|
5b08af |
Date: Fri, 13 Mar 2020 18:55:18 +0100
|
|
|
5b08af |
Subject: [PATCH 4/5] utils: use SystemRandom when generating random password.
|
|
|
5b08af |
(#204)
|
|
|
5b08af |
|
|
|
5b08af |
Message-id: <20200313185518.18544-2-jmaloy@redhat.com>
|
|
|
5b08af |
Patchwork-id: 94296
|
|
|
5b08af |
O-Subject: [RHEL-7.9 cloud-init PATCH 1/1] utils: use SystemRandom when generating random password. (#204)
|
|
|
5b08af |
Bugzilla: 1812173
|
|
|
5b08af |
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
|
|
|
5b08af |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
5b08af |
RH-Acked-by: Eduardo Otubo <eterrell@redhat.com>
|
|
|
5b08af |
|
|
|
5b08af |
From: Dimitri John Ledkov <xnox@ubuntu.com>
|
|
|
5b08af |
|
|
|
5b08af |
As noticed by Seth Arnold, non-deterministic SystemRandom should be
|
|
|
5b08af |
used when creating security sensitive random strings.
|
|
|
5b08af |
|
|
|
5b08af |
(cherry picked from commit 3e2f7356effc9e9cccc5ae945846279804eedc46)
|
|
|
5b08af |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
5b08af |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5b08af |
---
|
|
|
5b08af |
cloudinit/util.py | 3 ++-
|
|
|
5b08af |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
5b08af |
|
|
|
5b08af |
diff --git a/cloudinit/util.py b/cloudinit/util.py
|
|
|
5b08af |
index 9d9d5c7..5d51ba8 100644
|
|
|
5b08af |
--- a/cloudinit/util.py
|
|
|
5b08af |
+++ b/cloudinit/util.py
|
|
|
5b08af |
@@ -401,9 +401,10 @@ def translate_bool(val, addons=None):
|
|
|
5b08af |
|
|
|
5b08af |
|
|
|
5b08af |
def rand_str(strlen=32, select_from=None):
|
|
|
5b08af |
+ r = random.SystemRandom()
|
|
|
5b08af |
if not select_from:
|
|
|
5b08af |
select_from = string.ascii_letters + string.digits
|
|
|
5b08af |
- return "".join([random.choice(select_from) for _x in range(0, strlen)])
|
|
|
5b08af |
+ return "".join([r.choice(select_from) for _x in range(0, strlen)])
|
|
|
5b08af |
|
|
|
5b08af |
|
|
|
5b08af |
def rand_dict_key(dictionary, postfix=None):
|
|
|
5b08af |
--
|
|
|
5b08af |
1.8.3.1
|
|
|
5b08af |
|