- fix update_negative_cache() map source usage.

- fix program usage message.
This commit is contained in:
Ian Kent 2018-08-06 13:25:07 +08:00
parent 2caa3178ca
commit 6fa37fa28d
3 changed files with 147 additions and 1 deletions

View File

@ -0,0 +1,40 @@
autofs-5.1.4 - fix program usage message
From: Ian Kent <raven@themaw.net>
There is a discrepancy between the list of options in the usage
message of automount(8) and the options listed in the man page.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/automount.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -31,6 +31,7 @@ xx/xx/2018 autofs-5.1.5
- make umount_ent() recognise forced umount.
- fix age setting at startup.
- fix update_negative_cache() map source usage.
+- fix program usage message.
19/12/2017 autofs-5.1.4
- fix spec file url.
--- autofs-5.1.4.orig/daemon/automount.c
+++ autofs-5.1.4/daemon/automount.c
@@ -1893,9 +1893,13 @@ static void usage(void)
" -h --help this text\n"
" -p --pid-file f write process id to file f\n"
" -t --timeout n auto-unmount in n seconds (0-disable)\n"
+ " -M --master-wait n\n"
+ " maximum wait time (seconds) for master\n"
+ " map to become available\n"
" -v --verbose be verbose\n"
" -d --debug log debuging info\n"
- " -D --define define global macro variable\n"
+ " -Dvariable=value, --define variable=value\n"
+ " define global macro variable\n"
" -f --foreground do not fork into background\n"
" -r --random-multimount-selection\n"
" use ramdom replicated server selection\n"

View File

@ -0,0 +1,98 @@
autofs-5.1.4 - fix update_negative_cache() map source usage
From: Ian Kent <raven@themaw.net>
File map sources can be either plain text or executable.
When the map path is specified without a type (eg. when a
full path is used) an instance map source is used and the
original map is left unchanged.
But update_negative_cache() fails to take this into account
causing it to update the wrong map cache.
When a map reload is done the map entry appears to not exist
so the new map entry is added.
This could go unnoticed except that, after a map read, the
map entry cache cleans stale map entries and the existence
of this negative entry causes the new map entry to be deleted
and map lookups continue to fail.
In hindsite the use of an instance map source for this is
probably uneccessary but changing it will be risky so, for
now, just make update_negative_cache() use the correct map.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/lookup.c | 38 ++++++++++++++++++++++++++++++++++++--
2 files changed, 37 insertions(+), 2 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -30,6 +30,7 @@ xx/xx/2018 autofs-5.1.5
- use defines for expire type.
- make umount_ent() recognise forced umount.
- fix age setting at startup.
+- fix update_negative_cache() map source usage.
19/12/2017 autofs-5.1.4
- fix spec file url.
--- autofs-5.1.4.orig/daemon/lookup.c
+++ autofs-5.1.4/daemon/lookup.c
@@ -1100,6 +1100,37 @@ static enum nsswitch_status lookup_map_n
return result;
}
+static struct map_source *lookup_get_map_source(struct master_mapent *entry)
+{
+ struct map_source *map = entry->maps;
+ struct stat st;
+ char *type;
+
+ if (map->type || *map->argv[0] != '/')
+ return map;
+
+ if (*(map->argv[0] + 1) == '/')
+ return map;
+
+ if (stat(map->argv[0], &st) == -1)
+ return NULL;
+
+ if (!S_ISREG(st.st_mode))
+ return NULL;
+
+ if (st.st_mode & __S_IEXEC)
+ type = "program";
+ else
+ type = "file";
+
+ /* This is a file source with a path starting with "/".
+ * But file maps can be either plain text or executable
+ * so they use a map instance and the actual map source
+ * remains untouched.
+ */
+ return master_find_source_instance(map, type, map->format, 0, NULL);
+}
+
static void update_negative_cache(struct autofs_point *ap, struct map_source *source, const char *name)
{
struct master_mapent *entry = ap->entry;
@@ -1133,11 +1164,14 @@ static void update_negative_cache(struct
logmsg("key \"%s\" not found in map source(s).", name);
}
- /* Doesn't exist in any source, just add it somewhere */
+ /* Doesn't exist in any source, just add it somewhere.
+ * Also take care to use the same map source used by
+ * map reads and key lookups for the update.
+ */
if (source)
map = source;
else
- map = entry->maps;
+ map = lookup_get_map_source(entry);
if (map) {
time_t now = monotonic_time(NULL);
int rv = CHE_FAIL;

View File

@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.1.4
Release: 19%{?dist}
Release: 20%{?dist}
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@ -45,6 +45,8 @@ Patch29: autofs-5.1.4-change-expire-type-naming-to-better-reflect-usage.patch
Patch30: autofs-5.1.4-use-defines-for-expire-type.patch
Patch31: autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch
Patch32: autofs-5.1.4-fix-age-setting-at-startup.patch
Patch33: autofs-5.1.4-fix-update_negative_cache-map-source-usage.patch
Patch34: autofs-5.1.4-fix-program-usage-message.patch
%if %{with_systemd}
BuildRequires: systemd-units
@ -137,6 +139,8 @@ echo %{version}-%{release} > .version
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%build
LDFLAGS=-Wl,-z,now
@ -231,6 +235,10 @@ fi
%dir /etc/auto.master.d
%changelog
* Mon Aug 06 2018 Ian Kent <ikent@redhat.com> - 1:5.1.4-20
- fix update_negative_cache() map source usage.
- fix program usage message.
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1:5.1.4-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild