Skip to contentSkip to conversation

SELinux testsuite compilation fixes

PATCH In review Paul Moore 2 participants 9 messages Jun 4, 2015 – Jun 5, 2015 SELinux security module

lore
Share & tools
lore

Paul Moore

author
#0 lore raw

v3 cover SELinux testsuite compilation fixes

Third times the charm ... compilation fixes, blah blah blah ...

---

Paul Moore (6):
selinux-testsuite: add _GNU_SOURCE to tests/Makefile
selinux-testsuite: add some default CFLAGS
selinux-testsuite: fix some compile warnings in tests/nnp
selinux-testsuite: fix compile warnings in tests/setnice
selinux-testsuite: fix compile problems in tests/shm
selinux-testsuite: fix compile problems in tests/capable_file

 tests/Makefile                  |    3 +++
 tests/capable_file/test_lease.c |    9 +++++----
 tests/msg/msgrcv.c              |    9 ++++-----
 tests/msg/msgsnd.c              |   11 +++++------
 tests/nnp/execnnp.c             |    2 ++
 tests/setnice/parent.c          |    2 ++
 tests/shm/shmat.c               |    6 +-----
 tests/shm/shmctl.c              |    6 +-----
 tests/shm/shmget.c              |    6 +-----
 9 files changed, 24 insertions(+), 30 deletions(-)
author
#1 lore raw

PATCH v3 1/6 selinux-testsuite: add _GNU_SOURCE to tests/Makefile

As suggested by Stephen Smalley. A couple of msgbuf struct definitions had to be renamed as they were conflicting with system definitions.

---
 tests/Makefile     |    3 +++
 tests/msg/msgrcv.c |    9 ++++-----
 tests/msg/msgsnd.c |   11 +++++------
 3 files changed, 12 insertions(+), 11 deletions(-)
tests/Makefile +3 -0
index e9d4646..8100b8f 100644
@@ -1,3 +1,6 @@
+
+export CFLAGS+=-D_GNU_SOURCE
+
 DISTRO=$(shell ./os_detect)
 
 SUBDIRS_COMMON:=domain_trans entrypoint execshare exectrace execute_no_trans fdreceive inherit link mkdir msg open ptrace readlink relabel rename rxdir sem setattr setnice shm sigkill stat sysctl task_create task_setnice task_setscheduler task_getscheduler task_getsid task_getpgid task_setpgid wait file ioctl capable_file capable_net capable_sys
tests/msg/msgrcv.c +4 -5
index b23c801..1276c12 100644
@@ -5,10 +5,9 @@
 #include <sys/msg.h>
 
 #define MSGMAX 1024
