Skip to content

Commit 5f1d431

Browse files
committed
Adjusted RPM packaging to be avoid failed installs when selinux-policy version is not sufficient
We have two fallback strategies: 1) try to install a cfengine-enterprise-unconfined selinux module 2) instruct user to install semanage and run label-binaries-unconfined.sh script Ticket: ENT-12980 Changelog: title (cherry picked from commit 190c974)
1 parent 8c9098b commit 5f1d431

File tree

5 files changed

+34
-30
lines changed

5 files changed

+34
-30
lines changed

packaging/cfengine-community/cfengine-community.spec.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ rm -rf $RPM_BUILD_ROOT/usr/lib/systemd/system/cf-postgres.service
138138
%prefix/selinux/cfengine-enterprise.pp
139139
%prefix/selinux/cfengine-enterprise.te
140140
%prefix/selinux/cfengine-enterprise.fc
141+
%prefix/selinux/label-binaries-unconfined.sh
141142
%endif
142143

143144
# Globally installed configs, scripts

packaging/cfengine-nova-hub/cfengine-nova-hub.spec.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Requires(post): /usr/sbin/usermod, /bin/sed
2727
Requires: selinux-policy >= @@SELINUX_POLICY_VERSION@@
2828
%endif
2929

30+
3031
# we don't bundle OpenSSL on RHEL 8 (and newer in the future)
3132
%if %{?rhel}%{!?rhel:0} == 8
3233
Requires: libssl.so.1.1()(64bit) libssl.so.1.1(OPENSSL_1_1_0)(64bit) libssl.so.1.1(OPENSSL_1_1_1)(64bit)
@@ -354,6 +355,10 @@ exit 0
354355
%prefix/selinux/cfengine-enterprise.pp
355356
%prefix/selinux/cfengine-enterprise.te
356357
%prefix/selinux/cfengine-enterprise.fc
358+
%prefix/selinux/cfengine-enterprise-unconfined.pp
359+
%prefix/selinux/cfengine-enterprise-unconfined.te
360+
%prefix/selinux/cfengine-enterprise-unconfined.fc
361+
%prefix/selinux/label-binaries-unconfined.sh
357362
%endif
358363

359364
# Documentation

packaging/cfengine-nova/cfengine-nova.spec.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ exit 0
162162
%prefix/selinux/cfengine-enterprise.pp
163163
%prefix/selinux/cfengine-enterprise.te
164164
%prefix/selinux/cfengine-enterprise.fc
165+
%prefix/selinux/cfengine-enterprise-unconfined.pp
166+
%prefix/selinux/cfengine-enterprise-unconfined.te
167+
%prefix/selinux/cfengine-enterprise-unconfined.fc
168+
%prefix/selinux/label-binaries-unconfined.sh
165169
%endif
166170

167171
# Globally installed configs, scripts

packaging/common/cfengine-hub/postinstall.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,19 @@ then
66
if command -v /usr/sbin/selinuxenabled >/dev/null &&
77
/usr/sbin/selinuxenabled;
88
then
9-
command -v semodule >/dev/null || cf_console echo "warning! selinuxenabled exists and returns 0 but semodule not found"
10-
test -x /usr/sbin/load_policy || cf_console echo "warning! selinuxenabled exists and returns 0 but load_policy not found"
11-
test -x /usr/sbin/restorecon || cf_console echo "warning! selinuxenabled exists and returns 0 but restorecon not found"
9+
command -v semodule >/dev/null || cf_console echo "warning: selinuxenabled exists and returns 0 but semodule not found"
10+
test -x /usr/sbin/load_policy || cf_console echo "warning: selinuxenabled exists and returns 0 but load_policy not found"
11+
test -x /usr/sbin/restorecon || cf_console echo "warning: selinuxenabled exists and returns 0 but restorecon not found"
1212
fi
1313
if ! cf_console semodule -n -i "$PREFIX/selinux/cfengine-enterprise.pp"; then
14-
cf_console echo "warning! semodule import failed, examine /var/log/CFE*log and \
15-
consider installing selinux-policy-devel package and \
16-
rebuilding policy with: \
17-
\
18-
cd $PREFIX/selinux \
19-
make -f /usr/share/selinux/devel/Makefile -j1 \
20-
semodule -n -i $PREFIX/selinux/cfengine-enterprise.pp \
21-
\
22-
and then restarting services with \
23-
\
24-
systemctl restart cfengine3"
14+
cf_console echo "warning: cfengine-enterprise semodule install failed, will attempt to install cfengine-enterprise-unconfined instead. \
15+
The install failure should be examined in /var/log/CFEngine-Install.log and any issues reported as bugs at https://northerntech.atlassian.net/jira/software/c/projects/CFE/issues/."
16+
17+
if ! cf_console semodule -n -i "$PREFIX/selinux/cfengine-enterprise-unconfined.pp"; then
18+
cf_console echo "warning: cfengine-enterprise-unconfined semodule failed to install. As a last attempt you can install the semanage program (probably policycoreutils-python-utils package) and run $PREFIX/selinux/label-binaries-unconfined.sh."
19+
else
20+
cf_console echo "info: cfengine-enterprise-unconfined semodule is installed. This allows CFEngine binaries to run unconfined which is not ideal. Please report issues with default cfengine-enterprise selinux module."
21+
fi
2522
fi
2623
if /usr/sbin/selinuxenabled; then
2724
/usr/sbin/load_policy
@@ -33,7 +30,7 @@ if [ -x /bin/systemctl ]; then
3330
# This is important in case any of the units have been replaced by the package
3431
# and we call them in the postinstall script.
3532
if ! /bin/systemctl daemon-reload; then
36-
cf_console echo "warning! /bin/systemctl daemon-reload failed."
33+
cf_console echo "warning: /bin/systemctl daemon-reload failed."
3734
cf_console echo "systemd seems to be installed, but not working."
3835
cf_console echo "Relevant parts of CFEngine installation will fail."
3936
cf_console echo "Please fix systemd or use other ways to start CFEngine."

