LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-02-2020, 07:29 PM   #1
slacker1337
Member
 
Registered: Jun 2012
Location: Connecticut, USA
Distribution: Slackware
Posts: 148

Rep: Reputation: 40
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?
 
Old 02-02-2020, 07:53 PM   #2
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
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.
 
Old 02-02-2020, 08:28 PM   #3
slacker1337
Member
 
Registered: Jun 2012
Location: Connecticut, USA
Distribution: Slackware
Posts: 148

Original Poster
Rep: Reputation: 40
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>
 
1 members found this post helpful.
Old 02-02-2020, 08:57 PM   #4
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
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.

Last edited by upnort; 02-02-2020 at 09:05 PM.
 
Old 02-02-2020, 09:17 PM   #5
slacker1337
Member
 
Registered: Jun 2012
Location: Connecticut, USA
Distribution: Slackware
Posts: 148

Original Poster
Rep: Reputation: 40
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.
 
Old 02-02-2020, 10:03 PM   #6
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
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
 
Old 02-03-2020, 05:21 AM   #7
slacker1337
Member
 
Registered: Jun 2012
Location: Connecticut, USA
Distribution: Slackware
Posts: 148

Original Poster
Rep: Reputation: 40
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
 
Old 02-03-2020, 07:31 PM   #8
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
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.
 
Old 02-03-2020, 09:00 PM   #9
slacker1337
Member
 
Registered: Jun 2012
Location: Connecticut, USA
Distribution: Slackware
Posts: 148

Original Poster
Rep: Reputation: 40
I saw! It looks like he added the creation of /etc/exports.d as well. Thanks for your help upnort.
 
Old 02-05-2020, 01:36 PM   #10
perbh
Member
 
Registered: May 2008
Location: Republic of Texas
Posts: 393

Rep: Reputation: 81
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.

Last edited by perbh; 02-05-2020 at 01:42 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] NFS exports do not show up in /proc/fs/nfs/exports Gerard_2009 Linux - Server 2 09-07-2010 03:06 PM
NFS Root Boot - Exports soulkeeper Linux - Networking 3 07-24-2004 02:27 AM
Exports Walter Sobchek AIX 13 06-16-2004 01:25 PM
/etc/exports in Solaris retoon Solaris / OpenSolaris 7 06-19-2003 08:13 AM
/etc/exports: insecure meshcurrent Linux - Security 2 03-16-2003 04:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration