Skip to content

Commit

Permalink
Adapt rootpw tests to crypt module removal in Python 3.13
Browse files Browse the repository at this point in the history
Anaconda code is adapted in commit 1c4d063d4c530e5f76c7ee0ff33d95752b842f52
  • Loading branch information
rvykydal committed Jun 14, 2024
1 parent b73e900 commit 3eb97e1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions containers/runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN dnf -y update && \
lorax-lmc-virt \
parallel \
python3-libvirt \
python3-crypt-r \
createrepo_c \
python3-pip \
python3-rpmfluff \
Expand Down
9 changes: 7 additions & 2 deletions rootpw-basic.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ python3
%post --interpreter=/usr/bin/python3

import sys
import crypt
try:
# Use the standalone (not deprecated) package when available
import crypt_r
except ImportError:
# Fallback to the deprecated standard library module
import crypt as crypt_r # pylint: disable=deprecated-module

with open("/root/RESULT", "wt") as result:
# Test that the root password is what we expect it to be
Expand All @@ -39,7 +44,7 @@ with open("/root/RESULT", "wt") as result:
print("Unable to find root password", file=result)
sys.exit(0)

if crypt.crypt("qweqwe", shadow_fields[1]) != shadow_fields[1]:
if crypt_r.crypt("qweqwe", shadow_fields[1]) != shadow_fields[1]:
print("Root password is not correct: %s" % shadow_fields[1], file=result)
sys.exit(0)

Expand Down
1 change: 0 additions & 1 deletion rootpw-crypted.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ python3
%post --interpreter=/usr/bin/python3

import sys
import crypt

with open("/root/RESULT", "wt") as result:
# Test that the root password is what we expect it to be
Expand Down
1 change: 0 additions & 1 deletion rootpw-lock-no-password.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ python3
%post --interpreter=/usr/bin/python3

import sys
import crypt

with open("/root/RESULT", "wt") as result:
# Test that the root password is what we expect it to be
Expand Down
9 changes: 7 additions & 2 deletions rootpw-lock.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ python3
%post --interpreter=/usr/bin/python3

import sys
import crypt
try:
# Use the standalone (not deprecated) package when available
import crypt_r
except ImportError:
# Fallback to the deprecated standard library module
import crypt as crypt_r # pylint: disable=deprecated-module

with open("/root/RESULT", "wt") as result:
# Test that the root password is what we expect it to be
Expand All @@ -48,7 +53,7 @@ with open("/root/RESULT", "wt") as result:
print("Root password is not locked: %s" % shadow_fields[1], file=result)
sys.exit(0)

if crypt.crypt("qweqwe", shadow_fields[1][1:]) != shadow_fields[1][1:]:
if crypt_r.crypt("qweqwe", shadow_fields[1][1:]) != shadow_fields[1][1:]:
print("Root password is not correct: %s" % shadow_fields[1], file=result)
sys.exit(0)

Expand Down

0 comments on commit 3eb97e1

Please sign in to comment.