packaging/common/cfengine-non-hub/postinstall.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ if [ -x /bin/systemctl ]; then
22
# This is important in case any of the units have been replaced by the package
33
# and we call them in the postinstall script.
44
if ! /bin/systemctl daemon-reload; then
5-
cf_console echo "warning! /bin/systemctl daemon-reload failed."
5+
cf_console echo "warning: /bin/systemctl daemon-reload failed."
66
cf_console echo "systemd seems to be installed, but not working."
77
cf_console echo "Relevant parts of CFEngine installation will fail."
88
cf_console echo "Please fix systemd or use other ways to start CFEngine."
@@ -120,23 +120,20 @@ then
120120
if command -v /usr/sbin/selinuxenabled >/dev/null &&
121121
/usr/sbin/selinuxenabled;
122122
then
123-
command -v semodule >/dev/null || cf_console echo "warning! selinux exists and returns 0 but semodule not found"
124-
test -x /usr/sbin/load_policy || cf_console echo "warning! selinuxenabled exists and returns 0 but load_policy not found"
125-
test -x /usr/sbin/restorecon || cf_console echo "warning! selinuxenabled exists and returns 0 but restorecon not found"
123+
command -v semodule >/dev/null || cf_console echo "warning: selinux exists and returns 0 but semodule not found"
124+
test -x /usr/sbin/load_policy || cf_console echo "warning: selinuxenabled exists and returns 0 but load_policy not found"
125+
test -x /usr/sbin/restorecon || cf_console echo "warning: selinuxenabled exists and returns 0 but restorecon not found"
126126

127127
fi
128128
if ! cf_console semodule -n -i "$PREFIX/selinux/cfengine-enterprise.pp"; then
129-
cf_console echo "warning! semodule import failed, examine /var/log/CFE*log and \
130-
consider installing selinux-policy-devel package and \
131-
rebuilding policy with: \
132-
\
133-
cd $PREFIX/selinux \
134-
make -f /usr/share/selinux/devel/Makefile -j1 \
135-
semodule -n -i $PREFIX/selinux/cfengine-enterprise.pp \
136-
\
137-
and then restarting services with \
138-
\
139-
systemctl restart cfengine3"
129+
cf_console echo "warning: cfengine-enterprise semodule install failed, will attempt to install cfengine-enterprise-unconfined instead. \
130+
The install failure should be examined in /var/log/CFEngine-Install.log and any issues reported as bugs at https://northerntech.atlassian.net/jira/software/c/projects/CFE/issues/."
131+
132+
if ! cf_console semodule -n -i "$PREFIX/selinux/cfengine-enterprise-unconfined.pp"; then
133+
cf_console echo "warning: cfengine-enterprise-unconfined semodule failed to install. As a last attempt you can install the semanage program (probably policycoreutils-python-utils package) and run $PREFIX/selinux/label-binaries-unconfined.sh."
134+
else
135+
cf_console echo "info: cfengine-enterprise-unconfined semodule is installed. This allows CFEngine binaries to run unconfined which is not ideal. Please report issues with default cfengine-enterprise selinux module."
136+
fi
140137
fi
141138
if /usr/sbin/selinuxenabled; then
142139
/usr/sbin/load_policy

0 commit comments

Comments
 (0)