]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sys_linux: fix building with old libcap versions
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Apr 2018 14:18:23 +0000 (16:18 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Apr 2018 14:18:23 +0000 (16:18 +0200)
The cap_get_bound() function and CAP_IS_SUPPORTED macro were added in
libcap-2.21. Check if the macro is defined before use.

The sys/capability.h header from libcap-2.16 and earlier disables the
linux/types.h header, which breaks the linux/ptp_clock.h header. Change
the order to include sys/capability.h as the last system header.

sys_linux.c

index f4b532d95858e21d8688ab5314837703f47febdd..3d54483eb18d5356899983586431cf2c9e113ab1 100644 (file)
 #include <sys/resource.h>
 #endif
 
-#ifdef FEAT_PRIVDROP
-#include <sys/prctl.h>
-#include <sys/capability.h>
-#endif
-
 #if defined(FEAT_PHC) || defined(HAVE_LINUX_TIMESTAMPING)
 #include <linux/ptp_clock.h>
 #endif
 #endif
 #endif
 
+#ifdef FEAT_PRIVDROP
+#include <sys/prctl.h>
+#include <sys/capability.h>
+#endif
+
 #include "sys_linux.h"
 #include "sys_timex.h"
 #include "conf.h"
@@ -385,7 +385,7 @@ test_step_offset(void)
 static void
 report_time_adjust_blockers(void)
 {
-#ifdef FEAT_PRIVDROP
+#if defined(FEAT_PRIVDROP) && defined(CAP_IS_SUPPORTED)
   if (CAP_IS_SUPPORTED(CAP_SYS_TIME) && cap_get_bound(CAP_SYS_TIME))
     return;
   LOG(LOGS_WARN, "CAP_SYS_TIME not present");