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

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