From 54630ce5bef145b124394efe259ad867dce02256 Mon Sep 17 00:00:00 2001 From: AMMAAR-IC Date: Mon, 13 Apr 2026 02:53:53 +0530 Subject: [PATCH] Locate libcrypt via find_library and raise a clear error if missing ctypes.CDLL('libcrypt.so') fails on systems that only ship a versioned soname (e.g. libcrypt.so.2). Resolve the library with ctypes.util.find_library('crypt'), fall back to 'libcrypt.so', and raise an ImportError with a readable message if it still cannot be loaded. --- archinstall/lib/crypt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/crypt.py b/archinstall/lib/crypt.py index 6935d45059..c80063df93 100644 --- a/archinstall/lib/crypt.py +++ b/archinstall/lib/crypt.py @@ -1,6 +1,7 @@ import base64 import ctypes import os +from ctypes.util import find_library from pathlib import Path from cryptography.fernet import Fernet, InvalidToken @@ -8,7 +9,11 @@ from archinstall.lib.log import debug -libcrypt = ctypes.CDLL('libcrypt.so') +libcrypt_name = find_library('crypt') or 'libcrypt.so' +try: + libcrypt = ctypes.CDLL(libcrypt_name) +except OSError as exc: + raise ImportError('Could not load system libcrypt library; make sure libcrypt is installed and accessible.') from exc libcrypt.crypt.argtypes = [ctypes.c_char_p, ctypes.c_char_p] libcrypt.crypt.restype = ctypes.c_char_p