-
-struct msgbuf {
-  long mtype;     /* message type, must be > 0 */
-  char mtext[1024];  /* message data */
+struct msgbuf_test {
+	long mtype;
+	char mtext[MSGMAX];
 };
 
 int main(int argc, char **argv)
@@ -17,7 +16,7 @@ int main(int argc, char **argv)
 	int key = 0x8888;
 	int id;
 	int error;
-	struct msgbuf msgp;
+	struct msgbuf_test msgp;
 
 	while ((ch = getopt(argc, argv, "k:")) != EOF) {
 		switch (ch) {
tests/msg/msgsnd.c +5 -6
index e200aef..57bb027 100644
@@ -6,10 +6,9 @@
 #include <string.h>
 
 #define MSGMAX 1024
-
-struct msgbuf {
-  long mtype;     /* message type, must be > 0 */
-  char mtext[1024];  /* message data */
+struct msgbuf_test {
+	long mtype;
+	char mtext[MSGMAX];
 };
 
 int main(int argc, char **argv)
@@ -18,7 +17,7 @@ int main(int argc, char **argv)
 	int key = 0x8888;
 	int id;
 	int error;
-	struct msgbuf msgp;
+	struct msgbuf_test msgp;
 
 	while ((ch = getopt(argc, argv, "k:")) != EOF) {
 		switch (ch) {
@@ -32,7 +31,7 @@ int main(int argc, char **argv)
 	if (id == -1)
 		return 1;
 
-	memset(&msgp, 'z', sizeof(struct msgbuf));
+	memset(&msgp, 'z', sizeof(msgp));
 	msgp.mtype = 1;
 
 	error = msgsnd(id, &msgp, MSGMAX, IPC_NOWAIT);
author
#2 lore raw

PATCH v3 2/6 selinux-testsuite: add some default CFLAGS

In reply to Paul Moore
---
 tests/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile +1 -1
index 8100b8f..b679137 100644
@@ -1,5 +1,5 @@
 
-export CFLAGS+=-D_GNU_SOURCE
+export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE
 
 DISTRO=$(shell ./os_detect)
 
author
#3 lore raw

PATCH v3 3/6 selinux-testsuite: fix some compile warnings in tests/nnp

In reply to Paul Moore

Correct the following:

make[2]: Entering directory '/root/sources/selinux-testsuite/tests/nnp'
cc execnnp.c -lselinux -o execnnp
execnnp.c: In function 'main':
execnnp.c:27:9: warning: implicit declaration of function 'strverscmp'

        (strverscmp(uts.release, "3.18") < 0));
         ^

execnnp.c:47:8: warning: implicit declaration of function 'wait'
pid = wait(&status);

---
 tests/nnp/execnnp.c |    2 ++
 1 file changed, 2 insertions(+)
tests/nnp/execnnp.c +2 -0
index a5a80cf..756c2d0 100644
@@ -5,6 +5,8 @@
 #include <unistd.h>
 #include <sys/utsname.h>
 #include <sys/prctl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 int main(int argc, char **argv)
 {
author
#4 lore raw

PATCH v3 4/6 selinux-testsuite: fix compile warnings in tests/setnice

In reply to Paul Moore

Correct the following:

make[2]: Entering directory '/root/sources/selinux-testsuite/tests/setnice'
cc parent.c -lselinux -o parent
parent.c: In function 'main':
parent.c:92:9: warning: implicit declaration of function 'setpriority'

   rc =  setpriority(0,pid,10);
         ^
---
 tests/setnice/parent.c |    2 ++
 1 file changed, 2 insertions(+)
tests/setnice/parent.c +2 -0
index d5a2533..6d3c855 100644
@@ -3,6 +3,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 #include <signal.h>
 #include <selinux/selinux.h>
 #include <selinux/context.h>
author
#5 lore raw

PATCH v3 5/6 selinux-testsuite: fix compile problems in tests/shm

In reply to Paul Moore

Resolve the following problems:

make[2]: Entering directory '/home/pmoore/sources/selinux-testsuite/selinux_testsuite-upstream/tests/shm'
cc -g -O0 -Wall -D_GNU_SOURCE shmctl.c -o shmctl
shmctl.c: In function 'main':
shmctl.c:11:6: warning: variable 'num' set but not used

  int num = 1;
      ^
cc -g -O0 -Wall -D_GNU_SOURCE    shmat.c   -o shmat
shmat.c: In function 'main':
shmat.c:11:6: warning: variable 'num' set but not used
  int num = 1;
      ^
cc -g -O0 -Wall -D_GNU_SOURCE    shmget.c   -o shmget
shmget.c: In function 'main':
shmget.c:11:6: warning: variable 'num' set but not used
  int num = 1;
      ^
---
 tests/shm/shmat.c  |    6 +-----
 tests/shm/shmctl.c |    6 +-----
 tests/shm/shmget.c |    6 +-----
 3 files changed, 3 insertions(+), 15 deletions(-)
tests/shm/shmat.c +1 -5
index 89ac299..704d676 100644
@@ -8,20 +8,16 @@
 int main(int argc, char **argv)
 {
 	int ch;
-	int num = 1;
 	int key = 0x8888;
 	int id;
 	int error;
 	char *buf;
 
-	while ((ch = getopt(argc, argv, "k:-n:")) != -1) {
+	while ((ch = getopt(argc, argv, "k:")) != -1) {
 		switch (ch) {
 		case 'k':
 			key = atoi(optarg);
 			break;
-		case 'n':
-			num = atoi(optarg);
-			break;
 		}
 	}
 
tests/shm/shmctl.c +1 -5
index 78397b6..d17a804 100644
@@ -8,20 +8,16 @@
 int main(int argc, char **argv)
 {
 	int ch;
-	int num = 1;
 	int key = 0x8888;
 	int id;
 	int error;
 	struct shmid_ds buf;
 
-	while ((ch = getopt(argc, argv, "k:-n:")) != -1) {
+	while ((ch = getopt(argc, argv, "k:")) != -1) {
 		switch (ch) {
 		case 'k':
 			key = atoi(optarg);
 			break;
-		case 'n':
-			num = atoi(optarg);
-			break;
 		}
 	}
 
tests/shm/shmget.c +1 -5
index a04da25..42d6394 100644
@@ -8,18 +8,14 @@
 int main(int argc, char **argv)
 {
 	int ch;
-	int num = 1;
 	int key = 0x8888;
 	int id;
 
-	while ((ch = getopt(argc, argv, "k:-n:")) != -1) {
+	while ((ch = getopt(argc, argv, "k:")) != -1) {
 		switch (ch) {
 		case 'k':
 			key = atoi(optarg);
 			break;
-		case 'n':
-			num = atoi(optarg);
-			break;
 		}
 	}
 
author
#6 lore raw

PATCH v3 6/6 selinux-testsuite: fix compile problems in tests/capable_file

In reply to Paul Moore

Fix the following warnings:

make[2]: Entering directory '/home/pmoore/sources/selinux-testsuite/selinux_testsuite-upstream/tests/capable_file'
cc -g -O0 -Wall -D_GNU_SOURCE test_lease.c -o test_lease
test_lease.c: In function 'main':
test_lease.c:22:3: warning: implicit declaration of function 'open'
fd = open(argv[1], O_RDONLY, 0);
^
test_lease.c:29:3: warning: implicit declaration of function 'fcntl'
rc = fcntl(fd, F_SETLEASE, 0);
^

---
 tests/capable_file/test_lease.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tests/capable_file/test_lease.c +5 -4
index 606d75c..e8f29eb 100644
@@ -1,9 +1,10 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <linux/posix_types.h>
-#include<linux/fcntl.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 /*
  * Test the fcntl F_SETLEASE operation on a file whose name is given as 
Acked-by on v3 6/6
#7 lore raw

Re: [PATCH v3 6/6] selinux-testsuite: fix compile problems in tests/capable_file

Quoted 6 lines · Paul Moore

Fix the following warnings:

make[2]: Entering directory '/home/pmoore/sources/selinux-testsuite/selinux_testsuite-upstream/tests/capable_file'
cc -g -O0 -Wall -D_GNU_SOURCE test_lease.c -o test_lease
test_lease.c: In function 'main':
test_lease.c:22:3: warning: implicit declaration of function 'open'

Quoted 7 lines
   fd = open(argv[1], O_RDONLY, 0);
   ^
test_lease.c:29:3: warning: implicit declaration of function 'fcntl'
   rc = fcntl(fd, F_SETLEASE, 0);
   ^

for all 6 patches.

Quoted 31 lines
---
 tests/capable_file/test_lease.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tests/capable_file/test_lease.c +5 -4
index 606d75c..e8f29eb 100644
@@ -1,9 +1,10 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <linux/posix_types.h>
-#include<linux/fcntl.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 /*
  * Test the fcntl F_SETLEASE operation on a file whose name is given as 

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

author
#8 lore raw

Re: [PATCH v3 6/6] selinux-testsuite: fix compile problems in tests/capable_file

Quoted 15 lines · Stephen Smalley
Quoted 14 lines · Paul Moore

Fix the following warnings:

make[2]: Entering directory '/home/pmoore/sources/selinux-testsuite/selinux_testsuite-upstream/tests/
capable_file' cc -g -O0 -Wall -D_GNU_SOURCE test_lease.c -o
test_lease
test_lease.c: In function 'main':
test_lease.c:22:3: warning: implicit declaration of function 'open'

   fd = open(argv[1], O_RDONLY, 0);
   ^

test_lease.c:29:3: warning: implicit declaration of function 'fcntl'

Quoted 7 lines
Quoted 4 lines
   rc = fcntl(fd, F_SETLEASE, 0);
   ^

for all 6 patches.

Thanks. I went ahead and applied the patches last night along with the astyle patch.

Signature · 2 lines
paul moore
security @ redhat