andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0006-Issue-4973-installer-changes-permissions-on-run.patch

b2bc38
From b4a3b88faeafa6aa197d88ee84e4b2dbadd37ace Mon Sep 17 00:00:00 2001
b2bc38
From: Mark Reynolds <mreynolds@redhat.com>
b2bc38
Date: Mon, 1 Nov 2021 10:42:27 -0400
b2bc38
Subject: [PATCH 06/12] Issue 4973 - installer changes permissions on /run
b2bc38
b2bc38
Description:  There was a regression when we switched over to using /run
b2bc38
              that caused the installer to try and create /run which
b2bc38
              caused the ownership to change.  Fixed this by changing
b2bc38
              the "run_dir" to /run/dirsrv
b2bc38
b2bc38
relates: https://github.com/389ds/389-ds-base/issues/4973
b2bc38
b2bc38
Reviewed by: jchapman(Thanks!)
b2bc38
---
b2bc38
 ldap/admin/src/defaults.inf.in       |  2 +-
b2bc38
 src/lib389/lib389/instance/remove.py | 10 +---------
b2bc38
 src/lib389/lib389/instance/setup.py  | 13 +++----------
b2bc38
 3 files changed, 5 insertions(+), 20 deletions(-)
b2bc38
b2bc38
diff --git a/ldap/admin/src/defaults.inf.in b/ldap/admin/src/defaults.inf.in
b2bc38
index e02248b89..92b93d695 100644
b2bc38
--- a/ldap/admin/src/defaults.inf.in
b2bc38
+++ b/ldap/admin/src/defaults.inf.in
b2bc38
@@ -35,7 +35,7 @@ sysconf_dir = @sysconfdir@
b2bc38
 initconfig_dir = @initconfigdir@
b2bc38
 config_dir = @instconfigdir@/slapd-{instance_name}
b2bc38
 local_state_dir = @localstatedir@
b2bc38
-run_dir = @localrundir@
b2bc38
+run_dir = @localrundir@/dirsrv
b2bc38
 # This is the expected location of ldapi.
b2bc38
 ldapi = @localrundir@/slapd-{instance_name}.socket
b2bc38
 pid_file = @localrundir@/slapd-{instance_name}.pid
b2bc38
diff --git a/src/lib389/lib389/instance/remove.py b/src/lib389/lib389/instance/remove.py
b2bc38
index 1a35ddc07..e96db3896 100644
b2bc38
--- a/src/lib389/lib389/instance/remove.py
b2bc38
+++ b/src/lib389/lib389/instance/remove.py
b2bc38
@@ -52,9 +52,9 @@ def remove_ds_instance(dirsrv, force=False):
b2bc38
     remove_paths['ldif_dir'] = dirsrv.ds_paths.ldif_dir
b2bc38
     remove_paths['lock_dir'] = dirsrv.ds_paths.lock_dir
b2bc38
     remove_paths['log_dir'] = dirsrv.ds_paths.log_dir
b2bc38
-    # remove_paths['run_dir'] = dirsrv.ds_paths.run_dir
b2bc38
     remove_paths['inst_dir'] = dirsrv.ds_paths.inst_dir
b2bc38
     remove_paths['etc_sysconfig'] = "%s/sysconfig/dirsrv-%s" % (dirsrv.ds_paths.sysconf_dir, dirsrv.serverid)
b2bc38
+    remove_paths['ldapi'] = dirsrv.ds_paths.ldapi
b2bc38
 
b2bc38
     tmpfiles_d_path = dirsrv.ds_paths.tmpfiles_d + "/dirsrv-" + dirsrv.serverid + ".conf"
b2bc38
 
b2bc38
@@ -80,14 +80,6 @@ def remove_ds_instance(dirsrv, force=False):
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 57e7a9fd4..be6854af8 100644
b2bc38
--- a/src/lib389/lib389/instance/setup.py
b2bc38
+++ b/src/lib389/lib389/instance/setup.py
b2bc38
@@ -732,10 +732,6 @@ 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
-            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
@@ -759,7 +755,7 @@ class SetupDs(object):
b2bc38
                 db_dir=slapd['db_dir'],
b2bc38
                 db_home_dir=slapd['db_home_dir'],
b2bc38
                 ldapi_enabled="on",
b2bc38
-                ldapi=ldapi_path,
b2bc38
+                ldapi=slapd['ldapi'],
b2bc38
                 ldapi_autobind="on",
b2bc38
             )
b2bc38
             file_dse.write(dse_fmt)
b2bc38
@@ -861,7 +857,7 @@ class SetupDs(object):
b2bc38
             SER_ROOT_PW: self._raw_secure_password,
b2bc38
             SER_DEPLOYED_DIR: slapd['prefix'],
b2bc38
             SER_LDAPI_ENABLED: 'on',
b2bc38
-            SER_LDAPI_SOCKET: ldapi_path,
b2bc38
+            SER_LDAPI_SOCKET: slapd['ldapi'],
b2bc38
             SER_LDAPI_AUTOBIND: 'on'
b2bc38
         }
b2bc38
 
b2bc38
@@ -905,13 +901,10 @@ 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
-                             'schema_dir', 'tmp_dir')
b2bc38
+                             'run_dir', '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