|
|
b2bc38 |
From 03ca5111a8de602ecef9ad33206ba593b242d0df Mon Sep 17 00:00:00 2001
|
|
|
b2bc38 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
b2bc38 |
Date: Fri, 21 Jan 2022 10:15:35 -0500
|
|
|
b2bc38 |
Subject: [PATCH 1/2] Issue 5127 - run restorecon on /dev/shm at server startup
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Description:
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Update the systemd service file to execute a script that runs
|
|
|
b2bc38 |
restorecon on the DB home directory. This addresses issues with
|
|
|
b2bc38 |
backup/restore, reboot, and FS restore issues that can happen when
|
|
|
b2bc38 |
/dev/shm is missing or created outside of dscreate.
|
|
|
b2bc38 |
|
|
|
b2bc38 |
relates: https://github.com/389ds/389-ds-base/issues/5127
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Reviewed by: progier & viktor (Thanks!!)
|
|
|
b2bc38 |
---
|
|
|
b2bc38 |
Makefile.am | 2 +-
|
|
|
b2bc38 |
rpm/389-ds-base.spec.in | 1 +
|
|
|
b2bc38 |
wrappers/ds_selinux_restorecon.sh.in | 33 ++++++++++++++++++++++++++++
|
|
|
b2bc38 |
wrappers/systemd.template.service.in | 1 +
|
|
|
b2bc38 |
4 files changed, 36 insertions(+), 1 deletion(-)
|
|
|
b2bc38 |
create mode 100644 wrappers/ds_selinux_restorecon.sh.in
|
|
|
b2bc38 |
|
|
|
b2bc38 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
b2bc38 |
index fc5a6a7d1..d6ad273c3 100644
|
|
|
b2bc38 |
--- a/Makefile.am
|
|
|
b2bc38 |
+++ b/Makefile.am
|
|
|
b2bc38 |
@@ -775,7 +775,7 @@ libexec_SCRIPTS += ldap/admin/src/scripts/ds_selinux_enabled \
|
|
|
b2bc38 |
ldap/admin/src/scripts/ds_selinux_port_query
|
|
|
b2bc38 |
endif
|
|
|
b2bc38 |
if SYSTEMD
|
|
|
b2bc38 |
-libexec_SCRIPTS += wrappers/ds_systemd_ask_password_acl
|
|
|
b2bc38 |
+libexec_SCRIPTS += wrappers/ds_systemd_ask_password_acl wrappers/ds_selinux_restorecon.sh
|
|
|
b2bc38 |
endif
|
|
|
b2bc38 |
|
|
|
b2bc38 |
install-data-hook:
|
|
|
b2bc38 |
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
|
|
|
b2bc38 |
index d80de8422..6c0d95abd 100644
|
|
|
b2bc38 |
--- a/rpm/389-ds-base.spec.in
|
|
|
b2bc38 |
+++ b/rpm/389-ds-base.spec.in
|
|
|
b2bc38 |
@@ -623,6 +623,7 @@ exit 0
|
|
|
b2bc38 |
%{_sbindir}/ns-slapd
|
|
|
b2bc38 |
%{_mandir}/man8/ns-slapd.8.gz
|
|
|
b2bc38 |
%{_libexecdir}/%{pkgname}/ds_systemd_ask_password_acl
|
|
|
b2bc38 |
+%{_libexecdir}/%{pkgname}/ds_selinux_restorecon.sh
|
|
|
b2bc38 |
%{_mandir}/man5/99user.ldif.5.gz
|
|
|
b2bc38 |
%{_mandir}/man5/certmap.conf.5.gz
|
|
|
b2bc38 |
%{_mandir}/man5/slapd-collations.conf.5.gz
|
|
|
b2bc38 |
diff --git a/wrappers/ds_selinux_restorecon.sh.in b/wrappers/ds_selinux_restorecon.sh.in
|
|
|
b2bc38 |
new file mode 100644
|
|
|
b2bc38 |
index 000000000..063347de3
|
|
|
b2bc38 |
--- /dev/null
|
|
|
b2bc38 |
+++ b/wrappers/ds_selinux_restorecon.sh.in
|
|
|
b2bc38 |
@@ -0,0 +1,33 @@
|
|
|
b2bc38 |
+#!/bin/sh
|
|
|
b2bc38 |
+# BEGIN COPYRIGHT BLOCK
|
|
|
b2bc38 |
+# Copyright (C) 2022 Red Hat, Inc.
|
|
|
b2bc38 |
+#
|
|
|
b2bc38 |
+# All rights reserved.
|
|
|
b2bc38 |
+#
|
|
|
b2bc38 |
+# License: GPL (version 3 or any later version).
|
|
|
b2bc38 |
+# See LICENSE for details.
|
|
|
b2bc38 |
+# END COPYRIGHT BLOCK
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
+# Make sure we have the path to the dse.ldif
|
|
|
b2bc38 |
+if [ -z $1 ]
|
|
|
b2bc38 |
+then
|
|
|
b2bc38 |
+ echo "usage: ${0} /etc/dirsrv/slapd-<instance>/dse.ldif"
|
|
|
b2bc38 |
+ exit 0
|
|
|
b2bc38 |
+fi
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
+if ! command -v restorecon &> /dev/null
|
|
|
b2bc38 |
+then
|
|
|
b2bc38 |
+ # restorecon is not available
|
|
|
b2bc38 |
+ exit 0
|
|
|
b2bc38 |
+fi
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
+# Grep the db_home_dir out of the config file
|
|
|
b2bc38 |
+DS_HOME_DIR=`grep 'nsslapd-db-home-directory: ' $1 | awk '{print $2}'`
|
|
|
b2bc38 |
+if [ -z "$DS_HOME_DIR" ]
|
|
|
b2bc38 |
+then
|
|
|
b2bc38 |
+ # No DB home set, that's ok
|
|
|
b2bc38 |
+ exit 0
|
|
|
b2bc38 |
+fi
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
+# Now run restorecon
|
|
|
b2bc38 |
+restorecon ${DS_HOME_DIR}
|
|
|
b2bc38 |
diff --git a/wrappers/systemd.template.service.in b/wrappers/systemd.template.service.in
|
|
|
b2bc38 |
index a8c21a9be..4485e0ec0 100644
|
|
|
b2bc38 |
--- a/wrappers/systemd.template.service.in
|
|
|
b2bc38 |
+++ b/wrappers/systemd.template.service.in
|
|
|
b2bc38 |
@@ -14,6 +14,7 @@ EnvironmentFile=-@initconfigdir@/@package_name@
|
|
|
b2bc38 |
EnvironmentFile=-@initconfigdir@/@package_name@-%i
|
|
|
b2bc38 |
PIDFile=/run/@package_name@/slapd-%i.pid
|
|
|
b2bc38 |
ExecStartPre=@libexecdir@/ds_systemd_ask_password_acl @instconfigdir@/slapd-%i/dse.ldif
|
|
|
b2bc38 |
+ExecStartPre=@libexecdir@/ds_selinux_restorecon.sh @instconfigdir@/slapd-%i/dse.ldif
|
|
|
b2bc38 |
ExecStart=@sbindir@/ns-slapd -D @instconfigdir@/slapd-%i -i /run/@package_name@/slapd-%i.pid
|
|
|
b2bc38 |
PrivateTmp=on
|
|
|
b2bc38 |
|
|
|
b2bc38 |
--
|
|
|
b2bc38 |
2.31.1
|
|
|
b2bc38 |
|