autofs-5.1.2 - fix offset mount location multiple expansion From: Ian Kent When parsing an offset map entry mount location it shouldn't be expanded because it will have already been dequoted before being added to the map entry cache when it was first parsed. Expanding it again can lead to inconsistent behaviour between the expansion of simple map entry locations and offset locations that have had quoting removed as part of the initial parse. Signed-off-by: Ian Kent --- CHANGELOG | 1 + modules/parse_sun.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 1ea69d5..46487f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -59,6 +59,7 @@ xx/xx/2016 autofs-5.1.3 - fix work around sss startup delay. - fix invalid reference in remount_active_mount(). - use malloc for expanded map location. +- fix offset mount location multiple expansion. 15/06/2016 autofs-5.1.2 ======================= diff --git a/modules/parse_sun.c b/modules/parse_sun.c index 8955c84..536a9bc 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -1297,6 +1297,30 @@ int parse_mount(struct autofs_point *ap, const char *name, pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state); + /* Offset map entries have been expanded already, avoid expanding + * them again so that the quote handling is consistent between map + * entry locations and (previously expanded) offset map entry + * locations. + */ + if (*name == '/') { + cache_readlock(mc); + me = cache_lookup_distinct(mc, name); + if (me && me->multi && me->multi != me) { + cache_unlock(mc); + mapent_len = strlen(mapent) + 1; + pmapent = malloc(mapent_len + 1); + if (!pmapent) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + logerr(MODPREFIX "malloc: %s", estr); + return 1; + } + memset(pmapent, 0, mapent_len + 1); + strcpy(pmapent, mapent); + goto dont_expand; + } + cache_unlock(mc); + } + macro_lock(); ctxt->subst = addstdenv(ctxt->subst, NULL); @@ -1313,6 +1337,7 @@ int parse_mount(struct autofs_point *ap, const char *name, ctxt->subst = removestdenv(ctxt->subst, NULL); macro_unlock(); +dont_expand: pthread_setcancelstate(cur_state, NULL); debug(ap->logopt, MODPREFIX "expanded entry: %s", pmapent);