From 47e7470d27374c05ad70188500f7a89de374a76c Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Mon, 5 Feb 2018 11:52:40 +0800 Subject: [PATCH] - add error handling for ext_mount_add(). - account for recent libnsl changes. --- autofs-5.1.4-account-for-libnsl-changes.patch | 557 ++++++++++++++++++ ...add-error-handling-for-ext_mount_add.patch | 121 ++++ autofs.spec | 10 +- 3 files changed, 687 insertions(+), 1 deletion(-) create mode 100644 autofs-5.1.4-account-for-libnsl-changes.patch create mode 100644 autofs-5.1.4-add-error-handling-for-ext_mount_add.patch diff --git a/autofs-5.1.4-account-for-libnsl-changes.patch b/autofs-5.1.4-account-for-libnsl-changes.patch new file mode 100644 index 0000000..baf0af1 --- /dev/null +++ b/autofs-5.1.4-account-for-libnsl-changes.patch @@ -0,0 +1,557 @@ +autofs-5.1.4 - account for recent libnsl changes + +From: Ian Kent + +The glibc RPC code has been dropped. + +The NIS functionality comes in the libnsl library but it installs +its files into sub directories of the system include and library +directories. + +So configure needs to check for this and allow for it in the +compile and linking of the NIS and NIS+ lookup modules. +--- + CHANGELOG | 1 + Makefile.conf.in | 4 - + Makefile.rules | 2 + aclocal.m4 | 45 ++++++++ + configure | 288 ++++++++++++++++++++++++++++++++++++++++++++++++--- + configure.in | 27 ++--- + include/config.h.in | 3 + + modules/Makefile | 10 ++ + 8 files changed, 343 insertions(+), 37 deletions(-) + +diff --git a/CHANGELOG b/CHANGELOG +index 9d19c0a7..2d5d5b1f 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -8,6 +8,7 @@ xx/xx/2018 autofs-5.1.5 + - fix sublink option not set from defaults. + - fix error return in do_nfs_mount(). + - add error handling for ext_mount_add(). ++- account for recent libnsl changes. + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +diff --git a/Makefile.conf.in b/Makefile.conf.in +index f879e262..85662654 100644 +--- a/Makefile.conf.in ++++ b/Makefile.conf.in +@@ -14,8 +14,8 @@ DAEMON_LDFLAGS = @DAEMON_LDFLAGS@ + # Glibc < 2.17 requires librt for clock_gettime() + LIBCLOCK_GETTIME = @LIBCLOCK_GETTIME@ + +-# Special parameters for glibc (libc 6) +-LIBNSL = @LIBNSL@ ++NSLLIB = @NSL_LIBS@ ++NSLCFLAGS = @NSL_CFLAGS@ + LIBRESOLV = @LIBRESOLV@ + + # Hesiod support: yes (1) no (0) +diff --git a/Makefile.rules b/Makefile.rules +index 0edf9bfe..2bfa043c 100644 +--- a/Makefile.rules ++++ b/Makefile.rules +@@ -54,8 +54,6 @@ ifdef DMALLOCLIB + LIBS += $(DMALLOCLIB) + endif + +-LIBS += $(LIBNSL) +- + LIBS += $(LIBCLOCK_GETTIME) + + # Standard rules +diff --git a/aclocal.m4 b/aclocal.m4 +index 51772043..f1ed3870 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -417,3 +417,48 @@ fi + LIBS="$af_check_ldap_parse_page_control_save_libs" + ]) + ++dnl -------------------------------------------------------------------------- ++dnl AF_CHECK_YPCLNT_HEADER ++dnl ++dnl Check for include file rpcsvc/ypclnt.h for YellowPages support. ++dnl -------------------------------------------------------------------------- ++AC_DEFUN([AF_CHECK_YPCLNT_HEADER], ++[ ++# save current CFLAGS ++af_check_ypclnt_header_save_cflags="$CFLAGS" ++CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" ++ ++HAVE_YPCLNT=0 ++AC_CHECK_HEADER([rpcsvc/ypclnt.h], HAVE_YPCLNT=1) ++AC_SUBST(HAVE_YPCLNT) ++if test "$HAVE_YPCLNT" = "1"; then ++ AC_DEFINE(HAVE_YPCLNT, 1, ++ [Define if using YellowPages]) ++fi ++ ++# restore libs ++CFLAGS="$af_check_ypclnt_header_save_cflags" ++]) ++ ++dnl -------------------------------------------------------------------------- ++dnl AF_CHECK_NIS_HEADER ++dnl ++dnl Check for include file rpcsvc/nis.h for NIS+ support. ++dnl -------------------------------------------------------------------------- ++AC_DEFUN([AF_CHECK_NIS_HEADER], ++[ ++# save current CFLAGS ++af_check_nis_header_save_cflags="$CFLAGS" ++CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" ++ ++HAVE_NISPLUS=0 ++AC_CHECK_HEADER([rpcsvc/nis.h], HAVE_NISPLUS=1) ++AC_SUBST(HAVE_NISPLUS) ++if test "$HAVE_NISPLUS" = "1"; then ++ AC_DEFINE(HAVE_NISPLUS, 1, ++ [Define if using NIS+]) ++fi ++ ++# restore libs ++CFLAGS="$af_check_nis_header_save_cflags" ++]) +diff --git a/configure b/configure +index 476cea4b..2d517aac 100755 +--- a/configure ++++ b/configure +@@ -634,8 +634,8 @@ XML_FLAGS + LIBLDAP + HAVE_LDAP + LDAP_FLAGS +-HAVE_YPCLNT + HAVE_NISPLUS ++HAVE_YPCLNT + EGREP + GREP + CPP +@@ -643,7 +643,8 @@ HESIOD_FLAGS + LIBHESIOD + HAVE_HESIOD + LIBRESOLV +-LIBNSL ++NSL_LIBS ++NSL_CFLAGS + LIBCLOCK_GETTIME + KRB5_CONFIG + XML_CONFIG +@@ -764,6 +765,8 @@ CFLAGS + LDFLAGS + LIBS + CPPFLAGS ++NSL_CFLAGS ++NSL_LIBS + CPP' + + +@@ -1417,6 +1420,8 @@ 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 ++ NSL_CFLAGS C compiler flags for NSL, overriding pkg-config ++ NSL_LIBS linker flags for NSL, overriding pkg-config + CPP C preprocessor + + Use these variables to override the choices made by `configure' or to help +@@ -4500,9 +4505,186 @@ fi + + + +-# +-# glibc/libc 6 new libraries +-# ++ ++ ++ ++ ++ ++ ++ ++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; } ++ ++if test -n "$NSL_CFLAGS"; then ++ pkg_cv_NSL_CFLAGS="$NSL_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnsl\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "libnsl") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_NSL_CFLAGS=`$PKG_CONFIG --cflags "libnsl" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$NSL_LIBS"; then ++ pkg_cv_NSL_LIBS="$NSL_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnsl\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "libnsl") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_NSL_LIBS=`$PKG_CONFIG --libs "libnsl" 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 ++ NSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnsl" 2>&1` ++ else ++ NSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnsl" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$NSL_PKG_ERRORS" >&5 ++ ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for yp_match in -lnsl" >&5 + $as_echo_n "checking for yp_match in -lnsl... " >&6; } + if ${ac_cv_lib_nsl_yp_match+:} false; then : +@@ -4540,10 +4722,66 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_yp_match" >&5 + $as_echo "$ac_cv_lib_nsl_yp_match" >&6; } + if test "x$ac_cv_lib_nsl_yp_match" = xyes; then : +- LIBNSL="-lnsl" ++ NSL_LIBS="-lnsl" + fi + + ++NSL_CFLAGS="" ++ ++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 yp_match in -lnsl" >&5 ++$as_echo_n "checking for yp_match in -lnsl... " >&6; } ++if ${ac_cv_lib_nsl_yp_match+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lnsl $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 yp_match (); ++int ++main () ++{ ++return yp_match (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_nsl_yp_match=yes ++else ++ ac_cv_lib_nsl_yp_match=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_nsl_yp_match" >&5 ++$as_echo "$ac_cv_lib_nsl_yp_match" >&6; } ++if test "x$ac_cv_lib_nsl_yp_match" = xyes; then : ++ NSL_LIBS="-lnsl" ++fi ++ ++ ++NSL_CFLAGS="" ++ ++else ++ NSL_CFLAGS=$pkg_cv_NSL_CFLAGS ++ NSL_LIBS=$pkg_cv_NSL_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_query in -lresolv" >&5 + $as_echo_n "checking for res_query in -lresolv... " >&6; } +@@ -4659,8 +4897,6 @@ fi + + LDFLAGS="${AF_tmp_ldflags}" + +-# NIS+ support? +-HAVE_NISPLUS=0 + ac_ext=c + ac_cpp='$CPP $CPPFLAGS' + ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +@@ -5058,15 +5294,11 @@ fi + done + + +-ac_fn_c_check_header_mongrel "$LINENO" "rpcsvc/nis.h" "ac_cv_header_rpcsvc_nis_h" "$ac_includes_default" +-if test "x$ac_cv_header_rpcsvc_nis_h" = xyes; then : +- HAVE_NISPLUS=1 +-fi +- + ++# save current CFLAGS ++af_check_ypclnt_header_save_cflags="$CFLAGS" ++CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" + +- +-# YellowPages support? + HAVE_YPCLNT=0 + ac_fn_c_check_header_mongrel "$LINENO" "rpcsvc/ypclnt.h" "ac_cv_header_rpcsvc_ypclnt_h" "$ac_includes_default" + if test "x$ac_cv_header_rpcsvc_ypclnt_h" = xyes; then : +@@ -5081,6 +5313,32 @@ $as_echo "#define HAVE_YPCLNT 1" >>confdefs.h + + fi + ++# restore libs ++CFLAGS="$af_check_ypclnt_header_save_cflags" ++ ++ ++# save current CFLAGS ++af_check_nis_header_save_cflags="$CFLAGS" ++CFLAGS="$CFLAGS $NSL_CFLAGS $TIRPC_CFLAGS" ++ ++HAVE_NISPLUS=0 ++ac_fn_c_check_header_mongrel "$LINENO" "rpcsvc/nis.h" "ac_cv_header_rpcsvc_nis_h" "$ac_includes_default" ++if test "x$ac_cv_header_rpcsvc_nis_h" = xyes; then : ++ HAVE_NISPLUS=1 ++fi ++ ++ ++ ++if test "$HAVE_NISPLUS" = "1"; then ++ ++$as_echo "#define HAVE_NISPLUS 1" >>confdefs.h ++ ++fi ++ ++# restore libs ++CFLAGS="$af_check_nis_header_save_cflags" ++ ++ + # + # OpenLDAP support? Expect that this may have a special directory... + # +diff --git a/configure.in b/configure.in +index d3660923..d74775cc 100644 +--- a/configure.in ++++ b/configure.in +@@ -209,11 +209,13 @@ fi + AC_CHECK_LIB(rt, clock_gettime, LIBCLOCK_GETTIME="-lrt") + AC_SUBST(LIBCLOCK_GETTIME) + +-# +-# glibc/libc 6 new libraries +-# +-AC_CHECK_LIB(nsl, yp_match, LIBNSL="-lnsl") +-AC_SUBST(LIBNSL) ++PKG_PROG_PKG_CONFIG() ++PKG_CHECK_MODULES([NSL],[libnsl],, ++[ ++AC_CHECK_LIB(nsl, yp_match, NSL_LIBS="-lnsl") ++AC_SUBST(NSL_LIBS) ++NSL_CFLAGS="" ++]) + + AC_CHECK_LIB(resolv, res_query, LIBRESOLV="-lresolv") + AC_SUBST(LIBRESOLV) +@@ -254,19 +256,8 @@ AC_SUBST(LIBHESIOD) + AC_SUBST(HESIOD_FLAGS) + LDFLAGS="${AF_tmp_ldflags}" + +-# NIS+ support? +-HAVE_NISPLUS=0 +-AC_CHECK_HEADER(rpcsvc/nis.h, HAVE_NISPLUS=1) +-AC_SUBST(HAVE_NISPLUS) +- +-# YellowPages support? +-HAVE_YPCLNT=0 +-AC_CHECK_HEADER([rpcsvc/ypclnt.h], HAVE_YPCLNT=1) +-AC_SUBST(HAVE_YPCLNT) +-if test "$HAVE_YPCLNT" = "1"; then +- AC_DEFINE(HAVE_YPCLNT, 1, +- [Define if using YellowPages]) +-fi ++AF_CHECK_YPCLNT_HEADER() ++AF_CHECK_NIS_HEADER() + + # + # OpenLDAP support? Expect that this may have a special directory... +diff --git a/include/config.h.in b/include/config.h.in +index 04873e8f..991a2bda 100644 +--- a/include/config.h.in ++++ b/include/config.h.in +@@ -57,6 +57,9 @@ + /* define if you have MOUNT_NFS */ + #undef HAVE_MOUNT_NFS + ++/* Define if using NIS+ */ ++#undef HAVE_NISPLUS ++ + /* define if the umount command supports the -c option */ + #undef HAVE_NO_CANON_UMOUNT + +diff --git a/modules/Makefile b/modules/Makefile +index d9ab06c5..0447559a 100644 +--- a/modules/Makefile ++++ b/modules/Makefile +@@ -116,6 +116,16 @@ parse_amd.so: parse_amd.c amd_parse.tab.o amd_tok.o + # + # Ad hoc compilation rules for modules which need auxilliary libraries + # ++lookup_yp.so: lookup_yp.c ++ $(CC) $(SOLDFLAGS) $(CFLAGS) $(NSLCFLAGS) -o lookup_yp.so \ ++ lookup_yp.c $(LDFLAGS) $(AUTOFS_LIB) $(LIBS) $(NSLLIB) ++ $(STRIP) lookup_yp.so ++ ++lookup_nisplus.so: lookup_nisplus.c ++ $(CC) $(SOLDFLAGS) $(CFLAGS) $(NSLCFLAGS) -o lookup_nisplus.so \ ++ lookup_nisplus.c $(LDFLAGS) $(AUTOFS_LIB) $(LIBS) $(NSLLIB) ++ $(STRIP) lookup_nisplus.so ++ + lookup_hesiod.so: lookup_hesiod.c + $(CC) $(SOLDFLAGS) $(CFLAGS) $(HESIOD_FLAGS) -o lookup_hesiod.so \ + lookup_hesiod.c $(LDFLAGS) $(AUTOFS_LIB) $(LIBHESIOD) $(LIBRESOLV) $(LIBS) diff --git a/autofs-5.1.4-add-error-handling-for-ext_mount_add.patch b/autofs-5.1.4-add-error-handling-for-ext_mount_add.patch new file mode 100644 index 0000000..814ae30 --- /dev/null +++ b/autofs-5.1.4-add-error-handling-for-ext_mount_add.patch @@ -0,0 +1,121 @@ +autofs-5.1.4 - add error handling for ext_mount_add() + +From: Ian Kent + +Add error handling (memory allocation failures) for ext_mount_add(). + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 5 +---- + modules/parse_amd.c | 42 ++++++++++++++++++++++++++++++------------ + 3 files changed, 32 insertions(+), 16 deletions(-) + +diff --git a/CHANGELOG b/CHANGELOG +index d0cfa19b..9d19c0a7 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -7,6 +7,7 @@ xx/xx/2018 autofs-5.1.5 + - fix prefix option handling in expand_entry(). + - fix sublink option not set from defaults. + - fix error return in do_nfs_mount(). ++- add error handling for ext_mount_add(). + + 19/12/2017 autofs-5.1.4 + - fix spec file url. +diff --git a/lib/mounts.c b/lib/mounts.c +index 6fa304aa..f46fab2b 100644 +--- a/lib/mounts.c ++++ b/lib/mounts.c +@@ -715,15 +715,12 @@ int ext_mount_add(struct list_head *entry, const char *path, unsigned int umount + } + + em = malloc(sizeof(struct ext_mount)); +- if (!em) { +- ret = -1; ++ if (!em) + goto done; +- } + + em->mountpoint = strdup(path); + if (!em->mountpoint) { + free(em); +- ret = -1; + goto done; + } + em->umount = umount; +diff --git a/modules/parse_amd.c b/modules/parse_amd.c +index 2a5d9a30..e7debc56 100644 +--- a/modules/parse_amd.c ++++ b/modules/parse_amd.c +@@ -1080,7 +1080,14 @@ static int do_generic_mount(struct autofs_point *ap, const char *name, + umount = 1; + } + /* We have an external mount */ +- ext_mount_add(&entry->ext_mount, entry->fs, umount); ++ if (!ext_mount_add(&entry->ext_mount, entry->fs, umount)) { ++ umount_ent(ap, entry->fs); ++ error(ap->logopt, MODPREFIX ++ "error: could not add external mount %s", ++ entry->fs); ++ ret = 1; ++ goto out; ++ } + ret = do_link_mount(ap, name, entry, flags); + } + out: +@@ -1124,7 +1131,13 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name, + umount = 1; + } + /* We might be using an external mount */ +- ext_mount_add(&entry->ext_mount, entry->fs, umount); ++ if (!ext_mount_add(&entry->ext_mount, entry->fs, umount)) { ++ umount_ent(ap, entry->fs); ++ error(ap->logopt, MODPREFIX ++ "error: could not add external mount %s", entry->fs); ++ ret = 1; ++ goto out; ++ } + ret = do_link_mount(ap, name, entry, flags); + } + out: +@@ -1309,6 +1322,9 @@ static int do_program_mount(struct autofs_point *ap, + */ + if (ext_mount_inuse(entry->fs)) { + rv = 0; ++ /* An external mount with path entry->fs exists ++ * so ext_mount_add() won't fail. ++ */ + ext_mount_add(&entry->ext_mount, entry->fs, 1); + } else { + rv = mkdir_path(entry->fs, mp_mode); +@@ -1325,17 +1341,19 @@ static int do_program_mount(struct autofs_point *ap, + + rv = spawnv(ap->logopt, prog, (const char * const *) argv); + if (WIFEXITED(rv) && !WEXITSTATUS(rv)) { +- rv = 0; +- ext_mount_add(&entry->ext_mount, entry->fs, 1); +- debug(ap->logopt, MODPREFIX +- "%s: mounted %s", entry->type, entry->fs); +- } else { +- if (!ext_mount_inuse(entry->fs)) +- rmdir_path(ap, entry->fs, ap->dev); +- error(ap->logopt, MODPREFIX +- "%s: failed to mount using: %s", +- entry->type, entry->mount); ++ if (ext_mount_add(&entry->ext_mount, entry->fs, 1)) { ++ rv = 0; ++ debug(ap->logopt, MODPREFIX ++ "%s: mounted %s", entry->type, entry->fs); ++ goto do_free; ++ } ++ umount_ent(ap, entry->fs); + } ++ ++ if (!ext_mount_inuse(entry->fs)) ++ rmdir_path(ap, entry->fs, ap->dev); ++ error(ap->logopt, MODPREFIX ++ "%s: failed to mount using %s", entry->type, entry->mount); + } + do_free: + free_argv(argc, (const char **) argv); diff --git a/autofs.spec b/autofs.spec index e8b6f33..38cee3b 100644 --- a/autofs.spec +++ b/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.1.4 -Release: 6%{?dist} +Release: 7%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -21,6 +21,8 @@ Patch5: autofs-5.1.4-dont-use-array-for-path-when-not-neccessary.patch Patch6: autofs-5.1.4-fix-prefix-option-handling-in-expand_entry.patch Patch7: autofs-5.1.4-fix-sublink-option-not-set-from-defaults.patch Patch8: autofs-5.1.4-fix-error-return-in-do_nfs_mount.patch +Patch9: autofs-5.1.4-add-error-handling-for-ext_mount_add.patch +Patch10: autofs-5.1.4-account-for-libnsl-changes.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -90,6 +92,8 @@ echo %{version}-%{release} > .version %patch6 -p1 %patch7 -p1 %patch8 -p1 +%patch9 -p1 +%patch10 -p1 %build LDFLAGS=-Wl,-z,now @@ -183,6 +187,10 @@ fi %dir /etc/auto.master.d %changelog +* Mon Feb 5 2018 Ian Kent - 1:5.1.4-7 +- add error handling for ext_mount_add(). +- account for recent libnsl changes. + * Thu Feb 1 2018 Ian Kent - 1:5.1.4-6 - dont use array for path when not necessary. - fix prefix option handling in expand_entry().