All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/37] Current patch queue for review
@ 2016-10-25  1:17 Ian Kent
  2016-10-25  1:17 ` [PATCH 01/37] autofs-5.1.2 - fix release date in CHANGELOG Ian Kent
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

Hi all,

The patch queue is well overdue for a commit but since there's
been increased contributions for others recently I thought it
would be useful to post the patches for review and give a brief
description of what's in the queue and what still needs work. 

Many of the patches are striaght forward and I expect to commit
then in a week or so. Also keep in mind the commit order might
be different when the commit is actually done.

The patches around those titled "autofs-5.1.2 - wait for master
map available at start" and "autofs-5.1.2 - add master read wait
option" have been around for quite a while and have been a problem
in the past (which is why they haven't been committed yet) so I'm
not sure about them yet.

The series to add browse support for amd maps is not yet complete
so they will likely stay in the queue a bit longer. But I am keen
to get this functionality into a release as I know it is something
that at least a few people would like.

Anyway review of the patches would be appreciated.

---

Gustavo Zacarias (1):
      autofs-5.1.2 - build: check for clock_gettime in librt

Ian Kent (25):
      autofs-5.1.2 - fix release date in CHANGELOG
      autofs-5.1.2 - fix file map changed check
      autofs-5.1.2 - fix short memory allocation in lookup_amd_instance()
      autofs-5.1.2 - fix count_mounts() function
      autofs-5.1.2 - fix typo in MOUNT_FLAG_GHOST comment
      autofs-5.1.2 - fix cachefs parse message not being logged
      autofs-5.1.2 - fix argc off by one in mount_autofs.c
      autofs-5.1.2 - fix _strncmp() usage
      autofs-5.1.1 - fix create_client() RPC client handling
      autofs-5.1.2 - update and add README for old autofs schema
      autofs-5.1.2 - wait for master map available at start
      autofs-5.1.2 - add master read wait option
      autofs-5.1.2 - work around sss startup delay
      autofs-5.1.2 - add sss master map wait config option
      autofs-5.1.2 - fix typos in README.amd-maps
      autofs-5.1.2 - add ref counting to struct map_source
      autofs-5.1.2 - add support for amd browsable option
      autofs-5.1.2 - add function conf_amd_get_map_name()
      autofs-5.1.2 - add function conf_amd_get_mount_paths()
      autofs-5.1.2 - include amd mount section mounts in master mounts list
      autofs-5.1.2 - check for conflicting amd section mounts
      autofs-5.1.2 - add function conf_get_map_options()
      autofs-5.1.2 - capture cache option and its settings during parsing
      autofs-5.1.2 - handle map_option cache for top level mounts
      autofs-5.1.2 - handle amd cache option all in amd type auto mounts

Martin von Gagern (1):
      autofs-5.1.2 - fix libtirpc detection with -Wl,--as-needed

Thomas Petazzoni (1):
      autofs-5.1.2 - configure: add cache variable for Linux proc filesystem check

Tomohiro Kusumi (9):
      autofs-5.1.2 - Fix compiler warning in try_remount()
      autofs-5.1.2 - Drop redundant \n in logerr()
      autofs-5.1.2 - Fix size arg of fgets(3)
      autofs-5.1.2 - Fix a typo in CREDITS
      autofs-5.1.2 - Change .requestor to .requester for consistency
      autofs-5.1.2 - Remove unused local 2KB buffer
      autofs-5.1.2 - Fix typos in error messages
      autofs-5.1.2 - Fix fgets(3) size argument (another one)
      autofs-5.1.2 - Avoid local variable name shadowing another


 CHANGELOG                      |   40 ++++++++
 CREDITS                        |    2 
 Makefile.conf.in               |    3 +
 Makefile.rules                 |    2 
 README.amd-maps                |   64 ++++++++++---
 README.autofs-schema           |   18 ++++
 aclocal.m4                     |   21 ++--
 configure                      |   66 +++++++++++--
 configure.in                   |    4 +
 daemon/automount.c             |  107 +++++++++++++++++----
 daemon/indirect.c              |    7 +
 daemon/lookup.c                |  116 +++++++++++++++++++----
 daemon/module.c                |    4 -
 daemon/state.c                 |    4 -
 include/automount.h            |    9 +-
 include/defaults.h             |    8 ++
 include/dev-ioctl-lib.h        |    2 
 include/master.h               |    4 +
 include/parse_amd.h            |    7 +
 lib/defaults.c                 |  137 +++++++++++++++++++++++++++
 lib/dev-ioctl-lib.c            |   10 +-
 lib/master.c                   |  202 ++++++++++++++++++++++++++++++++++++++++
 lib/master_parse.y             |   30 +++++-
 lib/mounts.c                   |    9 +-
 lib/nss_parse.y                |    2 
 lib/rpc_subs.c                 |   21 ++--
 man/autofs.conf.5.in           |   27 +++++
 man/automount.8                |    4 +
 modules/amd_parse.y            |   16 ++-
 modules/amd_tok.l              |    2 
 modules/lookup_file.c          |   15 ++-
 modules/lookup_ldap.c          |   10 +-
 modules/lookup_nisplus.c       |   24 +++--
 modules/lookup_sss.c           |   72 +++++++++++++-
 modules/lookup_yp.c            |   23 +++--
 modules/mount_autofs.c         |   84 +++++++++++------
 modules/mount_ext2.c           |    2 
 modules/parse_amd.c            |    2 
 redhat/autofs.conf.default.in  |   24 ++++-
 samples/autofs.conf.default.in |   24 ++++-
 samples/autofs.schema          |   24 ++---
 41 files changed, 1042 insertions(+), 210 deletions(-)
 create mode 100644 README.autofs-schema

--
Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 01/37] autofs-5.1.2 - fix release date in CHANGELOG
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
@ 2016-10-25  1:17 ` Ian Kent
  2016-10-25  1:17 ` [PATCH 02/37] autofs-5.1.2 - build: check for clock_gettime in librt Ian Kent
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

Oops!

Also add heading for 5.1.3.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 39019a9..d31bb80 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,8 @@
-15/06/2015 autofs-5.1.2
+xx/xx/2016 autofs-5.1.3
+=======================
+- fix release date in CHANGELOG.
+
+15/06/2016 autofs-5.1.2
 =======================
 - update libtirpc workaround for new soname.
 - revert fix libtirpc name clash.

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 02/37] autofs-5.1.2 - build: check for clock_gettime in librt
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
  2016-10-25  1:17 ` [PATCH 01/37] autofs-5.1.2 - fix release date in CHANGELOG Ian Kent
@ 2016-10-25  1:17 ` Ian Kent
  2016-10-25  1:17 ` [PATCH 03/37] autofs-5.1.2 - Fix compiler warning in try_remount() Ian Kent
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

From: Gustavo Zacarias <gustavo@zacarias.com.ar>

Glibc versions older than 2.17 define clock_gettime() in librt, so add a
check for this.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
---
 CHANGELOG        |    1 +
 Makefile.conf.in |    3 +++
 Makefile.rules   |    2 ++
 configure        |   44 ++++++++++++++++++++++++++++++++++++++++++++
 configure.in     |    4 ++++
 5 files changed, 54 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index d31bb80..2e51f62 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 xx/xx/2016 autofs-5.1.3
 =======================
 - fix release date in CHANGELOG.
+- build: check for clock_gettime in librt.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/Makefile.conf.in b/Makefile.conf.in
index cb53e66..2bc3202 100644
--- a/Makefile.conf.in
+++ b/Makefile.conf.in
@@ -11,6 +11,9 @@
 DAEMON_CFLAGS  = @DAEMON_CFLAGS@
 DAEMON_LDFLAGS = @DAEMON_LDFLAGS@
 
+# Glibc < 2.17 requires librt for clock_gettime()
+LIBCLOCK_GETTIME = @LIBCLOCK_GETTIME@
+
 # Special parameters for glibc (libc 6)
 LIBNSL    = @LIBNSL@
 LIBRESOLV = @LIBRESOLV@
diff --git a/Makefile.rules b/Makefile.rules
index 6fa3e02..7d1af2e 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -56,6 +56,8 @@ endif
 
 LIBS += $(LIBNSL)
 
+LIBS += $(LIBCLOCK_GETTIME)
+
 # Standard rules
 
 .SUFFIXES: .c .o .s .so
diff --git a/configure b/configure
index 3e2de6f..6ae1f97 100755
--- a/configure
+++ b/configure
@@ -644,6 +644,7 @@ LIBHESIOD
 HAVE_HESIOD
 LIBRESOLV
 LIBNSL
+LIBCLOCK_GETTIME
 KRB5_CONFIG
 XML_CONFIG
 sssldir
@@ -4206,6 +4207,49 @@ $as_echo "#define WITHOUT_VERSIONSORT 1" >>confdefs.h
 
 fi
 
+# glibc < 2.17 needs librt for clock_gettime()
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
+$as_echo_n "checking for clock_gettime in -lrt... " >&6; }
+if ${ac_cv_lib_rt_clock_gettime+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt  $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 clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_rt_clock_gettime=yes
+else
+  ac_cv_lib_rt_clock_gettime=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_rt_clock_gettime" >&5
+$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
+if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then :
+  LIBCLOCK_GETTIME="-lrt"
+fi
+
+
+
 #
 # glibc/libc 6 new libraries
 #
diff --git a/configure.in b/configure.in
index 25d7c4e..a4318e8 100644
--- a/configure.in
+++ b/configure.in
@@ -177,6 +177,10 @@ if test "$ac_cv_search_versionsort" = "no"; then
 		[Define if your C library does not provide versionsort])
 fi
 
+# glibc < 2.17 needs librt for clock_gettime()
+AC_CHECK_LIB(rt, clock_gettime, LIBCLOCK_GETTIME="-lrt")
+AC_SUBST(LIBCLOCK_GETTIME)
+
 #
 # glibc/libc 6 new libraries
 #

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 03/37] autofs-5.1.2 - Fix compiler warning in try_remount()
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
  2016-10-25  1:17 ` [PATCH 01/37] autofs-5.1.2 - fix release date in CHANGELOG Ian Kent
  2016-10-25  1:17 ` [PATCH 02/37] autofs-5.1.2 - build: check for clock_gettime in librt Ian Kent
@ 2016-10-25  1:17 ` Ian Kent
  2016-10-25  1:17 ` [PATCH 04/37] autofs-5.1.2 - Drop redundant \n in logerr() Ian Kent
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Fix below compiler (gcc5) warning which isn't autoconf result dependent.
mounts.c:1779:7: warning: variable 'ret' set but not used [-Wunused-but-set-variable]

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG    |    1 +
 lib/mounts.c |    5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 2e51f62..288d175 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ xx/xx/2016 autofs-5.1.3
 =======================
 - fix release date in CHANGELOG.
 - build: check for clock_gettime in librt.
+- fix compiler warning in try_remount().
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/lib/mounts.c b/lib/mounts.c
index 1d1b4da..c67548e 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -1776,16 +1776,15 @@ static int remount_active_mount(struct autofs_point *ap,
 			*ioctlfd = -1;
 		}
 	} else {
-		int ret;
 		/*
 		 * What can I do if we can't remount the existing
 		 * mount(s) (possibly a partial failure), everything
 		 * following will be broken?
 		 */
 		if (type == t_indirect)
-			ret = do_remount_indirect(ap, fd, path);
+			do_remount_indirect(ap, fd, path);
 		else
-			ret = do_remount_direct(ap, fd, path);
+			do_remount_direct(ap, fd, path);
 	}
 
 	debug(ap->logopt, "re-connected to mount %s", path);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 04/37] autofs-5.1.2 - Drop redundant \n in logerr()
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (2 preceding siblings ...)
  2016-10-25  1:17 ` [PATCH 03/37] autofs-5.1.2 - Fix compiler warning in try_remount() Ian Kent
@ 2016-10-25  1:17 ` Ian Kent
  2016-10-25  1:17 ` [PATCH 05/37] autofs-5.1.2 - Fix size arg of fgets(3) Ian Kent
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Line break isn't necessary from the way logerr (and logmsg) is implemented,
and these two probably aren't intentional.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 daemon/module.c |    2 +-
 lib/nss_parse.y |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 288d175..99dc245 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ xx/xx/2016 autofs-5.1.3
 - fix release date in CHANGELOG.
 - build: check for clock_gettime in librt.
 - fix compiler warning in try_remount().
+- drop redundant \n in logerr().
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/module.c b/daemon/module.c
index bed8f7a..db01db8 100644
--- a/daemon/module.c
+++ b/daemon/module.c
@@ -34,7 +34,7 @@ int load_autofs4_module(void)
 	 */
 	fp = open_fopen_r("/proc/filesystems");
 	if (!fp) {
-		logerr("cannot open /proc/filesystems\n");
+		logerr("cannot open /proc/filesystems");
 		return 0;
 	}
 
diff --git a/lib/nss_parse.y b/lib/nss_parse.y
index 055e9d7..0721ba1 100644
--- a/lib/nss_parse.y
+++ b/lib/nss_parse.y
@@ -169,7 +169,7 @@ int nsswitch_parse(struct list_head *list)
 
 	nsswitch = open_fopen_r(NSSWITCH_FILE);
 	if (!nsswitch) {
-		logerr("couldn't open %s\n", NSSWITCH_FILE);
+		logerr("couldn't open %s", NSSWITCH_FILE);
 		return 1;
 	}
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 05/37] autofs-5.1.2 - Fix size arg of fgets(3)
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (3 preceding siblings ...)
  2016-10-25  1:17 ` [PATCH 04/37] autofs-5.1.2 - Drop redundant \n in logerr() Ian Kent
@ 2016-10-25  1:17 ` Ian Kent
  2016-10-25  1:17 ` [PATCH 06/37] autofs-5.1.2 - fix libtirpc detection with -Wl, --as-needed Ian Kent
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Since fgets(3) reads at most 1 less than size arg, it should
probably pass MAX_LINE_LEN+1 given that the conditional in the
next line tests if strlen() exceeds MAX_LINE_LEN.
(i.e. MAX_LINE_LEN isn't designed to include terminating \0)

buf has MAX_LINE_LEN+2 bytes, so passing MAX_LINE_LEN+1 is ok.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG      |    1 +
 lib/defaults.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 99dc245..cb895c4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ xx/xx/2016 autofs-5.1.3
 - build: check for clock_gettime in librt.
 - fix compiler warning in try_remount().
 - drop redundant \n in logerr().
+- Fix size arg of fgets(3).
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/lib/defaults.c b/lib/defaults.c
index 0e48a78..ae76513 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -879,7 +879,7 @@ static int read_config(unsigned int to_syslog, FILE *f, const char *name)
 	char *res;
 
 	new_sec = NULL;
-	while ((res = fgets(buf, MAX_LINE_LEN, f))) {
+	while ((res = fgets(buf, MAX_LINE_LEN + 1, f))) {
 		char *sec, *key, *value;
 
 		if (strlen(res) > MAX_LINE_LEN) {

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 06/37] autofs-5.1.2 - fix libtirpc detection with -Wl, --as-needed
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (4 preceding siblings ...)
  2016-10-25  1:17 ` [PATCH 05/37] autofs-5.1.2 - Fix size arg of fgets(3) Ian Kent
@ 2016-10-25  1:17 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 07/37] autofs-5.1.2 - Fix a typo in CREDITS Ian Kent
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:17 UTC (permalink / raw)
  To: autofs mailing list

From: Martin von Gagern <Martin.vGagern@gmx.net>

As reported in https://bugs.gentoo.org/show_bug.cgi?id=588106, the configure
script will fail to detect the presence of libtirpc if -Wl,--as-needed is
included in LDFLAGS.  That is because the check incorrectly includes the
argument -ltircp in the LDFLAGS variable, instead of the LIBS variable where
it belongs.  LIBS comes after the objects so it will be used to satisfy
their dependencies.  LDFLAGS will come before them, causing the library to
be skipped if the --as-needed linker flag is in effect.

Signed-off-by: Martin von Gagern <Martin.vGagern@gmx.net>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG  |    1 +
 aclocal.m4 |    6 +++---
 configure  |    6 +++---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index cb895c4..9291c20 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@ xx/xx/2016 autofs-5.1.3
 - fix compiler warning in try_remount().
 - drop redundant \n in logerr().
 - Fix size arg of fgets(3).
+- fix libtirpc detection with -Wl,--as-needed.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/aclocal.m4 b/aclocal.m4
index 2115204..fe949a2 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -413,9 +413,9 @@ AC_DEFUN([AF_CHECK_LIBTIRPC],
 [
 # save current flags
 af_check_libtirpc_save_cflags="$CFLAGS"
-af_check_libtirpc_save_ldflags="$LDFLAGS"
+af_check_libtirpc_save_libs="$LIBS"
 CFLAGS="$CFLAGS -I/usr/include/tirpc"
-LDFLAGS="$LDFLAGS -ltirpc"
+LIBS="$LIBS -ltirpc"
 
 AC_TRY_LINK(
     [ #include <rpc/rpc.h> ],
@@ -438,7 +438,7 @@ AC_CHECK_FUNCS([getrpcbyname getservbyname])
 
 # restore flags
 CFLAGS="$af_check_libtirpc_save_cflags"
-LDFLAGS="$af_check_libtirpc_save_ldflags"
+LIBS="$af_check_libtirpc_save_libs"
 ])
 
 AC_DEFUN([AF_WITH_LIBTIRPC],
diff --git a/configure b/configure
index 6ae1f97..5a05fe1 100755
--- a/configure
+++ b/configure
@@ -3195,9 +3195,9 @@ if test "${with_libtirpc+set}" = set; then :
 
 # save current flags
 af_check_libtirpc_save_cflags="$CFLAGS"
-af_check_libtirpc_save_ldflags="$LDFLAGS"
+af_check_libtirpc_save_libs="$LIBS"
 CFLAGS="$CFLAGS -I/usr/include/tirpc"
-LDFLAGS="$LDFLAGS -ltirpc"
+LIBS="$LIBS -ltirpc"
 
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -3250,7 +3250,7 @@ done
 
 # restore flags
 CFLAGS="$af_check_libtirpc_save_cflags"
-LDFLAGS="$af_check_libtirpc_save_ldflags"
+LIBS="$af_check_libtirpc_save_libs"
 
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 07/37] autofs-5.1.2 - Fix a typo in CREDITS
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (5 preceding siblings ...)
  2016-10-25  1:17 ` [PATCH 06/37] autofs-5.1.2 - fix libtirpc detection with -Wl, --as-needed Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 08/37] autofs-5.1.2 - Change .requestor to .requester for consistency Ian Kent
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Fix a typo in a contributor's name.
Two other parts of this file says "Aaron".

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <ikent@redhat.com>
---
 CHANGELOG |    1 +
 CREDITS   |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 9291c20..96260b7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ xx/xx/2016 autofs-5.1.3
 - drop redundant \n in logerr().
 - Fix size arg of fgets(3).
 - fix libtirpc detection with -Wl,--as-needed.
+- Fix a typo in CREDITS.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/CREDITS b/CREDITS
index 8d5057a..a931de1 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2,7 +2,7 @@
 CREDITS
 =======
 
-Arron Ogden
+Aaron Ogden
 -----------
 
 While other people have contributed to autofs in various ways

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 08/37] autofs-5.1.2 - Change .requestor to .requester for consistency
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (6 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 07/37] autofs-5.1.2 - Fix a typo in CREDITS Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 09/37] autofs-5.1.2 - fix file map changed check Ian Kent
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Since the name of ioctl command is AUTOFS_DEV_IOCTL_REQUESTER,
we should use .requester for consistency, assuming autofs
userspace doesn't have intention to provide these interface
for external programs or libraries which break api compatibiliy.

