Skip to contentSkip to conversation

selinux: Build policy on systems not supporting DCCP protocol

PATCH In review Richard Haines 3 participants 4 messages Apr 24, 2016 – Apr 25, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selinux: Build policy on systems not supporting DCCP protocol

Commit 3895fbbe0cf2ec52d6b6eda66084b6e9f8d88fb2 ("selinux: Add support for portcon dccp protocol") added support for the (portcon dccp ..) statement. This fix will allow policy to be built on platforms (see [1]) that do not have DCCP support by defining the IANA assigned IP Protocol Number 33 to IPPROTO_DCCP.

[1] https://android-review.googlesource.com/#/c/219568/

---
 checkpolicy/checkpolicy.c     | 3 +++
 checkpolicy/policy_define.c   | 3 +++
 libsepol/cil/src/cil_binary.c | 3 +++
 libsepol/src/module_to_cil.c  | 3 +++
 libsepol/src/ports.c          | 3 +++
 5 files changed, 15 insertions(+)
checkpolicy/checkpolicy.c +3 -0
index ea9ee00..7947c20 100644
@@ -64,6 +64,9 @@
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <stdio.h>
checkpolicy/policy_define.c +3 -0
index 7a4d2f1..2068b71 100644
@@ -36,6 +36,9 @@
 #include <string.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
 #include <arpa/inet.h>
 #include <stdlib.h>
 #include <limits.h>
libsepol/cil/src/cil_binary.c +3 -0
index 8233dfd..b8437c9 100644
@@ -31,6 +31,9 @@
 #include <stdio.h>
 #include <assert.h>
 #include <netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
 
 #include <sepol/policydb/policydb.h>
 #include <sepol/policydb/polcaps.h>
libsepol/src/module_to_cil.c +3 -0
index b478d9f..38f0dc3 100644
@@ -26,6 +26,9 @@
 #include <getopt.h>
 #include <libgen.h>
 #include <netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
libsepol/src/ports.c +3 -0
index b1ee094..62ec602 100644
@@ -1,4 +1,7 @@
 #include <netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
 #include <stdlib.h>
 
 #include "debug.h"
Signature · 1 line
2.5.5
#1 lore raw
Quoted 8 lines · Richard Haines

Commit 3895fbbe0cf2ec52d6b6eda66084b6e9f8d88fb2 ("selinux: Add support for portcon dccp protocol") added support for the (portcon dccp ..) statement. This fix will allow policy to be built on platforms (see [1]) that do not have DCCP support by defining the IANA assigned IP Protocol Number 33 to IPPROTO_DCCP.

[1] https://android-review.googlesource.com/#/c/219568/

Quoted 7 lines
---
  checkpolicy/checkpolicy.c     | 3 +++
  checkpolicy/policy_define.c   | 3 +++
  libsepol/cil/src/cil_binary.c | 3 +++
  libsepol/src/module_to_cil.c  | 3 +++
  libsepol/src/ports.c          | 3 +++

Seems like this should be in a private header.

Quoted 70 lines
  5 files changed, 15 insertions(+)
checkpolicy/checkpolicy.c +3 -0
index ea9ee00..7947c20 100644
@@ -64,6 +64,9 @@
  #include<sys/stat.h>
  #include<sys/socket.h>
  #include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
  #include<arpa/inet.h>
  #include<fcntl.h>
  #include<stdio.h>
checkpolicy/policy_define.c +3 -0
index 7a4d2f1..2068b71 100644
@@ -36,6 +36,9 @@
  #include<string.h>
  #include<sys/socket.h>
  #include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
  #include<arpa/inet.h>
  #include<stdlib.h>
  #include<limits.h>
libsepol/cil/src/cil_binary.c +3 -0
index 8233dfd..b8437c9 100644
@@ -31,6 +31,9 @@
  #include<stdio.h>
  #include<assert.h>
  #include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
 
  #include<sepol/policydb/policydb.h>
  #include<sepol/policydb/polcaps.h>
libsepol/src/module_to_cil.c +3 -0
index b478d9f..38f0dc3 100644
@@ -26,6 +26,9 @@
  #include<getopt.h>
  #include<libgen.h>
  #include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
  #include<signal.h>
  #include<stdarg.h>
  #include<stdio.h>
libsepol/src/ports.c +3 -0
index b1ee094..62ec602 100644
@@ -1,4 +1,7 @@
  #include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
  #include<stdlib.h>
 
  #include "debug.h"
#2 lore raw
Quoted 24 lines · Joshua Brindle
Quoted 9 lines

Richard Haines wrote:
Commit 3895fbbe0cf2ec52d6b6eda66084b6e9f8d88fb2 ("selinux: Add support for portcon dccp protocol") added support for the (portcon dccp ..) statement. This fix will allow policy to be built on platforms (see [1]) that do not have DCCP support by defining the IANA assigned IP Protocol Number 33 to IPPROTO_DCCP.

[1] https://android-review.googlesource.com/#/c/219568/

Quoted 7 lines

---

   checkpolicy/checkpolicy.c     | 3 +++
   checkpolicy/policy_define.c   | 3 +++
   libsepol/cil/src/cil_binary.c | 3 +++
   libsepol/src/module_to_cil.c  | 3 +++
   libsepol/src/ports.c          | 3 +++
Quoted 1 line

Seems like this should be in a private header.

I finally choose the way I did this to make it clear that netinet/in.h may not have dccp support.

Quoted 73 lines
Quoted 72 lines

   5 files changed, 15 insertions(+)

diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index ea9ee00..7947c20 100644
--- a/checkpolicy/checkpolicy.c
+++ b/checkpolicy/checkpolicy.c
@@ -64,6 +64,9 @@

   #include<sys/stat.h>
   #include<sys/socket.h>
   #include<netinet/in.h>
 +#ifndef IPPROTO_DCCP
 +#define IPPROTO_DCCP 33
 +#endif
   #include<arpa/inet.h>
   #include<fcntl.h>
   #include<stdio.h>
 diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
 index 7a4d2f1..2068b71 100644
 --- a/checkpolicy/policy_define.c
 +++ b/checkpolicy/policy_define.c
 @@ -36,6 +36,9 @@
   #include<string.h>
   #include<sys/socket.h>
   #include<netinet/in.h>
 +#ifndef IPPROTO_DCCP
 +#define IPPROTO_DCCP 33
 +#endif
   #include<arpa/inet.h>
   #include<stdlib.h>
   #include<limits.h>
 diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
 index 8233dfd..b8437c9 100644
 --- a/libsepol/cil/src/cil_binary.c
 +++ b/libsepol/cil/src/cil_binary.c
 @@ -31,6 +31,9 @@
   #include<stdio.h>
   #include<assert.h>
   #include<netinet/in.h>

+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif

   #include<sepol/policydb/policydb.h>
   #include<sepol/policydb/polcaps.h>
 diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
 index b478d9f..38f0dc3 100644
 --- a/libsepol/src/module_to_cil.c
 +++ b/libsepol/src/module_to_cil.c
 @@ -26,6 +26,9 @@
   #include<getopt.h>
   #include<libgen.h>
   #include<netinet/in.h>
 +#ifndef IPPROTO_DCCP
 +#define IPPROTO_DCCP 33
 +#endif
   #include<signal.h>
   #include<stdarg.h>
   #include<stdio.h>

diff --git a/libsepol/src/ports.c b/libsepol/src/ports.c index b1ee094..62ec602 100644
--- a/libsepol/src/ports.c
+++ b/libsepol/src/ports.c
@@ -1,4 +1,7 @@
#include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
#include<stdlib.h>

   #include "debug.h"
#3 lore raw
Quoted 24 lines · Richard Haines
Quoted 23 lines · Joshua Brindle
Quoted 16 lines

Richard Haines wrote:
Commit 3895fbbe0cf2ec52d6b6eda66084b6e9f8d88fb2 ("selinux: Add support for portcon dccp protocol") added support for the (portcon dccp ..) statement. This fix will allow policy to be built on platforms (see [1]) that do not have DCCP support by defining the IANA assigned IP Protocol Number 33 to IPPROTO_DCCP.

[1] https://android-review.googlesource.com/#/c/219568/

---

   checkpolicy/checkpolicy.c     | 3 +++
   checkpolicy/policy_define.c   | 3 +++
   libsepol/cil/src/cil_binary.c | 3 +++
   libsepol/src/module_to_cil.c  | 3 +++
   libsepol/src/ports.c          | 3 +++
Quoted 4 lines
Quoted 1 line

Seems like this should be in a private header.

I finally choose the way I did this to make it clear that netinet/in.h may not have dccp support.

Yes, doesn't seem worth defining a libsepol header that defines it and then including that in each of these files. It isn't as though the definition will ever change...

Quoted 79 lines
Quoted 71 lines
Quoted 71 lines

   5 files changed, 15 insertions(+)

diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index ea9ee00..7947c20 100644
--- a/checkpolicy/checkpolicy.c
+++ b/checkpolicy/checkpolicy.c
@@ -64,6 +64,9 @@

   #include<sys/stat.h>
   #include<sys/socket.h>
   #include<netinet/in.h>
 +#ifndef IPPROTO_DCCP
 +#define IPPROTO_DCCP 33
 +#endif
   #include<arpa/inet.h>
   #include<fcntl.h>
   #include<stdio.h>
 diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
 index 7a4d2f1..2068b71 100644
 --- a/checkpolicy/policy_define.c
 +++ b/checkpolicy/policy_define.c
 @@ -36,6 +36,9 @@
   #include<string.h>
   #include<sys/socket.h>
   #include<netinet/in.h>
 +#ifndef IPPROTO_DCCP
 +#define IPPROTO_DCCP 33
 +#endif
   #include<arpa/inet.h>
   #include<stdlib.h>
   #include<limits.h>
 diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
 index 8233dfd..b8437c9 100644
 --- a/libsepol/cil/src/cil_binary.c
 +++ b/libsepol/cil/src/cil_binary.c
 @@ -31,6 +31,9 @@
   #include<stdio.h>
   #include<assert.h>
   #include<netinet/in.h>

+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif

   #include<sepol/policydb/policydb.h>
   #include<sepol/policydb/polcaps.h>
 diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
 index b478d9f..38f0dc3 100644
 --- a/libsepol/src/module_to_cil.c
 +++ b/libsepol/src/module_to_cil.c
 @@ -26,6 +26,9 @@
   #include<getopt.h>
   #include<libgen.h>
   #include<netinet/in.h>
 +#ifndef IPPROTO_DCCP
 +#define IPPROTO_DCCP 33
 +#endif
   #include<signal.h>
   #include<stdarg.h>
   #include<stdio.h>

diff --git a/libsepol/src/ports.c b/libsepol/src/ports.c index b1ee094..62ec602 100644
--- a/libsepol/src/ports.c
+++ b/libsepol/src/ports.c
@@ -1,4 +1,7 @@
#include<netinet/in.h>
+#ifndef IPPROTO_DCCP
+#define IPPROTO_DCCP 33
+#endif
#include<stdlib.h>

Quoted 2 lines
Quoted 1 line
   #include "debug.h"

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