Browse code

Add a custom policy for hackers using ansible-test (#68535)

Signed-off-by: Rick Elrod <rick@elrod.me>

Rick Elrod authored on 2020/03/29 07:07:29
Showing 4 changed files
... ...
@@ -76,6 +76,8 @@ ansible.egg-info/
76 76
 /test/integration/cloud-config-*.*
77 77
 !/test/integration/cloud-config-*.*.template
78 78
 .python-version
79
+/hacking/tests/selinux/*.mod
80
+/hacking/tests/selinux/*.pp
79 81
 # Release directory
80 82
 packaging/release/ansible_release
81 83
 /.cache/
82 84
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+# ansible-podman selinux module
1
+
2
+On Fedora-derived systems (and possibly others), selinux can prevent podman
3
+from running the way we need it to for our tests to work.
4
+
5
+Loading this module (hopefully) allows you to
6
+[keep selinux enabled](https://stopdisablingselinux.com/) and still be able to
7
+run our tests.
8
+
9
+To use it, just run:
10
+
11
+```
12
+./build.sh
13
+```
14
+
15
+...which will build the module. Then run:
16
+
17
+```
18
+sudo semodule -i ansible-podman.pp
19
+```
20
+
21
+to insert and enable the module.
0 22
new file mode 100644
... ...
@@ -0,0 +1,17 @@
0
+module ansible-podman 1.0;
1
+
2
+require {
3
+        type container_t;
4
+        type cgroup_t;
5
+        type fusefs_t;
6
+        class dir { add_name create remove_name rmdir write };
7
+        class file { create relabelto write };
8
+        class bpf map_create;
9
+}
10
+
11
+
12
+allow container_t cgroup_t:dir { add_name create remove_name rmdir write };
13
+
14
+allow container_t cgroup_t:file { create write };
15
+allow container_t fusefs_t:file relabelto;
16
+allow container_t self:bpf map_create;
0 17
new file mode 100755
... ...
@@ -0,0 +1,9 @@
0
+#!/usr/bin/env bash
1
+set -x
2
+set -e
3
+checkmodule -Mmo ansible-podman.mod ansible-podman.te
4
+semodule_package -o ansible-podman.pp -m ansible-podman.mod
5
+
6
+set +x
7
+echo "Module built. Now run this as root:"
8
+echo "semodule -i $(pwd)/ansible-podman.pp"