]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/system/framework/misc/__init__.py: password pattern
authorIker Pedrosa <ipedrosa@redhat.com>
Tue, 9 Sep 2025 07:20:17 +0000 (09:20 +0200)
committerSerge Hallyn <serge@hallyn.com>
Wed, 25 Mar 2026 02:33:15 +0000 (21:33 -0500)
Expose shadow's password regex pattern in a function.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
tests/system/framework/misc/__init__.py

index 0ee8a080a59b2fdcfeacf6bedc499ce287a2efe8..1896b9cc7b98b62b8d3f859478793b607d4b320a 100644 (file)
@@ -52,3 +52,14 @@ def days_since_epoch():
     now_utc = datetime.datetime.now(datetime.timezone.utc)
     delta = now_utc - epoch
     return delta.days
+
+
+def shadow_password_pattern() -> str:
+    """
+    Returns the shadow password regex pattern.
+
+    This pattern matches encrypted password hashes stored in /etc/shadow files,
+    including common formats like MD5, SHA-256, SHA-512, and yescrypt. The pattern
+    expects the standard Unix crypt format: $algorithm$salt$hash with optional parameters.
+    """
+    return r"^\$(?:\w)\$[^$]*\$[\w./]+(?:\$[\w./]+)?$"