Blame SOURCES/autofs-5.1.4-use-systemd-sd_notify-at-startup.patch

7f6688
autofs-5.1.4 - use systemd sd_notify() at startup
7f6688
7f6688
From: Ian Kent <raven@themaw.net>
7f6688
7f6688
autofs needs to ensure statd is started before any NFS mounts
7f6688
are attempted.
7f6688
7f6688
When starting the statd service with the autofs service the statd
7f6688
service will trigger a restart of the autofs service during its
7f6688
start up. Sometimes this can happen during the automount start up
7f6688
itself.
7f6688
7f6688
When this happens it causes systemd to become confused and remove
7f6688
the pid file created by automount leaving systemd thinking the
7f6688
autofs service had failed start up when it was actually running.
7f6688
7f6688
It was recommened that autofs be changed to a "Type=notify" service
7f6688
to avoid this. Using this a pid file is no longer needed and is now
7f6688
not used.
7f6688
7f6688
Signed-off-by: Ian Kent <raven@themaw.net>
7f6688
---
7f6688
 CHANGELOG                 |    1 
7f6688
 Makefile.conf.in          |    3 
7f6688
 aclocal.m4                |    2 
7f6688
 autofs.spec               |    1 
7f6688
 configure                 |  577 +++++++++++++++++++++++++++++++++++-----------
7f6688
 configure.in              |   10 
7f6688
 daemon/Makefile           |    5 
7f6688
 daemon/automount.c        |   83 ++++--
7f6688
 samples/autofs.service.in |    5 
7f6688
 9 files changed, 529 insertions(+), 158 deletions(-)
7f6688
7f6688
--- autofs-5.0.7.orig/CHANGELOG
7f6688
+++ autofs-5.0.7/CHANGELOG
7f6688
@@ -300,6 +300,7 @@
7f6688
 - fix fd leak in rpc_do_create_client().
7f6688
 - add man page note about extra slashes in paths.
7f6688
 - add units After line to include statd service.
7f6688
+- use systemd sd_notify() at startup.
7f6688
 
7f6688
 25/07/2012 autofs-5.0.7
7f6688
 =======================
7f6688
--- autofs-5.0.7.orig/Makefile.conf.in
7f6688
+++ autofs-5.0.7/Makefile.conf.in
7f6688
@@ -15,6 +15,9 @@ DAEMON_LDFLAGS = @DAEMON_LDFLAGS@
7f6688
 LIBNSL    = @LIBNSL@
7f6688
 LIBRESOLV = @LIBRESOLV@
7f6688
 
7f6688
+SYSTEMD = @WITH_SYSTEMD@
7f6688
+LIBSYSTEMD = @systemd_LIBS@
7f6688
+
7f6688
 # Hesiod support: yes (1) no (0)
7f6688
 HESIOD = @HAVE_HESIOD@
7f6688
 LIBHESIOD = @LIBHESIOD@
7f6688
--- autofs-5.0.7.orig/autofs.spec
7f6688
+++ autofs-5.0.7/autofs.spec
7f6688
@@ -28,6 +28,7 @@ Source: ftp://ftp.kernel.org/pub/linux/d
7f6688
 Buildroot: %{_tmppath}/%{name}-tmp
7f6688
 %if %{with_systemd}
7f6688
 BuildRequires: systemd-units
7f6688
+BuildRequires: systemd-devel
7f6688
 %endif
7f6688
 %if %{with_libtirpc}
7f6688
 BuildRequires: libtirpc-devel
7f6688
--- autofs-5.0.7.orig/configure.in
7f6688
+++ autofs-5.0.7/configure.in
7f6688
@@ -11,6 +11,9 @@ define([AC_CACHE_LOAD], )dnl
7f6688
 define([AC_CACHE_SAVE], )dnl
7f6688
 AC_INIT(.autofs-5.0.7)
7f6688
 
7f6688
+# for pkg-config macros
7f6688
+m4_include([/usr/share/aclocal/pkg.m4])
7f6688
+
7f6688
 #
7f6688
 # autofs installs by default in /usr
7f6688
 #
7f6688
@@ -45,6 +48,7 @@ AF_INIT_D()
7f6688
 AC_SUBST(initdir)
7f6688
 AF_PID_D()
7f6688
 AC_SUBST(piddir)
7f6688
+PKG_PROG_PKG_CONFIG()
7f6688
 
7f6688
 #
7f6688
 # Check for systemd unit files direectory exists if unit file installation
7f6688
@@ -52,6 +56,12 @@ AC_SUBST(piddir)
7f6688
 #
7f6688
 AF_WITH_SYSTEMD()
7f6688
 AC_SUBST(systemddir)
