- fix some amd map handling problems.

This commit is contained in:
Ian Kent 2018-02-01 15:13:49 +08:00
parent db4d8fe82a
commit 6bb43b6bd8
5 changed files with 209 additions and 1 deletions

View File

@ -0,0 +1,56 @@
autofs-5.1.4 - dont use array for path when not necessary
From: Ian Kent <raven@themaw.net>
In parse_amd.c:do_link_mount() a character array is used to construct
a path when a pointer to the relevant amd entry field is sufficient.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 0f30596f..13f01397 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ xx/xx/2018 autofs-5.1.5
- fix directory create permission.
- fix use after free in do_master_list_reset().
- fix deadlock in dumpmaps.
+- dont use array for path when not necessary.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index c4b3ef0b..2cce5417 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -967,8 +967,8 @@ static int do_auto_mount(struct autofs_point *ap, const char *name,
static int do_link_mount(struct autofs_point *ap, const char *name,
struct amd_entry *entry, unsigned int flags)
{
- char target[PATH_MAX + 1];
const char *opts = (entry->opts && *entry->opts) ? entry->opts : NULL;
+ char *target;
int ret;
if (entry->sublink) {
@@ -977,14 +977,14 @@ static int do_link_mount(struct autofs_point *ap, const char *name,
"error: sublink option length is too long");
return 0;
}
- strcpy(target, entry->sublink);
+ target = entry->sublink;
} else {
if (strlen(entry->fs) > PATH_MAX) {
error(ap->logopt, MODPREFIX
"error: fs option length is too long");
return 0;
}
- strcpy(target, entry->fs);
+ target = entry->fs;
}
if (!(flags & CONF_AUTOFS_USE_LOFS))

View File

@ -0,0 +1,35 @@
autofs-5.1.4 - fix error return in do_nfs_mount()
From: Ian Kent <raven@themaw.net>
Fix incorrect error return in modules/parse_amd.c:do_nfs_mount().
---
CHANGELOG | 1 +
modules/parse_amd.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 756ef927..d0cfa19b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ xx/xx/2018 autofs-5.1.5
- dont use array for path when not necessary.
- fix prefix option handling in expand_entry().
- fix sublink option not set from defaults.
+- fix error return in do_nfs_mount().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 1c962fff..2a5d9a30 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -1099,7 +1099,7 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name,
if (strlen(entry->rhost) + strlen(entry->rfs) + 1 > PATH_MAX) {
error(ap->logopt, MODPREFIX
"error: rhost + rfs options length is too long");
- return 0;
+ return 1;
}
strcpy(target, entry->rhost);

View File

@ -0,0 +1,55 @@
autofs-5.1.4 - fix prefix option handling in expand_entry()
From: Ian Kent <raven@themaw.net>
The changes to fix the defaults handling in the amd map parser caused
the prefix option to not be expanded and also to not be propagated to
submounts in some cases.
But the prefix should be expanded in modules/parse_amd.c:expand_entry()
along with the reset of the amd map entry fields.
Just adding this to modules/parse_amd.c:expand_entry() (where it should
be) fixes the amd map entry expansion and also fixes the propagation
of the prefix to submounts.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 13f01397..19aec2ae 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ xx/xx/2018 autofs-5.1.5
- fix use after free in do_master_list_reset().
- fix deadlock in dumpmaps.
- dont use array for path when not necessary.
+- fix prefix option handling in expand_entry().
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 2cce5417..1a5a2960 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -725,6 +725,17 @@ static struct substvar *expand_entry(struct autofs_point *ap,
entry->rhost = host;
}
next:
+ if (entry->pref) {
+ if (expand_selectors(ap, entry->pref, &expand, sv)) {
+ debug(logopt, MODPREFIX
+ "pref expand(\"%s\") -> %s",
+ entry->pref, expand);
+ free(entry->pref);
+ entry->pref = expand;
+ }
+ sv = macro_addvar(sv, "pref", 4, entry->pref);
+ }
+
if (entry->sublink) {
if (expand_selectors(ap, entry->sublink, &expand, sv)) {
debug(logopt, MODPREFIX

View File

@ -0,0 +1,48 @@
autofs-5.1.4 - fix sublink option not set from defaults
From: Ian Kent <raven@themaw.net>
If the amd entry sublink option is given in a defaults entry
it isn't merged into the current entry during parsing.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 19aec2ae..756ef927 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@ xx/xx/2018 autofs-5.1.5
- fix deadlock in dumpmaps.
- dont use array for path when not necessary.
- fix prefix option handling in expand_entry().
+- fix sublink option not set from defaults.
19/12/2017 autofs-5.1.4
- fix spec file url.
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
index 1a5a2960..1c962fff 100644
--- a/modules/parse_amd.c
+++ b/modules/parse_amd.c
@@ -645,6 +645,18 @@ static void update_with_defaults(struct amd_entry *defaults,
}
}
+ if (!entry->sublink) {
+ if (defaults->sublink) {
+ tmp = strdup(defaults->sublink);
+ if (tmp)
+ entry->sublink = tmp;
+ } else {
+ v = macro_findvar(sv, "sublink", 2);
+ if (v)
+ entry->sublink = strdup(v->val);
+ }
+ }
+
return;
}

View File

@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.1.4
Release: 5%{?dist}
Release: 6%{?dist}
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@ -17,6 +17,10 @@ Patch1: autofs-5.1.4-fix-flag-file-permission.patch
Patch2: autofs-5.1.4-fix-directory-create-permission.patch
Patch3: autofs-5.1.4-fix-use-after-free-in-do_master_list_reset.patch
Patch4: autofs-5.1.4-fix-deadlock-in-dumpmaps.patch
Patch5: autofs-5.1.4-dont-use-array-for-path-when-not-neccessary.patch
Patch6: autofs-5.1.4-fix-prefix-option-handling-in-expand_entry.patch
Patch7: autofs-5.1.4-fix-sublink-option-not-set-from-defaults.patch
Patch8: autofs-5.1.4-fix-error-return-in-do_nfs_mount.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -82,6 +86,10 @@ echo %{version}-%{release} > .version
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%build
LDFLAGS=-Wl,-z,now
@ -175,6 +183,12 @@ fi
%dir /etc/auto.master.d
%changelog
* Thu Feb 1 2018 Ian Kent <ikent@redhat.com> - 1:5.1.4-6
- dont use array for path when not necessary.
- fix prefix option handling in expand_entry().
- fix sublink option not set from defaults.
- fix error return in do_nfs_mount().
* Wed Jan 10 2018 Ian Kent <ikent@redhat.com> - 1:5.1.4-5
- actually apply fix use after free in do_master_list_reset().
- fix deadlock in dumpmaps.