forked from openshift/os
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#966 from openshift-cherrypick-robot/cher…
…ry-pick-962-to-release-4.11 [release-4.11] OCPBUGS-727: overlay: Add `rhcos-selinux-policy-upgrade.service`
- Loading branch information
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
overlay.d/05rhcos/usr/lib/systemd/system/rhcos-selinux-policy-upgrade.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=RHEL CoreOS Rebuild SELinux Policy If Necessary | ||
Documentation=https://bugzilla.redhat.com/2057497 | ||
DefaultDependencies=false | ||
After=systemd-tmpfiles-setup.service local-fs.target | ||
Before=sysinit.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/libexec/rhcos-rebuild-selinux-policy | ||
|
||
[Install] | ||
WantedBy=sysinit.target |
16 changes: 16 additions & 0 deletions
16
overlay.d/05rhcos/usr/libexec/rhcos-rebuild-selinux-policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# Executed by rhcos-selinux-policy-upgrade.service | ||
set -euo pipefail | ||
|
||
RHEL_VERSION=$(. /usr/lib/os-release && echo ${RHEL_VERSION:-}) | ||
echo -n "RHEL_VERSION=${RHEL_VERSION:-}" | ||
case "${RHEL_VERSION:-}" in | ||
8.[0-6]) echo "Checking for policy recompilation";; | ||
*) echo "Assuming we have new enough ostree"; exit 0;; | ||
esac | ||
|
||
ls -al /{usr/,}etc/selinux/targeted/policy/policy.31 | ||
if ! cmp --quiet /{usr/,}etc/selinux/targeted/policy/policy.31; then | ||
echo "Recompiling policy due to local modifications as workaround for https://bugzilla.redhat.com/2057497" | ||
semodule -B | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../fedora-coreos-config/tests/kola/data/commonlib.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# Test for https://issues.redhat.com/browse/OCPBUGS-595 | ||
|
||
set -xeuo pipefail | ||
|
||
. $KOLA_EXT_DATA/commonlib.sh | ||
|
||
cd $(mktemp -d) | ||
journalctl -b -u rhcos-selinux-policy-upgrade > logs.txt | ||
RHEL_VERSION=$(. /usr/lib/os-release && echo ${RHEL_VERSION:-}) | ||
echo "RHEL_VERSION=${RHEL_VERSION:-}" | ||
service_should_start=0 | ||
case "${RHEL_VERSION:-}" in | ||
8.[0-6]) service_should_start=1;; | ||
*) ;; | ||
esac | ||
|
||
case "${AUTOPKGTEST_REBOOT_MARK:-}" in | ||
"") | ||
if grep -qFe 'Recompiling policy' logs.txt; then | ||
cat logs.txt | ||
fatal "Recompiled policy on first boot" | ||
fi | ||
setsebool -P container_manage_cgroup on | ||
/tmp/autopkgtest-reboot changed-policy | ||
;; | ||
"changed-policy") | ||
if test "${service_should_start}" = "1" && ! grep -qFe 'Recompiling policy' logs.txt; then | ||
cat logs.txt | ||
fatal "Failed to recompile policy on first boot" | ||
fi | ||
;; | ||
esac | ||
echo ok |