- fix file map lookup when reading included or nsswitch sources.

- a regression introduced by file map lookup optimisation in rev 9.
This commit is contained in:
Ian Kent 2009-03-17 02:51:24 +00:00
parent 06c6ae6974
commit 18373e6e09
2 changed files with 68 additions and 1 deletions

View File

@ -0,0 +1,61 @@
autofs-5.0.4 - always read file maps fix
From: Ian Kent <raven@themaw.net>
If map instances are present for a map source then either we have
plus included entries or we are looking through a list of nsswitch
sources. In either case we cannot avoid reading through the map
because we must preserve the key lookup order over multiple sources.
But also, we can't know if a source instance has been changed since
the last time we checked it until we preform a lookup against it.
So, in this case a lookup within the internal cache cannot be relied
upon to find the key we're looking for. At least, when we get to the
file source instance itself, the lookup for the key will be done from
the cache.
---
CHANGELOG | 1 +
modules/lookup_file.c | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index aab3209..da7ecbf 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -31,6 +31,7 @@
- fix double free in expire_proc().
- another easy alloca replacements fix.
- add LSB init script parameter block.
+- fix file map lookup when reading included or nsswitch sources.
4/11/2008 autofs-5.0.4
-----------------------
diff --git a/modules/lookup_file.c b/modules/lookup_file.c
index ec78090..bd30bc5 100644
--- a/modules/lookup_file.c
+++ b/modules/lookup_file.c
@@ -998,9 +998,20 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
cache_readlock(mc);
me = cache_lookup_first(mc);
- if (me && st.st_mtime <= me->age)
- goto do_cache_lookup;
- else
+ if (me && st.st_mtime <= me->age) {
+ /*
+ * If any map instances are present for this source
+ * then either we have plus included entries or we
+ * are looking through the list of nsswitch sources.
+ * In either case we cannot avoid reading through the
+ * map because we must preserve the key order over
+ * multiple sources. But also, we can't know, at this
+ * point, if a source instance has been changed since
+ * the last time we checked it.
+ */
+ if (!source->instance)
+ goto do_cache_lookup;
+ } else
source->stale = 1;
me = cache_lookup_distinct(mc, key);

View File

@ -4,7 +4,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.0.4
Release: 20
Release: 21
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@ -41,6 +41,7 @@ Patch28: autofs-5.0.4-fix-return-start-status-on-fail.patch
Patch29: autofs-5.0.4-fix-double-free-in-expire_proc.patch
Patch30: autofs-5.0.4-another-easy-alloca-replacements-fix.patch
Patch31: autofs-5.0.4-add-lsb-init-script-parameter-block.patch
Patch32: autofs-5.0.4-always-read-file-maps-fix.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs libtirpc-devel
Requires: kernel >= 2.6.17
@ -113,6 +114,7 @@ echo %{version}-%{release} > .version
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%build
#CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@ -165,6 +167,10 @@ fi
%{_libdir}/autofs/
%changelog
* Tue Mar 17 2009 Ian Kent <ikent@redhat.com> - 1:5.0.4-21
- fix file map lookup when reading included or nsswitch sources.
- a regression introduced by file map lookup optimisation in rev 9.
* Fri Mar 13 2009 Ian Kent <ikent@redhat.com> - 1:5.0.4-20
- add LSB init script parameter block.