Also note that kernel code of autofs uses "requester".

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
---
 CHANGELOG               |    1 +
 daemon/automount.c      |    2 +-
 include/automount.h     |    4 ++--
 include/dev-ioctl-lib.h |    2 +-
 lib/dev-ioctl-lib.c     |   10 +++++-----
 lib/mounts.c            |    4 ++--
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 96260b7..6333959 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@ xx/xx/2016 autofs-5.1.3
 - Fix size arg of fgets(3).
 - fix libtirpc detection with -Wl,--as-needed.
 - Fix a typo in CREDITS.
+- Change .requestor to .requester for consistency.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index ad5cafd..fee93cc 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -238,7 +238,7 @@ int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev)
 			crit(ap->logopt, "attempt to remove directory from a "
 			     "non-autofs filesystem!");
 			crit(ap->logopt,
-			     "requestor dev == %llu, \"%s\" owner dev == %llu",
+			     "requester dev == %llu, \"%s\" owner dev == %llu",
 			     dev, buf, st.st_dev);
 			return -1;
 		}
diff --git a/include/automount.h b/include/automount.h
index c0f5fbf..2029e3d 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -425,8 +425,8 @@ struct pending_args {
 	char name[PATH_MAX];		/* Name field of the request */
 	dev_t dev;			/* device number of mount */
 	unsigned int len;		/* Name field len */
-	uid_t uid;			/* uid of requestor */
-	gid_t gid;			/* gid of requestor */
+	uid_t uid;			/* uid of requester */
+	gid_t gid;			/* gid of requester */
 	unsigned long wait_queue_token;	/* Associated kernel wait token */
 };
 
diff --git a/include/dev-ioctl-lib.h b/include/dev-ioctl-lib.h
index b96e0dd..eb9075c 100644
--- a/include/dev-ioctl-lib.h
+++ b/include/dev-ioctl-lib.h
@@ -46,7 +46,7 @@ struct ioctl_ops {
 	int (*setpipefd)(unsigned int, int, int);
 	int (*catatonic)(unsigned int, int);
 	int (*timeout)(unsigned int, int, time_t);
-	int (*requestor)(unsigned int, int, const char *, uid_t *, gid_t *);
+	int (*requester)(unsigned int, int, const char *, uid_t *, gid_t *);
 	int (*expire)(unsigned int, int, const char *, unsigned int);
 	int (*askumount)(unsigned int, int, unsigned int *);
 	int (*ismountpoint)(unsigned int, int, const char *, unsigned int *);
diff --git a/lib/dev-ioctl-lib.c b/lib/dev-ioctl-lib.c
index 85b3272..e851923 100644
--- a/lib/dev-ioctl-lib.c
+++ b/lib/dev-ioctl-lib.c
@@ -56,7 +56,7 @@ static int dev_ioctl_send_fail(unsigned int, int, unsigned int, int);
 static int dev_ioctl_setpipefd(unsigned int, int, int);
 static int dev_ioctl_catatonic(unsigned int, int);
 static int dev_ioctl_timeout(unsigned int, int, time_t);
-static int dev_ioctl_requestor(unsigned int, int, const char *, uid_t *, gid_t *);
+static int dev_ioctl_requester(unsigned int, int, const char *, uid_t *, gid_t *);
 static int dev_ioctl_expire(unsigned int, int, const char *, unsigned int);
 static int dev_ioctl_askumount(unsigned int, int, unsigned int *);
 static int dev_ioctl_ismountpoint(unsigned int, int, const char *, unsigned int *);
@@ -85,7 +85,7 @@ static struct ioctl_ops dev_ioctl_ops = {
 	.setpipefd	= dev_ioctl_setpipefd,
 	.catatonic	= dev_ioctl_catatonic,
 	.timeout	= dev_ioctl_timeout,
-	.requestor	= dev_ioctl_requestor,
+	.requester	= dev_ioctl_requester,
 	.expire		= dev_ioctl_expire,
 	.askumount	= dev_ioctl_askumount,
 	.ismountpoint	= dev_ioctl_ismountpoint
@@ -103,7 +103,7 @@ static struct ioctl_ops ioctl_ops = {
 	.setpipefd	= NULL,
 	.catatonic	= ioctl_catatonic,
 	.timeout	= ioctl_timeout,
-	.requestor	= NULL,
+	.requester	= NULL,
 	.expire		= ioctl_expire,
 	.askumount	= ioctl_askumount,
 	.ismountpoint	= NULL
@@ -261,7 +261,7 @@ static void free_dev_ioctl_open(struct autofs_dev_ioctl *ioctl)
 
 /*
  * Allocate a parameter struct for misc device ioctl which includes
- * a path. This is used when getting the last mount requestor uid
+ * a path. This is used when getting the last mount requester uid
  * and gid and when checking if a path within the autofs filesystem
  * is a mount point. We add the path to the end of the struct.
  */
@@ -607,7 +607,7 @@ static int ioctl_timeout(unsigned int logopt, int ioctlfd, time_t timeout)
  * process uid and gid (or string variations of them) for mount
  * lookups within the map entry.
  */
-static int dev_ioctl_requestor(unsigned int logopt,
+static int dev_ioctl_requester(unsigned int logopt,
 			       int ioctlfd, const char *path,
 			       uid_t *uid, gid_t *gid)
 {
diff --git a/lib/mounts.c b/lib/mounts.c
index c67548e..d3d7345 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -1602,7 +1602,7 @@ static int do_remount_direct(struct autofs_point *ap, int fd, const char *path)
 	gid_t gid;
 	int ret;
 
-	ops->requestor(ap->logopt, fd, path, &uid, &gid);
+	ops->requester(ap->logopt, fd, path, &uid, &gid);
 	if (uid != -1 && gid != -1)
 		set_tsd_user_vars(ap->logopt, uid, gid);
 
@@ -1671,7 +1671,7 @@ static int do_remount_indirect(struct autofs_point *ap, int fd, const char *path
 			}
 		}
 
-		ops->requestor(ap->logopt, fd, buf, &uid, &gid);
+		ops->requester(ap->logopt, fd, buf, &uid, &gid);
 		if (uid != -1 && gid != -1)
 			set_tsd_user_vars(ap->logopt, uid, gid);
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 09/37] autofs-5.1.2 - fix file map changed check
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (7 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 08/37] autofs-5.1.2 - Change .requestor to .requester for consistency Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 10/37] autofs-5.1.2 - Remove unused local 2KB buffer Ian Kent
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

The CLOCK_MONOTONIC time cannot be used to file status times, time(2)
must be used instead.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG             |    1 +
 modules/lookup_file.c |    9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6333959..837debd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@ xx/xx/2016 autofs-5.1.3
 - fix libtirpc detection with -Wl,--as-needed.
 - Fix a typo in CREDITS.
 - Change .requestor to .requester for consistency.
+- fix file map changed check.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index 72444fe..d87ec73 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -45,6 +45,7 @@ struct lookup_context {
 	const char *mapname;
 	int opts_argc;
 	const char **opts_argv;
+	time_t last_read;
 	struct parse_mod *parse;
 };
 
@@ -783,6 +784,7 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	}
 
 	source->age = age;
+	ctxt->last_read = time(NULL);
 
 	fclose(f);
 
@@ -1076,7 +1078,7 @@ static int check_map_indirect(struct autofs_point *ap,
 
 static int map_update_needed(struct autofs_point *ap,
 			     struct map_source *source,
-			     struct lookup_context * ctxt)
+			     struct lookup_context *ctxt)
 {
 	struct mapent_cache *mc;
 	struct mapent *me;
@@ -1097,9 +1099,7 @@ static int map_update_needed(struct autofs_point *ap,
 		return -1;
 	}
 
-	cache_readlock(mc);
-	me = cache_lookup_first(mc);
-	if (me && st.st_mtime <= me->age) {
+	if (st.st_mtime <= ctxt->last_read) {
 		/*
 		 * If any map instances are present for this source
 		 * then either we have plus included entries or we
@@ -1116,7 +1116,6 @@ static int map_update_needed(struct autofs_point *ap,
 			ret = 0;
 	} else
 		source->stale = 1;
-	cache_unlock(mc);
 
 	return ret;
 }

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 10/37] autofs-5.1.2 - Remove unused local 2KB buffer
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (8 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 09/37] autofs-5.1.2 - fix file map changed check Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 11/37] autofs-5.1.2 - Fix typos in error messages Ian Kent
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |    3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 837debd..7aa7b4a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@ xx/xx/2016 autofs-5.1.3
 - Fix a typo in CREDITS.
 - Change .requestor to .requester for consistency.
 - fix file map changed check.
+- Remove unused local 2KB buffer.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index fee93cc..1bdc3aa 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1901,7 +1901,6 @@ static void usage(void)
 
 static void show_build_info(void)
 {
-	char buf[2048];
 	int count = 0;
 
 	printf("\nLinux automount version %s\n", version);
@@ -1913,8 +1912,6 @@ static void show_build_info(void)
 
 	printf("\nCompile options:\n  ");
 
-	memset(buf, 0, 2048);
-
 #ifndef ENABLE_MOUNT_LOCKING
 	printf("DISABLE_MOUNT_LOCKING ");
 	count = 22;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 11/37] autofs-5.1.2 - Fix typos in error messages
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (9 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 10/37] autofs-5.1.2 - Remove unused local 2KB buffer Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 12/37] autofs-5.1.2 - Fix fgets(3) size argument (another one) Ian Kent
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |    4 ++--
 daemon/state.c     |    4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 7aa7b4a..a0a2c46 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@ xx/xx/2016 autofs-5.1.3
 - Change .requestor to .requester for consistency.
 - fix file map changed check.
 - Remove unused local 2KB buffer.
+- Fix typos in error messages.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index 1bdc3aa..e51909c 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -945,7 +945,7 @@ static int set_log_priority(const char *path, int priority)
 
 	if (priority > LOG_DEBUG || priority < LOG_EMERG) {
 		fprintf(stderr, "Log priority %d is invalid.\n", priority);
-		fprintf(stderr, "Please spcify a number in the range 0-7.\n");
+		fprintf(stderr, "Please specify a number in the range 0-7.\n");
 		return -1;
 	}
 
@@ -1078,7 +1078,7 @@ int do_expire(struct autofs_point *ap, const char *name, int namelen)
 	}
 
 	if (!len) {
-		crit(ap->logopt, "path to long for buffer");
+		crit(ap->logopt, "path too long for buffer");
 		return 1;
 	}
 
diff --git a/daemon/state.c b/daemon/state.c
index ed533da..5d81438 100644
--- a/daemon/state.c
+++ b/daemon/state.c
@@ -575,7 +575,7 @@ static unsigned int st_readmap(struct autofs_point *ap)
 
 	ra = malloc(sizeof(struct readmap_args));
 	if (!ra) {
-		error(ap->logopt, "failed to malloc reamap cond struct");
+		error(ap->logopt, "failed to malloc readmap cond struct");
 		/* It didn't work: return to ready */
 		st_ready(ap);
 		if (!ap->submount)
@@ -600,7 +600,7 @@ static unsigned int st_readmap(struct autofs_point *ap)
 
 	status = pthread_create(&thid, &th_attr_detached, do_readmap, ra);
 	if (status) {
-		error(ap->logopt, "read map thread create failed");
+		error(ap->logopt, "readmap thread create failed");
 		st_readmap_cleanup(ra);
 		free(ra);
 		/* It didn't work: return to ready */

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 12/37] autofs-5.1.2 - Fix fgets(3) size argument (another one)
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (10 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 11/37] autofs-5.1.2 - Fix typos in error messages Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 13/37] autofs-5.1.2 - fix short memory allocation in lookup_amd_instance() Ian Kent
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

1. fgets(3) reads at most 1 less then the size argument.
2. Each line of /proc/filesystem isn't a filesystem path.

So it doesn't really matter if the size argument is PATH_MAX-1
or PATH_MAX (=sizeof(buf)) as long as the buffer is large enough.
We can just use sizeof(buf).

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 daemon/module.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index a0a2c46..28e857f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@ xx/xx/2016 autofs-5.1.3
 - fix file map changed check.
 - Remove unused local 2KB buffer.
 - Fix typos in error messages.
+- Fix fgets(3) size argument (another one).
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/module.c b/daemon/module.c
index db01db8..8879b64 100644
--- a/daemon/module.c
+++ b/daemon/module.c
@@ -38,7 +38,7 @@ int load_autofs4_module(void)
 		return 0;
 	}
 
-	while (fgets(buf, PATH_MAX - 1, fp)) {
+	while (fgets(buf, sizeof(buf), fp)) {
 		if (strstr(buf, "autofs")) {
 			fclose(fp);
 			return 1;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 13/37] autofs-5.1.2 - fix short memory allocation in lookup_amd_instance()
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (11 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 12/37] autofs-5.1.2 - Fix fgets(3) size argument (another one) Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 14/37] autofs-5.1.2 - fix count_mounts() function Ian Kent
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

Fix off by one memory allocation size in lookup_amd_instance().

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 daemon/lookup.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 28e857f..551443a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,7 @@ xx/xx/2016 autofs-5.1.3
 - Remove unused local 2KB buffer.
 - Fix typos in error messages.
 - Fix fgets(3) size argument (another one).
+- fix short memory allocation in lookup_amd_instance().
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/lookup.c b/daemon/lookup.c
index 201ccbb..582b5c9 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -786,7 +786,7 @@ static int lookup_amd_instance(struct autofs_point *ap,
 		return NSS_STATUS_UNKNOWN;
 	}
 
-	m_key = malloc(strlen(ap->path) + strlen(me->multi->key) + 1);
+	m_key = malloc(strlen(ap->path) + strlen(me->multi->key) + 2);
 	if (!m_key) {
 		error(ap->logopt,
 		     "failed to allocate storage for search key");

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 14/37] autofs-5.1.2 - fix count_mounts() function
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (12 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 13/37] autofs-5.1.2 - fix short memory allocation in lookup_amd_instance() Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 15/37] autofs-5.1.2 - configure: add cache variable for Linux proc filesystem check Ian Kent
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

count_mounts() gets the number of mounts wrong, make it include the
base directory also.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 551443a..5fcd123 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@ xx/xx/2016 autofs-5.1.3
 - Fix typos in error messages.
 - Fix fgets(3) size argument (another one).
 - fix short memory allocation in lookup_amd_instance().
+- fix count_mounts() function.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index e51909c..8d98054 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -420,7 +420,7 @@ int count_mounts(struct autofs_point *ap, const char *path, dev_t dev)
 	counter.count = 0;
 	counter.dev = dev;
 	
-	if (walk_tree(path, counter_fn, 0, ap, &counter) == -1)
+	if (walk_tree(path, counter_fn, 1, ap, &counter) == -1)
 		return -1;
 
 	return counter.count;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 15/37] autofs-5.1.2 - configure: add cache variable for Linux proc filesystem check
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (13 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 14/37] autofs-5.1.2 - fix count_mounts() function Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 16/37] autofs-5.1.2 - Avoid local variable name shadowing another Ian Kent
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

