- update patch for bug RHEL-12369.

This commit is contained in:
Ian Kent 2023-10-16 08:01:48 +08:00
parent 9b22cb05aa
commit 26e1c56896
2 changed files with 93 additions and 32 deletions

View File

@ -38,57 +38,113 @@ For example, in /etc/auto.home we can have:
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/indirect.c | 18 ++++++++++++++++++
daemon/indirect.c | 12 +++++++++++-
daemon/lookup.c | 4 ++++
include/parse_subs.h | 1 +
lib/parse_subs.c | 13 +++++++++++++
man/auto.master.5.in | 9 +++++++--
3 files changed, 26 insertions(+), 2 deletions(-)
6 files changed, 37 insertions(+), 3 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -150,6 +150,7 @@
diff --git a/CHANGELOG b/CHANGELOG
index 1ebb02fb..a0f4b526 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -95,6 +95,7 @@
- fix some sss error return cases.
- fix incorrect matching of cached wildcard key.
- fix expire retry looping.
+- allow -null map in indirect maps.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/daemon/indirect.c
+++ autofs-5.1.4/daemon/indirect.c
@@ -799,6 +799,8 @@ int handle_packet_missing_indirect(struc
/* Check if we recorded a mount fail for this key anywhere */
19/10/2021 autofs-5.1.8
- add xdr_exports().
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 0f7b620b..6ef05c36 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -796,9 +796,9 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin
return 0;
}
- /* Check if we recorded a mount fail for this key anywhere */
me = lookup_source_mapent(ap, pkt->name, LKP_DISTINCT);
if (me) {
+ unsigned int len;
+
+ /* 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);
@@ -807,6 +809,22 @@ int handle_packet_missing_indirect(struc
@@ -807,6 +807,16 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin
pthread_setcancelstate(state, NULL);
return 0;
}
+
+ len = me->mapent ? strlen(me->mapent) : 0;
+ if (me->mapent && len >= 5 && *me->mapent == '-') {
+ char sep = *(me->mapent + 5);
+
+ if (sep == 0 || sep == ' ' || sep == ',') {
+ if (!strncmp(me->mapent, "-null", 5)) {
+ 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;
+ }
cache_unlock(me->mc);
}
--- autofs-5.1.4.orig/man/auto.master.5.in
+++ autofs-5.1.4/man/auto.master.5.in
@@ -267,13 +267,18 @@ master map entry.
diff --git a/daemon/lookup.c b/daemon/lookup.c
index a3f660af..dc779480 100644
--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -774,6 +774,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)
diff --git a/include/parse_subs.h b/include/parse_subs.h
index e2212021..3768275a 100644
--- a/include/parse_subs.h
+++ b/include/parse_subs.h
@@ -122,6 +122,7 @@ int strmcmp(const char *, const char *, int);
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 *);
diff --git a/lib/parse_subs.c b/lib/parse_subs.c
index de8b6773..d48fdee2 100644
--- a/lib/parse_subs.c
+++ b/lib/parse_subs.c
@@ -912,6 +912,19 @@ char *sanitize_path(const char *path, int origlen, unsigned int type, unsigned i
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);
diff --git a/man/auto.master.5.in b/man/auto.master.5.in
index 16717015..34fff95b 100644
--- a/man/auto.master.5.in
+++ b/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

View File

@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.1.4
Release: 110%{?dist}
Release: 111%{?dist}
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@ -790,6 +790,11 @@ fi
%dir /etc/auto.master.d
%changelog
* Mon Sep 18 2023 Ian Kent <ikent@redhat.com> - 5.1.4-111
- RHEL-12369 - autofs attempts to mount nonexistant ".hidden" filesystems
- update patch "allow -null map in indirect maps".
- Resolves: RHEL-12369
* Mon Sep 18 2023 Ian Kent <ikent@redhat.com> - 5.1.4-110
- bz2232402 - autofs attempts to mount nonexistant ".hidden" filesystems
- allow -null map in indirect maps.