7f6688
+AC_SUBST(WITH_SYSTEMD)
7f6688
+PKG_CHECK_MODULES([systemd],[libsystemd],,
7f6688
+[
7f6688
+  AC_CHECK_LIB(systemd, sm_notify, systemd_LIBS="-lsystemd")
7f6688
+  AC_SUBST(systemd_LIBS)
7f6688
+])
7f6688
 
7f6688
 #
7f6688
 # Location of system config script directory?
7f6688
--- autofs-5.0.7.orig/daemon/Makefile
7f6688
+++ autofs-5.0.7/daemon/Makefile
7f6688
@@ -22,6 +22,11 @@ CFLAGS += -DVERSION_STRING=\"$(version)\
7f6688
 LDFLAGS += -rdynamic
7f6688
 LIBS = -ldl
7f6688
 
7f6688
+ifeq ($(SYSTEMD), 1)
7f6688
+    CFLAGS += -DWITH_SYSTEMD
7f6688
+    LIBS += $(LIBSYSTEMD)
7f6688
+endif
7f6688
+
7f6688
 ifeq ($(LDAP), 1)
7f6688
     CFLAGS += $(XML_FLAGS)
7f6688
     LIBS += $(XML_LIBS)
7f6688
--- autofs-5.0.7.orig/daemon/automount.c
7f6688
+++ autofs-5.0.7/daemon/automount.c
7f6688
@@ -36,6 +36,9 @@
7f6688
 #include <dirent.h>
7f6688
 #include <sys/vfs.h>
7f6688
 #include <sys/utsname.h>
7f6688
+#ifdef WITH_SYSTEMD
7f6688
+#include <systemd/sd-daemon.h>
7f6688
+#endif
7f6688
 
7f6688
 #include "automount.h"
7f6688
 #if defined(LIBXML2_WORKAROUND) || defined(TIRPC_WORKAROUND)
7f6688
@@ -65,7 +68,7 @@ unsigned int global_selection_options;
7f6688
 long global_negative_timeout = -1;
7f6688
 int do_force_unlink = 0;		/* Forceably unlink mount tree at startup */
7f6688
 
7f6688
-static int start_pipefd[2];
7f6688
+static int start_pipefd[2] = {-1, -1};
7f6688
 static int st_stat = 1;
7f6688
 static int *pst_stat = &st_stat;
7f6688
 static pthread_t state_mach_thid;
7f6688
@@ -1208,12 +1211,6 @@ static void become_daemon(unsigned foreg
7f6688
 		exit(0);
7f6688
 	}
7f6688
 
7f6688
-	if (open_pipe(start_pipefd) < 0) {
7f6688
-		fprintf(stderr, "%s: failed to create start_pipefd.\n",
7f6688
-			program);
7f6688
-		exit(0);
7f6688
-	}
7f6688
-
7f6688
 	/* Detach from foreground process */
