autofs-5.1.8 - fix incorrect path for is_mounted() in try_remount() From: Ian Kent A regression was introduced when the offset mount handling was rewritten. It resulted in an incorrect path sometimes being used in an is_mounted() check. Signed-off-by: Ian Kent --- CHANGELOG | 1 + lib/mounts.c | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f50f7c26..af95ba1f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -48,6 +48,7 @@ - fix deadlock with hosts map reload. - fix memory leak in update_hosts_mounts(). - fix minus only option handling in concat_options(). +- fix incorrect path for is_mounted() in try_remount(). 19/10/2021 autofs-5.1.8 - add xdr_exports(). diff --git a/lib/mounts.c b/lib/mounts.c index a3f9dfd7..06a9cf00 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -2803,14 +2803,30 @@ int try_remount(struct autofs_point *ap, struct mapent *me, unsigned int type) ap->flags &= ~MOUNT_FLAG_DIR_CREATED; else ap->flags |= MOUNT_FLAG_DIR_CREATED; + goto done; + } + + me->flags &= ~MOUNT_FLAG_DIR_CREATED; + /* Direct or offset mount, key is full path */ + if (MM_PARENT(me)->key[0] == '/') { + if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL)) + me->flags |= MOUNT_FLAG_DIR_CREATED; } else { - me->flags &= ~MOUNT_FLAG_DIR_CREATED; - if (type == t_offset) { - if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL)) - me->flags |= MOUNT_FLAG_DIR_CREATED; + char *p_key = MM_PARENT(me)->key; + char mp[PATH_MAX + 1]; + int len; + + len = mount_fullpath(mp, PATH_MAX, ap->path, ap->len, p_key); + if (len > PATH_MAX) { + /* This should never happen due to earlier checks */ + error(ap->logopt, "mountpoint path too long"); + return 0; } - } + if (!is_mounted(mp, MNTS_REAL)) + me->flags |= MOUNT_FLAG_DIR_CREATED; + } +done: /* * Either we opened the mount or we're re-reading the map. * If we opened the mount and ioctlfd is not -1 we have