From abe6750a7ee39852b011faa0791963d854788984 Mon Sep 17 00:00:00 2001 From: Matthias Gerstner Date: Wed, 20 Feb 2019 11:19:28 +0100 Subject: [PATCH 5/6] watchdog: be robust against unrelated localhost based nfs mounts While a bit exotic there can exist mounts of locally exported nfs shares that aren't related to EFS. In this case the watchdog fails, because it tries to access the port option that is not present in these unrelated mount entries. To fix this discard entries from /proc/mounts that don't carry a port option. --- src/watchdog/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/watchdog/__init__.py b/src/watchdog/__init__.py index caca0d9..d002cf9 100755 --- a/src/watchdog/__init__.py +++ b/src/watchdog/__init__.py @@ -95,6 +95,9 @@ def get_file_safe_mountpoint(mount): mountpoint = mountpoint[1:] opts = parse_options(mount.options) + if 'port' not in opts: + # some other localhost nfs mount not running over stunnel + return None return mountpoint + '.' + opts['port'] @@ -113,7 +116,9 @@ def get_current_local_nfs_mounts(mount_file='/proc/mounts'): mount_dict = {} for m in mounts: - mount_dict[get_file_safe_mountpoint(m)] = m + safe_mnt = get_file_safe_mountpoint(m) + if safe_mnt: + mount_dict[safe_mnt] = m return mount_dict -- 2.21.0