When cross-compiling, whether the /proc filesystem is available in the
build environment does not give any indication as to whether it will
be available in the execution environment.

This commit therefore adjust the AF_LINUX_PROCFS macro to use
AC_CACHE_CHECK(), so that an ac_cv_linux_procfs variable can be
preseeded in the environment to force the result of this check.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG  |    1 +
 aclocal.m4 |   15 +++++----------
 configure  |   16 ++++++++--------
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 5fcd123..ec1812a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,7 @@ xx/xx/2016 autofs-5.1.3
 - Fix fgets(3) size argument (another one).
 - fix short memory allocation in lookup_amd_instance().
 - fix count_mounts() function.
+- configure: add cache variable for Linux proc filesystem check.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/aclocal.m4 b/aclocal.m4
index fe949a2..00811e0 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -80,16 +80,11 @@ dnl
 dnl Check for the Linux /proc filesystem
 dnl --------------------------------------------------------------------------
 AC_DEFUN(AF_LINUX_PROCFS,
-[AC_MSG_CHECKING(for Linux proc filesystem)
-if test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux"
-then
-	linux_procfs=yes
-else
-	linux_procfs=no
-fi
-AC_MSG_RESULT($linux_procfs)
-if test $linux_procfs = yes
-then
+[AC_CACHE_CHECK([for Linux proc filesystem], [ac_cv_linux_procfs],
+	[ac_cv_linux_procfs=no
+	 test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux" && ac_cv_linux_procfs=yes])
+ if test $ac_cv_linux_procfs = yes
+ then
 	AC_DEFINE(HAVE_LINUX_PROCFS, 1,
 		[Define if you have the Linux /proc filesystem.])
 fi])
diff --git a/configure b/configure
index 5a05fe1..8467582 100755
--- a/configure
+++ b/configure
@@ -2194,16 +2194,16 @@ $as_echo "$searchpath" >&6; }
 #
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux proc filesystem" >&5
 $as_echo_n "checking for Linux proc filesystem... " >&6; }
-if test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux"
-then
-	linux_procfs=yes
+if ${ac_cv_linux_procfs+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-	linux_procfs=no
+  ac_cv_linux_procfs=no
+	 test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux" && ac_cv_linux_procfs=yes
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $linux_procfs" >&5
-$as_echo "$linux_procfs" >&6; }
-if test $linux_procfs = yes
-then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linux_procfs" >&5
+$as_echo "$ac_cv_linux_procfs" >&6; }
+ if test $ac_cv_linux_procfs = yes
+ then
 
 $as_echo "#define HAVE_LINUX_PROCFS 1" >>confdefs.h
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 16/37] autofs-5.1.2 - Avoid local variable name shadowing another
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (14 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 15/37] autofs-5.1.2 - configure: add cache variable for Linux proc filesystem check Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:18 ` [PATCH 17/37] autofs-5.1.2 - fix typo in MOUNT_FLAG_GHOST comment Ian Kent
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>

There are two local variabls int ret, and the one in the
inner scope doesn't need to be named as int ret.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 daemon/automount.c |    6 +-----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index ec1812a..853d40c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -15,6 +15,7 @@ xx/xx/2016 autofs-5.1.3
 - fix short memory allocation in lookup_amd_instance().
 - fix count_mounts() function.
 - configure: add cache variable for Linux proc filesystem check.
+- Avoid local variable name shadowing another.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index 8d98054..9d4c2b7 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -310,17 +310,13 @@ static int walk_tree(const char *base, int (*fn) (struct autofs_point *ap,
 				return -1;
 
 			while (n--) {
-				int ret, size;
-
 				if (strcmp(de[n]->d_name, ".") == 0 ||
 				    strcmp(de[n]->d_name, "..") == 0) {
 					free(de[n]);
 					continue;
 				}
 
-				size = sizeof(buf);
-				ret = cat_path(buf, size, base, de[n]->d_name);
-				if (!ret) {
+				if (!cat_path(buf, sizeof(buf), base, de[n]->d_name)) {
 					do {
 						free(de[n]);
 					} while (n--);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 17/37] autofs-5.1.2 - fix typo in MOUNT_FLAG_GHOST comment
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (15 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 16/37] autofs-5.1.2 - Avoid local variable name shadowing another Ian Kent
@ 2016-10-25  1:18 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 18/37] autofs-5.1.2 - fix cachefs parse message not being logged Ian Kent
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:18 UTC (permalink / raw)
  To: autofs mailing list

Signed-off-by: Ian Kent <raven@themaw.net>
---
 include/automount.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/automount.h b/include/automount.h
index 2029e3d..f643f84 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -507,7 +507,7 @@ struct kernel_mod_version {
 	unsigned int minor;
 };
 
-/* Enable/disable gohsted directories */
+/* Enable/disable ghosted directories */
 #define MOUNT_FLAG_GHOST		0x0001
 
 /* Directory created for this mount? */

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 18/37] autofs-5.1.2 - fix cachefs parse message not being logged
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (16 preceding siblings ...)
  2016-10-25  1:18 ` [PATCH 17/37] autofs-5.1.2 - fix typo in MOUNT_FLAG_GHOST comment Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 19/37] autofs-5.1.2 - fix argc off by one in mount_autofs.c Ian Kent
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

Signed-off-by: Ian Kent <raven@themaw.net>
---
 modules/amd_parse.y |    1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/amd_parse.y b/modules/amd_parse.y
index ce8623d..bfa1d51 100644
--- a/modules/amd_parse.y
+++ b/modules/amd_parse.y
@@ -301,6 +301,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
 		} else if (!strcmp($3, "cachefs")) {
 			sprintf(msg_buf, "file syatem %s is not "
 					 "supported by autofs, ignored", $3);
+			amd_msg(msg_buf);
 		} else {
 			amd_notify($1);
 			YYABORT;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 19/37] autofs-5.1.2 - fix argc off by one in mount_autofs.c
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (17 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 18/37] autofs-5.1.2 - fix cachefs parse message not being logged Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 20/37] autofs-5.1.2 - fix _strncmp() usage Ian Kent
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

The mount_autofs.c module incorrectly calculates the number of
arguments to its map.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG              |    1 +
 modules/mount_autofs.c |    8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 853d40c..f46428c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@ xx/xx/2016 autofs-5.1.3
 - fix count_mounts() function.
 - configure: add cache variable for Linux proc filesystem check.
 - Avoid local variable name shadowing another.
+- fix argc off by one in mount_autofs.c.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
index c6a3199..65c0a06 100644
--- a/modules/mount_autofs.c
+++ b/modules/mount_autofs.c
@@ -179,11 +179,11 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 
 	if (options) {
 		char *t = options;
-		do {
+		while ((t = strchr(t, ',')) != NULL) {
 			argc++;
 			if (*t == ',')
 				t++;
-		} while ((t = strchr(t, ',')) != NULL);
+		}
 	}
 	argv = (const char **) alloca((argc + 1) * sizeof(char *));
 
@@ -235,13 +235,13 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 
 	if (options) {
 		p = options;
-		do {
+		while ((p = strchr(p, ',')) != NULL) {
 			if (*p == ',') {
 				*p = '\0';
 				p++;
 			}
 			argv[argc++] = p;
-		} while ((p = strchr(p, ',')) != NULL);
+		}
 	}
 	argv[argc] = NULL;
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 20/37] autofs-5.1.2 - fix _strncmp() usage
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (18 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 19/37] autofs-5.1.2 - fix argc off by one in mount_autofs.c Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 21/37] autofs-5.1.1 - fix create_client() RPC client handling Ian Kent
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

A change to fix nfs mount options changed to using a custom strncmp()
function.

While the usage of the function is correct in the nfs and bind mount
modules it isn't correct in the autofs and ext2 mount modules.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG              |    1 +
 modules/mount_autofs.c |   12 ++++++------
 modules/mount_ext2.c   |    2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index f46428c..940c6ba 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,7 @@ xx/xx/2016 autofs-5.1.3
 - configure: add cache variable for Linux proc filesystem check.
 - Avoid local variable name shadowing another.
 - fix argc off by one in mount_autofs.c.
+- fix _strncmp() usage.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
index 65c0a06..0476a09 100644
--- a/modules/mount_autofs.c
+++ b/modules/mount_autofs.c
@@ -121,17 +121,17 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			while (*comma != '\0' && *comma != ',')
 				comma++;
 
-			if (_strncmp(cp, "nobrowse", 8) == 0)
+			if (_strncmp("nobrowse", cp, 8) == 0)
 				ghost = 0;
-			else if (_strncmp(cp, "nobind", 6) == 0)
+			else if (_strncmp("nobind", cp, 6) == 0)
 				nobind = 1;
-			else if (_strncmp(cp, "browse", 6) == 0)
+			else if (_strncmp("browse", cp, 6) == 0)
 				ghost = 1;
-			else if (_strncmp(cp, "symlink", 7) == 0)
+			else if (_strncmp("symlink", cp, 7) == 0)
 				symlnk = 1;
-			else if (_strncmp(cp, "hosts", 5) == 0)
+			else if (_strncmp("hosts", cp, 5) == 0)
 				hosts = 1;
-			else if (_strncmp(cp, "timeout=", 8) == 0) {
+			else if (_strncmp("timeout=", cp, 8) == 0) {
 				char *val = strchr(cp, '=');
 				unsigned tout;
 				if (val) {
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index c00e3d5..90fc087 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -82,7 +82,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
 
 	if (options && options[0]) {
 		for (p = options; (p1 = strchr(p, ',')); p = p1)
-			if (!_strncmp(p, "ro", p1 - p) && ++p1 - p == sizeof("ro"))
+			if (!_strncmp("ro", p, p1 - p) && ++p1 - p == sizeof("ro"))
 				ro = 1;
 		if (!strcmp(p, "ro"))
 			ro = 1;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 21/37] autofs-5.1.1 - fix create_client() RPC client handling
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (19 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 20/37] autofs-5.1.2 - fix _strncmp() usage Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 22/37] autofs-5.1.2 - update and add README for old autofs schema Ian Kent
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

The autofs socket minimization strategy is to reuse the socket
descriptor when creating an RPC client for the same protocol.

But in create_client() there is a case where the socket descriptor
can be obtained from RPC client, the RPC client destroyed, but
not cleared in the persistent data structure.

In create_client(), once an attempt is done to get the socket
descriptor, the RPC client should always be destroyed and cleared
in the persistent data structure.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG      |    1 +
 lib/rpc_subs.c |   21 ++++++++-------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 940c6ba..4e2e482 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@ xx/xx/2016 autofs-5.1.3
 - Avoid local variable name shadowing another.
 - fix argc off by one in mount_autofs.c.
 - fix _strncmp() usage.
+- fix create_client() RPC client handling.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
index 8995996..d0d4cf5 100644
--- a/lib/rpc_subs.c
+++ b/lib/rpc_subs.c
@@ -654,14 +654,12 @@ static int create_client(struct conn_info *info, CLIENT **client)
 	*client = NULL;
 
 	if (info->client) {
-		if (!clnt_control(info->client, CLGET_FD, (char *) &fd)) {
-			fd = RPC_ANYSOCK;
-			clnt_destroy(info->client);
-			info->client = NULL;
-		} else {
+		if (clnt_control(info->client, CLGET_FD, (char *) &fd))
 			clnt_control(info->client, CLSET_FD_NCLOSE, NULL);
-			clnt_destroy(info->client);
-		}
+		else
+			fd = RPC_ANYSOCK;
+		clnt_destroy(info->client);
+		info->client = NULL;
 	}
 
 	if (info->addr) {
@@ -677,7 +675,7 @@ static int create_client(struct conn_info *info, CLIENT **client)
 			goto out_close;
 		}
 
-		if (!info->client && fd != RPC_ANYSOCK) {
+		if (fd != RPC_ANYSOCK) {
 			close(fd);
 			fd = RPC_ANYSOCK;
 		}
@@ -695,7 +693,6 @@ static int create_client(struct conn_info *info, CLIENT **client)
 	if (ret) {
 		error(LOGOPT_ANY,
 		      "hostname lookup failed: %s", gai_strerror(ret));
-		info->client = NULL;
 		goto out_close;
 	}
 
@@ -714,7 +711,7 @@ static int create_client(struct conn_info *info, CLIENT **client)
 			goto out_close;
 		}
 
-		if (!info->client && fd != RPC_ANYSOCK) {
+		if (fd != RPC_ANYSOCK) {
 			close(fd);
 			fd = RPC_ANYSOCK;
 		}
@@ -726,7 +723,6 @@ static int create_client(struct conn_info *info, CLIENT **client)
 
 done:
 	if (!*client) {
-		info->client = NULL;
 		ret = -ENOTCONN;
 		goto out_close;
 	}
@@ -734,7 +730,6 @@ done:
 	/* Close socket fd on destroy, as is default for rpcowned fds */
 	if  (!clnt_control(*client, CLSET_FD_CLOSE, NULL)) {
 		clnt_destroy(*client);
-		info->client = NULL;
 		ret = -ENOTCONN;
 		goto out_close;
 	}
@@ -742,7 +737,7 @@ done:
 	return 0;
 
 out_close:
-	if (fd != -1)
+	if (fd != RPC_ANYSOCK)
 		close(fd);
 	return ret;
 }

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 22/37] autofs-5.1.2 - update and add README for old autofs schema
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (20 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 21/37] autofs-5.1.1 - fix create_client() RPC client handling Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 23/37] autofs-5.1.2 - wait for master map available at start Ian Kent
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

The distribution file samples/autofs.schema is very old and is
incorrect.

This schema was added to the discribution long ago when it was
not clear what schema to use for Linux autofs information.

The schema was updated (at least to have consistent OIDs) somewhere
along the line but the autofs distribution copy was never updated.
The schema has now been updated in autofs but it is not recommended
for use as the schema for autofs map information.

The rfc2307 or, preferably the, rfc2307bis schema is the recommened
schema to use.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG             |    1 +
 README.autofs-schema  |   18 ++++++++++++++++++
 samples/autofs.schema |   24 ++++++++++--------------
 3 files changed, 29 insertions(+), 14 deletions(-)
 create mode 100644 README.autofs-schema

diff --git a/CHANGELOG b/CHANGELOG
index 4e2e482..686d404 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@ xx/xx/2016 autofs-5.1.3
 - fix argc off by one in mount_autofs.c.
 - fix _strncmp() usage.
 - fix create_client() RPC client handling.
+- update and add README for old autofs schema.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/README.autofs-schema b/README.autofs-schema
new file mode 100644
index 0000000..c121e1c
--- /dev/null
+++ b/README.autofs-schema
@@ -0,0 +1,18 @@
+autofs schema
+=============
+
+The distribution file samples/autofs.schema is very old and is
+incorrect.
+
+This schema was added to the discribution long ago when it was
+not clear what schema to use for Linux autofs information.
+
+The schema was corrected somewhere along the line but the autofs
+distribution copy was never updated. The schema has now been
+updated but it is not recommended for use as the schema for autofs
+map information.
+
+The rfc2307 or, preferably the, rfc2307bis schema is the recommened
+schema to use.
+
+Ian
diff --git a/samples/autofs.schema b/samples/autofs.schema
index 98d78c4..07e23b4 100644
--- a/samples/autofs.schema
+++ b/samples/autofs.schema
@@ -1,6 +1,3 @@
-#
-# $id$
-#
 # Depends upon core.schema and cosine.schema
 
 # OID Base is 1.3.6.1.4.1.2312.4
@@ -11,17 +8,16 @@
 
 # Attribute Type Definitions
 
-attributetype ( 1.3.6.1.1.1.1.25 NAME 'automountInformation'
-        DESC 'Information used by the autofs automounter'
-        EQUALITY caseExactIA5Match
-        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+attributetype ( 1.3.6.1.4.1.2312.4.1.2 NAME 'automountInformation'
+	DESC 'Information used by the autofs automounter'
+	EQUALITY caseExactMatch
+	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
 
-objectclass ( 1.3.6.1.1.1.1.13 NAME 'automount' SUP top STRUCTURAL
-        DESC 'An entry in an automounter map'
-        MUST ( cn $ automountInformation $ objectclass )
-        MAY ( description ) )
+objectclass ( 1.3.6.1.4.1.2312.4.2.3 NAME 'automount' SUP top STRUCTURAL
+	DESC 'An entry in an automounter map'
+	MUST ( cn $ automountInformation $ objectclass )
+	MAY ( description ) )
 
 objectclass ( 1.3.6.1.4.1.2312.4.2.2 NAME 'automountMap' SUP top STRUCTURAL
-        DESC 'An group of related automount objects'
-        MUST ( ou ) )
-
+	DESC 'An group of related automount objects'
+	MUST ( ou ) )

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 23/37] autofs-5.1.2 - wait for master map available at start
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (21 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 22/37] autofs-5.1.2 - update and add README for old autofs schema Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 24/37] autofs-5.1.2 - add master read wait option Ian Kent
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

