autofs-5.1.9 - fix amd external mount mount handling From: Ian Kent Amd external mounts exist outside of the autofs file system and need extra effort to try and keep track of them so they are mounted and umounted when they should be. Cleanup cases where an external mount is already mounted. Signed-off-by: Ian Kent --- CHANGELOG | 1 + modules/parse_amd.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ba2fc5628..e7c78f989 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ - Fix incompatible function pointer types in cyrus-sasl module. - fix always recreate credential cache. - fix amd external mount error handling. +- fix amd external mount mount handling. 02/11/2023 autofs-5.1.9 - fix kernel mount status notification. diff --git a/modules/parse_amd.c b/modules/parse_amd.c index e54c6ca45..517940ce6 100644 --- a/modules/parse_amd.c +++ b/modules/parse_amd.c @@ -1189,8 +1189,9 @@ static int do_generic_mount(struct autofs_point *ap, const char *name, umount = 1; } /* If we have an external mount add it to the list */ - if (umount && !ext_mount_add(entry->fs, entry->umount)) { - umount_amd_ext_mount(ap, entry->fs); + if (!ext_mount_add(entry->fs, entry->umount)) { + if (umount) + umount_amd_ext_mount(ap, entry->fs); error(ap->logopt, MODPREFIX "error: could not add external mount %s", entry->fs); @@ -1239,8 +1240,9 @@ static int do_nfs_mount(struct autofs_point *ap, const char *name, umount = 1; } /* We might be using an external mount */ - if (umount && !ext_mount_add(entry->fs, entry->umount)) { - umount_amd_ext_mount(ap, entry->fs); + if (!ext_mount_add(entry->fs, entry->umount)) { + if (umount) + umount_amd_ext_mount(ap, entry->fs); error(ap->logopt, MODPREFIX "error: could not add external mount %s", entry->fs); ret = 1; @@ -1442,12 +1444,13 @@ static int do_program_mount(struct autofs_point *ap, * before executing the mount command and removing it at * umount. */ - if (ext_mount_inuse(entry->fs)) { + if (is_mounted(entry->fs, MNTS_REAL)) { + if (!ext_mount_add(entry->fs, entry->umount)) { + error(ap->logopt, MODPREFIX + "error: could not add external mount %s", entry->fs); + goto out; + } rv = 0; - /* An external mount with path entry->fs exists - * so ext_mount_add() won't fail. - */ - ext_mount_add(entry->fs, entry->umount); } else { rv = mkdir_path(entry->fs, mp_mode); if (rv && errno != EEXIST) {