Skip to content

Commit d6f5761

Browse files
allisonkarlitskayacgwalters
authored andcommitted
examples: [selinux hacks intensify]
We need to avoid https://bugzilla.redhat.com/show_bug.cgi?id=2374928 but `semanage` seems to have a bug when invoked more than once in a container build, so we can't just add another invocation. Use a module instead, to workaround both issues in one go. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 2171bac commit d6f5761

File tree

6 files changed

+75
-3
lines changed

6 files changed

+75
-3
lines changed

examples/uki/Containerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ RUN <<EOF
4444
set -eux
4545

4646
systemctl enable systemd-networkd
47-
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
47+
48+
checkmodule -M -m -o /etc/composefs_workarounds.mod /etc/composefs_workarounds.te
49+
semodule_package -o /etc/composefs_workarounds.pp -m /etc/composefs_workarounds.mod
50+
semodule -i /etc/composefs_workarounds.pp
51+
4852
passwd -d root
4953
mkdir /sysroot
5054
EOF
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module composefs_workarounds 1.0;
2+
3+
require {
4+
type sshd_t;
5+
type tmpfs_t;
6+
type systemd_gpt_generator_t;
7+
type init_var_run_t;
8+
class file read;
9+
class file open;
10+
class file getattr;
11+
class lnk_file read;
12+
}
13+
14+
# https://bugzilla.redhat.com/show_bug.cgi?id=2374928
15+
allow sshd_t tmpfs_t:file open;
16+
allow sshd_t tmpfs_t:file getattr;
17+
allow sshd_t tmpfs_t:file read;
18+
19+
# for volatile-root workaround
20+
allow systemd_gpt_generator_t init_var_run_t:lnk_file read;

examples/unified-secureboot/Containerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ RUN <<EOF
2828
set -eux
2929

3030
systemctl enable systemd-networkd
31-
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
31+
32+
checkmodule -M -m -o /etc/composefs_workarounds.mod /etc/composefs_workarounds.te
33+
semodule_package -o /etc/composefs_workarounds.pp -m /etc/composefs_workarounds.mod
34+
semodule -i /etc/composefs_workarounds.pp
35+
3236
passwd -d root
3337
mkdir /sysroot
3438
EOF
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module composefs_workarounds 1.0;
2+
3+
require {
4+
type sshd_t;
5+
type tmpfs_t;
6+
type systemd_gpt_generator_t;
7+
type init_var_run_t;
8+
class file read;
9+
class file open;
10+
class file getattr;
11+
class lnk_file read;
12+
}
13+
14+
# https://bugzilla.redhat.com/show_bug.cgi?id=2374928
15+
allow sshd_t tmpfs_t:file open;
16+
allow sshd_t tmpfs_t:file getattr;
17+
allow sshd_t tmpfs_t:file read;
18+
19+
# for volatile-root workaround
20+
allow systemd_gpt_generator_t init_var_run_t:lnk_file read;

examples/unified/Containerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ RUN <<EOF
2626
set -eux
2727

2828
systemctl enable systemd-networkd
29-
semanage permissive -a systemd_gpt_generator_t # for volatile-root workaround
29+
30+
checkmodule -M -m -o /etc/composefs_workarounds.mod /etc/composefs_workarounds.te
31+
semodule_package -o /etc/composefs_workarounds.pp -m /etc/composefs_workarounds.mod
32+
semodule -i /etc/composefs_workarounds.pp
33+
3034
passwd -d root
3135
mkdir /sysroot
3236
EOF
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module composefs_workarounds 1.0;
2+
3+
require {
4+
type sshd_t;
5+
type tmpfs_t;
6+
type systemd_gpt_generator_t;
7+
type init_var_run_t;
8+
class file read;
9+
class file open;
10+
class file getattr;
11+
class lnk_file read;
12+
}
13+
14+
# https://bugzilla.redhat.com/show_bug.cgi?id=2374928
15+
allow sshd_t tmpfs_t:file open;
16+
allow sshd_t tmpfs_t:file getattr;
17+
allow sshd_t tmpfs_t:file read;
18+
19+
# for volatile-root workaround
20+
allow systemd_gpt_generator_t init_var_run_t:lnk_file read;

0 commit comments

Comments
 (0)