autofs-5.1.7 - fix is mounted check on non existent path From: Ian Kent When checking if a path is a mount point the case of a non-existent path was not being handled. Signed-off-by: Ian Kent --- CHANGELOG | 1 + lib/dev-ioctl-lib.c | 3 +++ lib/mounts.c | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 484bd866..e55fd66a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ - fix mnts_remove_amdmount() uses wrong list. - Fix option for master read wait. - eliminate cache_lookup_offset() usage. +- fix is mounted check on non existent path. 25/01/2021 autofs-5.1.7 - make bind mounts propagation slave by default. diff --git a/lib/dev-ioctl-lib.c b/lib/dev-ioctl-lib.c index e8519236..7040c3da 100644 --- a/lib/dev-ioctl-lib.c +++ b/lib/dev-ioctl-lib.c @@ -759,6 +759,9 @@ static int dev_ioctl_ismountpoint(unsigned int logopt, int save_errno = errno; free_dev_ioctl_path(param); errno = save_errno; + /* Path doesn't exist */ + if (errno == ENOENT) + return 0; return -1; } diff --git a/lib/mounts.c b/lib/mounts.c index 42e8ef07..fe931b20 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -1649,8 +1649,18 @@ static int table_is_mounted(const char *mp, unsigned int type) struct mntent mnt_wrk; char buf[PATH_MAX * 3]; size_t mp_len = strlen(mp); + struct stat st; FILE *tab; - int ret = 0; + int ret; + + ret = stat(mp, &st); + if (ret == -1) { + if (errno == ENOENT) { + /* Path does not exist */ + return 0; + } + ret = 0; + } if (!mp || !mp_len || mp_len >= PATH_MAX) return 0;