diff --git a/lib/bootstrap.py b/lib/bootstrap.py index 160c1a59af86fbc2d605cf37f99c9667ea905568..118c7b13786d0fde60c75853ec7ef7894a38d81e 100644 --- a/lib/bootstrap.py +++ b/lib/bootstrap.py @@ -81,7 +81,7 @@ def _InitGanetiServerSetup(ss): """ # Create pseudo random password - randpass = sha.new(os.urandom(64)).hexdigest() + randpass = utils.GenerateSecret() # and write it into sstore ss.SetKey(ss.SS_NODED_PASS, randpass) diff --git a/lib/utils.py b/lib/utils.py index ebe974262854cdbb1a477dc6fbae6e2a008b2624..d73ee36a09cd2b00d4d327de9d2106d6fa166f2b 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -864,6 +864,16 @@ def NewUUID(): f.close() +def GenerateSecret(): + """Generates a random secret. + + This will generate a pseudo-random secret, and return its sha digest + (so that it can be used where an ASCII string is needed). + + """ + return sha.new(os.urandom(64)).hexdigest() + + def ReadFile(file_name, size=None): """Reads a file.