exports.d
I noticed today that /etc/exports.d isn't supported in Slackware's /etc/rc.d/rc.nfsd init script. I'm running 64bit 14.2 and have a few files in /etc/exports.d/ but my /etc/exports is empty.
Anyways, I found rc.nfsd checks whether /etc/exports is readable, then checks if there are any exports but it exists there if /etc/exports is empty, without checking /etc/exports.d. Has anyone else noticed this behavior? How do you all handle exports? |
Do the files use the .exports extension?
Man page: After reading /etc/exports exportfs reads files in the /etc/exports.d directory as extra export tables. Only files ending in .exports are considered. Files beginning with a dot are ignored. The format for extra export tables is the same as /etc/exports. |
Yes, all of my <dot> files have the ".exports" extension. The issue I found is here:
<code> nfsd_start() { # Sanity checks. Exit if there's no /etc/exports, or if there aren't any # shares defined in it. if [ ! -r /etc/exports ]; then # no config file, exit: exit elif ! grep -v '^#' /etc/exports | grep '/' 1> /dev/null 2> /dev/null ; then exit # no uncommented shares in /etc/exports fi </code> |
The rc.nfsd script executes exportfs -r.
According to the man page, the exportfs command looks for /etc/exports.d. Thus no rc.d script support should be needed to source /etc/exports.d. exportfs -r: Reexport all directories, synchronizing /var/lib/nfs/etab with /etc/exports and files under /etc/exports.d. This option removes entries in /var/lib/nfs/etab which have been deleted from /etc/exports or files under /etc/exports.d, and removes any entries from the kernel export table which are no longer valid. All well and good, but the rc.nfsd script terminates if /etc/exports does not exist or is empty, regardless of anything in /etc/exports.d. Seems the script needs a little love to look at /etc/exports.d before terminating. |
This is what I noticed as well. I could run /usr/sbin/exportfs and see the output from the exported filesystems, but I would get nothing running /usr/sbin/showmount -e <server_name> from the client side. In short, rc.nfsd was immediately exiting but it wasn't informing me of any problems.
|
Proposed patch with informative exit output. Please test.
Code:
--- rc.nfsd 2020-02-02 21:32:40.079584735 -0600 |
That's good, but doesn't check the original intent of PV's script - i.e. doesn't check to see if exports.d is actually exporting anything. I'd recommend the following:
*** /etc/rc.d/rc.nfsd 2020-02-03 06:13:21.621520725 -0500 --- /etc/rc.d/rc.nfsd.orig 2020-02-02 13:38:44.993237455 -0500 *************** nfsd_start() { *** 11,22 **** # Sanity checks. Exit if there's no /etc/exports, or if there aren't any # shares defined in it. if [ ! -r /etc/exports ]; then # no config file, exit: ! echo "/etc/exports is not readable" && exit elif ! grep -v '^#' /etc/exports | grep '/' 1> /dev/null 2> /dev/null ; then ! # exit # no uncommented shares in /etc/exports ! if [[ ! $( grep -v '^#' /etc/exports.d/*.exports | grep '^/' ) ]]; then ! echo "exports or exports.d export nothing" && exit # no uncommented shares in /etc/exports.d ! fi fi # If we do not detect nfsd support built into the kernel (or previously --- 11,19 ---- # Sanity checks. Exit if there's no /etc/exports, or if there aren't any # shares defined in it. if [ ! -r /etc/exports ]; then # no config file, exit: ! exit elif ! grep -v '^#' /etc/exports | grep '/' 1> /dev/null 2> /dev/null ; then ! exit # no uncommented shares in /etc/exports fi # If we do not detect nfsd support built into the kernel (or previously |
Might want to check the change in Current. The sanity checks have been removed. I don't know if Pat will backport the change to 14.2, but straightforward to fix.
|
I saw! It looks like he added the creation of /etc/exports.d as well. Thanks for your help upnort.
|
I always remove the test - I prefer (rightly or wrongly) to use /etc/rc.d/rc.local for my exports. Why? - well why not?
Sooo - it goes something like this: Code:
df -a | grep -wq '/pub$' || { /etc/exports (or exports.d) are fine if the exported fs is always available. Using rc.local I can do extensive checks as to the availability of the fs. |
All times are GMT -5. The time now is 09:12 PM. |