autofs-5.1.4 - use systemd sd_notify() at startup From: Ian Kent 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 --- CHANGELOG | 1 Makefile.conf.in | 3 aclocal.m4 | 3 autofs.spec | 1 configure | 1136 ++++++++++++++++++++++++++------------------- configure.in | 8 daemon/Makefile | 5 daemon/automount.c | 83 ++- samples/autofs.service.in | 5 9 files changed, 729 insertions(+), 516 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b9925cf7..e3ada7e7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ xx/xx/2018 autofs-5.1.5 - fix rpm spec install premissions on auto.net and auto.smb. - tiny patch for autofs typo and possible bug. - add units After line to include statd service. +- use systemd sd_notify() at startup. 19/12/2017 autofs-5.1.4 - fix spec file url. diff --git a/Makefile.conf.in b/Makefile.conf.in index 3fe1a0a0..ff9b18a1 100644 --- a/Makefile.conf.in +++ b/Makefile.conf.in @@ -18,6 +18,9 @@ NSLLIB = @NSL_LIBS@ NSLCFLAGS = @NSL_CFLAGS@ LIBRESOLV = @LIBRESOLV@ +SYSTEMD = @WITH_SYSTEMD@ +LIBSYSTEMD = @systemd_LIBS@ + # Hesiod support: yes (1) no (0) HESIOD = @HAVE_HESIOD@ LIBHESIOD = @LIBHESIOD@ diff --git a/aclocal.m4 b/aclocal.m4 index f1ed3870..ec362bb4 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -257,14 +257,17 @@ 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 else if test "$withval" != no; then systemddir=$withval + WITH_SYSTEMD=1 fi fi]) ]) diff --git a/autofs.spec b/autofs.spec index ac3b0a3f..f857d9da 100644 --- a/autofs.spec +++ b/autofs.spec @@ -32,6 +32,7 @@ Source: https://www.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}.tar Buildroot: %{_tmppath}/%{name}-tmp %if %{with_systemd} BuildRequires: systemd-units +BuildRequires: systemd-devel %endif %if %{with_libtirpc} BuildRequires: libtirpc-devel diff --git a/configure b/configure index 9682b36f..827921ba 100755 --- a/configure +++ b/configure @@ -674,6 +674,12 @@ MOUNT_NFS HAVE_MOUNT MOUNT DMALLOCLIB +TIRPC_LIBS +TIRPC_CFLAGS +flagdir +fifodir +mapdir +confdir OBJEXT EXEEXT ac_ct_CC @@ -681,16 +687,13 @@ CPPFLAGS LDFLAGS CFLAGS CC -TIRPC_LIBS -TIRPC_CFLAGS +systemd_LIBS +systemd_CFLAGS +WITH_SYSTEMD +systemddir PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG -flagdir -fifodir -mapdir -confdir -systemddir piddir initdir target_alias @@ -760,13 +763,15 @@ target_alias PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR -TIRPC_CFLAGS -TIRPC_LIBS +systemd_CFLAGS +systemd_LIBS CC CFLAGS LDFLAGS LIBS CPPFLAGS +TIRPC_CFLAGS +TIRPC_LIBS NSL_CFLAGS NSL_LIBS CPP' @@ -1413,9 +1418,10 @@ Some influential environment variables: directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path - TIRPC_CFLAGS - C compiler flags for TIRPC, overriding pkg-config - TIRPC_LIBS linker flags for TIRPC, overriding pkg-config + 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 if you have libraries in a @@ -1423,6 +1429,9 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + TIRPC_CFLAGS + C compiler flags for TIRPC, overriding pkg-config + TIRPC_LIBS linker flags for TIRPC, overriding pkg-config NSL_CFLAGS C compiler flags for NSL, overriding pkg-config NSL_LIBS linker flags for NSL, overriding pkg-config CPP C preprocessor @@ -2291,166 +2300,6 @@ if test -z "$piddir"; then fi -# -# Check for systemd unit files direectory exists if unit file installation -# is requested -# - -# Check whether --with-systemd was given. -if test "${with_systemd+set}" = set; then : - withval=$with_systemd; if test "$withval" = yes; then - if test -z "$systemddir"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking location of the systemd unit files directory" >&5 -$as_echo_n "checking location of the systemd unit files directory... " >&6; } - for systemd_d in /usr/lib/systemd/system /usr/lib64/systemd/system /lib/systemd/system /lib64/systemd/system; do - if test -z "$systemddir"; then - if test -d "$systemd_d"; then - systemddir="$systemd_d" - fi - fi - done - fi - if test -n "$systemddir"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $systemddir" >&5 -$as_echo "$systemddir" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - fi -else - if test "$withval" != no; then - systemddir=$withval - fi -fi -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 - flagdir="${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 -# - @@ -2571,111 +2420,46 @@ $as_echo "no" >&6; } fi fi -# Check whether --with-libtirpc was given. -if test "${with_libtirpc+set}" = set; then : - withval=$with_libtirpc; -fi - -if test "x$with_libtirpc" = "xyes"; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIRPC" >&5 -$as_echo_n "checking for TIRPC... " >&6; } +# +# Check for systemd unit files direectory exists if unit file installation +# is requested +# -if test -n "$TIRPC_CFLAGS"; then - pkg_cv_TIRPC_CFLAGS="$TIRPC_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_TIRPC_CFLAGS=`$PKG_CONFIG --cflags "libtirpc" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$TIRPC_LIBS"; then - pkg_cv_TIRPC_LIBS="$TIRPC_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_TIRPC_LIBS=`$PKG_CONFIG --libs "libtirpc" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes +# Check whether --with-systemd was given. +if test "${with_systemd+set}" = set; then : + withval=$with_systemd; if test "$withval" = yes; then + if test -z "$systemddir"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking location of the systemd unit files directory" >&5 +$as_echo_n "checking location of the systemd unit files directory... " >&6; } + for systemd_d in /usr/lib/systemd/system /usr/lib64/systemd/system /lib/systemd/system /lib64/systemd/system; do + if test -z "$systemddir"; then + if test -d "$systemd_d"; then + systemddir="$systemd_d" + fi + 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; } + fi else - pkg_failed=yes + if test "$withval" != no; then + systemddir=$withval + WITH_SYSTEMD=1 + fi 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 - TIRPC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtirpc" 2>&1` - else - TIRPC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtirpc" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$TIRPC_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (libtirpc) were not met: - -$TIRPC_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables TIRPC_CFLAGS -and TIRPC_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -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}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables TIRPC_CFLAGS -and TIRPC_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } -else - TIRPC_CFLAGS=$pkg_cv_TIRPC_CFLAGS - TIRPC_LIBS=$pkg_cv_TIRPC_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - - -$as_echo "#define WITH_LIBTIRPC 1" >>confdefs.h - - -$as_echo "#define TIRPC_WORKAROUND 1" >>confdefs.h - - -fi - ac_ext=c +ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -3362,110 +3146,614 @@ elif test $ac_cv_prog_cc_g = yes; then CFLAGS="-g" fi else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +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 + flagdir="${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 +# + + + + + + + +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 whether --with-libtirpc was given. +if test "${with_libtirpc+set}" = set; then : + withval=$with_libtirpc; +fi + +if test "x$with_libtirpc" = "xyes"; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIRPC" >&5 +$as_echo_n "checking for TIRPC... " >&6; } + +if test -n "$TIRPC_CFLAGS"; then + pkg_cv_TIRPC_CFLAGS="$TIRPC_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_TIRPC_CFLAGS=`$PKG_CONFIG --cflags "libtirpc" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$TIRPC_LIBS"; then + pkg_cv_TIRPC_LIBS="$TIRPC_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtirpc\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtirpc") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_TIRPC_LIBS=`$PKG_CONFIG --libs "libtirpc" 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 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} + if test $_pkg_short_errors_supported = yes; then + TIRPC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtirpc" 2>&1` + else + TIRPC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtirpc" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$TIRPC_PKG_ERRORS" >&5 -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + as_fn_error $? "Package requirements (libtirpc) were not met: -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; +$TIRPC_PKG_ERRORS -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : +Alternatively, you may set the environment variables TIRPC_CFLAGS +and TIRPC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +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}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. -fi +Alternatively, you may set the environment variables TIRPC_CFLAGS +and TIRPC_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + TIRPC_CFLAGS=$pkg_cv_TIRPC_CFLAGS + TIRPC_LIBS=$pkg_cv_TIRPC_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + +$as_echo "#define WITH_LIBTIRPC 1" >>confdefs.h -for ac_func in getrpcbyname getservbyname +$as_echo "#define TIRPC_WORKAROUND 1" >>confdefs.h + + +fi + for ac_func in getrpcbyname getservbyname do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -4522,126 +4810,6 @@ 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 - pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NSL" >&5 $as_echo_n "checking for NSL... " >&6; } diff --git a/configure.in b/configure.in index de06a96d..4b0a81f2 100644 --- a/configure.in +++ b/configure.in @@ -48,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 @@ -55,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? @@ -218,7 +225,6 @@ fi AC_CHECK_LIB(rt, clock_gettime, LIBCLOCK_GETTIME="-lrt") AC_SUBST(LIBCLOCK_GETTIME) -PKG_PROG_PKG_CONFIG() PKG_CHECK_MODULES([NSL],[libnsl],, [ AC_CHECK_LIB(nsl, yp_match, NSL_LIBS="-lnsl") diff --git a/daemon/Makefile b/daemon/Makefile index a455c683..a7ce430e 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -22,6 +22,11 @@ CFLAGS += -DVERSION_STRING=\"$(version)\" LDFLAGS += -rdynamic LIBS += -ldl -lpthread +ifeq ($(SYSTEMD), 1) + CFLAGS += -DWITH_SYSTEMD + LIBS += $(LIBSYSTEMD) +endif + ifeq ($(LDAP), 1) CFLAGS += $(XML_FLAGS) LIBS += $(XML_LIBS) diff --git a/daemon/automount.c b/daemon/automount.c index 28b3f2f5..3fbfb9aa 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -36,6 +36,9 @@ #include #include #include +#ifdef WITH_SYSTEMD +#include +#endif #include "automount.h" #if defined(LIBXML2_WORKAROUND) || defined(TIRPC_WORKAROUND) @@ -67,7 +70,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; @@ -1206,12 +1209,6 @@ static void become_daemon(unsigned foreground, unsigned daemon_check) 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()) { @@ -1221,6 +1218,12 @@ static void become_daemon(unsigned foreground, unsigned daemon_check) } 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]); @@ -2450,8 +2453,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); @@ -2460,8 +2465,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); @@ -2471,8 +2478,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); @@ -2483,8 +2492,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); @@ -2495,8 +2506,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); @@ -2513,8 +2526,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); @@ -2525,8 +2540,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); @@ -2537,8 +2554,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); @@ -2547,8 +2566,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); @@ -2596,9 +2617,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); diff --git a/samples/autofs.service.in b/samples/autofs.service.in index 766fc5a5..281d31ef 100644 --- a/samples/autofs.service.in +++ b/samples/autofs.service.in @@ -4,10 +4,9 @@ After=network.target ypbind.service sssd.service network-online.target remote-fs 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