If the network map source isn't available at start the master map
can't be read. In this case we should wait until it is available
so we can get a startup map.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG                |    1 +
 daemon/automount.c       |   81 ++++++++++++++++++++++++++++++++++++++++------
 daemon/lookup.c          |    8 +++++
 lib/master.c             |    3 ++
 modules/lookup_file.c    |    6 +++
 modules/lookup_nisplus.c |   14 ++++++--
 modules/lookup_yp.c      |   13 +++++--
 7 files changed, 108 insertions(+), 18 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 686d404..d1bc1e1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@ xx/xx/2016 autofs-5.1.3
 - fix _strncmp() usage.
 - fix create_client() RPC client handling.
 - update and add README for old autofs schema.
+- wait for master map available at start.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index 9d4c2b7..14af9ff 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -1403,9 +1403,10 @@ static void *do_read_master(void *arg)
 	return NULL;
 }
 
-static int do_hup_signal(struct master *master, time_t age)
+static int do_hup_signal(struct master *master)
 {
 	unsigned int logopt = master->logopt;
+	time_t age = monotonic_time(NULL);
 	pthread_t thid;
 	int status;
 
@@ -1494,7 +1495,7 @@ static void *statemachine(void *arg)
 			break;
 
 		case SIGHUP:
-			do_hup_signal(master_list, monotonic_time(NULL));
+			do_hup_signal(master_list);
 			break;
 
 		default:
@@ -2052,12 +2053,56 @@ static void remove_empty_args(char **argv, int *argc)
 	*argc = j;
 }
 
+static int do_master_read_master(struct master *master, int wait)
+{
+	sigset_t signalset;
+	/* Wait must be at least 1 second */
+	unsigned int retry_wait = 2;
+	unsigned int elapsed = 0;
+	int max_wait = wait;
+	int ret = 0;
+	time_t age;
+
+	sigemptyset(&signalset);
+	sigaddset(&signalset, SIGTERM);
+	sigaddset(&signalset, SIGINT);
+	sigaddset(&signalset, SIGHUP);
+	sigprocmask(SIG_UNBLOCK, &signalset, NULL);
+
+	while (1) {
+		struct timespec t = { retry_wait, 0 };
+
+		age = monotonic_time(NULL);
+		if (master_read_master(master, age, 0)) {
+			ret = 1;
+			break;
+		}
+
+		if (nanosleep(&t, NULL) == -1)
+			break;
+
+		if (max_wait > 0) {
+			elapsed += retry_wait;
+			if (elapsed >= max_wait) {
+				logmsg("problem reading master map, "
+					"maximum wait exceeded");
+				break;
+			}
+		}
+	}
+
+	sigprocmask(SIG_BLOCK, &signalset, NULL);
+
+	return ret;
+}
+
 int main(int argc, char *argv[])
 {
 	int res, opt, status;
 	int logpri = -1;
 	unsigned ghost, logging, daemon_check;
 	unsigned dumpmaps, foreground, have_global_options;
+	unsigned master_read;
 	time_t timeout;
 	time_t age = monotonic_time(NULL);
 	struct rlimit rlim;
@@ -2452,14 +2497,16 @@ int main(int argc, char *argv[])
 		dh_tirpc = dlopen("libtirpc.so.3", RTLD_NOW);
 #endif
 
-	if (!master_read_master(master_list, age, 0)) {
-		master_kill(master_list);
-		*pst_stat = 3;
-		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
-		close(start_pipefd[1]);
-		release_flag_file();
-		macro_free_global_table();
-		exit(3);
+	master_read = master_read_master(master_list, age, 0);
+	if (!master_read) {
+		if (foreground)
+			logerr("%s: failed to read master map, "
+			       "will retry!",
+			       program);
+		else
+			logerr("%s: failed to read master map, "
+			       "will retry in background!",
+			       program);
 	}
 
 	/*
@@ -2472,6 +2519,20 @@ int main(int argc, char *argv[])
 	res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
 	close(start_pipefd[1]);
 
+	if (!master_read) {
+		/*
+		 * Read master map, waiting until it is available, unless
+		 * a signal is received, in which case exit returning an
+		 * error.
+		 */
+		if (!do_master_read_master(master_list, -1)) {
+			logerr("%s: failed to read master map!", program);
+			master_kill(master_list);
+			release_flag_file();
+			exit(3);
+		}
+	}
+
 	state_mach_thid = pthread_self();
 	statemachine(NULL);
 
diff --git a/daemon/lookup.c b/daemon/lookup.c
index 582b5c9..0c2a01f 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -241,6 +241,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
 	}
 
 	/* First one gets it */
+	result = NSS_STATUS_UNKNOWN;
 	head = &nsslist;
 	list_for_each(p, head) {
 		struct nss_source *this;
@@ -248,6 +249,13 @@ int lookup_nss_read_master(struct master *master, time_t age)
 
 		this = list_entry(p, struct nss_source, list);
 
+		if (strncmp(this->source, "files", 5) &&
+		    strncmp(this->source, "nis", 3) &&
+		    strncmp(this->source, "nisplus", 7) &&
+		    strncmp(this->source, "ldap", 4) &&
+		    strncmp(this->source, "sss", 3))
+			continue;
+
 		debug(logopt,
 		      "reading master %s %s", this->source, master->name);
 
diff --git a/lib/master.c b/lib/master.c
index 9ffdd1a..4c6e79b 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -923,7 +923,10 @@ int master_read_master(struct master *master, time_t age, int readall)
 		master_mount_mounts(master, age, readall);
 	else {
 		master->read_fail = 0;
+		/* HUP signal sets readall == 1 only */
 		if (!readall)
+			return 0;
+		else
 			master_mount_mounts(master, age, readall);
 	}
 
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index d87ec73..d5f8c9e 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -507,6 +507,12 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 				     MODPREFIX
 				     "failed to read included master map %s",
 				     master->name);
+				/*
+				 * If we're starting up wee need the whole
+				 * master map initially, so tell the upper
+				 * layer to retry.
+				 */
+				master->read_fail = 1;
 			}
 			master->depth--;
 			master->recurse = 0;
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index 7832611..c8b75e6 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -149,19 +149,25 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
 		logerr(MODPREFIX "malloc: %s", estr);
 		pthread_setcancelstate(cur_state, NULL);
-		return NSS_STATUS_UNAVAIL;
+		return NSS_STATUS_UNKNOWN;
 	}
 	sprintf(tablename, "%s.org_dir.%s", ctxt->mapname, ctxt->domainname);
 
 	/* check that the table exists */
 	result = nis_lookup(tablename, FOLLOW_PATH | FOLLOW_LINKS);
 	if (result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) {
+		int status = result->status;
 		nis_freeresult(result);
-		crit(logopt,
-		     MODPREFIX "couldn't locate nis+ table %s", ctxt->mapname);
 		free(tablename);
 		pthread_setcancelstate(cur_state, NULL);
-		return NSS_STATUS_NOTFOUND;
+		if (status == NIS_UNAVAIL || status == NIS_FAIL)
+			return NSS_STATUS_UNAVAIL;
+		else {
+			crit(logopt,
+			     MODPREFIX "couldn't locate nis+ table %s",
+			     ctxt->mapname);
+			return NSS_STATUS_NOTFOUND;
+		}
 	}
 
 	sprintf(tablename, "[],%s.org_dir.%s", ctxt->mapname, ctxt->domainname);
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index 502d850..0d319fd 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -282,9 +282,9 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 	char *mapname;
 	int err;
 
-	mapname = alloca(strlen(ctxt->mapname) + 1);
+	mapname = malloc(strlen(ctxt->mapname) + 1);
 	if (!mapname)
-		return 0;
+		return NSS_STATUS_UNKNOWN;
 
 	strcpy(mapname, ctxt->mapname);
 
@@ -308,19 +308,24 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 			err = yp_all((char *) ctxt->domainname, mapname, &ypcb);
 		}
 
-		if (err == YPERR_SUCCESS)
+		if (err == YPERR_SUCCESS) {
+			free(mapname);
 			return NSS_STATUS_SUCCESS;
+		}
 
 		info(logopt,
 		     MODPREFIX "read of master map %s failed: %s",
 		     mapname, yperr_string(err));
 
-		if (err == YPERR_PMAP || err == YPERR_YPSERV)
+		free(mapname);
+
+		if (err == YPERR_YPSERV || err == YPERR_DOMAIN)
 			return NSS_STATUS_UNAVAIL;
 
 		return NSS_STATUS_NOTFOUND;
 	}
 
+	free(mapname);
 	return NSS_STATUS_SUCCESS;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 24/37] autofs-5.1.2 - add master read wait option
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (22 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 23/37] autofs-5.1.2 - wait for master map available at start Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 25/37] autofs-5.1.2 - work around sss startup delay Ian Kent
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

Add command line and configuration options to set the amount of time to
wait for the master map to become available at program start.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG                      |    1 +
 daemon/automount.c             |   11 +++++++++--
 include/defaults.h             |    2 ++
 lib/defaults.c                 |   17 +++++++++++++++++
 man/autofs.conf.5.in           |    5 +++++
 man/automount.8                |    4 ++++
 redhat/autofs.conf.default.in  |    7 +++++++
 samples/autofs.conf.default.in |    7 +++++++
 8 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index d1bc1e1..576f52a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -21,6 +21,7 @@ xx/xx/2016 autofs-5.1.3
 - fix create_client() RPC client handling.
 - update and add README for old autofs schema.
 - wait for master map available at start.
+- add master read wait option.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/automount.c b/daemon/automount.c
index 14af9ff..72c980e 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -2103,10 +2103,11 @@ int main(int argc, char *argv[])
 	unsigned ghost, logging, daemon_check;
 	unsigned dumpmaps, foreground, have_global_options;
 	unsigned master_read;
+	int master_wait;
 	time_t timeout;
 	time_t age = monotonic_time(NULL);
 	struct rlimit rlim;
-	const char *options = "+hp:t:vmdD:fVrO:l:n:CF";
+	const char *options = "+hp:t:vmdD:fVrO:l:n:CFM";
 	static const struct option long_options[] = {
 		{"help", 0, 0, 'h'},
 		{"pid-file", 1, 0, 'p'},
@@ -2123,6 +2124,7 @@ int main(int argc, char *argv[])
 		{"set-log-priority", 1, 0, 'l'},
 		{"dont-check-daemon", 0, 0, 'C'},
 		{"force", 0, 0, 'F'},
+		{"master-wait", 1, 0, 'M'},
 		{0, 0, 0, 0}
 	};
 
@@ -2143,6 +2145,7 @@ int main(int argc, char *argv[])
 	nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check);
 
 	kpkt_len = get_kpkt_len();
+	master_wait = defaults_get_master_wait();
 	timeout = defaults_get_timeout();
 	ghost = defaults_get_browse_mode();
 	logging = defaults_get_logging();
@@ -2202,6 +2205,10 @@ int main(int argc, char *argv[])
 			dumpmaps = 1;
 			break;
 
