== Our low-rent approach to verifying that NFS mounts are there [[Our mail system CurrentMailerConfiguration]] has everyone's inboxes in an old-fashioned _/var/mail_ style single directory; in fact it literally is _/var/mail_. This directory is NFS mounted from one of [[our fileservers ../solaris/ZFSFileserverSetupII]], which raises a little question: how can we be sure that it's actually there? Well, there's always going to be a _/var/mail_ directory. But what we care about is that this directory is the actual NFS mounted filesystem instead of the directory on the local root filesystem that is the mount point, because we very much do not want to ever deliver email to the latter. (Some people may say that limited directory permissions on the mount point should make delivery attempts fail. 'Should' is not a word that I like in this situation, either in 'should fail' or 'that failure should be retried'.) There are probably lots of clever solutions to this problem involving advanced tricks like embedded Perl bits in the mailer that look at NFS mount state and so on. We opted for a simple and low tech approach: we have a magic flag file in the NFS version of _/var/mail_, imaginatively called _.NFS-MOUNTED_. If the flag file is not present, we assume that the filesystem is not mounted and stall all email delivery to _/var/mail_. This scheme is subject to various potential issues (like accidentally deleting _.NFS-MOUNTED_ some day), but it has the great virtue that it is simple and relatively bulletproof. It helps that Exim has robust support for checking whether or not a file exists (although [[we use a hack EximDeferRouters]] for various reasons). The whole thing has worked well and basically transparently, and we haven't removed one those _.NFS-MOUNTED_ files by accident yet. (We actually use this trick for several NFS-mounted mail related directories that we need to verify are present before we start trying to do things involving them, not just _/var/mail_.) (I mentioned this trick in passing [[here EximDeferRouters]], but today I feel like writing it up explicitly.) === Sidebar: our alternate approach with user home directories Since user home directories are NFS mounted, you might be wondering if we also use flag files there to verify that the NFS mounts are present before checking things like _.forward_ files. Because of how our NFS mounts are organized, we use an alternate approach instead. In short, our NFS mounts aren't directly for user home directories; instead they're for filesystems with user home directories in them. (A user has a home directory like _/h/281/cks_, where _/h/281_ is the actual NFS mounted filesystem.) In this situation it suffices to just check that the user's home directory exists. If it does, the NFS filesystem it is in must be mounted (well, unless someone has done something very perverse). As a useful side bonus, this guards against various other errors (eg, 'user home directory was listed wrong in _/etc/passwd_').