Skip to contentSkip to conversation

syscalls/prctl07: Fix build.

PATCH New Cyril Hrubis 2 participants 2 messages Jul 16, 2019 – Jul 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/prctl07: Fix build.

Ideally this is last fix for prctl07.

Since I've changed the check_proc_capamb() to use macro definition instead of raw integer value we depend on sys/capability.h being included to compile the code.

So this commit changes:

The sys/capability.h is included under HAVE_SYS_CAPABILITY_H now and so the function is ifdefed out if we don't have that header.

Also it looks like HAVE_LIBCAP is not defined unless libcap supports cap_compare() which should be fixed. The check for libcap and cap_compare() has to be uncoupled but that has to be done in a sepratate patch.

---
 testcases/kernel/syscalls/prctl/prctl07.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/prctl/prctl07.c +4 -2
index 37d77df33..79f7710a8 100644
@@ -25,7 +25,7 @@
 #include <sys/prctl.h>
 #include <stdlib.h>
 #include "config.h"
-#ifdef HAVE_LIBCAP
+#ifdef HAVE_SYS_CAPABILITY_H
 # include <sys/capability.h>
 #endif
 #include "lapi/syscalls.h"
@@ -35,7 +35,8 @@
 
 #define PROC_STATUS "/proc/self/status"
 
-static inline void check_proc_capamb(char *message, int flag)
+#ifdef HAVE_SYS_CAPABILITY_H
+static void check_proc_capamb(char *message, int flag)
 {
 	int cap_num;
 	char CapAmb[20];
@@ -62,6 +63,7 @@ static inline void check_proc_capamb(char *message, int flag)
 			"%s, CapAmb in %s doesn't have CAP_NET_BIND_SERVICE",
 			message, PROC_STATUS);
 }
+#endif
 
 static inline void check_cap_raise(unsigned int cap, char *message, int fail_flag)
 {
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 syscalls/prctl07: Fix build.

Quoted 9 lines

Ideally this is last fix for prctl07.

Since I've changed the check_proc_capamb() to use macro definition instead of raw integer value we depend on sys/capability.h being included to compile the code.

So this commit changes:

Quoted 7 lines

The sys/capability.h is included under HAVE_SYS_CAPABILITY_H now and so the function is ifdefed out if we don't have that header.

Also it looks like HAVE_LIBCAP is not defined unless libcap supports cap_compare() which should be fixed. The check for libcap and cap_compare() has to be uncoupled but that has to be done in a sepratate patch.

Hi Cyril

I have a patch for this on 2019.5 [1] but not correct way. Also, I am going to simpify and remove some m4.
I will uncouple libcap and cap_compare in ltp-cap.m4.

[1]http://lists.linux.it/pipermail/ltp/2019-May/011925.html

Quoted 36 lines
---
  testcases/kernel/syscalls/prctl/prctl07.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/prctl/prctl07.c +4 -2
index 37d77df33..79f7710a8 100644
@@ -25,7 +25,7 @@
  #include<sys/prctl.h>
  #include<stdlib.h>
  #include "config.h"
-#ifdef HAVE_LIBCAP
+#ifdef HAVE_SYS_CAPABILITY_H
  # include<sys/capability.h>
  #endif
  #include "lapi/syscalls.h"
@@ -35,7 +35,8 @@
 
  #define PROC_STATUS "/proc/self/status"
 
-static inline void check_proc_capamb(char *message, int flag)
+#ifdef HAVE_SYS_CAPABILITY_H
+static void check_proc_capamb(char *message, int flag)
  {
  	int cap_num;
  	char CapAmb[20];
@@ -62,6 +63,7 @@ static inline void check_proc_capamb(char *message, int flag)
  			"%s, CapAmb in %s doesn't have CAP_NET_BIND_SERVICE",
  			message, PROC_STATUS);
  }
+#endif
 
  static inline void check_cap_raise(unsigned int cap, char *message, int fail_flag)
  {