The feature_bitmap field of "struct audit_status" only appeared in
kernel headers >= 3.19. However, the code using it in libaudit.c is only
conditional on the existence of AUDIT_FEATURE_VERSION, which has been
added in Linux 3.13.
This means that building audit with kernel headers >= 3.13 but < 3.19
currently fails:
libaudit.c: In function 'load_feature_bitmap':
libaudit.c:609:33: error: 'struct audit_status' has no member named
'feature_bitmap'
features_bitmap = rep.status->feature_bitmap;
^
libaudit.c: In function 'audit_rule_fieldpair_data':
libaudit.c:1424:9: warning: this decimal constant is unsigned only in ISO C90 [enabled by
default]
4294967295;
This commit fixes that by testing the availability of the feature_bitmap
field.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni(a)free-electrons.com>
---
Note: it would be worth checking this commit in details. I assumed that
the function load_feature_bitmap() would simply return with
features_bitmap set to AUDIT_FEATURES_UNSUPPORTED, just as if
HAVE_DECL_AUDIT_FEATURE_VERSION was not defined. I am not sure if it is
the appropriate behavior.
---
configure.ac | 1 +
lib/libaudit.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 219720b..00788c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,7 @@ AC_CHECK_SIZEOF([unsigned int])
AC_CHECK_SIZEOF([unsigned long])
AM_PROG_CC_C_O
AC_CHECK_DECLS([AUDIT_FEATURE_VERSION], [], [], [[#include <linux/audit.h>]])
+AC_CHECK_MEMBERS([struct audit_status.feature_bitmap], [], [], [[#include
<linux/audit.h>]])
AC_CHECK_DECLS([AUDIT_VERSION_BACKLOG_WAIT_TIME], [], [], [[#include
<linux/audit.h>]])
AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
dnl; posix_fallocate is used in audisp-remote
diff --git a/lib/libaudit.c b/lib/libaudit.c
index 2c96f29..510d841 100644
--- a/lib/libaudit.c
+++ b/lib/libaudit.c
@@ -579,7 +579,7 @@ static void load_feature_bitmap(void)
return;
}
-#if HAVE_DECL_AUDIT_FEATURE_VERSION
+#if defined(HAVE_DECL_AUDIT_FEATURE_VERSION) &&
defined(HAVE_STRUCT_AUDIT_STATUS_FEATURE_BITMAP)
if ((rc = audit_request_status(fd)) > 0) {
struct audit_reply rep;
int i;
--
2.7.4