7f6688
 	if (foreground) {
7f6688
 		if (daemon_check && !aquire_flag_file()) {
7f6688
@@ -1223,6 +1220,12 @@ static void become_daemon(unsigned foreg
7f6688
 		}
7f6688
 		log_to_stderr();
7f6688
 	} else {
7f6688
+		if (open_pipe(start_pipefd) < 0) {
7f6688
+			fprintf(stderr, "%s: failed to create start_pipefd.\n",
7f6688
+				program);
7f6688
+			exit(0);
7f6688
+		}
7f6688
+
7f6688
 		pid = fork();
7f6688
 		if (pid > 0) {
7f6688
 			close(start_pipefd[1]);
7f6688
@@ -2455,8 +2458,10 @@ int main(int argc, char *argv[])
7f6688
 	if (pthread_attr_init(&th_attr)) {
7f6688
 		logerr("%s: failed to init thread attribute struct!",
7f6688
 		     program);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2465,8 +2470,10 @@ int main(int argc, char *argv[])
7f6688
 	if (pthread_attr_init(&th_attr_detached)) {
7f6688
 		logerr("%s: failed to init thread attribute struct!",
7f6688
 		     program);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2476,8 +2483,10 @@ int main(int argc, char *argv[])
7f6688
 			&th_attr_detached, PTHREAD_CREATE_DETACHED)) {
7f6688
 		logerr("%s: failed to set detached thread attribute!",
7f6688
 		     program);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2488,8 +2497,10 @@ int main(int argc, char *argv[])
7f6688
 			&th_attr_detached, detached_thread_stack_size)) {
7f6688
 		logerr("%s: failed to set stack size thread attribute!",
7f6688
 		       program);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2500,8 +2511,10 @@ int main(int argc, char *argv[])
7f6688
 			&th_attr_detached, &detached_thread_stack_size)) {
7f6688
 		logerr("%s: failed to get detached thread stack size!",
7f6688
 		       program);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2518,8 +2531,10 @@ int main(int argc, char *argv[])
7f6688
 		logerr("%s: failed to create thread data key for std env vars!",
7f6688
 		       program);
7f6688
 		master_kill(master_list);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2530,8 +2545,10 @@ int main(int argc, char *argv[])
7f6688
 		logerr("%s: failed to create thread data key for attempt ID!",
7f6688
 		       program);
7f6688
 		master_kill(master_list);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2542,8 +2559,10 @@ int main(int argc, char *argv[])
7f6688
 	if (!alarm_start_handler()) {
7f6688
 		logerr("%s: failed to create alarm handler thread!", program);
7f6688
 		master_kill(master_list);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2552,8 +2571,10 @@ int main(int argc, char *argv[])
7f6688
 	if (!st_start_handler()) {
7f6688
 		logerr("%s: failed to create FSM handler thread!", program);
7f6688
 		master_kill(master_list);
7f6688
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-		close(start_pipefd[1]);
7f6688
+		if (start_pipefd[1] != -1) {
7f6688
+			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+			close(start_pipefd[1]);
7f6688
+		}
7f6688
 		release_flag_file();
7f6688
 		macro_free_global_table();
7f6688
 		exit(1);
7f6688
@@ -2599,9 +2620,15 @@ int main(int argc, char *argv[])
7f6688
 	 */
7f6688
 	do_force_unlink = 0;
7f6688
 
7f6688
-	st_stat = 0;
7f6688
-	res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
-	close(start_pipefd[1]);
7f6688
+	if (start_pipefd[1] != -1) {
7f6688
+		st_stat = 0;
7f6688
+		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
7f6688
+		close(start_pipefd[1]);
7f6688
+	}
7f6688
+
7f6688
+#ifdef WITH_SYSTEMD
7f6688
+	sd_notify(1, "READY=1");
7f6688
+#endif
7f6688
 
7f6688
 	state_mach_thid = pthread_self();
7f6688
 	statemachine(NULL);
7f6688
--- autofs-5.0.7.orig/samples/autofs.service.in
7f6688
+++ autofs-5.0.7/samples/autofs.service.in
7f6688
@@ -4,10 +4,9 @@ After=network.target ypbind.service sssd
7f6688
 Wants=network-online.target rpc-statd.service rpcbind.service
7f6688
 
7f6688
 [Service]
7f6688
-Type=forking
7f6688
-PIDFile=@@autofspiddir@@/autofs.pid
7f6688
+Type=notify
7f6688
 EnvironmentFile=-@@autofsconfdir@@/autofs
7f6688
-ExecStart=@@sbindir@@/automount $OPTIONS --pid-file @@autofspiddir@@/autofs.pid
7f6688
+ExecStart=@@sbindir@@/automount $OPTIONS --foreground --dont-check-daemon
7f6688
 ExecReload=/usr/bin/kill -HUP $MAINPID
7f6688
 KillMode=process
7f6688
 TimeoutSec=180
7f6688
--- autofs-5.0.7.orig/configure
7f6688
+++ autofs-5.0.7/configure
7f6688
@@ -672,6 +672,10 @@ HAVE_MOUNT
7f6688
 MOUNT
7f6688
 DMALLOCLIB
7f6688
 TIRPCLIB
7f6688
+flagdir
7f6688
+fifodir
7f6688
+mapdir
7f6688
+confdir
7f6688
 OBJEXT
7f6688
 EXEEXT
7f6688
 ac_ct_CC
7f6688
@@ -679,11 +683,13 @@ CPPFLAGS
7f6688
 LDFLAGS
7f6688
 CFLAGS
7f6688
 CC
7f6688
-flagdir
7f6688
-fifodir
7f6688
-mapdir
7f6688
-confdir
7f6688
+systemd_LIBS
7f6688
+systemd_CFLAGS
7f6688
+WITH_SYSTEMD
7f6688
 systemddir
7f6688
+PKG_CONFIG_LIBDIR
7f6688
+PKG_CONFIG_PATH
7f6688
+PKG_CONFIG
7f6688
 piddir
7f6688
 initdir
7f6688
 target_alias
7f6688
@@ -748,6 +754,11 @@ enable_limit_getgrgid_size
7f6688
       ac_precious_vars='build_alias
7f6688
 host_alias
7f6688
 target_alias
7f6688
+PKG_CONFIG
7f6688
+PKG_CONFIG_PATH
7f6688
+PKG_CONFIG_LIBDIR
7f6688
+systemd_CFLAGS
7f6688
+systemd_LIBS
7f6688
 CC
7f6688
 CFLAGS
7f6688
 LDFLAGS
7f6688
@@ -1388,6 +1399,15 @@ Optional Packages:
7f6688
   --with-sasl=DIR	  enable SASL support for LDAP maps (libs and includes in DIR)
7f6688
 
7f6688
 Some influential environment variables:
7f6688
+  PKG_CONFIG  path to pkg-config utility
7f6688
+  PKG_CONFIG_PATH
7f6688
+              directories to add to pkg-config's search path
7f6688
+  PKG_CONFIG_LIBDIR
7f6688
+              path overriding pkg-config's built-in search path
7f6688
+  systemd_CFLAGS
7f6688
+              C compiler flags for systemd, overriding pkg-config
7f6688
+  systemd_LIBS
7f6688
+              linker flags for systemd, overriding pkg-config
7f6688
   CC          C compiler command
7f6688
   CFLAGS      C compiler flags
7f6688
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
7f6688
@@ -2161,6 +2181,31 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
7f6688
 
7f6688
 
7f6688
 
7f6688
+# for pkg-config macros
7f6688
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
7f6688
+# serial 11 (pkg-config-0.29.1)
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
 #
7f6688
 # autofs installs by default in /usr
7f6688
 #
7f6688
@@ -2236,6 +2281,126 @@ if test -z "$piddir"; then
7f6688
 fi
7f6688
 
7f6688
 
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+
7f6688
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
7f6688
+	if test -n "$ac_tool_prefix"; then
7f6688
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
7f6688
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
7f6688
+$as_echo_n "checking for $ac_word... " >&6; }
7f6688
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
7f6688
+  $as_echo_n "(cached) " >&6
7f6688
+else
7f6688
+  case $PKG_CONFIG in
7f6688
+  [\\/]* | ?:[\\/]*)
7f6688
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
7f6688
+  ;;
7f6688
+  *)
7f6688
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7f6688
+for as_dir in $PATH
7f6688
+do
7f6688
+  IFS=$as_save_IFS
7f6688
+  test -z "$as_dir" && as_dir=.
7f6688
+    for ac_exec_ext in '' $ac_executable_extensions; do
7f6688
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
7f6688
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
7f6688
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
7f6688
+    break 2
7f6688
+  fi
7f6688
+done
7f6688
+  done
7f6688
+IFS=$as_save_IFS
7f6688
+
7f6688
+  ;;
7f6688
+esac
7f6688
+fi
7f6688
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
7f6688
+if test -n "$PKG_CONFIG"; then
7f6688
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
7f6688
+$as_echo "$PKG_CONFIG" >&6; }
7f6688
+else
7f6688
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7f6688
+$as_echo "no" >&6; }
7f6688
+fi
7f6688
+
7f6688
+
7f6688
+fi
7f6688
+if test -z "$ac_cv_path_PKG_CONFIG"; then
7f6688
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
7f6688
+  # Extract the first word of "pkg-config", so it can be a program name with args.
7f6688
+set dummy pkg-config; ac_word=$2
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
7f6688
+$as_echo_n "checking for $ac_word... " >&6; }
7f6688
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
7f6688
+  $as_echo_n "(cached) " >&6
7f6688
+else
7f6688
+  case $ac_pt_PKG_CONFIG in
7f6688
+  [\\/]* | ?:[\\/]*)
7f6688
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
7f6688
+  ;;
7f6688
+  *)
7f6688
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7f6688
+for as_dir in $PATH
7f6688
+do
7f6688
+  IFS=$as_save_IFS
7f6688
+  test -z "$as_dir" && as_dir=.
7f6688
+    for ac_exec_ext in '' $ac_executable_extensions; do
7f6688
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
7f6688
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
7f6688
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
7f6688
+    break 2
7f6688
+  fi
7f6688
+done
7f6688
+  done
7f6688
+IFS=$as_save_IFS
7f6688
+
7f6688
+  ;;
7f6688
+esac
7f6688
+fi
7f6688
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
7f6688
+if test -n "$ac_pt_PKG_CONFIG"; then
7f6688
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
7f6688
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
7f6688
+else
7f6688
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7f6688
+$as_echo "no" >&6; }
7f6688
+fi
7f6688
+
7f6688
+  if test "x$ac_pt_PKG_CONFIG" = x; then
7f6688
+    PKG_CONFIG=""
7f6688
+  else
7f6688
+    case $cross_compiling:$ac_tool_warned in
7f6688
+yes:)
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
7f6688
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
7f6688
+ac_tool_warned=yes ;;
7f6688
+esac
7f6688
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
7f6688
+  fi
7f6688
+else
7f6688
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
7f6688
+fi
7f6688
+
7f6688
+fi
7f6688
+if test -n "$PKG_CONFIG"; then
7f6688
+	_pkg_min_version=0.9.0
7f6688
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
7f6688
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
7f6688
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
7f6688
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7f6688
+$as_echo "yes" >&6; }
7f6688
+	else
7f6688
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7f6688
+$as_echo "no" >&6; }
7f6688
+		PKG_CONFIG=""
7f6688
+	fi
7f6688
+fi
7f6688
+
7f6688
 #
