From 0666b520654fb256f833a1bf6f5410867d2dac9c Mon Sep 17 00:00:00 2001 From: William Brown Date: Jan 15 2019 00:03:37 +0000 Subject: Ticket 50123 - with_tmpfiles_d is associated to systemd Description: with_tmpfiles_d does not operate unless it's part of a systemd install. This moves the configure check and operation to within the "with_systemd" code. https://pagure.io/389-ds-base/issue/50123 Reviewed by: vashirov (Thanks!) --- diff --git a/Makefile.am b/Makefile.am index d4c392c..a2af646 100644 --- a/Makefile.am +++ b/Makefile.am @@ -327,6 +327,7 @@ serverincdir = $(includedir)/@serverincdir@ gdbautoloaddir = $(prefixdir)/share/gdb/auto-load$(sbindir) cockpitdir = $(prefixdir)/share/cockpit@cockpitdir@ metainfodir = $(prefixdir)/share/metainfo/389-console +tmpfiles_d = @tmpfiles_d@ # This has to be hardcoded to /lib - $libdir changes between lib/lib64, but # sysctl.d is always in /lib. @@ -2290,7 +2291,7 @@ fixupcmd = sed \ -e 's,@with_fhs_opt\@,@with_fhs_opt@,g' \ -e 's,@with_selinux\@,@with_selinux@,g' \ -e 's,@with_systemd\@,$(WITH_SYSTEMD),g' \ - -e 's,@with_tmpfiles_d\@,@with_tmpfiles_d@,g' \ + -e 's,@tmpfiles_d\@,$(tmpfiles_d),g' \ -e 's,@perlexec\@,@perlexec@,g' \ -e 's,@pythonexec\@,@pythonexec@,g' \ -e 's,@sttyexec\@,@sttyexec@,g' \ diff --git a/configure.ac b/configure.ac index 7b67e0d..db80560 100644 --- a/configure.ac +++ b/configure.ac @@ -501,25 +501,6 @@ schemadir=/$PACKAGE_NAME/schema defaultuser=dirsrv defaultgroup=dirsrv -if test -z "$with_tmpfiles_d" ; then - if test -d $sysconfdir/tmpfiles.d ; then - with_tmpfiles_d='$(sysconfdir)/tmpfiles.d' - fi -fi -AC_MSG_CHECKING(for --with-tmpfiles-d) -AC_ARG_WITH(tmpfiles-d, - AS_HELP_STRING([--with-tmpfiles-d=PATH], - [system uses tmpfiles.d to handle temp files/dirs (default: $with_tmpfiles_d)]) -) -if test "$with_tmpfiles_d" = yes ; then - AC_MSG_ERROR([You must specify --with-tmpfiles-d=/full/path/to/tmpfiles.d directory]) -elif test "$with_tmpfiles_d" = no ; then - with_tmpfiles_d= -else - AC_MSG_RESULT([$with_tmpfiles_d]) -fi -AC_SUBST(with_tmpfiles_d) - AC_MSG_CHECKING(for --with-perldir) AC_ARG_WITH([perldir], AS_HELP_STRING([--with-perldir=PATH], diff --git a/ldap/admin/src/defaults.inf.in b/ldap/admin/src/defaults.inf.in index ae847e9..f749295 100644 --- a/ldap/admin/src/defaults.inf.in +++ b/ldap/admin/src/defaults.inf.in @@ -1,12 +1,13 @@ ; --- BEGIN COPYRIGHT BLOCK --- ; Copyright (C) 2016 Red Hat, Inc. +; Copyright (C) 2019 William Brown ; All rights reserved. ; ; License: GPL (version 3 or any later version). ; See LICENSE for details. ; --- END COPYRIGHT BLOCK --- -; Author: firstyear at redhat.com +; Author: wbrown at suse.de ; This is a set of default paths that tools consuming DS should search ; for paths. This is the foundation of the version 2 ds setup inf @@ -40,7 +41,7 @@ pid_file = @localstatedir@/run/dirsrv/slapd-{instance_name}.pid inst_dir = @serverdir@/slapd-{instance_name} plugin_dir = @serverplugindir@ system_schema_dir = @systemschemadir@ -tmpfiles_d = @with_tmpfiles_d@ +tmpfiles_d = @tmpfiles_d@ ; These values can be altered in an installation of ds user = dirsrv diff --git a/m4/systemd.m4 b/m4/systemd.m4 index 38e39e7..42bcea1 100644 --- a/m4/systemd.m4 +++ b/m4/systemd.m4 @@ -114,6 +114,24 @@ if test "$with_systemd" = yes; then fi AC_SUBST(with_systemdgroupname) + if test -z "$with_tmpfiles_d" ; then + if test -d $sysconfdir/tmpfiles.d ; then + tmpfiles_d='$(sysconfdir)/tmpfiles.d' + fi + fi + AC_MSG_CHECKING(for --with-tmpfiles-d) + AC_ARG_WITH(tmpfiles-d, + AS_HELP_STRING([--with-tmpfiles-d=PATH], + [system uses tmpfiles.d to handle temp files/dirs (default: $tmpfiles_d)]) + ) + if test "$with_tmpfiles_d" = yes ; then + AC_MSG_ERROR([You must specify --with-tmpfiles-d=/full/path/to/tmpfiles.d directory]) + elif test "$with_tmpfiles_d" = no ; then + tmpfiles_d= + else + tmpfiles_d=$with_tmpfiles_d + AC_MSG_RESULT([$tmpfiles_d]) + fi fi # End of with_systemd @@ -128,4 +146,6 @@ AC_SUBST(systemd_inc) AC_SUBST(systemd_lib) AC_SUBST(systemd_defs) +AC_SUBST(tmpfiles_d) + diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 7a39603..0b08ef2 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -1222,11 +1222,13 @@ class DirSrv(SimpleLDAPObject, object): env.update(os.environ) output = None try: - output = subprocess.check_output(["%s/ns-slapd" % self.get_sbin_dir(), - "-D", - self.ds_paths.config_dir, - "-i", - self.ds_paths.pid_file], env=env, stderr=subprocess.STDOUT) + cmd = ["%s/ns-slapd" % self.get_sbin_dir(), + "-D", + self.ds_paths.config_dir, + "-i", + self.ds_paths.pid_file], + self.log.debug("DEBUG: starting with %s" % cmd) + output = subprocess.check_output(*cmd, env=env, stderr=subprocess.STDOUT) except subprocess.CalledProcessError: self.log.error(output) count = timeout diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py index c01eb77..931ed05 100644 --- a/src/lib389/lib389/instance/setup.py +++ b/src/lib389/lib389/instance/setup.py @@ -718,15 +718,16 @@ class SetupDs(object): "enable", "dirsrv@%s" % slapd['instance_name']]) - # Setup tmpfiles_d - tmpfile_d = ds_paths.tmpfiles_d + "/dirsrv-" + slapd['instance_name'] + ".conf" - with open(tmpfile_d, "w") as TMPFILE_D: - TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['run_dir'], slapd['user'], slapd['group'])) - TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['lock_dir'].replace("slapd-" + slapd['instance_name'], ""), - slapd['user'], slapd['group'])) - TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['lock_dir'], slapd['user'], slapd['group'])) + # Setup tmpfiles_d + tmpfile_d = ds_paths.tmpfiles_d + "/dirsrv-" + slapd['instance_name'] + ".conf" + with open(tmpfile_d, "w") as TMPFILE_D: + TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['run_dir'], slapd['user'], slapd['group'])) + TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['lock_dir'].replace("slapd-" + slapd['instance_name'], ""), + slapd['user'], slapd['group'])) + TMPFILE_D.write("d {} 0770 {} {}\n".format(slapd['lock_dir'], slapd['user'], slapd['group'])) # Else we need to detect other init scripts? + # WB: No, we just install and assume that docker will start us ... # Bind sockets to our type?