Use passlib in place of legacycrypt - #396
Conversation
1c3ac9b to
c6ea37e
Compare
33fec9a to
54e648b
Compare
54e648b to
a3afb27
Compare
bc754e8 to
789db8a
Compare
4b18836 to
78b593a
Compare
78b593a to
6aa0263
Compare
|
@xcp-ng/os-platform-release another reviewer wanted here. |
|
Since diff --git a/lib/installer.py b/lib/installer.py
index 02fb96d..d384cd5 100644
--- a/lib/installer.py
+++ b/lib/installer.py
@@ -5,7 +5,7 @@ import time
import xml.etree.ElementTree as ET
from lib.commands import SSHCommandFailed, ssh
-from lib.common import wait_for
+from lib.common import hash_password, wait_for
from typing import Any, Self
@@ -36,6 +36,8 @@ class AnswerFile:
# makes a mutable deep copy of all `contents`
@staticmethod
def _normalize_structure(defn: dict[str, Any]) -> dict[str, Any]:
+ from data import HOST_DEFAULT_PASSWORD, INSERT_HOST_DEFAULT_PASSWORD_HASH
+
assert isinstance(defn, dict), f"{defn!r} is not a dict"
assert 'TAG' in defn, f"{defn} has no TAG"
@@ -47,7 +49,10 @@ class AnswerFile:
for key, value in defn.items():
if key == 'CONTENTS':
if isinstance(value, str):
- new_defn['CONTENTS'] = value
+ if value == INSERT_HOST_DEFAULT_PASSWORD_HASH:
+ new_defn['CONTENTS'] = hash_password(HOST_DEFAULT_PASSWORD)
+ else:
+ new_defn['CONTENTS'] = value
else:
new_defn['CONTENTS'] = [
AnswerFile._normalize_structure(item)With INSERT_HOST_DEFAULT_PASSWORD_HASH = "<INSERT_HOST_DEFAULT_PASSWORD_HASH>"But maybe that's outside the scope of this PR. |
|
The scope of this PR was focused on removing an anoying depedency. |
| host.xe(f'{xe_prefix}-param-clear', args) | ||
|
|
||
| def hash_password(password: str) -> str: | ||
| """Hash password for /etc/password.""" |
There was a problem hiding this comment.
| """Hash password for /etc/password.""" | |
| """Hash password for /etc/shadow.""" |
123e95d to
f1dc1d7
Compare
ydirson
left a comment
There was a problem hiding this comment.
other than that remark, lgtm
| setup_formatted_and_mounted_disk, | ||
| shortened_nodeid, | ||
| teardown_formatted_and_mounted_disk, |
There was a problem hiding this comment.
this does not seem to belong to this commit
f1dc1d7 to
406cf12
Compare
406cf12 to
435faac
Compare
4352f75 to
903b4d8
Compare
legacycrypt requires to install libcrypt.so.1 manually Keep legacycrypt as a dependency for now, to ease the transition to those who already have a custom data.py. Move hash_password() to lib.common, to make easier to change the implementation in the future. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
903b4d8 to
4004073
Compare
|
@glehmann are you waiting on something before the merge? |
|
Tested on |
legacycrypt requires to install libcrypt.so.1 manually
Keep legacycrypt as a dependency for now, to ease the transition to those who already have a custom data.py.
Move hash_password() to lib.common, to make easier to change the implementation in the future.
This is in draft while I test if it actually works with an install test.
This PR is part of a tree containing 3 PRs:
mastermaster