]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libaudit-util: fix build with audit disabled
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Mon, 22 Sep 2025 15:27:27 +0000 (17:27 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 22 Sep 2025 17:17:52 +0000 (18:17 +0100)
```
In file included from ../src/test/test-dlopen-so.c:21:
../src/test/test-dlopen-so.c: In function ‘run’:
../src/test/test-dlopen-so.c:53:23: error: implicit declaration of function ‘dlopen_libaudit’; did you mean ‘dlopen_libfido2’? [-Werror=implicit-function-declaration]
   53 |         ASSERT_DLOPEN(dlopen_libaudit, HAVE_AUDIT);
      |                       ^~~~~~~~~~~~~~~
../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’
  181 |                 typeof(expr) _result = (expr);                                                                  \
      |                        ^~~~
../src/test/test-dlopen-so.c:53:9: note: in expansion of macro ‘ASSERT_DLOPEN’
   53 |         ASSERT_DLOPEN(dlopen_libaudit, HAVE_AUDIT);
      |         ^~~~~~~~~~~~~
../src/test/test-dlopen-so.c:53:23: warning: nested extern declaration of ‘dlopen_libaudit’ [-Wnested-externs]
   53 |         ASSERT_DLOPEN(dlopen_libaudit, HAVE_AUDIT);
      |                       ^~~~~~~~~~~~~~~
../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’
  181 |                 typeof(expr) _result = (expr);                                                                  \
      |                        ^~~~
../src/test/test-dlopen-so.c:53:9: note: in expansion of macro ‘ASSERT_DLOPEN’
   53 |         ASSERT_DLOPEN(dlopen_libaudit, HAVE_AUDIT);
      |         ^~~~~~~~~~~~~

```

Follow-up for 4d8c5c657ae0829f93944a00302e7ce700913e54

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

index beac269f217b2ec1511f8688969e644084e36514..147aaf9a1df80b31a98de87606113b8ddc783ec9 100644 (file)
@@ -19,8 +19,10 @@ DLSYM_PROTOTYPE(audit_log_acct_message) = NULL;
 DLSYM_PROTOTYPE(audit_log_user_avc_message) = NULL;
 DLSYM_PROTOTYPE(audit_log_user_comm_message) = NULL;
 static DLSYM_PROTOTYPE(audit_open) = NULL;
+#endif
 
 int dlopen_libaudit(void) {
+#if HAVE_AUDIT
         ELF_NOTE_DLOPEN("libaudit",
                         "Support for Audit logging",
                         ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
@@ -35,8 +37,12 @@ int dlopen_libaudit(void) {
                         DLSYM_ARG(audit_log_user_avc_message),
                         DLSYM_ARG(audit_log_user_comm_message),
                         DLSYM_ARG(audit_open));
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
+#if HAVE_AUDIT
 static int try_audit_request(int fd) {
         struct iovec iov;
         struct msghdr mh;
index b4e7a56c5095ecdcf5e508ccac9aeaceb52d3539..f33258f9e1a9eae17faf396941db7f62ca4bbe13 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "forward.h"
 
+int dlopen_libaudit(void);
+
 #if HAVE_AUDIT
 #  include <libaudit.h>         /* IWYU pragma: export */
 
@@ -11,8 +13,6 @@
 extern DLSYM_PROTOTYPE(audit_log_acct_message);
 extern DLSYM_PROTOTYPE(audit_log_user_avc_message);
 extern DLSYM_PROTOTYPE(audit_log_user_comm_message);
-
-int dlopen_libaudit(void);
 #endif
 
 bool use_audit(void);