+		case 'M':
+			master_wait = getnumopt(optarg, opt);
+			break;
+
 		case 'O':
 			if (!have_global_options) {
 				global_options = strdup(optarg);
@@ -2525,7 +2532,7 @@ int main(int argc, char *argv[])
 		 * a signal is received, in which case exit returning an
 		 * error.
 		 */
-		if (!do_master_read_master(master_list, -1)) {
+		if (!do_master_read_master(master_list, master_wait)) {
 			logerr("%s: failed to read master map!", program);
 			master_kill(master_list);
 			release_flag_file();
diff --git a/include/defaults.h b/include/defaults.h
index 8db2bb1..80db18d 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -25,6 +25,7 @@
 #define DEFAULT_MASTER_MAP_NAME	"auto.master"
 
 #define DEFAULT_TIMEOUT			"600"
+#define DEFAULT_MASTER_WAIT		"-1"
 #define DEFAULT_NEGATIVE_TIMEOUT	"60"
 #define DEFAULT_MOUNT_WAIT		"-1"
 #define DEFAULT_UMOUNT_WAIT		"12"
@@ -152,6 +153,7 @@ void defaults_conf_release(void);
 const char *defaults_get_master_map(void);
 int defaults_master_set(void);
 unsigned int defaults_get_timeout(void);
+int defaults_get_master_wait(void);
 unsigned int defaults_get_negative_timeout(void);
 unsigned int defaults_get_browse_mode(void);
 unsigned int defaults_get_logging(void);
diff --git a/lib/defaults.c b/lib/defaults.c
index ae76513..5fa4a2b 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -48,6 +48,7 @@
 #define NAME_MASTER_MAP			"master_map_name"
 
 #define NAME_TIMEOUT			"timeout"
+#define NAME_MASTER_WAIT		"master_wait"
 #define NAME_NEGATIVE_TIMEOUT		"negative_timeout"
 #define NAME_BROWSE_MODE		"browse_mode"
 #define NAME_LOGGING			"logging"
@@ -288,6 +289,11 @@ static int conf_load_autofs_defaults(void)
 	if (ret == CFG_FAIL)
 		goto error;
 
+	ret = conf_update(sec, NAME_MASTER_WAIT,
+			  DEFAULT_MASTER_WAIT, CONF_ENV);
+	if (ret == CFG_FAIL)
+		goto error;
+
 	ret = conf_update(sec, NAME_NEGATIVE_TIMEOUT,
 			  DEFAULT_NEGATIVE_TIMEOUT, CONF_ENV);
 	if (ret == CFG_FAIL)
@@ -1569,6 +1575,17 @@ unsigned int defaults_get_timeout(void)
 	return (unsigned int) timeout;
 }
 
+int defaults_get_master_wait(void)
+{
+	long wait;
+
+	wait = conf_get_number(autofs_gbl_sec, NAME_MASTER_WAIT);
+	if (wait < 0)
+		wait = atol(DEFAULT_MASTER_WAIT);
+
+	return (int) wait;
+}
+
 unsigned int defaults_get_negative_timeout(void)
 {
 	long n_timeout;
diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in
index 4405ac8..466db10 100644
--- a/man/autofs.conf.5.in
+++ b/man/autofs.conf.5.in
@@ -30,6 +30,11 @@ default is 10 minutes, but the default installed configuration
 overrides this and sets the timeout to 5 minutes to be consistent
 with earlier autofs releases.
 .TP
+.B master_wait
+sets the default maximum time to wait for the master map to become
+available if it cannot be read at program start (program default -1,
+wait forever).
+.TP
 .B negative_timeout
 .br
 Set the default timeout for caching failed key lookups (program default
diff --git a/man/automount.8 b/man/automount.8
index d1db4ec..601c18c 100644
--- a/man/automount.8
+++ b/man/automount.8
@@ -37,6 +37,10 @@ The internal program default is 10 minutes, but the default
 installed configuration overrides this and sets the timeout
 to 5 minutes to be consistent with earlier autofs releases.
 .TP
+.I "\-M <seconds>, \-\-master-wait <seconds>"
+Set the maximum time to wait for the master map to become available
+if it cannot be read at program start.
+.TP
 .I "\-n <seconds>, \-\-negative\-timeout <seconds>"
 Set the default timeout for caching failed key lookups. The default is 60 seconds.
 .TP
diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in
index d114249..2fa8a4c 100644
--- a/redhat/autofs.conf.default.in
+++ b/redhat/autofs.conf.default.in
@@ -14,6 +14,13 @@
 #
 timeout = 300
 #
+# master_wait - set the default maximum time to wait for the
+# 		master map to become available if it cannot
+# 		be read at program start (default -1, wait
+# 		forever).
+#
+#master_wait = -1
+#
 # negative_timeout - set the default negative timeout for
 # 		     failed mount attempts (default 60).
 #
diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
index bc25f52..77c5999 100644
--- a/samples/autofs.conf.default.in
+++ b/samples/autofs.conf.default.in
@@ -14,6 +14,13 @@
 #
 timeout = 300
 #
+# master_wait - set the default maximum time to wait for the
+# 		master map to become available if it cannot
+# 		be read at program start (default -1, wait
+# 		forever).
+#
+# master_wait = -1
+#
 # negative_timeout - set the default negative timeout for
 # 		     failed mount attempts (default 60).
 #

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 25/37] autofs-5.1.2 - work around sss startup delay
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (23 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 24/37] autofs-5.1.2 - add master read wait option Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 26/37] autofs-5.1.2 - add sss master map wait config option Ian Kent
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

When sssd is starting up there can be a delay before the map
information is read. During that time an ENOENT can be returned
when there actually is a map and autofs must respect the ENOENT
return and continue becuase no map present is a valid response.

To work around that make the master map read wait and retry for
for a time to give sssd a chance to read the map before returning
either an ENOENT or, if the retry limit is exceeded, ETIMEDOUT.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG            |    1 +
 modules/lookup_sss.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 576f52a..90688e6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@ xx/xx/2016 autofs-5.1.3
 - update and add README for old autofs schema.
 - wait for master map available at start.
 - add master read wait option.
+- work around sss startup delay.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index e01dd28..702e7b5 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -30,6 +30,11 @@
 
 #define MAPFMT_DEFAULT "sun"
 
+/* Half a second between retries */
+#define SETAUTOMOUNTENT_MASTER_INTERVAL	500000000
+/* Try for 10 seconds */
+#define SETAUTOMOUNTENT_MASTER_RETRIES	10 * 2
+
 #define MODPREFIX "lookup(sss): "
 
 #define SSS_SO_NAME "libsss_autofs"
@@ -219,6 +224,53 @@ static int setautomntent(unsigned int logopt,
 	return ret;
 }
 
+static int setautomntent_wait(unsigned int logopt,
+			      struct lookup_context *ctxt,
+			      const char *mapname,
+			      void **sss_ctxt, unsigned int retries)
+{
+	unsigned int retry = 0;
+	int ret = 0;
+
+	*sss_ctxt = NULL;
+
+	while (++retry < retries) {
+		struct timespec t = { 0, SETAUTOMOUNTENT_MASTER_INTERVAL };
+		struct timespec r;
+
+		ret = ctxt->setautomntent(mapname, sss_ctxt);
+		if (ret != ENOENT)
+			break;
+
+		if (*sss_ctxt) {
+			free(*sss_ctxt);
+			*sss_ctxt = NULL;
+		}
+
+		while (nanosleep(&t, &r) == -1 && errno == EINTR)
+			memcpy(&t, &r, sizeof(struct timespec));
+	}
+
+
+	if (ret) {
+		char buf[MAX_ERR_BUF];
+		char *estr;
+
+		if (*sss_ctxt) {
+			free(*sss_ctxt);
+			*sss_ctxt = NULL;
+		}
+
+		if (retry == retries)
+			ret = ETIMEDOUT;
+
+		estr = strerror_r(ret, buf, MAX_ERR_BUF);
+		error(logopt, MODPREFIX "setautomntent: %s", estr);
+	}
+
+	return ret;
+}
+
 static int endautomntent(unsigned int logopt,
 			 struct lookup_context *ctxt, void **sss_ctxt)
 {
@@ -247,6 +299,15 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 
 	ret = setautomntent(logopt, ctxt, ctxt->mapname, &sss_ctxt);
 	if (ret) {
+		unsigned int retries;
+
+		if (ret != ENOENT)
+			return NSS_STATUS_UNAVAIL;
+
+		retries = SETAUTOMOUNTENT_MASTER_RETRIES;
+		ret = setautomntent_wait(logopt,
+					 ctxt, ctxt->mapname, &sss_ctxt,
+					 retries);
 		if (ret == ENOENT)
 			return NSS_STATUS_NOTFOUND;
 		return NSS_STATUS_UNAVAIL;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 26/37] autofs-5.1.2 - add sss master map wait config option
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (24 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 25/37] autofs-5.1.2 - work around sss startup delay Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 27/37] autofs-5.1.2 - fix typos in README.amd-maps Ian Kent
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

When sssd is starting up it can sometimes return "no such entry" for a
short time until it has read in the LDAP map information. This affects
reading the master map at autofs startup and results in no automount
mounts if sssd is the primary map source.

This problem should be resolved in sssd but it's a problem for the
moment so a configuration option, sss_master_map_wait, has been added
to work around it.

The internal program default is 0, don't wait but the installed
configuration sets this to 10 seconds to work around the problem.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG                      |    1 +
 include/defaults.h             |    3 +++
 lib/defaults.c                 |   18 ++++++++++++++++++
 man/autofs.conf.5.in           |    7 +++++++
 modules/lookup_sss.c           |    7 ++++---
 redhat/autofs.conf.default.in  |   10 ++++++++++
 samples/autofs.conf.default.in |   10 ++++++++++
 7 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 90688e6..e89086b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -23,6 +23,7 @@ xx/xx/2016 autofs-5.1.3
 - wait for master map available at start.
 - add master read wait option.
 - work around sss startup delay.
+- add sss master map wait config option.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/defaults.h b/include/defaults.h
index 80db18d..1dea48c 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -51,6 +51,8 @@
 #define DEFAULT_USE_HOSTNAME_FOR_MOUNTS  "0"
 #define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0"
 
+#define DEFAULT_SSS_MASTER_MAP_WAIT	"0"
+
 /* Config entry flags */
 #define CONF_NONE			0x00000000
 #define CONF_ENV			0x00000001
@@ -169,6 +171,7 @@ const char *defaults_get_auth_conf_file(void);
 unsigned int defaults_get_map_hash_table_size(void);
 unsigned int defaults_use_hostname_for_mounts(void);
 unsigned int defaults_disable_not_found_message(void);
+unsigned int defaults_get_sss_master_map_wait(void);
 
 unsigned int conf_amd_mount_section_exists(const char *);
 char *conf_amd_get_arch(void);
diff --git a/lib/defaults.c b/lib/defaults.c
index 5fa4a2b..3ac231b 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -77,6 +77,8 @@
 #define NAME_USE_HOSTNAME_FOR_MOUNTS	"use_hostname_for_mounts"
 #define NAME_DISABLE_NOT_FOUND_MESSAGE	"disable_not_found_message"
 
+#define NAME_SSS_MASTER_MAP_WAIT	"sss_master_map_wait"
+
 #define NAME_AMD_ARCH				"arch"
 #define NAME_AMD_AUTO_ATTRCACHE			"auto_attrcache"
 #define NAME_AMD_AUTO_DIR			"auto_dir"
@@ -354,6 +356,11 @@ static int conf_load_autofs_defaults(void)
 	if (ret == CFG_FAIL)
 		goto error;
 
+	ret = conf_update(sec, NAME_SSS_MASTER_MAP_WAIT,
+			  DEFAULT_SSS_MASTER_MAP_WAIT, CONF_ENV);
+	if (ret == CFG_FAIL)
+		goto error;
+
 	/* LDAP_URI and SEARCH_BASE can occur multiple times */
 	while ((co = conf_lookup(sec, NAME_LDAP_URI)))
 		conf_delete(co->section, co->name);
@@ -1753,6 +1760,17 @@ unsigned int defaults_disable_not_found_message(void)
 	return res;
 }
 
+unsigned int defaults_get_sss_master_map_wait(void)
+{
+	int res;
+
+	res = conf_get_yesno(autofs_gbl_sec, NAME_SSS_MASTER_MAP_WAIT);
+	if (res < 0)
+		res = atoi(DEFAULT_SSS_MASTER_MAP_WAIT);
+
+	return res;
+}
+
 unsigned int conf_amd_mount_section_exists(const char *section)
 {
 	return conf_section_exists(section);
diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in
index 466db10..93ff7af 100644
--- a/man/autofs.conf.5.in
+++ b/man/autofs.conf.5.in
@@ -141,6 +141,13 @@ The original request to add this log message needed it to be unconditional.
 That produces, IMHO, unnecessary noise in the log so a configuration option
 has been added to provide the ability to turn it off. The default is "no"
 to maintain the current behaviour.
+.TP
+.B sss_master_map_wait
+.br
+Set the time to wait and retry if sssd returns "no such entry" when starting
+up. When sssd is starting up it can sometimes return "no such entry" for a
+short time until it has read in the LDAP map information. Default is 0 seconds,
+don't wait.
 .SS LDAP Configuration
 .P
 Configuration settings available are:
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index 702e7b5..ce4d0ed 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -32,8 +32,6 @@
 
 /* Half a second between retries */
 #define SETAUTOMOUNTENT_MASTER_INTERVAL	500000000
-/* Try for 10 seconds */
-#define SETAUTOMOUNTENT_MASTER_RETRIES	10 * 2
 
 #define MODPREFIX "lookup(sss): "
 
@@ -304,7 +302,10 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 		if (ret != ENOENT)
 			return NSS_STATUS_UNAVAIL;
 
-		retries = SETAUTOMOUNTENT_MASTER_RETRIES;
+		retries = defaults_get_sss_master_map_wait() * 2;
+		if (retries <= 0)
+			return NSS_STATUS_NOTFOUND;
+
 		ret = setautomntent_wait(logopt,
 					 ctxt, ctxt->mapname, &sss_ctxt,
 					 retries);
diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in
index 2fa8a4c..9bceab3 100644
--- a/redhat/autofs.conf.default.in
+++ b/redhat/autofs.conf.default.in
@@ -166,6 +166,16 @@ mount_nfs_default_protocol = 4
 #
 #disable_not_found_message = "no"
 #
+# sss_master_map_wait - When sssd is starting up it can sometimes return
+# 			"no such entry" for a short time until it has read
+# 			in the LDAP map information. Internal default is 0
+# 			seconds, don't wait but if there is a problem with
+# 			autofs not finding the master map at startup (when
+# 			it should) then try setting this to 10 to work
+# 			around it.
+#
+#sss_master_map_wait = 0
+#
 # Otions for the amd parser within autofs.
 #
 # amd configuration options that are aren't used, haven't been
diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
index 77c5999..a275e08 100644
--- a/samples/autofs.conf.default.in
+++ b/samples/autofs.conf.default.in
@@ -165,6 +165,16 @@ browse_mode = no
 #
 #disable_not_found_message = "no"
 #
+# sss_master_map_wait - When sssd is starting up it can sometimes return
+#			"no such entry" for a short time until it has read
+# 			in the LDAP map information. Internal default is 0
+# 			seconds, don't wait but if there is a problem with
+# 			autofs not finding the master map at startup (when
+# 			it should) then try setting this to 10 to work
+# 			around it.
+#
+#sss_master_map_wait = 0
+#
 # Otions for the amd parser within autofs.
 #
 # amd configuration options that are aren't used, haven't been

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 27/37] autofs-5.1.2 - fix typos in README.amd-maps
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (25 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 26/37] autofs-5.1.2 - add sss master map wait config option Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 28/37] autofs-5.1.2 - add ref counting to struct map_source Ian Kent
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

Fix a few typos and try and clearify some statements in the README.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 README.amd-maps |   15 ++++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index e89086b..6b097ff 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -24,6 +24,7 @@ xx/xx/2016 autofs-5.1.3
 - add master read wait option.
 - work around sss startup delay.
 - add sss master map wait config option.
+- fix typos in README.amd-maps.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/README.amd-maps b/README.amd-maps
index b31a7db..e79f521 100644
--- a/README.amd-maps
+++ b/README.amd-maps
@@ -7,7 +7,8 @@ The ability to parse amd format maps has been added to autofs.
 How to use amd maps in autofs
 -----------------------------
 
-To add amd map parsing to autofs new "format" module has been added.
+To add amd map parsing to autofs a new "format" module has been added.
+
 To use this new map format module the existing master map syntax is
 used as described below.
 
@@ -20,7 +21,7 @@ For amd format maps this becomes:
 /amd/mp   file,amd:amd.mp
 
 which will use file as the map source and the amd format parser for
-the map. But see the section below on configuration below for how to
+the map. But see the section below on configuration for how to
 eliminate the need to specify "map-type,format" in the master map.
 
 Configuration sub-system changes
@@ -42,18 +43,18 @@ All that's needed to add an existing amd configuration to autofs is to
 add it below the autofs configuration. Apart from changing the amd
 "[ global ]" section name to "[ amd ]" nothing else should need to be
 changed. However, quite a few amd configuration options don't have
-meaning within autofs. When these options are seen it should be logged.
+meaning within autofs. When these options are seen they are logged.
 
 Be aware that, if the an old configuration exists and the configuration
 hasn't been updated after the installation, changes to the the old
 configuration will override changes to the new configuration because
 backward compatibility takes priority over the new implementation.
 
-The amd per-map sections have two functions, to allow per-mount
+The amd per-mount sections have two functions, to allow per-mount
 configuration, as it does in amd, and to allow master map entries to
 avoid the need to specify the "type,format" part of the master map
-entry so they can use the nsswitch map source functionality in the
-same way autofs master map entries do.
+entry. This allows them to use the nsswitch map source functionality
+in the same way autofs master map entries do.
 
 If a section for an amd mount is added below the global amd section
 using the mount point path (as is done in amd.conf) then autofs will
@@ -63,7 +64,7 @@ be given in the master map entry the map_name option is not mandatory
 as it is in amd and will no be used.
 
 If a mount point is present in the master map and the source of the
