@@ -47,6 +47,7 @@ utils/idmapd/idmapd
utils/lockd/lockd
utils/mount/mount.nfs
utils/mountd/mountd
+utils/exportd/exportd
utils/nfsd/nfsd
utils/nfsstat/nfsstat
utils/nhfsstone/nhfsstone
@@ -706,6 +706,7 @@ AC_CONFIG_FILES([
utils/idmapd/Makefile
utils/mount/Makefile
utils/mountd/Makefile
+ utils/exportd/Makefile
utils/nfsd/Makefile
utils/nfsref/Makefile
utils/nfsstat/Makefile
@@ -5,6 +5,7 @@ OPTDIRS =
if CONFIG_NFSV4
OPTDIRS += idmapd
OPTDIRS += nfsidmap
+OPTDIRS += exportd
endif
if CONFIG_NFSV41
new file mode 100644
@@ -0,0 +1,58 @@
+## Process this file with automake to produce Makefile.in
+
+OPTLIBS =
+
+man8_MANS = exportd.man
+EXTRA_DIST = $(man8_MANS)
+
+NFSPREFIX = nfsv4.
+KPREFIX = @kprefix@
+sbin_PROGRAMS = exportd
+
+exportd_SOURCES = exportd.c
+exportd_LDADD = ../../support/nfs/libnfs.la
+
+exportd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS)
+
+MAINTAINERCLEANFILES = Makefile.in
+
+#######################################################################
+# The following allows the current practice of having
+# daemons renamed during the install to include NFSPREFIX
+# and the KPREFIX
+# This could all be done much easier with program_transform_name
+# ( program_transform_name = s/^/$(NFSPREFIX)$(KPREFIX)/ )
+# but that also renames the man pages, which the current
+# practice does not do.
+install-exec-hook:
+ (cd $(DESTDIR)$(sbindir) && \
+ for p in $(sbin_PROGRAMS); do \
+ mv -f $$p$(EXEEXT) $(NFSPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\
+ done)
+uninstall-hook:
+ (cd $(DESTDIR)$(sbindir) && \
+ for p in $(sbin_PROGRAMS); do \
+ rm -f $(NFSPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\
+ done)
+
+
+# XXX This makes some assumptions about what automake does.
+# XXX But there is no install-man-hook or install-man-local.
+install-man: install-man8 install-man-links
+uninstall-man: uninstall-man8 uninstall-man-links
+
+install-man-links:
+ (cd $(DESTDIR)$(man8dir) && \
+ for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \
+ inst=`echo $$m | sed -e 's/man$$/8/'`; \
+ rm -f $(NFSPREFIX)$$inst ; \
+ $(LN_S) $$inst $(NFSPREFIX)$$inst ; \
+ done)
+
+uninstall-man-links:
+ (cd $(DESTDIR)$(man8dir) && \
+ for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \
+ inst=`echo $$m | sed -e 's/man$$/8/'`; \
+ rm -f $(NFSPREFIX)$$inst ; \
+ done)
+
new file mode 100644
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2021 Red Hat <nfs@redhat.com>
+ *
+ * support/exportd/exportd.c
+ *
+ * Routines used to support NFSv4 exports
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <getopt.h>
+
+#include "nfslib.h"
+#include "conffile.h"
+
+
+static struct option longopts[] =
+{
+ { "foreground", 0, 0, 'F' },
+ { "debug", 1, 0, 'd' },
+ { "help", 0, 0, 'h' },
+ { NULL, 0, 0, 0 }
+};
+
+/*
+ * Signal handlers.
+ */
+inline static void set_signals(void);
+
+static void
+killer (int sig)
+{
+ xlog (L_NOTICE, "Caught signal %d, un-registering and exiting.", sig);
+ exit(0);
+}
+static void
+sig_hup (int UNUSED(sig))
+{
+ /* don't exit on SIGHUP */
+ xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n");
+ return;
+}
+inline static void
+set_signals(void)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGPIPE, &sa, NULL);
+ /* WARNING: the following works on Linux and SysV, but not BSD! */
+ sigaction(SIGCHLD, &sa, NULL);
+
+ sa.sa_handler = killer;
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
+ sa.sa_handler = sig_hup;
+ sigaction(SIGHUP, &sa, NULL);
+}
+static void
+usage(const char *prog, int n)
+{
+ fprintf(stderr,
+ "Usage: %s [-f|--foreground] [-h|--help] [-d kind|--debug kind]\n", prog);
+ exit(n);
+}
+
+int
+main(int argc, char **argv)
+{
+ char *progname;
+ int foreground = 0;
+ int c;
+
+ /* Set the basename */
+ if ((progname = strrchr(argv[0], '/')) != NULL)
+ progname++;
+ else
+ progname = argv[0];
+
+ /* Initialize logging. */
+ xlog_open(progname);
+
+ conf_init_file(NFS_CONFFILE);
+ xlog_set_debug(progname);
+
+ while ((c = getopt_long(argc, argv, "d:fh", longopts, NULL)) != EOF) {
+ switch (c) {
+ case 'd':
+ xlog_sconfig(optarg, 1);
+ break;
+ case 'f':
+ foreground++;
+ break;
+ case 'h':
+ usage(progname, 0);
+ break;
+ case '?':
+ default:
+ usage(progname, 1);
+ }
+
+ }
+
+ if (!foreground)
+ xlog_stderr(0);
+
+ daemon_init(foreground);
+
+ set_signals();
+
+ daemon_ready();
+}
new file mode 100644
@@ -0,0 +1,74 @@
+.\"@(#)nfsv4.exportd.8"
+.\"
+.\" Copyright (C) 2021 Red Hat <nfs@redhat.com>
+.\"
+.TH nfsv4.exportd 8 "02 Feb 2021"
+.SH NAME
+nfsv4.exportd \- NFSv4 Server Mount Daemon
+.SH SYNOPSIS
+.BI "/usr/sbin/nfsv4.exportd [" options "]"
+.SH DESCRIPTION
+The
+.B nfsv4.exportd
+is used to manage NFSv4 exports. The NFSv4 server
+receives a mount request from a client and pass it up to
+.B nfsv4.exportd.
+.B nfsv4.exportd
+then uses the exports(5) export
+table to verify the validity of the mount request.
+.PP
+An NFS server maintains a table of local physical file systems
+that are accessible to NFS clients.
+Each file system in this table is referred to as an
+.IR "exported file system" ,
+or
+.IR export ,
+for short.
+.PP
+Each file system in the export table has an access control list.
+.B nfsv4.exportd
+uses these access control lists to determine
+whether an NFS client is permitted to access a given file system.
+For details on how to manage your NFS server's export table, see the
+.BR exports (5)
+and
+.BR exportfs (8)
+man pages.
+.SH OPTIONS
+.TP
+.B \-d kind " or " \-\-debug kind
+Turn on debugging. Valid kinds are: all, auth, call, general and parse.
+.TP
+.B \-F " or " \-\-foreground
+Run in foreground (do not daemonize)
+.TP
+.B \-h " or " \-\-help
+Display usage message.
+.SH CONFIGURATION FILE
+Many of the options that can be set on the command line can also be
+controlled through values set in the
+.B [exportd]
+or, in some cases, the
+.B [nfsd]
+sections of the
+.I /etc/nfs.conf
+configuration file.
+Values recognized in the
+.B [exportd]
+section include
+.B debug
+which each have the same effect as the option with the same name.
+.SH FILES
+.TP 2.5i
+.I /etc/exports
+input file for
+.BR exportfs ,
+listing exports, export options, and access control lists
+.SH SEE ALSO
+.BR exportfs (8),
+.BR exports (5),
+.BR showmount (8),
+.BR nfs.conf (5),
+.BR firwall-cmd (1),
+.sp
+RFC 3530 - "Network File System (NFS) version 4 Protocol"
Signed-off-by: Steve Dickson <steved@redhat.com> --- .gitignore | 1 + configure.ac | 1 + utils/Makefile.am | 1 + utils/exportd/Makefile.am | 58 ++++++++++++++++++ utils/exportd/exportd.c | 121 ++++++++++++++++++++++++++++++++++++++ utils/exportd/exportd.man | 74 +++++++++++++++++++++++ 6 files changed, 256 insertions(+) create mode 100644 utils/exportd/Makefile.am create mode 100644 utils/exportd/exportd.c create mode 100644 utils/exportd/exportd.man