diff options
author | Andrew Gierth <andrew@tao146.riddles.org.uk> | 2023-07-10 15:09:56 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-10-24 00:46:01 +0000 |
commit | 361f7820cde9cc9e9eb7118155b6a39c1a52ef9d (patch) | |
tree | a556a1f13d401f0ce0d82ef0adc07c551f5b2893 | |
parent | be2333b68d71bea99768749db3057f4fd66f9d5d (diff) | |
download | src-361f7820cde9cc9e9eb7118155b6a39c1a52ef9d.tar.gz src-361f7820cde9cc9e9eb7118155b6a39c1a52ef9d.zip |
automount: check for mounted-over autofs instances on flush
PR: 272446
(cherry picked from commit 21b8e363c4eb24c0a5659101603cc08a86d87759)
-rw-r--r-- | usr.sbin/autofs/automount.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c index 188bbc3a040f..cee647cb4e2c 100644 --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -260,6 +260,7 @@ static void flush_caches(void) { struct statfs *mntbuf; + struct statfs statbuf; int i, nitems; nitems = getmntinfo(&mntbuf, MNT_WAIT); @@ -274,6 +275,21 @@ flush_caches(void) mntbuf[i].f_mntonname); continue; } + /* + * A direct map mountpoint may have been mounted over, in + * which case we can't MNT_UPDATE it. There's an obvious race + * condition remaining here, but that has to be fixed in the + * kernel. + */ + if (statfs(mntbuf[i].f_mntonname, &statbuf) != 0) { + log_err(1, "cannot statfs %s", mntbuf[i].f_mntonname); + continue; + } + if (strcmp(statbuf.f_fstypename, "autofs") != 0) { + log_debugx("skipping %s, filesystem type is not autofs", + mntbuf[i].f_mntonname); + continue; + } flush_autofs(mntbuf[i].f_mntonname); } |