import UBI autofs-5.1.7-58.el9

This commit is contained in:
eabdullin 2024-04-30 15:34:42 +00:00
parent ba67546f06
commit 0ec617a5e0
5 changed files with 338 additions and 1 deletions

View File

@ -0,0 +1,152 @@
autofs-5.1.8 - allow -null map in indirect maps
From: Ian Kent <raven@themaw.net>
We have had reports of GUI programs (such as Nautilus) probing for files
such as .hidden in the parent directory of the directory being accessed.
If using an indirect mount map with a wildcard map entry autofs is duty
bound to try and mount these which usually results in a mount failure but
can also cause lengthy delays in some cases.
There are some challenges to modifying application code and even if it
can be done it's always open to being broken later by developers that
aren't aware of the reasoning behind the original changes.
Now, there is a machanism in autofs that can be used to ignore certain
map entries, the "builtin map -null", see auto.master(5). Currently it
can be used only in the master map but this change extends it to be used
in indirect mount maps as well. In this way it can be used to handle
problematic entries by simply adding a map entry that uses the builtin
-null map.
For example:
.hidden -null
* someserver:/remote/home/&
This mechanism is not standard so if one is using systems other than
those with Linux autofs and central map storage, such as LDAP, then
it would be necessary to configure nsswitch to ensure the files map
source is consulted first followed by the remote map source. Then the
-null map entries included in a local file map that uses plus map
inclusion to move on the the central map source if there is no match.
For example, in /etc/auto.home we can have:
.hidden -null
+auto.home
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/indirect.c | 12 +++++++++++-
daemon/lookup.c | 4 ++++
include/parse_subs.h | 1 +
lib/parse_subs.c | 13 +++++++++++++
man/auto.master.5.in | 9 +++++++--
6 files changed, 37 insertions(+), 3 deletions(-)
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -157,6 +157,7 @@
- fix some sss error return cases.
- fix incorrect matching of cached wildcard key.
- fix expire retry looping.
+- allow -null map in indirect maps.
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/daemon/indirect.c
+++ autofs-5.1.7/daemon/indirect.c
@@ -796,13 +796,23 @@ int handle_packet_missing_indirect(struc
return 0;
}
- /* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, pkt->name, LKP_DISTINCT);
if (me) {
+ /* Check if we recorded a mount fail for this key */
if (me->status >= monotonic_time(NULL)) {
ops->send_fail(ap->logopt, ap->ioctlfd,
pkt->wait_queue_token, -ENOENT);
cache_unlock(me->mc);
+ master_mutex_unlock();
+ pthread_setcancelstate(state, NULL);
+ return 0;
+ }
+
+ /* Ignore nulled indirect map entries */
+ if (starts_with_null_opt(me->mapent)) {
+ ops->send_fail(ap->logopt, ap->ioctlfd,
+ pkt->wait_queue_token, -ENOENT);
+ cache_unlock(me->mc);
master_mutex_unlock();
pthread_setcancelstate(state, NULL);
return 0;
--- autofs-5.1.7.orig/daemon/lookup.c
+++ autofs-5.1.7/daemon/lookup.c
@@ -772,6 +772,10 @@ int lookup_ghost(struct autofs_point *ap
goto next;
}
+ /* Ignore nulled indirect map entries */
+ if (starts_with_null_opt(me->mapent))
+ goto next;
+
fullpath = make_browse_path(ap->logopt,
ap->path, me->key, ap->pref);
if (!fullpath)
--- autofs-5.1.7.orig/include/parse_subs.h
+++ autofs-5.1.7/include/parse_subs.h
@@ -122,6 +122,7 @@ int strmcmp(const char *, const char *,
char *dequote(const char *, int, unsigned int);
int span_space(const char *, unsigned int);
char *sanitize_path(const char *, int, unsigned int, unsigned int);
+int starts_with_null_opt(const char *);
char *merge_options(const char *, const char *);
int expandamdent(const char *, char *, const struct substvar *);
int expand_selectors(struct autofs_point *, const char *, char **, struct substvar *);
--- autofs-5.1.7.orig/lib/parse_subs.c
+++ autofs-5.1.7/lib/parse_subs.c
@@ -878,6 +878,19 @@ char *sanitize_path(const char *path, in
return s_path;
}
+int starts_with_null_opt(const char *str)
+{
+ if (str && strlen(str) >= 5 && *str == '-') {
+ char sep = *(str + 5);
+
+ if (sep == 0 || sep == ' ' || sep == ',') {
+ if (!strncmp(str, "-null", 5))
+ return 1;
+ }
+ }
+ return 0;
+}
+
static char *hasopt(const char *str, const char *opt)
{
const size_t optlen = strlen(opt);
--- autofs-5.1.7.orig/man/auto.master.5.in
+++ autofs-5.1.7/man/auto.master.5.in
@@ -269,13 +269,18 @@ master map entry.
If "\-null" is given as the map it is used to tell automount(8) to ignore a subsequent
master map entry with the given path.
.P
-It can only be used for paths that appear in the master map (or in direct mount maps).
+It can be used for paths that appear in the master map or in direct mount maps (but
+not in direct mount maps themselves) or as a key in an indirect mount map.
+.P
+An indirect mount map key can be nulled. If so the map key is ignored and does not
+result in a mount attempt (essentially the key lookup is abandoned early on).
.P
An indirect mount map top level mount point path can be nulled. If so no mounts from
the nulled mount are performed (essentially it isn't mounted).
.P
Direct mount map path entries can be nulled. Since they must be present at startup
-they are (notionally) part of the master map.
+they are (notionally) part of the master map so direct mount paths that use the -null
+map may be used in the master map to ignore subsequent direct mount map entries.
.P
A nulled master map entry path will ignore a single subsequent matching entry. Any
matching entry following that will be treated as it normally would be. An example

View File

@ -0,0 +1,44 @@
autofs-5.1.8 - fix multi-mount check
From: Ian Kent <raven@themaw.net>
When checking if a mount location is a multi-mount after the first location
the next '-' or '/' indicates it's a multi-mount.
But the '-' can be part of a mount location and can follow a space leading
to incorrectly deciding the location is a multi-mount.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_sun.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -158,6 +158,7 @@
- fix incorrect matching of cached wildcard key.
- fix expire retry looping.
- allow -null map in indirect maps.
+- fix multi-mount check.
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/modules/parse_sun.c
+++ autofs-5.1.7/modules/parse_sun.c
@@ -787,7 +787,14 @@ static int check_is_multi(const char *ma
if (not_first_chunk) {
if (*p == '"')
p++;
- if (*p == '/' || *p == '-') {
+ /*
+ * Although an options string here would mean
+ * we have a multi-mount we can't rely on it
+ * since it's also valid in a mount location.
+ */
+ if (*p == '-')
+ p++;
+ if (*p == '/') {
multi = 1;
break;
}

View File

@ -0,0 +1,68 @@
autofs-5.1.9 - fix deadlock in remount
From: Ian Kent <raven@themaw.net>
If we're starting up or trying to re-connect to an existing direct
mount we could be iterating through the map entries with the readlock
held so we can't just take the writelock for direct mounts. But when
trying to re-connect to an existing mount at startup there won't be
any other process updating the map entry cache.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_sun.c | 26 ++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -160,6 +160,7 @@
- allow -null map in indirect maps.
- fix multi-mount check.
- fix get parent multi-mount check in try_remount().
+- fix deadlock in remount.
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/modules/parse_sun.c
+++ autofs-5.1.7/modules/parse_sun.c
@@ -889,7 +889,18 @@ update_offset_entry(struct autofs_point
strcpy(m_mapent, loc);
}
- cache_writelock(mc);
+ /*
+ * If we're starting up or trying to re-connect to an existing
+ * direct mount we could be iterating through the map entries
+ * with the readlock held so we can't just take the writelock
+ * for direct mounts. But at when trying to re-connect to an
+ * existing mount at startup there won't be any other process
+ * updating the map entry cache.
+ */
+ if (ap->state == ST_INIT && ap->flags & MOUNT_FLAG_REMOUNT)
+ cache_readlock(mc);
+ else
+ cache_writelock(mc);
ret = cache_update_offset(mc, name, m_key, m_mapent, age);
me = cache_lookup_distinct(mc, m_key);
@@ -1581,7 +1592,18 @@ dont_expand:
free(myoptions);
} while (*p == '/' || (*p == '"' && *(p + 1) == '/'));
- cache_writelock(mc);
+ /*
+ * If we're starting up or trying to re-connect to an existing
+ * direct mount we could be iterating through the map entries
+ * with the readlock held so we can't just take the writelock
+ * for direct mounts. But at when trying to re-connect to an
+ * existing mount at startup there won't be any other process
+ * updating the map entry cache.
+ */
+ if (ap->state == ST_INIT && ap->flags & MOUNT_FLAG_REMOUNT)
+ cache_readlock(mc);
+ else
+ cache_writelock(mc);
me = cache_lookup_distinct(mc, name);
if (!me) {
cache_unlock(mc);

View File

@ -0,0 +1,43 @@
autofs-5.1.9 - fix get parent multi-mount check in try_remount()
From: Ian Kent <raven@themaw.net>
In commit 635b90ecc (autofs-5.1.8 - fix mount tree startup reconnect)
when getting the parent the check for a multi-mount should include a
check for the root of the multi-mount as well since the root does not
set the parent.
We could set the root parent to itself but that may have side effects
because the convention has always been the parent is NULL for the
multi-mount root.
Reported-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Suggested-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
lib/mounts.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -159,6 +159,7 @@
- fix expire retry looping.
- allow -null map in indirect maps.
- fix multi-mount check.
+- fix get parent multi-mount check in try_remount().
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/lib/mounts.c
+++ autofs-5.1.7/lib/mounts.c
@@ -2878,7 +2878,7 @@ int try_remount(struct autofs_point *ap,
}
me->flags &= ~MOUNT_FLAG_DIR_CREATED;
- mapent = IS_MM(me) ? MM_PARENT(me) : me;
+ mapent = IS_MM(me) && !IS_MM_ROOT(me) ? MM_PARENT(me) : me;
/* Direct or offset mount, key is full path */
if (mapent->key[0] == '/') {
if (!is_mounted(mapent->key, MNTS_REAL))

View File

@ -12,7 +12,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.1.7
Release: 55%{?dist}
Release: 58%{?dist}
Epoch: 1
License: GPLv2+
Source: https://www.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}-2.tar.gz
@ -186,6 +186,12 @@ Patch173: autofs-5.1.8-fix-some-sss-error-return-cases.patch
Patch174: autofs-5.1.8-fix-incorrect-matching-of-cached-wildcard-key.patch
Patch175: autofs-5.1.8-fix-expire-retry-looping.patch
Patch176: autofs-5.1.8-allow-null-map-in-indirect-maps.patch
Patch177: autofs-5.1.8-fix-multi-mount-check.patch
Patch178: autofs-5.1.9-fix-get-parent-multi-mount-check-in-try_remount.patch
Patch179: autofs-5.1.9-fix-deadlock-in-remount.patch
%if %{with_systemd}
BuildRequires: systemd-units
BuildRequires: systemd-devel
@ -415,6 +421,12 @@ echo %{version}-%{release} > .version
%patch174 -p1
%patch175 -p1
%patch176 -p1
%patch177 -p1
%patch178 -p1
%patch179 -p1
%build
LDFLAGS=-Wl,-z,now
%configure \
@ -522,6 +534,24 @@ fi
%dir /etc/auto.master.d
%changelog
* Fri Dec 22 2023 Ian Kent <ikent@redhat.com> - 1:5.1.7-58
- RHEL-19731 - SIGSEGV using hierarchical map entries on reload with
autofs-5.1.4-109
- fix get parent multi-mount check in try_remount().
- fix deadlock in remount.
- Resolves: RHEL-19731
* Mon Oct 30 2023 Ian Kent <ikent@redhat.com> - 1:5.1.7-57
- RHEL-13084 - multi mount detection fails for share with blank+dash causing
SEGV crash
- fix multi-mount check.
- Resolves: RHEL-13084
* Thu Oct 26 2023 Ian Kent <ikent@redhat.com> - 1:5.1.7-56
- RHEL-13083 - autofs attempts to mount nonexistant ".hidden" filesystems
- allow -null map in indirect maps.
- Resolves: RHEL-13083
* Wed Aug 02 2023 Ian Kent <ikent@redhat.com> - 1:5.1.7-55
- bz2223252 - filesystems mount and expire immediately
- fix expire retry looping.