From 6bb43b6bd89537818bd9b0e055b91a7887748df9 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Thu, 1 Feb 2018 15:13:49 +0800 Subject: [PATCH] - fix some amd map handling problems. --- ...e-array-for-path-when-not-neccessary.patch | 56 +++++++++++++++++++ ...1.4-fix-error-return-in-do_nfs_mount.patch | 35 ++++++++++++ ...efix-option-handling-in-expand_entry.patch | 55 ++++++++++++++++++ ...sublink-option-not-set-from-defaults.patch | 48 ++++++++++++++++ autofs.spec | 16 +++++- 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 autofs-5.1.4-dont-use-array-for-path-when-not-neccessary.patch create mode 100644 autofs-5.1.4-fix-error-return-in-do_nfs_mount.patch create mode 100644 autofs-5.1.4-fix-prefix-option-handling-in-expand_entry.patch create mode 100644 autofs-5.1.4-fix-sublink-option-not-set-from-defaults.patch diff --git a/autofs-5.1.4-dont-use-array-for-path-when-not-neccessary.patch b/autofs-5.1.4-dont-use-array-for-path-when-not-neccessary.patch new file mode 100644 index 0000000..b95f0ea --- /dev/null +++ b/autofs-5.1.4-dont-use-array-for-path-when-not-neccessary.patch @@ -0,0 +1,56 @@ +autofs-5.1.4 - dont use array for path when not necessary + +From: Ian Kent + +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 +--- + 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)) diff --git a/autofs-5.1.4-fix-error-return-in-do_nfs_mount.patch b/autofs-5.1.4-fix-error-return-in-do_nfs_mount.patch new file mode 100644 index 0000000..80d0a87 --- /dev/null +++ b/autofs-5.1.4-fix-error-return-in-do_nfs_mount.patch @@ -0,0 +1,35 @@ +autofs-5.1.4 - fix error return in do_nfs_mount() + +From: Ian Kent + +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); diff --git a/autofs-5.1.4-fix-prefix-option-handling-in-expand_entry.patch b/autofs-5.1.4-fix-prefix-option-handling-in-expand_entry.patch new file mode 100644 index 0000000..4e3996b --- /dev/null +++ b/autofs-5.1.4-fix-prefix-option-handling-in-expand_entry.patch @@ -0,0 +1,55 @@ +autofs-5.1.4 - fix prefix option handling in expand_entry() + +From: Ian Kent + +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 +--- + 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 diff --git a/autofs-5.1.4-fix-sublink-option-not-set-from-defaults.patch b/autofs-5.1.4-fix-sublink-option-not-set-from-defaults.patch new file mode 100644 index 0000000..cefb27c --- /dev/null +++ b/autofs-5.1.4-fix-sublink-option-not-set-from-defaults.patch @@ -0,0 +1,48 @@ +autofs-5.1.4 - fix sublink option not set from defaults + +From: Ian Kent + +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 +--- + 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; + } + diff --git a/autofs.spec b/autofs.spec index 8c9640a..e8b6f33 100644 --- a/autofs.spec +++ b/autofs.spec @@ -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 - 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 - 1:5.1.4-5 - actually apply fix use after free in do_master_list_reset(). - fix deadlock in dumpmaps.