Skip to contentSkip to conversation

fix obvious compilation problems in cap_bounds

PATCH In review Cyril Hrubis 1 participant 6 messages Nov 8, 2010 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix obvious compilation problems in cap_bounds

Hi!
Following patch fixes obvious problems with cap_bounds compilation

* CAP_LAST_CAP is defined in linux/capability.h => include it

* remove int errno; definition

* move #ifdef HAVE_SYS_CAPABILITY_H after int main(int argc, char *argv[]) in check_pe.c

* small typos and coding style

Signature · 2 lines
Cyril Hrubis
[email protected]
testcases/kernel/security/cap_bound/cap_bounds_r.c +1 -2
index 0b1c5b3..13c5400 100644
@@ -29,14 +29,13 @@
 #if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
 #endif
+#include <linux/capability.h>
 #include <sys/prctl.h>
 #include <test.h>
 
 char *TCID = "cap_bounds_r";
 int TST_TOTAL=1;
 
-int errno;
-
 int main(int argc, char *argv[])
 {
 #if HAVE_SYS_CAPABILITY_H
testcases/kernel/security/cap_bound/cap_bounds_rw.c +4 -5
index 827a305..c23c598 100644
@@ -28,20 +28,19 @@
 #if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
 #endif
+#include <linux/capability.h>
 #include <sys/prctl.h>
 #include <test.h>
 
 char *TCID = "cap_bounds_rw";
 int TST_TOTAL=1;
 
-int errno;
-
 int check_remaining_caps(int lastdropped)
 {
 	int i;
 	int ret;
 
-	for (i=0; i <= lastdropped; i++) {
+	for (i = 0; i <= lastdropped; i++) {
 #if HAVE_DECL_PR_CAPBSET_READ
 		ret = prctl(PR_CAPBSET_READ, i);
 #else
@@ -57,7 +56,7 @@ int check_remaining_caps(int lastdropped)
 			return i;
 		}
 	}
-	for (; i<=CAP_LAST_CAP; i++) {
+	for (; i <= CAP_LAST_CAP; i++) {
 #if HAVE_DECL_PR_CAPBSET_READ
 		ret = prctl(PR_CAPBSET_READ, i);
 #else
@@ -108,7 +107,7 @@ int main(int argc, char *argv[])
 		tst_resm(TINFO, " %d is should not exist\n", max(INSANE, CAP_LAST_CAP+1));
 		tst_exit();
 	}
-	for (i=0; i<=CAP_LAST_CAP; i++) {
+	for (i = 0; i <= CAP_LAST_CAP; i++) {
 #if HAVE_DECL_PR_CAPBSET_DROP
 		ret = prctl(PR_CAPBSET_DROP, i);
 #else
testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c +0 -2
index 7033a37..1f3634b 100644
@@ -37,8 +37,6 @@
 char *TCID = "cap_bounds_r";
 int TST_TOTAL=2;
 
-int errno;
-
 int main(int argc, char *argv[])
 {
 #if HAVE_SYS_CAPABILITY_H
testcases/kernel/security/cap_bound/check_pe.c +3 -5
index f621e70..2f5aec9 100644
@@ -38,12 +38,10 @@
 char *TCID = "check_pe";
 int TST_TOTAL=1;
 
-int errno;
-
-#if HAVE_SYS_CAPABILITY_H
-#ifdef HAVE_LIBCAP
 int main(int argc, char *argv[])
 {
+#ifdef HAVE_SYS_CAPABILITY_H
+#ifdef HAVE_LIBCAP
 	int ret = 1;
 	cap_flag_value_t f;
 	cap_t cur;
@@ -72,7 +70,7 @@ int main(int argc, char *argv[])
 			tst_resm(TPASS, "cap is in pE\n");
 			tst_exit();
 		}
-		tst_resm(TFAIL, "Cap is not in pE\n");
+		tst_resm(TFAIL, "cap is not in pE\n");
 		tst_exit();
 	}
 	if (f == CAP_CLEAR) {
testcases/kernel/security/cap_bound/dummy.c +1 -1
index e882940..3ee7c9b 100644
@@ -5,7 +5,7 @@
 #include <sys/capability.h>
 #endif
 
-int main()
+int main(void)
 {
 #if HAVE_SYS_CAPABILITY_H
 #ifdef HAVE_LIBCAP
testcases/kernel/security/cap_bound/exec_with_inh.c +0 -2
index 123f665..dc18b63 100644
@@ -37,8 +37,6 @@
 char *TCID = "exec_with_inh";
 int TST_TOTAL=1;
 
-int errno;
-
 int main(int argc, char *argv[])
 {
 #if HAVE_SYS_CAPABILITY_H
testcases/kernel/security/cap_bound/exec_without_inh.c +0 -2
index df3c4d9..8d99883 100644
@@ -37,8 +37,6 @@
 char *TCID = "exec_without_inh";
 int TST_TOTAL=1;
 
-int errno;
-
 int main(int argc, char *argv[])
 {
 #if HAVE_SYS_CAPABILITY_H

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi!

Quoted 9 lines
Quoted 9 lines

Following patch fixes obvious problems with cap_bounds compilation

* CAP_LAST_CAP is defined in linux/capability.h => include it

* remove int errno; definition

* move #ifdef HAVE_SYS_CAPABILITY_H after int main(int argc, char *argv[]) in check_pe.c

Quoted 6 lines
Quoted 1 line

* small typos and coding style

Hi Cyril!
Quick question -- why doesn't sys/capability.h build on
linux/capability.h (in particular what OS did you run into this issue on)?

You are right, the problem is that HAVE_SYS_CAPABILITY_H is not in config.h even when libcap-devel is installed and headers are found (there is only #define HAVE_LIBCAP 1).

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw

Hi!

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Following patch fixes obvious problems with cap_bounds compilation

* CAP_LAST_CAP is defined in linux/capability.h => include it

* remove int errno; definition

* move #ifdef HAVE_SYS_CAPABILITY_H after int main(int argc, char *argv[]) in check_pe.c

* small typos and coding style

Quoted 9 lines
Quoted 4 lines

Hi Cyril!
Quick question -- why doesn't sys/capability.h build on
linux/capability.h (in particular what OS did you run into this issue on)?

You are right, the problem is that HAVE_SYS_CAPABILITY_H is not in config.h even when libcap-devel is installed and headers are found (there is only #define HAVE_LIBCAP 1).

Hmm, adding sys/capability.h into AC_CHECK_HEADERS() in configure.ac seem to fixed this. Still I have no idea why AC_CHECK_HEADER() in m4/ltp-cap.m4 hasn't exported HAVE_SYS_CAPABILITY_H.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Hi!

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines

Following patch fixes obvious problems with cap_bounds compilation

* CAP_LAST_CAP is defined in linux/capability.h => include it

* remove int errno; definition

* move #ifdef HAVE_SYS_CAPABILITY_H after int main(int argc, char *argv[]) in check_pe.c

Quoted 6 lines
Quoted 1 line

* small typos and coding style

Hi Cyril!
    Quick question -- why doesn't sys/capability.h build on linux/capability.h (in particular what OS did you run into this issue on)?

You are right, the problem is that HAVE_SYS_CAPABILITY_H is not in config.h even when libcap-devel is installed and headers are found (there is only #define HAVE_LIBCAP 1).

Quoted 6 lines
Quoted 3 lines

Hmm, adding sys/capability.h into AC_CHECK_HEADERS() in configure.ac seem to fixed this. Still I have no idea why AC_CHECK_HEADER() in m4/ltp-cap.m4 hasn't exported HAVE_SYS_CAPABILITY_H.

Probably because I forgot to remove the square brackets; give the
patch attached a shot and let me know how it goes...

Nope, it looks like AC_CHECK_HEADER() does not set HAVE_* at all(1). So we need to change AC_HECK_HEADER() to AC_CHECK_HEADERS() in m4/ltp-cap.m4.

1) http://www.gnu.org/software/hello/manual/autoconf/Generic-Headers.html

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Hi!

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

Following patch fixes obvious problems with cap_bounds compilation

* CAP_LAST_CAP is defined in linux/capability.h => include it

* remove int errno; definition

* move #ifdef HAVE_SYS_CAPABILITY_H after int main(int argc, char *argv[]) in check_pe.c

* small typos and coding style

Quoted 9 lines
Quoted 4 lines

Hi Cyril!
    Quick question -- why doesn't sys/capability.h build on linux/capability.h (in particular what OS did you run into this issue on)?

You are right, the problem is that HAVE_SYS_CAPABILITY_H is not in config.h even when libcap-devel is installed and headers are found (there is only #define HAVE_LIBCAP 1).

Hmm, adding sys/capability.h into AC_CHECK_HEADERS() in configure.ac seem to fixed this. Still I have no idea why AC_CHECK_HEADER() in m4/ltp-cap.m4 hasn't exported HAVE_SYS_CAPABILITY_H.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

    Probably because I forgot to remove the square brackets; give the patch attached a shot and let me know how it goes...

Nope, it looks like AC_CHECK_HEADER() does not set HAVE_* at all(1).  So we need to change AC_HECK_HEADER() to AC_CHECK_HEADERS() in m4/ltp-cap.m4.

That's kind of lame :/... Could you try this patch instead please?

Yes, this works regardless if there are square braces around sys/capability.h or not.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Hi!

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 10 lines

Following patch fixes obvious problems with cap_bounds compilation

* CAP_LAST_CAP is defined in linux/capability.h => include it

* remove int errno; definition

* move #ifdef HAVE_SYS_CAPABILITY_H after int main(int argc, char *argv[]) in check_pe.c

* small typos and coding style

Hi Cyril!
    Quick question -- why doesn't sys/capability.h build on linux/capability.h (in particular what OS did you run into this issue on)?

Quoted 8 lines
Quoted 4 lines

You are right, the problem is that HAVE_SYS_CAPABILITY_H is not in config.h even when libcap-devel is installed and headers are found (there is only #define HAVE_LIBCAP 1).

Hmm, adding sys/capability.h into AC_CHECK_HEADERS() in configure.ac seem to fixed this. Still I have no idea why AC_CHECK_HEADER() in m4/ltp-cap.m4 hasn't exported HAVE_SYS_CAPABILITY_H.

    Probably because I forgot to remove the square brackets; give the patch attached a shot and let me know how it goes...

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Nope, it looks like AC_CHECK_HEADER() does not set HAVE_* at all(1).  So we need to change AC_HECK_HEADER() to AC_CHECK_HEADERS() in m4/ltp-cap.m4.

    That's kind of lame :/... Could you try this patch instead please?

Yes, this works regardless if there are square braces around sys/capability.h or not.

Do you want me to create new patch (for the original issue) without #include <linux/capability.h>?

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list