refactor: update lib modules (common, dnsmasq, logging, network, state, nginx)

This commit is contained in:
2026-06-16 03:35:50 +00:00
parent 593dece92b
commit c5813d68b3
6 changed files with 196 additions and 33 deletions
+4 -10
View File
@@ -484,23 +484,17 @@ def write_htpasswd(user: str, password: str) -> None:
def _hash_password(password: str) -> str:
"""Hash *password* using Apache ``apr1`` format via passlib, with crypt fallback.
"""Hash *password* using SHA-256 crypt (``$5$`` format) via passlib.
Args:
password: Plain-text password to hash.
Returns:
The hashed password string suitable for ``.htpasswd``.
The hashed password string suitable for ``.htpasswd`` (e.g. ``$5$rounds=…$…``).
"""
try:
from passlib.hash import apache_passwd
from passlib.hash import sha256_crypt
return apache_passwd.using(rounds=12).hash(password)
except Exception:
import crypt as _crypt
salt = os.urandom(16).hex()[:16]
return _crypt.crypt(password, f"$5${salt}")
return sha256_crypt.hash(password)
__all__ = [