autofs-5.1.6 - fix unlink mounts umount order From: Ian Kent The recent changes to mount table handling to support the "ignore" autofs pseudo option resulted in the incorrect umount order being used in the unlink_mount_tree() function. To fix this change unlink_mount_tree() to use the existing get_mnt_list() function to construct a correctly ordered list for the umounts. Signed-off-by: Ian Kent --- CHANGELOG | 1 + lib/mounts.c | 39 +++++++++------------------------------ 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 965b82e4..2974e628 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,7 @@ xx/xx/2020 autofs-5.1.7 - include linux/nfs.h directly in rpc_subs.h. - fix typo in daemon/automount.c. - fix direct mount unlink_mount_tree() path. +- fix unlink mounts umount order. 07/10/2019 autofs-5.1.6 - support strictexpire mount option. diff --git a/lib/mounts.c b/lib/mounts.c index a2d1f149..e5ac580f 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -951,42 +951,21 @@ local_getmntent_r(FILE *tab, struct mntent *mnt, char *buf, int size) int unlink_mount_tree(struct autofs_point *ap, const char *mp) { - FILE *tab; - struct mntent *mnt; - struct mntent mnt_wrk; - char buf[PATH_MAX * 3]; - unsigned int mp_len = strlen(mp); + struct mnt_list *mnts, *mnt; int rv, ret = 1; - tab = open_fopen_r(_PROC_MOUNTS); - if (!tab) { - char *estr = strerror_r(errno, buf, PATH_MAX - 1); - logerr("fopen: %s", estr); + mnts = get_mnt_list(mp, 1); + if (!mnts) return 0; - } - while ((mnt = local_getmntent_r(tab, &mnt_wrk, buf, PATH_MAX * 3))) { - unsigned int mnt_dir_len; - int is_autofs; - - if (strncmp(mnt->mnt_dir, mp, mp_len)) - continue; - - mnt_dir_len = strlen(mnt->mnt_dir); - is_autofs = !strcmp(mnt->mnt_type, "autofs"); - - if (mnt_dir_len == mp_len && !is_autofs) { - ret = 0; - break; - } - - if (is_autofs) - rv = umount2(mnt->mnt_dir, MNT_DETACH); + for (mnt = mnts; mnt; mnt = mnt->next) { + if (mnt->flags | MNTS_AUTOFS) + rv = umount2(mnt->mp, MNT_DETACH); else - rv = spawn_umount(ap->logopt, "-l", mnt->mnt_dir, NULL); + rv = spawn_umount(ap->logopt, "-l", mnt->mp, NULL); if (rv == -1) { debug(ap->logopt, - "can't unlink %s from mount tree", mnt->mnt_dir); + "can't unlink %s from mount tree", mnt->mp); switch (errno) { case EINVAL: @@ -1002,7 +981,7 @@ int unlink_mount_tree(struct autofs_point *ap, const char *mp) } } } - fclose(tab); + free_mnt_list(mnts); return ret; }