<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Richard Palethorpe <<a href="mailto:rpalethorpe@suse.de">rpalethorpe@suse.de</a>> wrote:<br></div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail_default" style="font-size:small">...</span><br>
>  #ifdef HAVE_SYS_CAPABILITY_H<br>
>  # include <sys/capability.h><br>
> +# undef _LINUX_TYPES_H<br>
<br>
My concern here is if linux/types.h has already been included. Then this<br>
could cause a redefinition error if it is included again.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Hmm, it looks tricky to solve this, because I didn't find a macro to show version in libcap files.</div><br></div><div><div class="gmail_default" style="font-size:small">Another method I can think of is to build a small program to check if that libcap version is newer or not during the configure phase. If yes, then export a new macro HAVE_NEWER_LIBCAP to be used in /lapi/capability.h.</div></div></div><div><br></div><div><div class="gmail_default" style="font-size:small">The following patch has been verified on both rhel6 and rhel8, any comments?</div><div class="gmail_default" style="font-size:small">[I'm not familiar with m4 syntax, just copy from other places]</div><br></div><div class="gmail_default" style="font-size:small">diff --git a/include/lapi/capability.h b/include/lapi/capability.h</div>index 3c2ee7937..3607179b5 100644<br>--- a/include/lapi/capability.h<br>+++ b/include/lapi/capability.h<br>@@ -10,7 +10,9 @@<br> <br> #ifdef HAVE_SYS_CAPABILITY_H<br> # include <sys/capability.h><br>-# undef _LINUX_TYPES_H<br>+# ifndef HAVE_NEWER_LIBCAP<br>+#  undef _LINUX_TYPES_H<br>+# endif<br> #endif<br> <br> #ifndef CAP_NET_RAW<br>diff --git a/m4/ltp-cap.m4 b/m4/ltp-cap.m4<br>index 02d3cac8c..8b1546401 100644<br>--- a/m4/ltp-cap.m4<br>+++ b/m4/ltp-cap.m4<br>@@ -14,4 +14,20 @@ if test "x$cap_libs" != x; then<br>        AC_DEFINE(HAVE_LIBCAP)<br> fi<br> AC_SUBST(CAP_LIBS,$cap_libs)<br>+<br>+AH_TEMPLATE(HAVE_NEWER_LIBCAP,<br>+[Define to 1 if you have newer libcap-2 installed.])<br>+AC_COMPILE_IFELSE([AC_LANG_SOURCE([<br>+#include <sys/capability.h><br>+#include <linux/types.h><br>+int main(void) {<br>+       __u16 a;<br>+       __u32 b;<br>+       return 0;<br>+}])],[has_newer_libcap="yes"])<br>+<br>+if test "x$has_newer_libcap" = xyes; then<br>+       AC_DEFINE(HAVE_NEWER_LIBCAP)<br>+fi<br> ])<br><div class="gmail_default" style="font-size:small"></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>