Skip to content

Commit

Permalink
Add SELinux support [WIP]
Browse files Browse the repository at this point in the history
Signed-off-by: David Cassany <[email protected]>
  • Loading branch information
davidcassany committed May 3, 2021
1 parent 00d103d commit 95aeb1d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/base/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "base"
category: "distro"
version: "0.3.6"
version: "0.3.6+1"

hidden: true # No need to make it installable for now
labels:
Expand Down
7 changes: 5 additions & 2 deletions packages/cos/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ requires:
- name: cos-features
category: system
version: ">=0"
- name: "refpolicy"
category: "system"
version: ">=0"

steps:
- sed -i 's/:VERSION:/{{.Values.version}}/g' setup.yaml
Expand Down Expand Up @@ -85,8 +88,8 @@ excludes:
- ^/var/lib/YaST2

# Perl
# - ^/usr/bin/perl.*
# - ^/usr/lib/perl.*
- ^/usr/bin/perl.*
- ^/usr/lib/perl.*

# Wget - we are only shipping curl
- ^/etc/wgetrc
Expand Down
4 changes: 2 additions & 2 deletions packages/cos/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ stages:
set img=/cOS/active.img
loopback loop0 /$img
set root=($root)
linux (loop0)/boot/vmlinuz console=tty1 ro root=LABEL=COS_ACTIVE iso-scan/filename=/cOS/active.img panic=5
linux (loop0)/boot/vmlinuz console=tty1 ro root=LABEL=COS_ACTIVE iso-scan/filename=/cOS/active.img panic=5 security=selinux selinux=1
initrd (loop0)/boot/initrd
}
Expand All @@ -56,7 +56,7 @@ stages:
set img=/cOS/passive.img
loopback loop0 /$img
set root=($root)
linux (loop0)/boot/vmlinuz console=tty1 ro root=LABEL=COS_PASSIVE iso-scan/filename=/cOS/passive.img panic=5
linux (loop0)/boot/vmlinuz console=tty1 ro root=LABEL=COS_PASSIVE iso-scan/filename=/cOS/passive.img panic=5 security=selinux selinux=1
initrd (loop0)/boot/initrd
}
Expand Down
34 changes: 34 additions & 0 deletions packages/refpolicy/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
requires:
- name: "base"
category: "distro"
version: ">=0"

prelude:
{{ if .Values.distribution }}
{{if eq .Values.distribution "opensuse" }}
- zypper in -y wget sed bzip2 && zypper install -y -t pattern devel_basis
{{else if eq .Values.distribution "fedora" }}
- dnf install -y wget sed "@Development Tools"
{{end}}
{{end}}
- wget https://raw.githubusercontent.com/wiki/SELinuxProject/refpolicy/files/refpolicy-{{.Values.policy_version}}.tar.bz2 -O refpolicy-src.tar.bz2
- tar xaf refpolicy-src.tar.bz2

steps:
{{ if .Values.distribution }}
{{if eq .Values.distribution "opensuse" }}
- zypper in -y selinux-tools audit policycoreutils restorecond python-xml
{{end}}
{{end}}
- cp config /etc/selinux/config
- cd refpolicy && make install-src
- cd /etc/selinux/refpolicy/src/policy && make conf && \
{{ if .Values.distribution }}
{{if eq .Values.distribution "opensuse" }}
sed -e "s|^.*DISTRO *=.*$|DISTRO = suse|g" \
{{else if eq .Values.distribution "fedora" }}
sed -e "s|^.*DISTRO *=.*$|DISTRO = redhat|g" \
{{end}}
{{end}}
-e "s|^.*DIRECT_INITRC *=.*$|DIRECT_INITRC=y|g" -i build.conf
- cd /etc/selinux/refpolicy/src/policy && make load
10 changes: 10 additions & 0 deletions packages/refpolicy/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=refpolicy
5 changes: 5 additions & 0 deletions packages/refpolicy/definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: "refpolicy"
category: "system"
version: "0.0.4"

policy_version: "2.20180114"
1 change: 1 addition & 0 deletions values/opensuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ packages: >-
haveged
tar
rsync
timezone
kernel_package: kernel-default

0 comments on commit 95aeb1d

Please sign in to comment.