]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pam-util: fix build without PAM
authorMike Yuan <me@yhndnzj.com>
Mon, 22 Sep 2025 16:53:12 +0000 (18:53 +0200)
committerMike Yuan <me@yhndnzj.com>
Mon, 22 Sep 2025 18:08:44 +0000 (20:08 +0200)
Follow-up for 882c9ce0402ec6e37201628a9a361500ff39b1ed
Prompted by #39077

Note that HAVE_PAM ifdeffery in pam-util.c is removed,
since its build as a whole is conditioned out if
!HAVE_PAM in shared/meson.build.

src/shared/pam-util.c
src/shared/pam-util.h

index a967a41bee7241e96ef1690bc8e5231750ecb001..81ae094e85503546676814aa39d12d14d43b6fdd 100644 (file)
@@ -16,7 +16,6 @@
 #include "stdio-util.h"
 #include "string-util.h"
 
-#if HAVE_PAM
 static void *libpam_dl = NULL;
 
 DLSYM_PROTOTYPE(pam_acct_mgmt) = NULL;
@@ -61,7 +60,6 @@ int dlopen_libpam(void) {
                         DLSYM_ARG(pam_syslog),
                         DLSYM_ARG(pam_vsyslog));
 }
-#endif
 
 void pam_log_setup(void) {
         /* Make sure we don't leak the syslog fd we open by opening/closing the fd each time. */
index d33ab537eb00d08721bed4cfb2ef1d592e63e03e..a4d35faa115971b0713f055c4c3f768233223eed 100644 (file)
@@ -1,14 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <syslog.h>
-
 #include "forward.h"
 
 #if HAVE_PAM
 #include <security/pam_appl.h>
 #include <security/pam_ext.h>
 #include <security/pam_modules.h> /* IWYU pragma: export */
+#include <syslog.h>
 
 #include "dlfcn-util.h"
 
@@ -29,7 +28,6 @@ extern DLSYM_PROTOTYPE(pam_syslog);
 extern DLSYM_PROTOTYPE(pam_vsyslog);
 
 int dlopen_libpam(void);
-#endif
 
 void pam_log_setup(void);
 
@@ -77,3 +75,11 @@ int pam_get_data_many_internal(pam_handle_t *handle, ...) _sentinel_;
 #define pam_get_data_many(handle, ...) pam_get_data_many_internal(handle, __VA_ARGS__, NULL)
 
 int pam_prompt_graceful(pam_handle_t *handle, int style, char **ret_response, const char *fmt, ...) _printf_(4,5);
+
+#else
+
+static inline int dlopen_libpam(void) {
+        return -EOPNOTSUPP;
+}
+
+#endif