-map is nis then it should be sufficient to use (for example):
+map is nis then it is sufficient to use (for example):
 
 /amd/mp           amd.mp
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 28/37] autofs-5.1.2 - add ref counting to struct map_source
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (26 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 27/37] autofs-5.1.2 - fix typos in README.amd-maps Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:19 ` [PATCH 29/37] autofs-5.1.2 - add support for amd browsable option Ian Kent
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

amd map format maps that are type "auto" frequently refer to the
current map in their map entries.

While this isn't a problem for relatively small maps it can be very
wasteful for large maps and even more so for maps that have multi-
component keys that trigger type "auto" mounts as they progress down
the directory tree.

So add a reference count in order for amd type "auto" mounts to use
the parent map if it matches.

sun format maps are much less likley to use the same map and if they
do they are usually trivial, one line maps, so it isn't a problem.

But, more importantly, sun format maps need to track recursive inclusion
and inclusion depth for a given map source when plus map inclusion is
used which prevents the map soucre from being shared.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG              |    1 +
 daemon/indirect.c      |    7 +++++-
 include/master.h       |    3 ++
 lib/master.c           |   22 +++++++++++++++++
 modules/mount_autofs.c |   61 ++++++++++++++++++++++++++++++++----------------
 5 files changed, 73 insertions(+), 21 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6b097ff..5b3d0d1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -25,6 +25,7 @@ xx/xx/2016 autofs-5.1.3
 - work around sss startup delay.
 - add sss master map wait config option.
 - fix typos in README.amd-maps.
+- add ref counting to struct map_source.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 4c32bdb..5d84b89 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -97,7 +97,12 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
 	int ret;
 	int err;
 
-	ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
+	/* If the map is being shared the exp_timeout can't be inherited
+	 * from the map source since it may be different so the autofs
+	 * point exp_runfreq must have already been set.
+	 */
+	if (ap->entry->maps->ref <= 1)
+		ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 
 	if (ops->version && !do_force_unlink) {
 		ap->flags |= MOUNT_FLAG_REMOUNT;
diff --git a/include/master.h b/include/master.h
index 3f97acd..3947cd5 100644
--- a/include/master.h
+++ b/include/master.h
@@ -23,6 +23,7 @@
 #define MAP_FLAG_FORMAT_AMD	0x0001
 
 struct map_source {
+	unsigned int ref;
 	unsigned int flags;
 	char *type;
 	char *format;
@@ -89,6 +90,8 @@ struct map_source *
 master_add_map_source(struct master_mapent *, char *, char *, time_t, int, const char **);
 struct map_source *
 master_find_map_source(struct master_mapent *, const char *, const char *, int, const char **);
+struct map_source *
+master_get_map_source(struct master_mapent *, const char *, const char *, int, const char **);
 void master_free_map_source(struct map_source *, unsigned int);
 struct map_source *
 master_find_source_instance(struct map_source *, const char *, const char *, int, const char **);
diff --git a/lib/master.c b/lib/master.c
index 4c6e79b..fceb5dd 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -181,6 +181,7 @@ master_add_map_source(struct master_mapent *entry,
 	if (!source)
 		return NULL;
 	memset(source, 0, sizeof(struct map_source));
+	source->ref = 1;
 
 	if (type) {
 		ntype = strdup(type);
@@ -232,6 +233,8 @@ master_add_map_source(struct master_mapent *entry,
 
 		this = __master_find_map_source(entry, type, format, argc, tmpargv);
 		if (this) {
+			error(entry->ap->logopt,
+			      "map source used without taking reference");
 			this->age = age;
 			master_free_map_source(source, 0);
 			master_source_unlock(entry);
@@ -330,8 +333,27 @@ struct map_source *master_find_map_source(struct master_mapent *entry,
 	return source;
 }
 
+struct map_source *
+master_get_map_source(struct master_mapent *entry,
+		      const char *type, const char *format,
+		      int argc, const char **argv)
+{
+	struct map_source *source = NULL;
+
+	master_source_readlock(entry);
+	source = __master_find_map_source(entry, type, format, argc, argv);
+	if (source)
+		source->ref++;
+	master_source_unlock(entry);
+
+	return source;
+}
+
 static void __master_free_map_source(struct map_source *source, unsigned int free_cache)
 {
+	/* instance map sources are not ref counted */
+	if (source->ref && --source->ref)
+		return;
 	if (source->type)
 		free(source->type);
 	if (source->format)
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
index 0476a09..3ba5271 100644
--- a/modules/mount_autofs.c
+++ b/modules/mount_autofs.c
@@ -208,18 +208,37 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 	}
 	if (info->map)
 		argv[0] = info->map;
+
+	if (options) {
+		p = options;
+		while ((p = strchr(p, ',')) != NULL) {
+			if (*p == ',') {
+				*p = '\0';
+				p++;
+			}
+			argv[argc++] = p;
+		}
+	}
+	argv[argc] = NULL;
+
 	/*
-	 * If the parent map format is amd and the format isn't
-	 * specified in the map entry set it from the parent map
-	 * source.
+	 * For amd type "auto" the map is often re-used so check
+	 * if the the parent map can be used and use it if it
+	 * matches.
+	 *
+	 * Also if the parent map format is amd and the format
+	 * isn't specified in the map entry set it from the parent
+	 * map source.
 	 */
-	if (!info->format && ap->entry->maps) {
+	source = NULL;
+	if (ap->entry->maps && ap->entry->maps->flags & MAP_FLAG_FORMAT_AMD) {
 		struct map_source *s = ap->entry->maps;
+
 		/*
 		 * For amd maps, if the format and source type aren't
 		 * specified try and set them from the parent.
 		 */
-		if (s->flags & MAP_FLAG_FORMAT_AMD) {
+		if (!info->format) {
 			info->format = strdup("amd");
 			if (!info->format)
 				warn(ap->logopt, MODPREFIX
@@ -231,23 +250,19 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 					     "failed to set amd map type");
 			}
 		}
-	}
 
-	if (options) {
-		p = options;
-		while ((p = strchr(p, ',')) != NULL) {
-			if (*p == ',') {
-				*p = '\0';
-				p++;
-			}
-			argv[argc++] = p;
-		}
+		source = master_get_map_source(ap->entry,
+					       info->type, info->format,
+					       argc, argv);
+		if (source)
+			entry->maps = source;
 	}
-	argv[argc] = NULL;
 
-	source = master_add_map_source(entry,
-				       info->type, info->format,
-				       monotonic_time(NULL), argc, argv);
+	if (!source)
+		source = master_add_map_source(entry,
+					       info->type, info->format,
+					       monotonic_time(NULL),
+					       argc, argv);
 	if (!source) {
 		error(ap->logopt,
 		      MODPREFIX "failed to add map source to entry");
@@ -256,7 +271,13 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 		return 1;
 	}
 	free_map_type_info(info);
-	source->exp_timeout = timeout;
+	/* The exp_timeout can't be inherited if the map is shared, so
+	 * the autofs point exp_runfreq must be set here.
+	 */
+	if (source->ref <= 1)
+		source->exp_timeout = timeout;
+	else
+		nap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 
 	mounts_mutex_lock(ap);
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 29/37] autofs-5.1.2 - add support for amd browsable option
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (27 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 28/37] autofs-5.1.2 - add ref counting to struct map_source Ian Kent
@ 2016-10-25  1:19 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 30/37] autofs-5.1.2 - add function conf_amd_get_map_name() Ian Kent
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:19 UTC (permalink / raw)
  To: autofs mailing list

From: Ian Kent <ikent@redhat.com>

Add support for the "browsable_dirs" configuration option and the
pseudo mount option "browsable" of amd format maps.

Note that support for the configuration option "browsable_dirs = full"
and the pseudo mount option "fullybrowsable" of type auto map entries
cannot be implemented using  the existing kernel to user space autofs
implementation.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG                      |    1 
 README.amd-maps                |    2 -
 daemon/lookup.c                |  106 ++++++++++++++++++++++++++++++++--------
 lib/master_parse.y             |   14 ++++-
 man/autofs.conf.5.in           |    7 ++-
 modules/amd_parse.y            |    3 -
 modules/mount_autofs.c         |    8 ++-
 modules/parse_amd.c            |    2 -
 redhat/autofs.conf.default.in  |    7 ++-
 samples/autofs.conf.default.in |    7 ++-
 10 files changed, 120 insertions(+), 37 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 5b3d0d1..da3b54e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@ xx/xx/2016 autofs-5.1.3
 - add sss master map wait config option.
 - fix typos in README.amd-maps.
 - add ref counting to struct map_source.
+- add support for amd browsable option.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/README.amd-maps b/README.amd-maps
index e79f521..4f1d58d 100644
--- a/README.amd-maps
+++ b/README.amd-maps
@@ -101,7 +101,7 @@ What hasn't been implemented
 ----------------------------
 
 The configuration options fully_qualified_hosts, unmount_on_exit and
-browsable_dirs (and a couple of others) aren't implemented.
+browsable_dirs = full (and a couple of others) aren't implemented.
 
 Map types (sources) ndbm, passwd are not implemented.
 The map source "sss" can't be used for amd format maps.
diff --git a/daemon/lookup.c b/daemon/lookup.c
index 0c2a01f..a58be30 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -655,6 +655,56 @@ int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time
 	return 0;
 }
 
+static char *make_browse_path(unsigned int logopt,
+			      const char *root, const char *key,
+			      const char *prefix)
+{
+	unsigned int l_prefix;
+	unsigned int k_len, r_len;
+	char *k_start;
+	char *path;
+
+	k_start = (char *) key;
+	k_len = strlen(key);
+	l_prefix = 0;
+
+	if (prefix) {
+		l_prefix = strlen(prefix);
+
+		if (l_prefix > k_len)
+			return NULL;
+
+		/* If the prefix doesn't match the beginning
+		 * of the key this entry isn't a sub directory
+		 * at this level.
+		 */
+		if (strncmp(key, prefix, l_prefix))
+			return NULL;
+
+		/* Directory entry starts following the prefix */
+		k_start += l_prefix;
+	}
+
+	/* No remaining "/" allowed here */
+	if (strchr(k_start, '/'))
+		return NULL;
+
+	r_len = strlen(root);
+
+	if ((r_len + strlen(k_start)) > KEY_MAX_LEN)
+		return NULL;
+
+	path = malloc(r_len + k_len + 2);
+	if (!path) {
+		warn(logopt, "failed to allocate full path");
+		return NULL;
+	}
+
+	sprintf(path, "%s/%s", root, k_start);
+
+	return path;
+}
+
 int lookup_ghost(struct autofs_point *ap, const char *root)
 {
 	struct master_mapent *entry = ap->entry;
@@ -698,10 +748,19 @@ int lookup_ghost(struct autofs_point *ap, const char *root)
 			if (!me->mapent)
 				goto next;
 
-			if (!strcmp(me->key, "*"))
+			/* Wildcard cannot be a browse directory and amd map
+			 * keys may end with the wildcard.
+			 */
+			if (strchr(me->key, '*'))
 				goto next;
 
+			/* This will also take care of amd "/defaults" entry as
+			 * amd map keys are not allowd to start with "/"
+			 */
 			if (*me->key == '/') {
+				if (map->flags & MAP_FLAG_FORMAT_AMD)
+					goto next;
+
 				/* It's a busy multi-mount - leave till next time */
 				if (list_empty(&me->multi_list))
 					error(ap->logopt,
@@ -709,12 +768,10 @@ int lookup_ghost(struct autofs_point *ap, const char *root)
 				goto next;
 			}
 
-			fullpath = malloc(strlen(me->key) + strlen(root) + 3);
-			if (!fullpath) {
-				warn(ap->logopt, "failed to allocate full path");
+			fullpath = make_browse_path(ap->logopt,
+						    root, me->key, ap->pref);
+			if (!fullpath)
 				goto next;
-			}
-			sprintf(fullpath, "%s/%s", root, me->key);
 
 			ret = stat(fullpath, &st);
 			if (ret == -1 && errno != ENOENT) {
@@ -724,6 +781,17 @@ int lookup_ghost(struct autofs_point *ap, const char *root)
 				goto next;
 			}
 
+			/* Directory already exists? */
+			if (!ret) {
+				/* Shouldn't need this
+				me->dev = st.st_dev;
+				me->ino = st.st_ino;
+				*/
+				debug(ap->logopt, "me->dev %d me->ino %d", me->dev, me->ino);
+				free(fullpath);
+				goto next;
+			}
+
 			ret = mkdir_path(fullpath, 0555);
 			if (ret < 0 && errno != EEXIST) {
 				char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
@@ -1233,28 +1301,23 @@ void lookup_close_lookup(struct autofs_point *ap)
 	return;
 }
 
-static char *make_fullpath(const char *root, const char *key)
+static char *make_fullpath(struct autofs_point *ap, const char *key)
 {
+	char *path = NULL;
 	int l;
-	char *path;
 
-	if (*key == '/') {
+	if (*key != '/')
+		path = make_browse_path(ap->logopt, ap->path, key, ap->pref);
+	else {
 		l = strlen(key) + 1;
 		if (l > KEY_MAX_LEN)
-			return NULL;
+			goto out;
 		path = malloc(l);
 		if (!path)
-			return NULL;
+			goto out;
 		strcpy(path, key);
-	} else {
-		l = strlen(key) + 1 + strlen(root) + 1;
-		if (l > KEY_MAX_LEN)
-			return NULL;
-		path = malloc(l);
-		if (!path)
-			return NULL;
-		sprintf(path, "%s/%s", root, key);
 	}
+out:
 	return path;
 }
 
@@ -1285,13 +1348,14 @@ void lookup_prune_one_cache(struct autofs_point *ap, struct mapent_cache *mc, ti
 
 		key = strdup(me->key);
 		me = cache_enumerate(mc, me);
-		if (!key || !strcmp(key, "*")) {
+		/* Don't consider any entries with a wildcard */
+		if (!key || strchr(key, '*')) {
 			if (key)
 				free(key);
 			continue;
 		}
 
-		path = make_fullpath(ap->path, key);
+		path = make_fullpath(ap, key);
 		if (!path) {
 			warn(ap->logopt, "can't malloc storage for path");
 			free(key);
diff --git a/lib/master_parse.y b/lib/master_parse.y
index 0011429..7536324 100644
--- a/lib/master_parse.y
+++ b/lib/master_parse.y
@@ -811,14 +811,22 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 
 	if (format && !strcmp(format, "amd")) {
 		unsigned int loglevel = conf_amd_get_log_options();
+		unsigned int flags = conf_amd_get_flags(path);
+
 		if (loglevel <= LOG_DEBUG && loglevel > LOG_INFO)
 			logopt = LOGOPT_DEBUG;
 		else if (loglevel <= LOG_INFO && loglevel > LOG_ERR)
 			logopt = LOGOPT_VERBOSE;
-		/* amd mounts don't support browse mode */
-		ghost = 0;
-	}
 
+		/* It isn't possible to provide the fullybrowsable amd
+		 * browsing functionality within the autofs framework.
+		 * This flag will not be set if browsable_dirs = full
+		 * in the configuration or fullybrowsable is present as
+		 * an option.
+		 */
+		if (flags & CONF_BROWSABLE_DIRS)
+			ghost = 1;
+	}
 
 	if (timeout < 0) {
 		/*
diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in
index 93ff7af..2bb262e 100644
--- a/man/autofs.conf.5.in
+++ b/man/autofs.conf.5.in
@@ -355,7 +355,12 @@ and that will be done.
 .TP
 .B browsable_dirs
 .br
-Not yet implemented.
+Allow map keys to be shown in directory listings. This option
+can have values of "yes" or "no". The default is "no". A variation
+of this option, "browsable", can be used as a pseudo mount option
+in type "auto" map entries to provide provide browsing funtionality
+in sub-mounts. The amd "browsable_dirs = full" option cannot be
+implemented within the current autofs framework and is not supported.
 .TP
 .B exec_map_timeout
 .br
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
index bfa1d51..b33250a 100644
--- a/modules/amd_parse.y
+++ b/modules/amd_parse.y
@@ -433,8 +433,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
 
 options: OPTION
 	{
-		if (!strcmp($1, "browsable") ||
-		    !strcmp($1, "fullybrowsable") ||
+		if (!strcmp($1, "fullybrowsable") ||
 		    !strcmp($1, "nounmount") ||
 		    !strcmp($1, "unmount")) {
 			sprintf(msg_buf, "option %s is not currently "
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
index 3ba5271..e404c83 100644
--- a/modules/mount_autofs.c
+++ b/modules/mount_autofs.c
@@ -121,11 +121,13 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			while (*comma != '\0' && *comma != ',')
 				comma++;
 
-			if (_strncmp("nobrowse", cp, 8) == 0)
+			if (_strncmp("nobrowse", cp, 8) == 0 ||
+			    _strncmp("nobrowsable", cp, 11) == 0)
 				ghost = 0;
 			else if (_strncmp("nobind", cp, 6) == 0)
 				nobind = 1;
-			else if (_strncmp("browse", cp, 6) == 0)
+			else if (_strncmp("browse", cp, 6) == 0 ||
+				 _strncmp("browsable", cp, 9) == 0)
 				ghost = 1;
 			else if (_strncmp("symlink", cp, 7) == 0)
 				symlnk = 1;
@@ -287,8 +289,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			nap->pref = am_entry->pref;
 			am_entry->pref = NULL;
 		}
-		/* amd mounts don't support browse mode */
-		nap->flags &= ~MOUNT_FLAG_GHOST;
 	}
 
 	if (handle_mounts_startup_cond_init(&suc)) {
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 38d76b8..2ff43fa 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -930,7 +930,7 @@ static int do_auto_mount(struct autofs_point *ap, const char *name,
 	}
 
 	return do_mount(ap, ap->path,
-			name, strlen(name), target, "autofs", NULL);
+			name, strlen(name), target, "autofs", entry->opts);
 }
 
 static int do_link_mount(struct autofs_point *ap, const char *name,
diff --git a/redhat/autofs.conf.default.in b/redhat/autofs.conf.default.in
index 9bceab3..f7adcb5 100644
--- a/redhat/autofs.conf.default.in
+++ b/redhat/autofs.conf.default.in
@@ -274,8 +274,6 @@ mount_nfs_default_protocol = 4
 #	is a sensible option to implement and that will be
 #	done.
 #
-# browsable_dirs - not yet implemented.
-#
 # exec_map_timeout - a timeout is not currently used for
 #	for program maps, might be implemented.
 #
@@ -318,6 +316,11 @@ mount_nfs_default_protocol = 4
 #	takes its default value from the autofs internal default
 #	of 600 seconds.
 #
+# browsable_dirs - make map keys visible in directory listings.
+#	Note that support for the "fullybrowsable" option cannot
+#	be added using the existing kernel to user space autofs
+#	implementation.
+#
 # autofs_use_lofs - if set to "yes" autofs will attempt to use bind
 #	mounts for type "auto" when possible.
 #
diff --git a/samples/autofs.conf.default.in b/samples/autofs.conf.default.in
index a275e08..5311da7 100644
--- a/samples/autofs.conf.default.in
+++ b/samples/autofs.conf.default.in
@@ -273,8 +273,6 @@ browse_mode = no
 #	is a sensible option to implement and that will be
 #	done.
 #
-# browsable_dirs - not yet implemented.
-#
 # exec_map_timeout - a timeout is not currently used for
 #	for program maps, might be implemented.
 #
@@ -317,6 +315,11 @@ browse_mode = no
 #	takes its default value from the autofs internal default
 #	of 600 seconds.
 #
+# browsable_dirs - make map keys visible in directory listings.
+#	Note that support for the "fullybrowsable" option cannot
+#	be added using the existing kernel to user space autofs
+#	implementation.
+#
 # autofs_use_lofs - if set to "yes" autofs will attempt to use bind
 #	mounts for type "auto" when possible.
 #

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 30/37] autofs-5.1.2 - add function conf_amd_get_map_name()
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (28 preceding siblings ...)
  2016-10-25  1:19 ` [PATCH 29/37] autofs-5.1.2 - add support for amd browsable option Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 31/37] autofs-5.1.2 - add function conf_amd_get_mount_paths() Ian Kent
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

Add configuration function to get the map_name option from
an amd mount configuration section.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 include/defaults.h |    1 +
 lib/defaults.c     |   10 ++++++++++
 3 files changed, 12 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index da3b54e..38c565f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -27,6 +27,7 @@ xx/xx/2016 autofs-5.1.3
 - fix typos in README.amd-maps.
 - add ref counting to struct map_source.
 - add support for amd browsable option.
+- add function conf_amd_get_map_name().
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/defaults.h b/include/defaults.h
index 1dea48c..fd29f22 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -194,6 +194,7 @@ char *conf_amd_get_nfs_proto(void);
 char *conf_amd_get_nis_domain(void);
 unsigned int conf_amd_set_nis_domain(const char *);
 char *conf_amd_get_map_defaults(const char *);
+char *conf_amd_get_map_name(const char *);
 char *conf_amd_get_map_type(const char *);
 char *conf_amd_get_search_path(const char *);
 unsigned int conf_amd_get_dismount_interval(const char *);
diff --git a/lib/defaults.c b/lib/defaults.c
index 3ac231b..fba5d78 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -108,6 +108,7 @@
 #define NAME_AMD_MAP_DEFAULTS			"map_defaults"
 #define NAME_AMD_MAP_OPTIONS			"map_options"
 #define NAME_AMD_MAP_RELOAD_INTERVAL		"map_reload_interval"
+#define NAME_AMD_MAP_NAME			"map_name"
 #define NAME_AMD_MAP_TYPE			"map_type"
 #define NAME_AMD_MOUNT_TYPE			"mount_type"
 #define NAME_AMD_PID_FILE			"pid_file"
@@ -1934,6 +1935,15 @@ char *conf_amd_get_map_defaults(const char *section)
 	return tmp;
 }
 
