From: Luca Boccassi Date: Thu, 5 Mar 2026 17:19:19 +0000 (+0000) Subject: libcrypt: also try to dlopen libcrypt.so.1.1 X-Git-Tag: v260-rc3~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88ed85137cd8aaf75ac3d821d37e51fede63e971;p=thirdparty%2Fsystemd.git libcrypt: also try to dlopen libcrypt.so.1.1 On top of libcrypt.so.2 and libcrypt.so.1, also try libcrypt.so.1.1 as a third fallback. This is used on debian alpha, and it was reported that it is intended to ship like that, with a different SONAME than other architectures: https://packages.debian.org/sid/alpha/libcrypt1/filelist --- diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index 85069314be4..4760d66c92a 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -30,25 +30,27 @@ int dlopen_libcrypt(void) { if (cached < 0) return cached; /* Already tried, and failed. */ - /* Several distributions like Debian/Ubuntu and OpenSUSE provide libxcrypt as libcrypt.so.1, - * while others like Fedora/CentOS and Arch provide it as libcrypt.so.2. */ + /* Several distributions like Debian/Ubuntu and OpenSUSE provide libxcrypt as libcrypt.so.1 + * (libcrypt.so.1.1 on some architectures), while others like Fedora/CentOS and Arch provide it as + * libcrypt.so.2. */ ELF_NOTE_DLOPEN("crypt", "Support for hashing passwords", ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, - "libcrypt.so.2", "libcrypt.so.1"); + "libcrypt.so.2", "libcrypt.so.1", "libcrypt.so.1.1"); _cleanup_(dlclosep) void *dl = NULL; - r = dlopen_safe("libcrypt.so.2", &dl, /* reterr_dlerror= */ NULL); - if (r < 0) { - const char *dle = NULL; - r = dlopen_safe("libcrypt.so.1", &dl, &dle); - if (r < 0) { - log_debug_errno(r, "libcrypt.so.2/libcrypt.so.1 is not available: %s", dle ?: STRERROR(r)); - return (cached = -EOPNOTSUPP); /* turn into recognizable error */ + const char *dle = NULL; + FOREACH_STRING(soname, "libcrypt.so.2", "libcrypt.so.1", "libcrypt.so.1.1") { + r = dlopen_safe(soname, &dl, &dle); + if (r >= 0) { + log_debug("Loaded '%s' via dlopen().", soname); + break; } - log_debug("Loaded 'libcrypt.so.1' via dlopen()"); - } else - log_debug("Loaded 'libcrypt.so.2' via dlopen()"); + } + if (r < 0) { + log_debug_errno(r, "Failed to load libcrypt: %s", dle ?: STRERROR(r)); + return (cached = -EOPNOTSUPP); /* turn into recognizable error */ + } r = dlsym_many_or_warn( dl, LOG_DEBUG,