From 95f514da06625fb012e182b82e4a03ccf95b573e Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 5 Dec 2024 21:59:05 +0900 Subject: [PATCH] Replace crypt module The crypt module was removed in Python 3.13 . Replace the module by new methods from oslo_utils.secretutils . Closes-Bug: #2083955 Change-Id: Ib574fc1b0f267e9b42f899f02a7ef84188ef9e85 --- ironic/conductor/utils.py | 10 +++++----- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py index 2cbf99ca80..dbabacd861 100644 --- a/ironic/conductor/utils.py +++ b/ironic/conductor/utils.py @@ -13,7 +13,6 @@ # under the License. import contextlib -import crypt import datetime import functools import os @@ -26,6 +25,7 @@ from oslo_log import log from oslo_serialization import jsonutils from oslo_service import loopingcall from oslo_utils import excutils +from oslo_utils import secretutils from oslo_utils import strutils from oslo_utils import timeutils @@ -49,8 +49,8 @@ CONF = cfg.CONF PASSWORD_HASH_FORMAT = { - 'sha256': crypt.METHOD_SHA256, - 'sha512': crypt.METHOD_SHA512, + 'sha256': 'SHA-256', + 'sha512': 'SHA-512', } @@ -1475,7 +1475,7 @@ def make_salt(): :returns: a valid salt for use with crypt.crypt """ - return crypt.mksalt( + return secretutils.crypt_mksalt( method=PASSWORD_HASH_FORMAT[ CONF.conductor.rescue_password_hash_algorithm]) @@ -1485,7 +1485,7 @@ def hash_password(password=''): :param password: password to be hashed """ - return crypt.crypt(password, make_salt()) + return secretutils.crypt_password(password, make_salt()) def get_attached_vif(port): diff --git a/requirements.txt b/requirements.txt index a560f23a05..7562e533ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ oslo.policy>=4.5.0 # Apache-2.0 oslo.serialization>=2.25.0 # Apache-2.0 oslo.service>=1.24.0 # Apache-2.0 oslo.upgradecheck>=1.3.0 # Apache-2.0 -oslo.utils>=7.3.0 # Apache-2.0 +oslo.utils>=8.0.0 # Apache-2.0 osprofiler>=1.5.0 # Apache-2.0 os-traits>=0.4.0 # Apache-2.0 pecan>=1.0.0 # BSD