SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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>
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
+++ rc.nfsd.new 2020-02-02 22:00:02.939046867 -0600
@@ -8,12 +8,17 @@
# Written for Slackware Linux by Patrick J. Volkerding <volkerdi@slackware.com>.
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:
+ # Sanity checks. Exit if there is no /etc/exports, /etc/exports.d is
+ # empty, or /etc/exports contains no uncommented entries
+ if [ ! -r /etc/exports ] && [ ! -d /etc/exports.d ]; then
+ echo "/etc/exports and /etc/exports.d do not exist. Exiting."
+ exit
+ elif [ ! -r /etc/exports ] && [ -d /etc/exports.d ] && [ "$(/bin/ls -A /etc/exports.d 2>/dev/null)" = "" ]; then
+ echo "/etc/exports does not exist and /etc/exports.d is empty. Exiting."
+ exit
+ elif [ ! -r /etc/exports ] && ! grep -v '^#' /etc/exports | grep '/' 1> /dev/null 2> /dev/null ; then
+ echo "/etc/exports exists but is empty or contains only comments. Exiting."
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
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 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$' || {
pub=/usb/public
test -d $pub && {
mount --bind $pub /pub && {
echo ":: mounted /pub on $pub ..."
mount --bind /pub /home/ftp/pub && {
echo ":: mounted /home/ftp/pub on /pub ..."
mops="rw,insecure,async,no_root_squash,anonuid=0,anongid=0"
exportfs -iv -o $mops 192.168.1.0/22:/pub
unset mops
}
}
}
unset pub
}
I have similar exports on other machines where the fs I want to export may or may not be available (probably because it is an external disk).
/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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.