|
|
b2bc38 |
From 9c08a053938eb28821fad7d0850c046ef2ed44c4 Mon Sep 17 00:00:00 2001
|
|
|
b2bc38 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
b2bc38 |
Date: Wed, 9 Dec 2020 16:16:30 -0500
|
|
|
b2bc38 |
Subject: [PATCH 05/12] Issue 4092 - systemd-tmpfiles warnings
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Bug Description:
|
|
|
b2bc38 |
|
|
|
b2bc38 |
systemd-tmpfiles warns about legacy paths in our tmpfiles configs.
|
|
|
b2bc38 |
Using /var/run also introduces a race condition, see the following
|
|
|
b2bc38 |
issue https://pagure.io/389-ds-base/issue/47429
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Fix Description:
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Instead of using @localstatedir@/run use @localrundir@ which was
|
|
|
b2bc38 |
introduced in #850.
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Relates: https://github.com/389ds/389-ds-base/issues/766
|
|
|
b2bc38 |
Fixes: https://github.com/389ds/389-ds-base/issues/4092
|
|
|
b2bc38 |
|
|
|
b2bc38 |
Reviewed by: vashirov & firstyear(Thanks!)
|
|
|
b2bc38 |
---
|
|
|
b2bc38 |
Makefile.am | 4 ++--
|
|
|
b2bc38 |
configure.ac | 10 ++++++++--
|
|
|
b2bc38 |
dirsrvtests/tests/suites/basic/basic_test.py | 3 ++-
|
|
|
b2bc38 |
ldap/admin/src/defaults.inf.in | 8 ++++----
|
|
|
b2bc38 |
ldap/servers/snmp/main.c | 8 ++++----
|
|
|
b2bc38 |
src/lib389/lib389/__init__.py | 3 +++
|
|
|
b2bc38 |
src/lib389/lib389/instance/options.py | 7 ++++++-
|
|
|
b2bc38 |
src/lib389/lib389/instance/remove.py | 13 ++++++++-----
|
|
|
b2bc38 |
src/lib389/lib389/instance/setup.py | 10 ++++++++--
|
|
|
b2bc38 |
9 files changed, 45 insertions(+), 21 deletions(-)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
b2bc38 |
index 36434cf17..fc5a6a7d1 100644
|
|
|
b2bc38 |
--- a/Makefile.am
|
|
|
b2bc38 |
+++ b/Makefile.am
|
|
|
b2bc38 |
@@ -141,8 +141,8 @@ PATH_DEFINES = -DLOCALSTATEDIR="\"$(localstatedir)\"" -DSYSCONFDIR="\"$(sysconfd
|
|
|
b2bc38 |
-DLIBDIR="\"$(libdir)\"" -DBINDIR="\"$(bindir)\"" \
|
|
|
b2bc38 |
-DDATADIR="\"$(datadir)\"" -DDOCDIR="\"$(docdir)\"" \
|
|
|
b2bc38 |
-DSBINDIR="\"$(sbindir)\"" -DPLUGINDIR="\"$(serverplugindir)\"" \
|
|
|
b2bc38 |
- -DTEMPLATEDIR="\"$(sampledatadir)\"" -DSYSTEMSCHEMADIR="\"$(systemschemadir)\""
|
|
|
b2bc38 |
-
|
|
|
b2bc38 |
+ -DTEMPLATEDIR="\"$(sampledatadir)\"" -DSYSTEMSCHEMADIR="\"$(systemschemadir)\"" \
|
|
|
b2bc38 |
+ -DLOCALRUNDIR="\"$(localrundir)\""
|
|
|
b2bc38 |
# Now that we have all our defines in place, setup the CPPFLAGS
|
|
|
b2bc38 |
|
|
|
b2bc38 |
# These flags are the "must have" for all components
|
|
|
b2bc38 |
diff --git a/configure.ac b/configure.ac
|
|
|
b2bc38 |
index 61bf35e4a..9845beb7d 100644
|
|
|
b2bc38 |
--- a/configure.ac
|
|
|
b2bc38 |
+++ b/configure.ac
|
|
|
b2bc38 |
@@ -418,7 +418,14 @@ fi
|
|
|
b2bc38 |
|
|
|
b2bc38 |
m4_include(m4/fhs.m4)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
-localrundir='/run'
|
|
|
b2bc38 |
+# /run directory path
|
|
|
b2bc38 |
+AC_ARG_WITH([localrundir],
|
|
|
b2bc38 |
+ AS_HELP_STRING([--with-localrundir=DIR],
|
|
|
b2bc38 |
+ [Runtime data directory]),
|
|
|
b2bc38 |
+ [localrundir=$with_localrundir],
|
|
|
b2bc38 |
+ [localrundir="/run"])
|
|
|
b2bc38 |
+AC_SUBST([localrundir])
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
cockpitdir=/389-console
|
|
|
b2bc38 |
|
|
|
b2bc38 |
# installation paths - by default, we store everything
|
|
|
b2bc38 |
@@ -899,7 +906,6 @@ AC_SUBST(ldaplib_defs)
|
|
|
b2bc38 |
AC_SUBST(ldaptool_bindir)
|
|
|
b2bc38 |
AC_SUBST(ldaptool_opts)
|
|
|
b2bc38 |
AC_SUBST(plainldif_opts)
|
|
|
b2bc38 |
-AC_SUBST(localrundir)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
AC_SUBST(brand)
|
|
|
b2bc38 |
AC_SUBST(capbrand)
|
|
|
b2bc38 |
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py
|
|
|
b2bc38 |
index 41726f073..7e80c443b 100644
|
|
|
b2bc38 |
--- a/dirsrvtests/tests/suites/basic/basic_test.py
|
|
|
b2bc38 |
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
|
|
|
b2bc38 |
@@ -901,7 +901,8 @@ def test_basic_ldapagent(topology_st, import_example_ldif):
|
|
|
b2bc38 |
# Remember, this is *forking*
|
|
|
b2bc38 |
check_output([os.path.join(topology_st.standalone.get_sbin_dir(), 'ldap-agent'), config_file])
|
|
|
b2bc38 |
# First kill any previous agents ....
|
|
|
b2bc38 |
- pidpath = os.path.join(var_dir, 'run/ldap-agent.pid')
|
|
|
b2bc38 |
+ run_dir = topology_st.standalone.get_run_dir()
|
|
|
b2bc38 |
+ pidpath = os.path.join(run_dir, 'ldap-agent.pid')
|
|
|
b2bc38 |
pid = None
|
|
|
b2bc38 |
with open(pidpath, 'r') as pf:
|
|
|
b2bc38 |
pid = pf.readlines()[0].strip()
|
|
|
b2bc38 |
diff --git a/ldap/admin/src/defaults.inf.in b/ldap/admin/src/defaults.inf.in
|
|
|
b2bc38 |
index d5f504591..e02248b89 100644
|
|
|
b2bc38 |
--- a/ldap/admin/src/defaults.inf.in
|
|
|
b2bc38 |
+++ b/ldap/admin/src/defaults.inf.in
|
|
|
b2bc38 |
@@ -35,12 +35,12 @@ sysconf_dir = @sysconfdir@
|
|
|
b2bc38 |
initconfig_dir = @initconfigdir@
|
|
|
b2bc38 |
config_dir = @instconfigdir@/slapd-{instance_name}
|
|
|
b2bc38 |
local_state_dir = @localstatedir@
|
|
|
b2bc38 |
-run_dir = @localstatedir@/run/dirsrv
|
|
|
b2bc38 |
+run_dir = @localrundir@
|
|
|
b2bc38 |
# This is the expected location of ldapi.
|
|
|
b2bc38 |
-ldapi = @localstatedir@/run/slapd-{instance_name}.socket
|
|
|
b2bc38 |
+ldapi = @localrundir@/slapd-{instance_name}.socket
|
|
|
b2bc38 |
+pid_file = @localrundir@/slapd-{instance_name}.pid
|
|
|
b2bc38 |
ldapi_listen = on
|
|
|
b2bc38 |
ldapi_autobind = on
|
|
|
b2bc38 |
-pid_file = @localstatedir@/run/dirsrv/slapd-{instance_name}.pid
|
|
|
b2bc38 |
inst_dir = @serverdir@/slapd-{instance_name}
|
|
|
b2bc38 |
plugin_dir = @serverplugindir@
|
|
|
b2bc38 |
system_schema_dir = @systemschemadir@
|
|
|
b2bc38 |
@@ -54,7 +54,7 @@ root_dn = cn=Directory Manager
|
|
|
b2bc38 |
schema_dir = @instconfigdir@/slapd-{instance_name}/schema
|
|
|
b2bc38 |
cert_dir = @instconfigdir@/slapd-{instance_name}
|
|
|
b2bc38 |
|
|
|
b2bc38 |
-lock_dir = @localstatedir@/lock/dirsrv/slapd-{instance_name}
|
|
|
b2bc38 |
+lock_dir = @localrundir@/lock/dirsrv/slapd-{instance_name}
|
|
|
b2bc38 |
log_dir = @localstatedir@/log/dirsrv/slapd-{instance_name}
|
|
|
b2bc38 |
access_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/access
|
|
|
b2bc38 |
audit_log = @localstatedir@/log/dirsrv/slapd-{instance_name}/audit
|
|
|
b2bc38 |
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
|
|
|
b2bc38 |
index 88a4d532a..e6271a8a9 100644
|
|
|
b2bc38 |
--- a/ldap/servers/snmp/main.c
|
|
|
b2bc38 |
+++ b/ldap/servers/snmp/main.c
|
|
|
b2bc38 |
@@ -287,14 +287,14 @@ load_config(char *conf_path)
|
|
|
b2bc38 |
}
|
|
|
b2bc38 |
|
|
|
b2bc38 |
/* set pidfile path */
|
|
|
b2bc38 |
- if ((pidfile = malloc(strlen(LOCALSTATEDIR) + strlen("/run/") +
|
|
|
b2bc38 |
+ if ((pidfile = malloc(strlen(LOCALRUNDIR) + strlen("/") +
|
|
|
b2bc38 |
strlen(LDAP_AGENT_PIDFILE) + 1)) != NULL) {
|
|
|
b2bc38 |
- strncpy(pidfile, LOCALSTATEDIR, strlen(LOCALSTATEDIR) + 1);
|
|
|
b2bc38 |
+ strncpy(pidfile, LOCALRUNDIR, strlen(LOCALRUNDIR) + 1);
|
|
|
b2bc38 |
/* The above will likely not be NULL terminated, but we need to
|
|
|
b2bc38 |
* be sure that we're properly NULL terminated for the below
|
|
|
b2bc38 |
* strcat() to work properly. */
|
|
|
b2bc38 |
- pidfile[strlen(LOCALSTATEDIR)] = (char)0;
|
|
|
b2bc38 |
- strcat(pidfile, "/run/");
|
|
|
b2bc38 |
+ pidfile[strlen(LOCALRUNDIR)] = (char)0;
|
|
|
b2bc38 |
+ strcat(pidfile, "/");
|
|
|
b2bc38 |
strcat(pidfile, LDAP_AGENT_PIDFILE);
|
|
|
b2bc38 |
} else {
|
|
|
b2bc38 |
printf("ldap-agent: malloc error processing config file\n");
|
|
|
b2bc38 |
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py
|
|
|
b2bc38 |
index e0299c5b4..2a0b83913 100644
|
|
|
b2bc38 |
--- a/src/lib389/lib389/__init__.py
|
|
|
b2bc38 |
+++ b/src/lib389/lib389/__init__.py
|
|
|
b2bc38 |
@@ -1709,6 +1709,9 @@ class DirSrv(SimpleLDAPObject, object):
|
|
|
b2bc38 |
def get_bin_dir(self):
|
|
|
b2bc38 |
return self.ds_paths.bin_dir
|
|
|
b2bc38 |
|
|
|
b2bc38 |
+ def get_run_dir(self):
|
|
|
b2bc38 |
+ return self.ds_paths.run_dir
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
def get_plugin_dir(self):
|
|
|
b2bc38 |
return self.ds_paths.plugin_dir
|
|
|
b2bc38 |
|
|
|
b2bc38 |
diff --git a/src/lib389/lib389/instance/options.py b/src/lib389/lib389/instance/options.py
|
|
|
b2bc38 |
index 4e083618c..d5b95e6df 100644
|
|
|
b2bc38 |
--- a/src/lib389/lib389/instance/options.py
|
|
|
b2bc38 |
+++ b/src/lib389/lib389/instance/options.py
|
|
|
b2bc38 |
@@ -1,5 +1,5 @@
|
|
|
b2bc38 |
# --- BEGIN COPYRIGHT BLOCK ---
|
|
|
b2bc38 |
-# Copyright (C) 2019 Red Hat, Inc.
|
|
|
b2bc38 |
+# Copyright (C) 2021 Red Hat, Inc.
|
|
|
b2bc38 |
# All rights reserved.
|
|
|
b2bc38 |
#
|
|
|
b2bc38 |
# License: GPL (version 3 or any later version).
|
|
|
b2bc38 |
@@ -32,6 +32,7 @@ format_keys = [
|
|
|
b2bc38 |
'backup_dir',
|
|
|
b2bc38 |
'db_dir',
|
|
|
b2bc38 |
'db_home_dir',
|
|
|
b2bc38 |
+ 'ldapi',
|
|
|
b2bc38 |
'ldif_dir',
|
|
|
b2bc38 |
'lock_dir',
|
|
|
b2bc38 |
'log_dir',
|
|
|
b2bc38 |
@@ -233,6 +234,10 @@ class Slapd2Base(Options2):
|
|
|
b2bc38 |
self._helptext['local_state_dir'] = "Sets the location of Directory Server variable data. Only set this parameter in a development environment."
|
|
|
b2bc38 |
self._advanced['local_state_dir'] = True
|
|
|
b2bc38 |
|
|
|
b2bc38 |
+ self._options['ldapi'] = ds_paths.ldapi
|
|
|
b2bc38 |
+ self._type['ldapi'] = str
|
|
|
b2bc38 |
+ self._helptext['ldapi'] = "Sets the location of socket interface of the Directory Server."
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
self._options['lib_dir'] = ds_paths.lib_dir
|
|
|
b2bc38 |
self._type['lib_dir'] = str
|
|
|
b2bc38 |
self._helptext['lib_dir'] = "Sets the location of Directory Server shared libraries. Only set this parameter in a development environment."
|
|
|
b2bc38 |
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
|
|
|
b2bc38 |
index d7bb48ce0..1a35ddc07 100644
|
|
|
b2bc38 |
--- a/src/lib389/lib389/instance/remove.py
|
|
|
b2bc38 |
+++ b/src/lib389/lib389/instance/remove.py
|
|
|
b2bc38 |
@@ -78,13 +78,16 @@ def remove_ds_instance(dirsrv, force=False):
|
|
|
b2bc38 |
|
|
|
b2bc38 |
_log.debug("Found instance marker at %s! Proceeding to remove ..." % dse_ldif_path)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
- # Stop the instance (if running) and now we know it really does exist
|
|
|
b2bc38 |
- # and hopefully have permission to access it ...
|
|
|
b2bc38 |
- _log.debug("Stopping instance %s" % dirsrv.serverid)
|
|
|
b2bc38 |
- dirsrv.stop()
|
|
|
b2bc38 |
-
|
|
|
b2bc38 |
### ANY NEW REMOVAL ACTION MUST BE BELOW THIS LINE!!!
|
|
|
b2bc38 |
|
|
|
b2bc38 |
+ # Remove LDAPI socket file
|
|
|
b2bc38 |
+ ldapi_path = os.path.join(dirsrv.ds_paths.run_dir, "slapd-%s.socket" % dirsrv.serverid)
|
|
|
b2bc38 |
+ if os.path.exists(ldapi_path):
|
|
|
b2bc38 |
+ try:
|
|
|
b2bc38 |
+ os.remove(ldapi_path)
|
|
|
b2bc38 |
+ except OSError as e:
|
|
|
b2bc38 |
+ _log.debug(f"Failed to remove LDAPI socket ({ldapi_path}) Error: {str(e)}")
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
# Remove these paths:
|
|
|
b2bc38 |
# for path in ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',
|
|
|
b2bc38 |
# 'ldif_dir', 'lock_dir', 'log_dir', 'run_dir'):
|
|
|
b2bc38 |
diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py
|
|
|
b2bc38 |
index ab7a2da85..57e7a9fd4 100644
|
|
|
b2bc38 |
--- a/src/lib389/lib389/instance/setup.py
|
|
|
b2bc38 |
+++ b/src/lib389/lib389/instance/setup.py
|
|
|
b2bc38 |
@@ -732,7 +732,10 @@ class SetupDs(object):
|
|
|
b2bc38 |
dse += line.replace('%', '{', 1).replace('%', '}', 1)
|
|
|
b2bc38 |
|
|
|
b2bc38 |
with open(os.path.join(slapd['config_dir'], 'dse.ldif'), 'w') as file_dse:
|
|
|
b2bc38 |
- ldapi_path = os.path.join(slapd['local_state_dir'], "run/slapd-%s.socket" % slapd['instance_name'])
|
|
|
b2bc38 |
+ if os.path.exists(os.path.dirname(slapd['ldapi'])):
|
|
|
b2bc38 |
+ ldapi_path = slapd['ldapi']
|
|
|
b2bc38 |
+ else:
|
|
|
b2bc38 |
+ ldapi_path = os.path.join(slapd['run_dir'], "slapd-%s.socket" % slapd['instance_name'])
|
|
|
b2bc38 |
dse_fmt = dse.format(
|
|
|
b2bc38 |
schema_dir=slapd['schema_dir'],
|
|
|
b2bc38 |
lock_dir=slapd['lock_dir'],
|
|
|
b2bc38 |
@@ -902,10 +905,13 @@ class SetupDs(object):
|
|
|
b2bc38 |
self.log.info("Perform SELinux labeling ...")
|
|
|
b2bc38 |
selinux_paths = ('backup_dir', 'cert_dir', 'config_dir', 'db_dir',
|
|
|
b2bc38 |
'ldif_dir', 'lock_dir', 'log_dir', 'db_home_dir',
|
|
|
b2bc38 |
- 'run_dir', 'schema_dir', 'tmp_dir')
|
|
|
b2bc38 |
+ 'schema_dir', 'tmp_dir')
|
|
|
b2bc38 |
for path in selinux_paths:
|
|
|
b2bc38 |
selinux_restorecon(slapd[path])
|
|
|
b2bc38 |
|
|
|
b2bc38 |
+ # Don't run restorecon on the entire /run directory
|
|
|
b2bc38 |
+ selinux_restorecon(slapd['run_dir'] + '/dirsrv')
|
|
|
b2bc38 |
+
|
|
|
b2bc38 |
selinux_label_port(slapd['port'])
|
|
|
b2bc38 |
|
|
|
b2bc38 |
# Start the server
|
|
|
b2bc38 |
--
|
|
|
b2bc38 |
2.31.1
|
|
|
b2bc38 |
|