7f6688
 # Check for systemd unit files direectory exists if unit file installation
7f6688
 # is requested
7f6688
@@ -2255,9 +2420,11 @@ $as_echo_n "checking location of the sys
7f6688
       fi
7f6688
     done
7f6688
   fi
7f6688
+  WITH_SYSTEMD=0
7f6688
   if test -n "$systemddir"; then
7f6688
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $systemddir" >&5
7f6688
 $as_echo "$systemddir" >&6; }
7f6688
+    WITH_SYSTEMD=1
7f6688
   else
7f6688
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
7f6688
 $as_echo "not found" >&6; }
7f6688
@@ -2268,129 +2435,6 @@ fi
7f6688
 
7f6688
 
7f6688
 
7f6688
-#
7f6688
-# Location of system config script directory?
7f6688
-#
7f6688
-if test -z "$confdir"; then
7f6688
-  for conf_d in /etc/sysconfig /etc/defaults /etc/conf.d /etc/default; do
7f6688
-    if test -z "$confdir"; then
7f6688
-      if test -d "$conf_d"; then
7f6688
-	confdir="$conf_d"
7f6688
-      fi
7f6688
-    fi
7f6688
-  done
7f6688
-fi
7f6688
-
7f6688
-# Check whether --with-confdir was given.
7f6688
-if test "${with_confdir+set}" = set; then :
7f6688
-  withval=$with_confdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
-	then
7f6688
-		:
7f6688
-	else
7f6688
-		confdir="${withval}"
7f6688
-	fi
7f6688
-
7f6688
-fi
7f6688
-
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs configuration file directory" >&5
7f6688
-$as_echo_n "checking for autofs configuration file directory... " >&6; }
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $confdir" >&5
7f6688
-$as_echo "$confdir" >&6; }
7f6688
-
7f6688
-
7f6688
-#
7f6688
-# The user can specify --with-mapsdir=PATH to specify autofs maps go
7f6688
-#
7f6688
-if test -z "$mapdir"; then
7f6688
-  for map_d in /etc/autofs /etc; do
7f6688
-    if test -z "$mapdir"; then
7f6688
-      if test -d "$map_d"; then
7f6688
-	mapdir="$map_d"
7f6688
-      fi
7f6688
-    fi
7f6688
-  done
7f6688
-fi
7f6688
-
7f6688
-# Check whether --with-mapdir was given.
7f6688
-if test "${with_mapdir+set}" = set; then :
7f6688
-  withval=$with_mapdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
-	then
7f6688
-		:
7f6688
-	else
7f6688
-		mapdir="${withval}"
7f6688
-	fi
7f6688
-
7f6688
-fi
7f6688
-
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs maps directory" >&5
7f6688
-$as_echo_n "checking for autofs maps directory... " >&6; }
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $mapdir" >&5
7f6688
-$as_echo "$mapdir" >&6; }
7f6688
-
7f6688
-
7f6688
-#
7f6688
-# The user can specify --with-fifodir=PATH to specify where autofs fifos go
7f6688
-#
7f6688
-if test -z "$fifodir"; then
7f6688
-  for fifo_d in /run /var/run /tmp; do
7f6688
-    if test -z "$fifodir"; then
7f6688
-      if test -d "$fifo_d"; then
7f6688
-        fifodir="$fifo_d"
7f6688
-      fi
7f6688
-    fi
7f6688
-  done
7f6688
-fi
7f6688
-
7f6688
-# Check whether --with-fifodir was given.
7f6688
-if test "${with_fifodir+set}" = set; then :
7f6688
-  withval=$with_fifodir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
-	then
7f6688
-		:
7f6688
-	else
7f6688
-		fifodir="${withval}"
7f6688
-	fi
7f6688
-
7f6688
-fi
7f6688
-
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs fifos directory" >&5
7f6688
-$as_echo_n "checking for autofs fifos directory... " >&6; }
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fifodir" >&5
7f6688
-$as_echo "$fifodir" >&6; }
7f6688
-
7f6688
-
7f6688
-#
7f6688
-# The user can specify --with-flagdir=PATH to specify where autofs flag file goes
7f6688
-#
7f6688
-if test -z "$flagdir"; then
7f6688
-  for flag_d in /run /var/run /tmp; do
7f6688
-    if test -z "$flagdir"; then
7f6688
-      if test -d "$flag_d"; then
7f6688
-        flagdir="$flag_d"
7f6688
-      fi
7f6688
-    fi
7f6688
-  done
7f6688
-fi
7f6688
-
7f6688
-# Check whether --with-flagdir was given.
7f6688
-if test "${with_flagdir+set}" = set; then :
7f6688
-  withval=$with_flagdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
-	then
7f6688
-		:
7f6688
-	else
7f6688
-		filagdir="${withval}"
7f6688
-	fi
7f6688
-
7f6688
-fi
7f6688
-
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs flag file directory" >&5
7f6688
-$as_echo_n "checking for autofs flag file directory... " >&6; }
7f6688
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flagdir" >&5
7f6688
-$as_echo "$flagdir" >&6; }
7f6688
-
7f6688
-
7f6688
-#
7f6688
-# Use libtirpc
7f6688
-#
7f6688
 ac_ext=c
