>From 369a699ab14988bb5a07c7e5e2ed773f351e7929 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Tue, 7 Jan 2014 15:43:13 -0500
Subject: [PATCH 12/12] BUILD: Simplify enabling journald on installed systems

systemd supports overrides of the standard service file to be placed in
/etc/systemd/system/<service>.service.d/

With this patch, we will install a commented-out override file to /etc
that will instruct the user on how to enable logging to journald.
---
 Makefile.am                      |  9 +++++++++
 configure.ac                     |  5 +++--
 contrib/sssd.spec.in             |  2 ++
 src/conf_macros.m4               | 20 ++++++++++++++++++++
 src/sysv/systemd/journal.conf.in |  7 +++++++
 5 files changed, 41 insertions(+), 2 deletions(-)
 create mode 100644 src/sysv/systemd/journal.conf.in

diff --git a/Makefile.am b/Makefile.am
index 9c155d68c7f452bb02a4da154992fa2fca6af273..77952cfb29697996534dab34c9eb31f2ed13cb7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,6 +3,10 @@ if HAVE_DEVSHM
     extra_distcheck_flags += --with-test-dir=/dev/shm
 endif
 
+if HAVE_SYSTEMD_UNIT
+    extra_distcheck_flags += --with-syslog=journald
+endif
+
 DISTCHECK_CONFIGURE_FLAGS = --with-ldb-lib-dir="$$dc_install_base"/lib/ldb \
                             --enable-all-experimental-features \
                             $(extra_distcheck_flags)
@@ -51,6 +55,7 @@ pipepath = @pipepath@
 mcpath = @mcpath@
 initdir = @initdir@
 systemdunitdir = @systemdunitdir@
+systemdconfdir = @systemdconfdir@/sssd.service.d
 logpath = @logpath@
 pubconfpath = @pubconfpath@
 pkgconfigdir = $(libdir)/pkgconfig
@@ -2036,9 +2041,12 @@ endif
 
 dist_init_SCRIPTS =
 dist_systemdunit_DATA =
+dist_systemdconf_DATA =
 if HAVE_SYSTEMD_UNIT
     dist_systemdunit_DATA += \
         src/sysv/systemd/sssd.service
+    dist_systemdconf_DATA += \
+        src/sysv/systemd/journal.conf
 else
 if HAVE_SUSE
     dist_init_SCRIPTS += \
@@ -2136,6 +2144,7 @@ endif
 
 if HAVE_SYSTEMD_UNIT
 	mkdir -p $(DESTDIR)$(systemdunitdir)
+	mkdir -p $(DESTDIR)$(systemdconfdir)
 else
 	mkdir -p $(DESTDIR)$(initdir)
 endif
diff --git a/configure.ac b/configure.ac
index 93038204fad6f2f52bc741cfcc3aebc9bdecb988..82951396aa8990f15e468b0e919437e7d066e14d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -181,6 +181,7 @@ fi
 WITH_INITSCRIPT
 if test x$initscript = xsystemd; then
     WITH_SYSTEMD_UNIT_DIR
+    WITH_SYSTEMD_CONF_DIR
 fi
 
 PKG_CHECK_MODULES([DBUS],[dbus-1])
@@ -313,8 +314,8 @@ AC_DEFINE_UNQUOTED([ABS_BUILD_DIR], ["$abs_build_dir"], [Absolute path to the bu
 AC_SUBST([abs_builddir], $abs_build_dir)
 
 AC_CONFIG_FILES([Makefile contrib/sssd.spec src/examples/rwtab src/doxy.config
-                 src/sysv/systemd/sssd.service src/sysv/sssd
-                 src/sysv/gentoo/sssd src/sysv/SUSE/sssd
+                 src/sysv/systemd/sssd.service src/sysv/systemd/journal.conf
+                 src/sysv/sssd src/sysv/gentoo/sssd src/sysv/SUSE/sssd
                  po/Makefile.in src/man/Makefile
                  src/providers/ipa/ipa_hbac.pc src/providers/ipa/ipa_hbac.doxy
                  src/lib/idmap/sss_idmap.pc src/lib/idmap/sss_idmap.doxy
diff --git a/contrib/sssd.spec.in b/contrib/sssd.spec.in
index ec75b53a4f73ed40f14cf215bcc9fba849ed7e88..e0830f8f863a9a03b00793b9b324ae0ffebf4188 100644
--- a/contrib/sssd.spec.in
+++ b/contrib/sssd.spec.in
@@ -585,6 +585,8 @@ rm -rf $RPM_BUILD_ROOT
 %attr(750,root,root) %dir %{_var}/log/%{name}
 %attr(711,root,root) %dir %{_sysconfdir}/sssd
 %ghost %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/sssd/sssd.conf
+%attr(755,root,root) %dir %{_sysconfdir}/systemd/system/sssd.service.d
+%config(noreplace) %{_sysconfdir}/systemd/system/sssd.service.d/journal.conf
 %config(noreplace) %{_sysconfdir}/logrotate.d/sssd
 %config(noreplace) %{_sysconfdir}/rwtab.d/sssd
 %dir %{_datadir}/sssd
diff --git a/src/conf_macros.m4 b/src/conf_macros.m4
index 4be819d4a3389dfcf89a0452aab8165c0ec216e4..71118593c81ba81804b077a0a51719b9c71574c7 100644
--- a/src/conf_macros.m4
+++ b/src/conf_macros.m4
@@ -221,6 +221,26 @@ AC_DEFUN([WITH_SYSTEMD_UNIT_DIR],
   AC_SUBST(systemdunitdir)
   ])
 
+dnl A macro to configure the directory to install the systemd unit file
+dnl overrides to
+AC_DEFUN([WITH_SYSTEMD_CONF_DIR],
+  [ AC_ARG_WITH([systemdconfdir],
+                [ AC_HELP_STRING([--with-systemdconfdir=DIR],
+                                 [Directory for systemd service file overrides [Auto]]
+                                ),
+                ],
+               )
+  if test x"$with_systemdconfdir" != x; then
+    systemdconfdir=$with_systemdconfdir
+  else
+    systemdconfdir=$($PKG_CONFIG --variable=systemdsystemconfdir systemd)
+    if test x"$systemdconfdir" = x; then
+      AC_MSG_ERROR([Could not detect systemd config directory])
+    fi
+  fi
+  AC_SUBST(systemdconfdir)
+  ])
+
 AC_DEFUN([WITH_MANPAGES],
   [ AC_ARG_WITH([manpages],
                 [AC_HELP_STRING([--with-manpages],
diff --git a/src/sysv/systemd/journal.conf.in b/src/sysv/systemd/journal.conf.in
new file mode 100644
index 0000000000000000000000000000000000000000..d89325e0872881e3e8485102d9971871101098f3
--- /dev/null
+++ b/src/sysv/systemd/journal.conf.in
@@ -0,0 +1,7 @@
+[Service]
+# Uncomment *both* of the following lines to enable debug logging
+# to go to journald instead of /var/log/sssd. You will need to
+# run 'systemctl daemon-reload' and then restart the SSSD service
+# for this to take effect
+#ExecStart=
+#ExecStart=@sbindir@/sssd -D
-- 
1.8.5.3

