summaryrefslogtreecommitdiff
path: root/ironic_python_agent/extensions
diff options
context:
space:
mode:
authorIury Gregory Melo Ferreira <imelofer@redhat.com>2020-03-18 17:14:29 +0100
committerIury Gregory Melo Ferreira <imelofer@redhat.com>2020-03-19 15:16:00 +0100
commit7f8afac092e44ca3c93350a73c7b9ff29a0642ba (patch)
tree9b66d95971b97e250e9838056e70bb1d58ebb50a /ironic_python_agent/extensions
parent6f1f9c7f6ed55689f5e738e7b6f01a5c789099e5 (diff)
downloadironic-python-agent-7f8afac092e44ca3c93350a73c7b9ff29a0642ba.tar.gz
Use crypt to generate salt
Let's use the crypt to generate the salt, the crypt.crypt can handle the generation of the salt if we don't pass. Change-Id: I63fca663940e44924a201b166bdd79d8f7710bee Story: 2007443 Task: 39103
Diffstat (limited to 'ironic_python_agent/extensions')
-rw-r--r--ironic_python_agent/extensions/rescue.py15
1 files changed, 1 insertions, 14 deletions
diff --git a/ironic_python_agent/extensions/rescue.py b/ironic_python_agent/extensions/rescue.py
index 6ec8a2f9..036a17f7 100644
--- a/ironic_python_agent/extensions/rescue.py
+++ b/ironic_python_agent/extensions/rescue.py
@@ -11,8 +11,6 @@
# limitations under the License.
import crypt
-import random
-import string
from oslo_log import log
@@ -25,16 +23,6 @@ PASSWORD_FILE = '/etc/ipa-rescue-config/ipa-rescue-password'
class RescueExtension(base.BaseAgentExtension):
- def make_salt(self):
- """Generate a random salt for hashing the rescue password.
-
- Salt should be a two-character string from the set [a-zA-Z0-9].
-
- :returns: a valid salt for use with crypt.crypt
- """
- allowed_chars = string.ascii_letters + string.digits
- return random.choice(allowed_chars) + random.choice(allowed_chars)
-
def write_rescue_password(self, rescue_password="", hashed=False):
"""Write rescue password to a file for use after IPA exits.
@@ -55,8 +43,7 @@ class RescueExtension(base.BaseAgentExtension):
if hashed:
hashed_password = password
else:
- salt = self.make_salt()
- hashed_password = crypt.crypt(rescue_password, salt)
+ hashed_password = crypt.crypt(rescue_password)
try:
with open(PASSWORD_FILE, 'w') as f:
f.write(hashed_password)