7f6688
 ac_cpp='$CPP $CPPFLAGS'
7f6688
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
7f6688
@@ -3181,6 +3225,285 @@ ac_link='$CC -o conftest$ac_exeext $CFLA
7f6688
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
7f6688
 
7f6688
 
7f6688
+
7f6688
+pkg_failed=no
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for systemd" >&5
7f6688
+$as_echo_n "checking for systemd... " >&6; }
7f6688
+
7f6688
+if test -n "$systemd_CFLAGS"; then
7f6688
+    pkg_cv_systemd_CFLAGS="$systemd_CFLAGS"
7f6688
+ elif test -n "$PKG_CONFIG"; then
7f6688
+    if test -n "$PKG_CONFIG" && \
7f6688
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd\""; } >&5
7f6688
+  ($PKG_CONFIG --exists --print-errors "libsystemd") 2>&5
7f6688
+  ac_status=$?
7f6688
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
7f6688
+  test $ac_status = 0; }; then
7f6688
+  pkg_cv_systemd_CFLAGS=`$PKG_CONFIG --cflags "libsystemd" 2>/dev/null`
7f6688
+		      test "x$?" != "x0" && pkg_failed=yes
7f6688
+else
7f6688
+  pkg_failed=yes
7f6688
+fi
7f6688
+ else
7f6688
+    pkg_failed=untried
7f6688
+fi
7f6688
+if test -n "$systemd_LIBS"; then
7f6688
+    pkg_cv_systemd_LIBS="$systemd_LIBS"
7f6688
+ elif test -n "$PKG_CONFIG"; then
7f6688
+    if test -n "$PKG_CONFIG" && \
7f6688
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd\""; } >&5
7f6688
+  ($PKG_CONFIG --exists --print-errors "libsystemd") 2>&5
7f6688
+  ac_status=$?
7f6688
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
7f6688
+  test $ac_status = 0; }; then
7f6688
+  pkg_cv_systemd_LIBS=`$PKG_CONFIG --libs "libsystemd" 2>/dev/null`
7f6688
+		      test "x$?" != "x0" && pkg_failed=yes
7f6688
+else
7f6688
+  pkg_failed=yes
7f6688
+fi
7f6688
+ else
7f6688
+    pkg_failed=untried
7f6688
+fi
7f6688
+
7f6688
+
7f6688
+
7f6688
+if test $pkg_failed = yes; then
7f6688
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7f6688
+$as_echo "no" >&6; }
7f6688
+
7f6688
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
7f6688
+        _pkg_short_errors_supported=yes
7f6688
+else
7f6688
+        _pkg_short_errors_supported=no
7f6688
+fi
7f6688
+        if test $_pkg_short_errors_supported = yes; then
7f6688
+	        systemd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libsystemd" 2>&1`
7f6688
+        else
7f6688
+	        systemd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libsystemd" 2>&1`
7f6688
+        fi
7f6688
+	# Put the nasty error message in config.log where it belongs
7f6688
+	echo "$systemd_PKG_ERRORS" >&5
7f6688
+
7f6688
+
7f6688
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sm_notify in -lsystemd" >&5
7f6688
+$as_echo_n "checking for sm_notify in -lsystemd... " >&6; }
7f6688
+if ${ac_cv_lib_systemd_sm_notify+:} false; then :
7f6688
+  $as_echo_n "(cached) " >&6
7f6688
+else
7f6688
+  ac_check_lib_save_LIBS=$LIBS
7f6688
+LIBS="-lsystemd  $LIBS"
7f6688
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7f6688
+/* end confdefs.h.  */
7f6688
+
7f6688
+/* Override any GCC internal prototype to avoid an error.
7f6688
+   Use char because int might match the return type of a GCC
7f6688
+   builtin and then its argument prototype would still apply.  */
7f6688
+#ifdef __cplusplus
7f6688
+extern "C"
7f6688
+#endif
7f6688
+char sm_notify ();
7f6688
+int
7f6688
+main ()
7f6688
+{
7f6688
+return sm_notify ();
7f6688
+  ;
7f6688
+  return 0;
7f6688
+}
7f6688
+_ACEOF
7f6688
+if ac_fn_c_try_link "$LINENO"; then :
7f6688
+  ac_cv_lib_systemd_sm_notify=yes
7f6688
+else
7f6688
+  ac_cv_lib_systemd_sm_notify=no
7f6688
+fi
7f6688
+rm -f core conftest.err conftest.$ac_objext \
7f6688
+    conftest$ac_exeext conftest.$ac_ext
7f6688
+LIBS=$ac_check_lib_save_LIBS
7f6688
+fi
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_systemd_sm_notify" >&5
7f6688
+$as_echo "$ac_cv_lib_systemd_sm_notify" >&6; }
7f6688
+if test "x$ac_cv_lib_systemd_sm_notify" = xyes; then :
7f6688
+  systemd_LIBS="-lsystemd"
7f6688
+fi
7f6688
+
7f6688
+
7f6688
+
7f6688
+elif test $pkg_failed = untried; then
7f6688
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7f6688
+$as_echo "no" >&6; }
7f6688
+
7f6688
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sm_notify in -lsystemd" >&5
7f6688
+$as_echo_n "checking for sm_notify in -lsystemd... " >&6; }
7f6688
+if ${ac_cv_lib_systemd_sm_notify+:} false; then :
7f6688
+  $as_echo_n "(cached) " >&6
7f6688
+else
7f6688
+  ac_check_lib_save_LIBS=$LIBS
7f6688
+LIBS="-lsystemd  $LIBS"
7f6688
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7f6688
+/* end confdefs.h.  */
7f6688
+
7f6688
+/* Override any GCC internal prototype to avoid an error.
7f6688
+   Use char because int might match the return type of a GCC
7f6688
+   builtin and then its argument prototype would still apply.  */
7f6688
+#ifdef __cplusplus
7f6688
+extern "C"
7f6688
+#endif
7f6688
+char sm_notify ();
7f6688
+int
7f6688
+main ()
7f6688
+{
7f6688
+return sm_notify ();
7f6688
+  ;
7f6688
+  return 0;
7f6688
+}
7f6688
+_ACEOF
7f6688
+if ac_fn_c_try_link "$LINENO"; then :
7f6688
+  ac_cv_lib_systemd_sm_notify=yes
7f6688
+else
7f6688
+  ac_cv_lib_systemd_sm_notify=no
7f6688
+fi
7f6688
+rm -f core conftest.err conftest.$ac_objext \
7f6688
+    conftest$ac_exeext conftest.$ac_ext
7f6688
+LIBS=$ac_check_lib_save_LIBS
7f6688
+fi
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_systemd_sm_notify" >&5
7f6688
+$as_echo "$ac_cv_lib_systemd_sm_notify" >&6; }
7f6688
+if test "x$ac_cv_lib_systemd_sm_notify" = xyes; then :
7f6688
+  systemd_LIBS="-lsystemd"
7f6688
+fi
7f6688
+
7f6688
+
7f6688
+
7f6688
+else
7f6688
+	systemd_CFLAGS=$pkg_cv_systemd_CFLAGS
7f6688
+	systemd_LIBS=$pkg_cv_systemd_LIBS
7f6688
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
7f6688
+$as_echo "yes" >&6; }
7f6688
+
7f6688
+fi
7f6688
+
7f6688
+#
7f6688
+# Location of system config script directory?
7f6688
+#
7f6688
+if test -z "$confdir"; then
7f6688
+  for conf_d in /etc/sysconfig /etc/defaults /etc/conf.d /etc/default; do
7f6688
+    if test -z "$confdir"; then
7f6688
+      if test -d "$conf_d"; then
7f6688
+	confdir="$conf_d"
7f6688
+      fi
7f6688
+    fi
7f6688
+  done
7f6688
+fi
7f6688
+
7f6688
+# Check whether --with-confdir was given.
7f6688
+if test "${with_confdir+set}" = set; then :
7f6688
+  withval=$with_confdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
+	then
7f6688
+		:
7f6688
+	else
7f6688
+		confdir="${withval}"
7f6688
+	fi
7f6688
+
7f6688
+fi
7f6688
+
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs configuration file directory" >&5
7f6688
+$as_echo_n "checking for autofs configuration file directory... " >&6; }
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $confdir" >&5
7f6688
+$as_echo "$confdir" >&6; }
7f6688
+
7f6688
+
7f6688
+#
7f6688
+# The user can specify --with-mapsdir=PATH to specify autofs maps go
7f6688
+#
7f6688
+if test -z "$mapdir"; then
7f6688
+  for map_d in /etc/autofs /etc; do
7f6688
+    if test -z "$mapdir"; then
7f6688
+      if test -d "$map_d"; then
7f6688
+	mapdir="$map_d"
7f6688
+      fi
7f6688
+    fi
7f6688
+  done
7f6688
+fi
7f6688
+
7f6688
+# Check whether --with-mapdir was given.
7f6688
+if test "${with_mapdir+set}" = set; then :
7f6688
+  withval=$with_mapdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
+	then
7f6688
+		:
7f6688
+	else
7f6688
+		mapdir="${withval}"
7f6688
+	fi
7f6688
+
7f6688
+fi
7f6688
+
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs maps directory" >&5
7f6688
+$as_echo_n "checking for autofs maps directory... " >&6; }
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $mapdir" >&5
7f6688
+$as_echo "$mapdir" >&6; }
7f6688
+
7f6688
+
7f6688
+#
7f6688
+# The user can specify --with-fifodir=PATH to specify where autofs fifos go
7f6688
+#
7f6688
+if test -z "$fifodir"; then
7f6688
+  for fifo_d in /run /var/run /tmp; do
7f6688
+    if test -z "$fifodir"; then
7f6688
+      if test -d "$fifo_d"; then
7f6688
+        fifodir="$fifo_d"
7f6688
+      fi
7f6688
+    fi
7f6688
+  done
7f6688
+fi
7f6688
+
7f6688
+# Check whether --with-fifodir was given.
7f6688
+if test "${with_fifodir+set}" = set; then :
7f6688
+  withval=$with_fifodir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
+	then
7f6688
+		:
7f6688
+	else
7f6688
+		fifodir="${withval}"
7f6688
+	fi
7f6688
+
7f6688
+fi
7f6688
+
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs fifos directory" >&5
7f6688
+$as_echo_n "checking for autofs fifos directory... " >&6; }
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $fifodir" >&5
7f6688
+$as_echo "$fifodir" >&6; }
7f6688
+
7f6688
+
7f6688
+#
7f6688
+# The user can specify --with-flagdir=PATH to specify where autofs flag file goes
7f6688
+#
7f6688
+if test -z "$flagdir"; then
7f6688
+  for flag_d in /run /var/run /tmp; do
7f6688
+    if test -z "$flagdir"; then
7f6688
+      if test -d "$flag_d"; then
7f6688
+        flagdir="$flag_d"
7f6688
+      fi
7f6688
+    fi
7f6688
+  done
7f6688
+fi
7f6688
+
7f6688
+# Check whether --with-flagdir was given.
7f6688
+if test "${with_flagdir+set}" = set; then :
7f6688
+  withval=$with_flagdir; if test -z "$withval" -o "$withval" = "yes" -o "$withval" = "no"
7f6688
+	then
7f6688
+		:
7f6688
+	else
7f6688
+		filagdir="${withval}"
7f6688
+	fi
7f6688
+
7f6688
+fi
7f6688
+
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for autofs flag file directory" >&5
7f6688
+$as_echo_n "checking for autofs flag file directory... " >&6; }
7f6688
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $flagdir" >&5
7f6688
+$as_echo "$flagdir" >&6; }
7f6688
+
7f6688
+
7f6688
+#
7f6688
+# Use libtirpc
7f6688
+#
7f6688
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtirpc is requested and available" >&5
7f6688
 $as_echo_n "checking if libtirpc is requested and available... " >&6; }
7f6688
 
7f6688
--- autofs-5.0.7.orig/aclocal.m4
7f6688
+++ autofs-5.0.7/aclocal.m4
7f6688
@@ -242,8 +242,10 @@ AC_DEFUN([AF_WITH_SYSTEMD],
7f6688
       fi
7f6688
     done
7f6688
   fi
7f6688
+  WITH_SYSTEMD=0
7f6688
   if test -n "$systemddir"; then
7f6688
     AC_MSG_RESULT($systemddir)
7f6688
+    WITH_SYSTEMD=1
7f6688
   else
7f6688
     AC_MSG_RESULT(not found)
7f6688
   fi