+char *conf_amd_get_map_name(const char *section)
+{
+	char *tmp = NULL;
+	if (section)
+		tmp = conf_get_string(section, NAME_AMD_MAP_NAME);
+
+	return tmp;
+}
+
 char *conf_amd_get_map_type(const char *section)
 {
 	char *tmp = NULL;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 31/37] autofs-5.1.2 - add function conf_amd_get_mount_paths()
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (29 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 30/37] autofs-5.1.2 - add function conf_amd_get_map_name() Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 32/37] autofs-5.1.2 - include amd mount section mounts in master mounts list Ian Kent
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

Add configuration function to get an array of amd mount section
paths.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 include/defaults.h |    1 +
 lib/defaults.c     |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 38c565f..0853484 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -28,6 +28,7 @@ xx/xx/2016 autofs-5.1.3
 - add ref counting to struct map_source.
 - add support for amd browsable option.
 - add function conf_amd_get_map_name().
+- add function conf_amd_get_mount_paths().
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/defaults.h b/include/defaults.h
index fd29f22..c0d0aef 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -174,6 +174,7 @@ unsigned int defaults_disable_not_found_message(void);
 unsigned int defaults_get_sss_master_map_wait(void);
 
 unsigned int conf_amd_mount_section_exists(const char *);
+char **conf_amd_get_mount_paths(void);
 char *conf_amd_get_arch(void);
 char *conf_amd_get_karch(void);
 char *conf_amd_get_os(void);
diff --git a/lib/defaults.c b/lib/defaults.c
index fba5d78..102eda5 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -771,6 +771,81 @@ static struct conf_option *conf_lookup(const char *section, const char *key)
 	return co;
 }
 
+static char **conf_enumerate_amd_mount_sections(void)
+{
+	struct conf_option *this;
+	unsigned int count;
+	char **paths;
+	char *last;
+	int i, j;
+
+	last = NULL;
+	count = 0;
+	for (i = 0; i < CFG_TABLE_SIZE; i++) {
+		if (!config->hash[i])
+			continue;
+
+		this = config->hash[i];
+		while (this) {
+			/* Only amd mount section names begin with '/' */
+			if (*this->section != '/') {
+				this = this->next;
+				continue;
+			}
+
+			if (!last ||
+			   strcmp(this->section, last))
+				count ++;
+			last = this->section;
+			this = this->next;
+		}
+	}
+
+	if (!count)
+		return NULL;
+
+	paths = (char **) malloc(((count + 1) * sizeof(char *)));
+	if (!paths)
+		return NULL;
+	memset(paths, 0, ((count + 1) * sizeof(char *)));
+
+	last = NULL;
+	j = 0;
+
+	for (i = 0; i < CFG_TABLE_SIZE; i++) {
+		if (!config->hash[i])
+			continue;
+
+		this = config->hash[i];
+		while (this) {
+			/* Only amd mount section names begin with '/' */
+			if (*this->section != '/') {
+				this = this->next;
+				continue;
+			}
+
+			if (!last ||
+			    strcmp(this->section, last)) {
+				char *path = strdup(this->section);
+				if (!path)
+					goto fail;
+				paths[j++] = path;
+			}
+			last = this->section;
+			this = this->next;
+		}
+	}
+
+	return paths;
+
+fail:
+	i = 0;
+	while (paths[i])
+		free(paths[i++]);
+	free(paths);
+	return NULL;
+}
+
 static unsigned int conf_section_exists(const char *section)
 {
 	struct conf_option *co;
@@ -1777,6 +1852,11 @@ unsigned int conf_amd_mount_section_exists(const char *section)
 	return conf_section_exists(section);
 }
 
+char **conf_amd_get_mount_paths(void)
+{
+	return conf_enumerate_amd_mount_sections();
+}
+
 char *conf_amd_get_arch(void)
 {
 	return conf_get_string(amd_gbl_sec, NAME_AMD_ARCH);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 32/37] autofs-5.1.2 - include amd mount section mounts in master mounts list
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (30 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 31/37] autofs-5.1.2 - add function conf_amd_get_mount_paths() Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 33/37] autofs-5.1.2 - check for conflicting amd section mounts Ian Kent
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

Currently a master map entry is required for amd format maps and
top level amd mount path configuration sections can only used to
provide additional per-mount configuration.

But being able to use the top level amd format mount path
configuration sections alone allows potentially incompatible
master map entries to not be included in the master map.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 README.amd-maps |   49 +++++++++++++++++++++----
 lib/master.c    |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 0853484..3a1b534 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,7 @@ xx/xx/2016 autofs-5.1.3
 - add support for amd browsable option.
 - add function conf_amd_get_map_name().
 - add function conf_amd_get_mount_paths().
+- include amd mount sections mounts in master mounts list.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/README.amd-maps b/README.amd-maps
index 4f1d58d..386b068 100644
--- a/README.amd-maps
+++ b/README.amd-maps
@@ -9,8 +9,10 @@ How to use amd maps in autofs
 
 To add amd map parsing to autofs a new "format" module has been added.
 
-To use this new map format module the existing master map syntax is
-used as described below.
+There are two ways to use this new map format module. First, the existing
+master map syntax can be used as described below, and second, sections that
+use the top level mount path may be added to the autofs configuration below
+the "amd" section in much the same way as is done with amd.
 
 The master map entry syntax is:
 
@@ -21,8 +23,22 @@ For amd format maps this becomes:
 /amd/mp   file,amd:amd.mp
 
 which will use file as the map source and the amd format parser for
-the map. But see the section below on configuration for how to
-eliminate the need to specify "map-type,format" in the master map.
+the map.
+
+In order to use nsswitch to specify the map source an amd per-mount
+section needs to be added to the autofs configuration so autofs
+knows the master map entry is an amd format mount.
+
+If an amd-per-mount section is added to the autofs configuration a
+corresponding master map entry is optional. If both are present the
+map name given in the master map entry will override a "map_name"
+option in the amd per-mount section.
+
+If an amd per-mount section is used alone then not giving the "map_type"
+option will alow the use of nsswicth for map selection.
+
+See below for an example of an amd per-mount configuration entry.
+
 
 Configuration sub-system changes
 --------------------------------
@@ -56,12 +72,19 @@ avoid the need to specify the "type,format" part of the master map
 entry. This allows them to use the nsswitch map source functionality
 in the same way autofs master map entries do.
 
+If amd per-mount sections are present in the autofs configuration
+their corresponding master map entries are optional. This allows
+amd maps to be used without adding incompatible entries to the autofs
+master map in shared infrastructure environments.
+
 If a section for an amd mount is added below the global amd section
 using the mount point path (as is done in amd.conf) then autofs will
 know the map format is amd (it doesn't matter if there are no other
-configuration options in the mount point section). Since the map must
-be given in the master map entry the map_name option is not mandatory
-as it is in amd and will no be used.
+configuration options in the mount point section).
+
+If there is a corresponding master map entry the map given in the
+master map entry will be used over the map_name option if it is
+present in an amd per-mount section.
 
 If a mount point is present in the master map and the source of the
 map is nis then it is sufficient to use (for example):
@@ -86,6 +109,18 @@ or
 [ /amd/mp ]
 map_type = nis
 
+An example of an amd per-mount configuration entry is:
+
+[ amd ]
+...
+
+[ /test ]
+map_name = /etc/amd.test
+#map_type = file
+#search_path =			/etc
+#browsable_dirs =		yes | no
+browsable_dirs =		yes
+
 
 amd map options that can be used
 --------------------------------
diff --git a/lib/master.c b/lib/master.c
index fceb5dd..ba48d1b 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -911,6 +911,114 @@ struct master *master_new(const char *name, unsigned int timeout, unsigned int g
 	return master;
 }
 
+static void master_add_amd_mount_section_mounts(struct master *master, time_t age)
+{
+	unsigned int m_logopt = master->logopt;
+	struct master_mapent *entry;
+	struct map_source *source;
+	unsigned int loglevel;
+	unsigned int logopt;
+	unsigned int flags;
+	char *argv[2];
+	char **paths;
+	int ret;
+	int i;
+
+	loglevel = conf_amd_get_log_options();
+
+	paths = conf_amd_get_mount_paths();
+	if (!paths)
+		return;
+
+	i = 0;
+	while (paths[i]) {
+		const char *path = paths[i];
+		unsigned int ghost = 0;
+		char *type = NULL;
+		char *map = NULL;
+
+		entry = master_find_mapent(master, path);
+		if (entry) {
+			info(m_logopt,
+			     "ignoring duplicate amd section mount %s",
+			     path);
+			goto next;
+		}
+
+		map = conf_amd_get_map_name(path);
+		if (!map) {
+			error(m_logopt,
+			      "failed to get map name for amd section mount %s",
+			      path);
+			goto next;
+		}
+
+		entry = master_new_mapent(master, path, age);
+		if (!entry) {
+			error(m_logopt,
+			      "failed to allocate new amd section mount %s",
+			      path);
+			goto next;
+		}
+
+		logopt = m_logopt;
+		if (loglevel <= LOG_DEBUG && loglevel > LOG_INFO)
+			logopt = LOGOPT_DEBUG;
+		else if (loglevel <= LOG_INFO && loglevel > LOG_ERR)
+			logopt = LOGOPT_VERBOSE;
+
+		/* It isn't possible to provide the fullybrowsable amd
+		 * browsing functionality within the autofs framework.
+		 * This flag will not be set if browsable_dirs = full
+		 * in the configuration or fullybrowsable is present as
+		 * an option.
+		 */
+		flags = conf_amd_get_flags(path);
+		if (flags & CONF_BROWSABLE_DIRS)
+			ghost = 1;
+
+		ret = master_add_autofs_point(entry, logopt, 0, ghost, 0);
+		if (!ret) {
+			error(m_logopt, "failed to add autofs_point");
+			master_free_mapent(entry);
+			goto next;
+		}
+
+		type = conf_amd_get_map_type(path);
+		argv[0] = map;
+		argv[1] = NULL;
+
+		source = master_add_map_source(entry, type, "amd",
+					       age, 1, (const char **) argv);
+		if (!source) {
+			error(m_logopt,
+			      "failed to add source for amd section mount %s",
+			      path);
+			master_free_mapent(entry);
+			goto next;
+		}
+
+		source->exp_timeout = conf_amd_get_dismount_interval(path);
+		source->master_line = 0;
+
+		entry->age = age;
+		entry->current = NULL;
+
+		master_add_mapent(master, entry);
+next:
+		if (type)
+			free(type);
+		if (map)
+			free(map);
+		i++;
+	}
+
+	i = 0;
+	while (paths[i])
+		free(paths[i++]);
+	free(paths);
+}
+
 int master_read_master(struct master *master, time_t age, int readall)
 {
 	unsigned int logopt = master->logopt;
@@ -939,6 +1047,7 @@ int master_read_master(struct master *master, time_t age, int readall)
 	master_init_scan();
 	lookup_nss_read_master(master, age);
 	cache_unlock(nc);
+	master_add_amd_mount_section_mounts(master, age);
 	master_mutex_unlock();
 
 	if (!master->read_fail)

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 33/37] autofs-5.1.2 - check for conflicting amd section mounts
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (31 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 32/37] autofs-5.1.2 - include amd mount section mounts in master mounts list Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 34/37] autofs-5.1.2 - add function conf_get_map_options() Ian Kent
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

Allowing the addition of amd section mounts to the master mounts list
can lead to conflicting mount point paths.

Check for conflicts and skip the amd mount section mounts if a conflict
with the master map mounts is found.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG        |    1 +
 include/master.h |    1 +
 lib/master.c     |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 3a1b534..6553a40 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,7 @@ xx/xx/2016 autofs-5.1.3
 - add function conf_amd_get_map_name().
 - add function conf_amd_get_mount_paths().
 - include amd mount sections mounts in master mounts list.
+- check for conflicting amd section mounts.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/master.h b/include/master.h
index 3947cd5..087ddbe 100644
--- a/include/master.h
+++ b/include/master.h
@@ -106,6 +106,7 @@ void master_source_lock_cleanup(void *);
 void master_source_current_wait(struct master_mapent *);
 void master_source_current_signal(struct master_mapent *);
 struct master_mapent *master_find_mapent(struct master *, const char *);
+unsigned int master_partial_match_mapent(struct master *, const char *);
 struct autofs_point *__master_find_submount(struct autofs_point *, const char *);
 struct autofs_point *master_find_submount(struct autofs_point *, const char *);
 struct amd_entry *__master_find_amdmount(struct autofs_point *, const char *);
diff --git a/lib/master.c b/lib/master.c
index ba48d1b..6beae87 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -711,6 +711,53 @@ struct master_mapent *master_find_mapent(struct master *master, const char *path
 	return NULL;
 }
 
+unsigned int master_partial_match_mapent(struct master *master, const char *path)
+{
+	struct list_head *head, *p;
+	size_t path_len = strlen(path);
+	int ret = 0;
+
+	head = &master->mounts;
+	list_for_each(p, head) {
+		struct master_mapent *entry;
+		size_t entry_len;
+		size_t cmp_len;
+
+		entry = list_entry(p, struct master_mapent, list);
+
+		entry_len = strlen(entry->path);
+		cmp_len = min(entry_len, path_len);
+
+		if (!strncmp(entry->path, path, cmp_len)) {
+			/* paths are equal, matching master map entry ? */
+			if (entry_len == path_len) {
+				if (entry->maps &&
+				    entry->maps->flags & MAP_FLAG_FORMAT_AMD)
+					ret = 1;
+				else
+					ret = -1;
+				break;
+			}
+
+			/* amd mount conflicts with entry mount */
+			if (entry_len > path_len &&
+			    *(entry->path + path_len) == '/') {
+				ret = -1;
+				break;
+			}
+
+			/* entry mount conflicts with amd mount */
+			if (entry_len < path_len &&
+			    *(path + entry_len) == '/') {
+				ret = -1;
+				break;
+			}
+		}
+	}
+
+	return ret;
+}
+
 struct autofs_point *__master_find_submount(struct autofs_point *ap, const char *path)
 {
 	struct list_head *head, *p;
@@ -937,10 +984,16 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 		char *type = NULL;
 		char *map = NULL;
 
-		entry = master_find_mapent(master, path);
-		if (entry) {
+		ret = master_partial_match_mapent(master, path);
+		if (ret) {
+			/* If this amd entry is already present in the
+			 * master map it's not a duplicate, don't issue
+			 * an error message.
+			 */
+			if (ret == 1)
+				goto next;
 			info(m_logopt,
-			     "ignoring duplicate amd section mount %s",
+			     "amd section mount path conflict, %s ignored",
 			     path);
 			goto next;
 		}

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 34/37] autofs-5.1.2 - add function conf_get_map_options()
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (32 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 33/37] autofs-5.1.2 - check for conflicting amd section mounts Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 35/37] autofs-5.1.2 - capture cache option and its settings during parsing Ian Kent
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

Add configuration function to get the map_options option from
an amd mount configuration section.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG          |    1 +
 include/defaults.h |    1 +
 lib/defaults.c     |   10 ++++++++++
 3 files changed, 12 insertions(+)

diff --git a/CHANGELOG b/CHANGELOG
index 6553a40..32452de 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -31,6 +31,7 @@ xx/xx/2016 autofs-5.1.3
 - add function conf_amd_get_mount_paths().
 - include amd mount sections mounts in master mounts list.
 - check for conflicting amd section mounts.
+- add function conf_get_map_options().
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/defaults.h b/include/defaults.h
index c0d0aef..d3f2c2d 100644
--- a/include/defaults.h
+++ b/include/defaults.h
@@ -196,6 +196,7 @@ char *conf_amd_get_nis_domain(void);
 unsigned int conf_amd_set_nis_domain(const char *);
 char *conf_amd_get_map_defaults(const char *);
 char *conf_amd_get_map_name(const char *);
+char *conf_get_map_options(const char *);
 char *conf_amd_get_map_type(const char *);
 char *conf_amd_get_search_path(const char *);
 unsigned int conf_amd_get_dismount_interval(const char *);
diff --git a/lib/defaults.c b/lib/defaults.c
index 102eda5..a1e041d 100644
--- a/lib/defaults.c
+++ b/lib/defaults.c
@@ -109,6 +109,7 @@
 #define NAME_AMD_MAP_OPTIONS			"map_options"
 #define NAME_AMD_MAP_RELOAD_INTERVAL		"map_reload_interval"
 #define NAME_AMD_MAP_NAME			"map_name"
+#define NAME_AMD_MAP_OPTIONS			"map_options"
 #define NAME_AMD_MAP_TYPE			"map_type"
 #define NAME_AMD_MOUNT_TYPE			"mount_type"
 #define NAME_AMD_PID_FILE			"pid_file"
@@ -2024,6 +2025,15 @@ char *conf_amd_get_map_name(const char *section)
 	return tmp;
 }
 
+char *conf_get_map_options(const char *section)
+{
+	char *tmp = NULL;
+	if (section)
+		tmp = conf_get_string(section, NAME_AMD_MAP_OPTIONS);
+
+	return tmp;
+}
+
 char *conf_amd_get_map_type(const char *section)
 {
 	char *tmp = NULL;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 35/37] autofs-5.1.2 - capture cache option and its settings during parsing
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (33 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 34/37] autofs-5.1.2 - add function conf_get_map_options() Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 36/37] autofs-5.1.2 - handle map_option cache for top level mounts Ian Kent
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

