Blob Blame History Raw
autofs-5.1.4 - use systemd sd_notify() at startup

From: Ian Kent <raven@themaw.net>

autofs needs to ensure statd is started before any NFS mounts
are attempted.

When starting the statd service with the autofs service the statd
service will trigger a restart of the autofs service during its
start up. Sometimes this can happen during the automount start up
itself.

When this happens it causes systemd to become confused and remove
the pid file created by automount leaving systemd thinking the
autofs service had failed start up when it was actually running.

It was recommened that autofs be changed to a "Type=notify" service
to avoid this. Using this a pid file is no longer needed and is now
not used.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG                 |    1 
 Makefile.conf.in          |    3 
 aclocal.m4                |    2 
 autofs.spec               |    1 
 configure                 |  577 +++++++++++++++++++++++++++++++++++-----------
 configure.in              |   10 
 daemon/Makefile           |    5 
 daemon/automount.c        |   83 ++++--
 samples/autofs.service.in |    5 
 9 files changed, 529 insertions(+), 158 deletions(-)

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