The amd map format parser was not aware of the optional sync
parameter of the cache option.

Make the parser aware of the sync option and capture the cache
option and its settings during map parsing.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG           |    1 +
 include/parse_amd.h |    7 +++++++
 modules/amd_parse.y |   12 +++++++++---
 modules/amd_tok.l   |    2 +-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 32452de..ec184b4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -32,6 +32,7 @@ xx/xx/2016 autofs-5.1.3
 - include amd mount sections mounts in master mounts list.
 - check for conflicting amd section mounts.
 - add function conf_get_map_options().
+- capture cache option and its settings during parsing.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/parse_amd.h b/include/parse_amd.h
index 313edd5..1664947 100644
--- a/include/parse_amd.h
+++ b/include/parse_amd.h
@@ -39,9 +39,16 @@
 #define AMD_DEFAULTS_RESET	0x02000000
 #define AMD_DEFAULTS_MASK	0xff000000
 
+#define AMD_CACHE_OPTION_NONE	0x0000
+#define AMD_CACHE_OPTION_INC	0x0001
+#define AMD_CACHE_OPTION_ALL	0x0002
+#define AMD_CACHE_OPTION_REGEXP	0x0004
+#define AMD_CACHE_OPTION_SYNC	0x8000
+
 struct amd_entry {
 	char *path;
 	unsigned long flags;
+	unsigned int cache_opts;
 	char *type;
 	char *map_type;
 	char *pref;
diff --git a/modules/amd_parse.y b/modules/amd_parse.y
index b33250a..e99820b 100644
--- a/modules/amd_parse.y
+++ b/modules/amd_parse.y
@@ -425,9 +425,14 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
 	}
 	| MAP_OPTION OPTION_ASSIGN CACHE_OPTION
 	{
-		sprintf(msg_buf, "option %s is not used, autofs "
-				 "default caching is always used", $1);
-		amd_info(msg_buf);
+		if (strncmp($3, "inc", 3))
+			entry.cache_opts = AMD_CACHE_OPTION_INC;
+		else if (strncmp($3, "all", 3))
+			entry.cache_opts = AMD_CACHE_OPTION_ALL;
+		else if (strncmp($3, "re", 2))
+			entry.cache_opts = AMD_CACHE_OPTION_REGEXP;
+		if (strstr($3, "sync"))
+			entry.cache_opts |= AMD_CACHE_OPTION_SYNC;
 	}
 	;
 
@@ -535,6 +540,7 @@ static int amd_msg(const char *s)
 static void local_init_vars(void)
 {
 	memset(&entry, 0, sizeof(entry));
+	entry.cache_opts = AMD_CACHE_OPTION_NONE;
 	memset(opts, 0, sizeof(opts));
 }
 
diff --git a/modules/amd_tok.l b/modules/amd_tok.l
index 03e716f..2eac5cb 100644
--- a/modules/amd_tok.l
+++ b/modules/amd_tok.l
@@ -101,7 +101,7 @@ NOPT		({SSTR}|(({IP4ADDR}(\/{V4MASK})?)|({IP6ADDR}(\/{V6MASK})?)))
 MAPOPT		(fs|type|maptype|pref|sublink|cache)
 MNTOPT		(opts|addopts|remopts)
 FSOPTS		(rhost|rfs|dev|cachedir|mount|unmount|umount|delay)
-CHEOPT		(mapdefault|none|inc|re|regexp|all)
+CHEOPT		((mapdefault|none|inc|re|regexp|all)(,sync)?)
 MAPTYPE		(file|nis|nisplus|ldap|hesiod|exec|ndbm|passwd|union)
 FSTYPE_LOCAL	(link|linkx|lofs|ufs|ext2|ext3|ext4|xfs|jfs|cdfs|cachefs)
 FSTYPE_NET	(nfs|nfsx|nfsl|host)

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 36/37] autofs-5.1.2 - handle map_option cache for top level mounts
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (34 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 35/37] autofs-5.1.2 - capture cache option and its settings during parsing Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-10-25  1:20 ` [PATCH 37/37] autofs-5.1.2 - handle amd cache option all in amd type auto mounts Ian Kent
  2016-11-04  8:53 ` [PATCH 00/37] Current patch queue for review Ian Kent
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

In order to read in the map at mount time autofs top level mounts
must be set as browsasble but amd top level mounts that have the
map_option cache:=all set need to read in the map without the browse
option being set.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG            |    1 +
 include/automount.h  |    3 +++
 lib/master.c         |   15 +++++++++++++++
 lib/master_parse.y   |   16 ++++++++++++++++
 man/autofs.conf.5.in |    8 ++++++--
 5 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index ec184b4..8f47520 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -33,6 +33,7 @@ xx/xx/2016 autofs-5.1.3
 - check for conflicting amd section mounts.
 - add function conf_get_map_options().
 - capture cache option and its settings during parsing.
+- handle map_option cache for top level mounts.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/include/automount.h b/include/automount.h
index f643f84..1d378c2 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -528,6 +528,9 @@ struct kernel_mod_version {
 /* Use symlinks instead of bind mounting local mounts */
 #define MOUNT_FLAG_SYMLINK		0x0040
 
+/* Read amd map even if it's not to be ghosted (browsable) */
+#define MOUNT_FLAG_AMD_CACHE_ALL	0x0080
+
 struct autofs_point {
 	pthread_t thid;
 	char *path;			/* Mount point name */
diff --git a/lib/master.c b/lib/master.c
index 6beae87..6bb67ce 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -983,6 +983,7 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 		unsigned int ghost = 0;
 		char *type = NULL;
 		char *map = NULL;
+		char *opts;
 
 		ret = master_partial_match_mapent(master, path);
 		if (ret) {
@@ -1037,6 +1038,20 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 			goto next;
 		}
 
+		opts = conf_get_map_options(path);
+		if (opts) {
+			/* autofs uses the equivalent of cache:=inc,sync
+			 * (except for file maps which use cache:=all,sync)
+			 * but if the map is large then it may be necessary
+			 * to read the whole map at startup even if browsing
+			 * is is not enabled, so look for cache:=all in the
+			 * map_options configuration entry.
+			 */
+			if (strstr(opts, "cache:=all"))
+				entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
+			free(opts);
+		}
+
 		type = conf_amd_get_map_type(path);
 		argv[0] = map;
 		argv[1] = NULL;
diff --git a/lib/master_parse.y b/lib/master_parse.y
index 7536324..8ee0bdd 100644
--- a/lib/master_parse.y
+++ b/lib/master_parse.y
@@ -863,6 +863,22 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 	if (mode && mode < LONG_MAX)
 		entry->ap->mode = mode;
 
+	if (format && !strcmp(format, "amd")) {
+		char *opts = conf_get_map_options(path);
+		if (opts) {
+			/* autofs uses the equivalent of cache:=inc,sync
+			 * (except for file maps which use cache:=all,sync)
+			 * but if the map is large then it may be necessary
+			 * to read the whole map at startup even if browsing
+			 * is is not enabled, so look for cache:=all in the
+			 * map_options configuration entry.
+			 */
+			if (strstr(opts, "cache:=all"))
+				entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
+			free(opts);
+		}
+	}
+
 /*
 	source = master_find_map_source(entry, type, format,
 					local_argc, (const char **) local_argv); 
diff --git a/man/autofs.conf.5.in b/man/autofs.conf.5.in
index 2bb262e..4ebcd27 100644
--- a/man/autofs.conf.5.in
+++ b/man/autofs.conf.5.in
@@ -291,8 +291,12 @@ protocol version.
 .BR cache_duration ", " map_reload_interval ", " map_options
 .br
 The map	entry cache is continually updated and stale entries
-cleaned on re-load, which is done when map changes aredetected
-so these configuration entries are not used by autofs.
+cleaned on re-load, which is done when map changes are detected
+so these configuration entries are not used by autofs. An
+exception to this is the case where the map is large. In this
+case it may be necessary to read the whole map at startup even if
+browsing is is not enabled. Adding the cache:=all option to
+map_options can be used to for this.
 .TP
 .B localhost_address
 This is not used within autofs. This configuration option was

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 37/37] autofs-5.1.2 - handle amd cache option all in amd type auto mounts
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (35 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 36/37] autofs-5.1.2 - handle map_option cache for top level mounts Ian Kent
@ 2016-10-25  1:20 ` Ian Kent
  2016-11-04  8:53 ` [PATCH 00/37] Current patch queue for review Ian Kent
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-10-25  1:20 UTC (permalink / raw)
  To: autofs mailing list

In order to read in the map at mount time autofs submounts must be
set as browasble but amd type auto mounts that have the cache:=all
option set need to read in the map without the browse option being
set.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG                |    1 +
 modules/lookup_ldap.c    |   10 ++++++----
 modules/lookup_nisplus.c |   10 ++++++----
 modules/lookup_sss.c     |   10 ++++++----
 modules/lookup_yp.c      |   10 ++++++----
 modules/mount_autofs.c   |    3 +++
 6 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 8f47520..0df6b31 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@ xx/xx/2016 autofs-5.1.3
 - add function conf_get_map_options().
 - capture cache option and its settings during parsing.
 - handle map_option cache for top level mounts.
+- handle amd cache option all in amd type auto mounts.
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 45100ab..98701e5 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -2797,11 +2797,13 @@ static int read_one_map(struct autofs_point *ap,
 	int rv, l;
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
diff --git a/modules/lookup_nisplus.c b/modules/lookup_nisplus.c
index c8b75e6..6430b89 100644
--- a/modules/lookup_nisplus.c
+++ b/modules/lookup_nisplus.c
@@ -239,11 +239,13 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	master_source_current_signal(ap->entry);
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
index ce4d0ed..6d924cf 100644
--- a/modules/lookup_sss.c
+++ b/modules/lookup_sss.c
@@ -402,11 +402,13 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	mc = source->mc;
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
diff --git a/modules/lookup_yp.c b/modules/lookup_yp.c
index 0d319fd..b139b28 100644
--- a/modules/lookup_yp.c
+++ b/modules/lookup_yp.c
@@ -401,11 +401,13 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	master_source_current_signal(ap->entry);
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
index e404c83..20bcd11 100644
--- a/modules/mount_autofs.c
+++ b/modules/mount_autofs.c
@@ -289,6 +289,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			nap->pref = am_entry->pref;
 			am_entry->pref = NULL;
 		}
+
+		if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL)
+			nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
 	}
 
 	if (handle_mounts_startup_cond_init(&suc)) {

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/37] Current patch queue for review
  2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
                   ` (36 preceding siblings ...)
  2016-10-25  1:20 ` [PATCH 37/37] autofs-5.1.2 - handle amd cache option all in amd type auto mounts Ian Kent
@ 2016-11-04  8:53 ` Ian Kent
  37 siblings, 0 replies; 39+ messages in thread
From: Ian Kent @ 2016-11-04  8:53 UTC (permalink / raw)
  To: autofs mailing list

On Tue, 2016-10-25 at 09:17 +0800, Ian Kent wrote:
> Hi all,
> 
> The patch queue is well overdue for a commit but since there's
> been increased contributions for others recently I thought it
> would be useful to post the patches for review and give a brief
> description of what's in the queue and what still needs work. 
> 
> Many of the patches are striaght forward and I expect to commit
> then in a week or so. Also keep in mind the commit order might
> be different when the commit is actually done.
> 
> The patches around those titled "autofs-5.1.2 - wait for master
> map available at start" and "autofs-5.1.2 - add master read wait
> option" have been around for quite a while and have been a problem
> in the past (which is why they haven't been committed yet) so I'm
> not sure about them yet.
> 
> The series to add browse support for amd maps is not yet complete
> so they will likely stay in the queue a bit longer. But I am keen
> to get this functionality into a release as I know it is something
> that at least a few people would like.

The patches up to and including
"autofs-5.1.2 - add sss master map wait config option"
plus one additional patch have been committed to the repository and pushed
to https://www.kernel.org/pub/linux/daemons/autofs/v5/patches-5.1.3/.

For anyone interested the additional patch is
"autofs-5.1.2 - fix quoted key handling in sanitize_path()"
a bug fix for quoting map keys in non-master map maps.

Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2016-11-04  8:53 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25  1:17 [PATCH 00/37] Current patch queue for review Ian Kent
2016-10-25  1:17 ` [PATCH 01/37] autofs-5.1.2 - fix release date in CHANGELOG Ian Kent
2016-10-25  1:17 ` [PATCH 02/37] autofs-5.1.2 - build: check for clock_gettime in librt Ian Kent
2016-10-25  1:17 ` [PATCH 03/37] autofs-5.1.2 - Fix compiler warning in try_remount() Ian Kent
2016-10-25  1:17 ` [PATCH 04/37] autofs-5.1.2 - Drop redundant \n in logerr() Ian Kent
2016-10-25  1:17 ` [PATCH 05/37] autofs-5.1.2 - Fix size arg of fgets(3) Ian Kent
2016-10-25  1:17 ` [PATCH 06/37] autofs-5.1.2 - fix libtirpc detection with -Wl, --as-needed Ian Kent
2016-10-25  1:18 ` [PATCH 07/37] autofs-5.1.2 - Fix a typo in CREDITS Ian Kent
2016-10-25  1:18 ` [PATCH 08/37] autofs-5.1.2 - Change .requestor to .requester for consistency Ian Kent
2016-10-25  1:18 ` [PATCH 09/37] autofs-5.1.2 - fix file map changed check Ian Kent
2016-10-25  1:18 ` [PATCH 10/37] autofs-5.1.2 - Remove unused local 2KB buffer Ian Kent
2016-10-25  1:18 ` [PATCH 11/37] autofs-5.1.2 - Fix typos in error messages Ian Kent
2016-10-25  1:18 ` [PATCH 12/37] autofs-5.1.2 - Fix fgets(3) size argument (another one) Ian Kent
2016-10-25  1:18 ` [PATCH 13/37] autofs-5.1.2 - fix short memory allocation in lookup_amd_instance() Ian Kent
2016-10-25  1:18 ` [PATCH 14/37] autofs-5.1.2 - fix count_mounts() function Ian Kent
2016-10-25  1:18 ` [PATCH 15/37] autofs-5.1.2 - configure: add cache variable for Linux proc filesystem check Ian Kent
2016-10-25  1:18 ` [PATCH 16/37] autofs-5.1.2 - Avoid local variable name shadowing another Ian Kent
2016-10-25  1:18 ` [PATCH 17/37] autofs-5.1.2 - fix typo in MOUNT_FLAG_GHOST comment Ian Kent
2016-10-25  1:19 ` [PATCH 18/37] autofs-5.1.2 - fix cachefs parse message not being logged Ian Kent
2016-10-25  1:19 ` [PATCH 19/37] autofs-5.1.2 - fix argc off by one in mount_autofs.c Ian Kent
2016-10-25  1:19 ` [PATCH 20/37] autofs-5.1.2 - fix _strncmp() usage Ian Kent
2016-10-25  1:19 ` [PATCH 21/37] autofs-5.1.1 - fix create_client() RPC client handling Ian Kent
2016-10-25  1:19 ` [PATCH 22/37] autofs-5.1.2 - update and add README for old autofs schema Ian Kent
2016-10-25  1:19 ` [PATCH 23/37] autofs-5.1.2 - wait for master map available at start Ian Kent
2016-10-25  1:19 ` [PATCH 24/37] autofs-5.1.2 - add master read wait option Ian Kent
2016-10-25  1:19 ` [PATCH 25/37] autofs-5.1.2 - work around sss startup delay Ian Kent
2016-10-25  1:19 ` [PATCH 26/37] autofs-5.1.2 - add sss master map wait config option Ian Kent
2016-10-25  1:19 ` [PATCH 27/37] autofs-5.1.2 - fix typos in README.amd-maps Ian Kent
2016-10-25  1:19 ` [PATCH 28/37] autofs-5.1.2 - add ref counting to struct map_source Ian Kent
2016-10-25  1:19 ` [PATCH 29/37] autofs-5.1.2 - add support for amd browsable option Ian Kent
2016-10-25  1:20 ` [PATCH 30/37] autofs-5.1.2 - add function conf_amd_get_map_name() Ian Kent
2016-10-25  1:20 ` [PATCH 31/37] autofs-5.1.2 - add function conf_amd_get_mount_paths() Ian Kent
2016-10-25  1:20 ` [PATCH 32/37] autofs-5.1.2 - include amd mount section mounts in master mounts list Ian Kent
2016-10-25  1:20 ` [PATCH 33/37] autofs-5.1.2 - check for conflicting amd section mounts Ian Kent
2016-10-25  1:20 ` [PATCH 34/37] autofs-5.1.2 - add function conf_get_map_options() Ian Kent
2016-10-25  1:20 ` [PATCH 35/37] autofs-5.1.2 - capture cache option and its settings during parsing Ian Kent
2016-10-25  1:20 ` [PATCH 36/37] autofs-5.1.2 - handle map_option cache for top level mounts Ian Kent
2016-10-25  1:20 ` [PATCH 37/37] autofs-5.1.2 - handle amd cache option all in amd type auto mounts Ian Kent
2016-11-04  8:53 ` [PATCH 00/37] Current patch queue for review Ian Kent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.