64c563
diff -up nfs-utils-1.3.0/configure.ac.orig nfs-utils-1.3.0/configure.ac
64c563
--- nfs-utils-1.3.0/configure.ac.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/configure.ac	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -23,6 +23,12 @@ AC_ARG_WITH(statedir,
64c563
 	statedir=$withval,
64c563
 	statedir=/var/lib/nfs)
64c563
 	AC_SUBST(statedir)
64c563
+AC_ARG_WITH(nfsconfig,
64c563
+	[AC_HELP_STRING([--with-nfsconfig=/config/file],
64c563
+			[use general config file /config/file @<:@default=/etc/nfs.conf@:>@])],
64c563
+	nfsconfig=$withval,
64c563
+	nfsconfig=/etc/nfs.conf)
64c563
+	AC_SUBST(nfsconfig)
64c563
 AC_ARG_WITH(statdpath,
64c563
 	[AC_HELP_STRING([--with-statdpath=/foo],
64c563
 			[define the statd state dir as /foo instead of the NFS statedir @<:@default=/var/lib/nfs@:>@])],
64c563
@@ -442,6 +448,7 @@ dnl Export some path names to config.h
64c563
 dnl *************************************************************
64c563
 AC_DEFINE_UNQUOTED(NFS_STATEDIR, "$statedir", [This defines the location of the NFS state files. Warning: this must match definitions in config.mk!])
64c563
 AC_DEFINE_UNQUOTED(NSM_DEFAULT_STATEDIR, "$statdpath", [Define this to the pathname where statd keeps its state file])
64c563
+AC_DEFINE_UNQUOTED(NFS_CONFFILE, "$nfsconfig", [This defines the location of NFS daemon config file])
64c563
 
64c563
 if test "x$cross_compiling" = "xno"; then
64c563
 	CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-"$CFLAGS"}
64c563
diff -up nfs-utils-1.3.0/support/include/conffile.h.orig nfs-utils-1.3.0/support/include/conffile.h
64c563
--- nfs-utils-1.3.0/support/include/conffile.h.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/support/include/conffile.h	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -35,6 +35,8 @@
64c563
 
64c563
 #include <sys/queue.h>
64c563
 #include <ctype.h>
64c563
+#include <stdint.h>
64c563
+#include <stdbool.h>
64c563
 
64c563
 struct conf_list_node {
64c563
 	TAILQ_ENTRY(conf_list_node) link;
64c563
@@ -56,6 +58,7 @@ extern struct sockaddr *conf_get_address
64c563
 extern struct conf_list *conf_get_list(char *, char *);
64c563
 extern struct conf_list *conf_get_tag_list(char *, char *);
64c563
 extern int      conf_get_num(char *, char *, int);
64c563
+extern _Bool    conf_get_bool(char *, char *, _Bool);
64c563
 extern char    *conf_get_str(char *, char *);
64c563
 extern char    *conf_get_section(char *, char *, char *);
64c563
 extern void     conf_init(void);
64c563
diff -up nfs-utils-1.3.0/support/include/xlog.h.orig nfs-utils-1.3.0/support/include/xlog.h
64c563
--- nfs-utils-1.3.0/support/include/xlog.h.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/support/include/xlog.h	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -41,6 +41,7 @@ void			xlog_stderr(int on);
64c563
 void			xlog_syslog(int on);
64c563
 void			xlog_config(int fac, int on);
64c563
 void			xlog_sconfig(char *, int on);
64c563
+void			xlog_from_conffile(char *);
64c563
 int			xlog_enabled(int fac);
64c563
 void			xlog(int fac, const char *fmt, ...);
64c563
 void			xlog_warn(const char *fmt, ...);
64c563
diff -up nfs-utils-1.3.0/support/nfs/conffile.c.orig nfs-utils-1.3.0/support/nfs/conffile.c
64c563
--- nfs-utils-1.3.0/support/nfs/conffile.c.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/support/nfs/conffile.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -52,6 +52,7 @@
64c563
 #pragma GCC visibility push(hidden)
64c563
 
64c563
 static void conf_load_defaults(void);
64c563
+static int conf_load(int trans, char *path);
64c563
 static int conf_set(int , char *, char *, char *, 
64c563
 	char *, int , int );
64c563
 
64c563
@@ -107,8 +108,6 @@ struct conf_binding {
64c563
 char *conf_path;
64c563
 LIST_HEAD (conf_bindings, conf_binding) conf_bindings[256];
64c563
 
64c563
-static char *conf_addr;
64c563
-
64c563
 static __inline__ u_int8_t
64c563
 conf_hash(char *s)
64c563
 {
64c563
@@ -213,7 +212,7 @@ static void
64c563
 conf_parse_line(int trans, char *line, size_t sz)
64c563
 {
64c563
 	char *val, *ptr;
64c563
-	size_t i, valsize;
64c563
+	size_t i;
64c563
 	size_t j;
64c563
 	static char *section = 0;
64c563
 	static char *arg = 0;
64c563
@@ -300,18 +299,32 @@ conf_parse_line(int trans, char *line, s
64c563
 			}
64c563
 			line[strcspn (line, " \t=")] = '\0';
64c563
 			val = line + i + 1 + strspn (line + i + 1, " \t");
64c563
-			valsize = 0;
64c563
-			while (val[valsize++]);
64c563
 
64c563
-			/* Skip trailing spaces and comments */
64c563
-			for (j = 0; j < valsize; j++) {
64c563
-				if (val[j] == '#' || val[j] == ';' || isspace(val[j])) {
64c563
-					val[j] = '\0';
64c563
-					break;
64c563
+			if (val[0] == '"') {
64c563
+				val ++;
64c563
+				j = strcspn(val, "\"");
64c563
+				val[j] = 0;
64c563
+			} else if (val[0] == '\'') {
64c563
+				val ++;
64c563
+				j = strcspn(val, "'");
64c563
+				val[j] = 0;
64c563
+			} else {
64c563
+				/* Skip trailing spaces and comments */
64c563
+				for (j = 0; val[j]; j++) {
64c563
+					if ((val[j] == '#' || val[j] == ';')
64c563
+					    && (j == 0 || isspace(val[j-1]))) {
64c563
+						val[j] = '\0';
64c563
+						break;
64c563
+					}
64c563
 				}
64c563
+				while (j && isspace(val[j-1]))
64c563
+					val[--j] = '\0';
64c563
 			}
64c563
-			/* XXX Perhaps should we not ignore errors?  */
64c563
-			conf_set(trans, section, arg, line, val, 0, 0);
64c563
+			if (strcasecmp(line, "include") == 0)
64c563
+				conf_load(trans, val);
64c563
+			else
64c563
+				/* XXX Perhaps should we not ignore errors?  */
64c563
+				conf_set(trans, section, arg, line, val, 0, 0);
64c563
 			return;
64c563
 		}
64c563
 	}
64c563
@@ -368,23 +381,18 @@ conf_init (void)
64c563
 	conf_reinit();
64c563
 }
64c563
 
64c563
-/* Open the config file and map it into our address space, then parse it.  */
64c563
-void
64c563
-conf_reinit(void)
64c563
+static int
64c563
+conf_load(int trans, char *path)
64c563
 {
64c563
-	struct conf_binding *cb = 0;
64c563
-	int fd, trans;
64c563
-	unsigned int i;
64c563
-	size_t sz;
64c563
-	char *new_conf_addr = 0;
64c563
 	struct stat sb;
64c563
+	if ((stat (path, &sb) == 0) || (errno != ENOENT)) {
64c563
+		char *new_conf_addr;
64c563
+		size_t sz = sb.st_size;
64c563
+		int fd = open (path, O_RDONLY, 0);
64c563
 
64c563
-	if ((stat (conf_path, &sb) == 0) || (errno != ENOENT)) {
64c563
-		sz = sb.st_size;
64c563
-		fd = open (conf_path, O_RDONLY, 0);
64c563
 		if (fd == -1) {
64c563
-			xlog_warn("conf_reinit: open (\"%s\", O_RDONLY) failed", conf_path);
64c563
-			return;
64c563
+			xlog_warn("conf_reinit: open (\"%s\", O_RDONLY) failed", path);
64c563
+			return -1;
64c563
 		}
64c563
 
64c563
 		new_conf_addr = malloc(sz);
64c563
@@ -396,39 +404,46 @@ conf_reinit(void)
64c563
 		/* XXX I assume short reads won't happen here.  */
64c563
 		if (read (fd, new_conf_addr, sz) != (int)sz) {
64c563
 			xlog_warn("conf_reinit: read (%d, %p, %lu) failed",
64c563
-   				fd, new_conf_addr, (unsigned long)sz);
64c563
+				fd, new_conf_addr, (unsigned long)sz);
64c563
 			goto fail;
64c563
 		}
64c563
 		close(fd);
64c563
 
64c563
-		trans = conf_begin();
64c563
 		/* XXX Should we not care about errors and rollback?  */
64c563
 		conf_parse(trans, new_conf_addr, sz);
64c563
+		free(new_conf_addr);
64c563
+		return 0;
64c563
+	fail:
64c563
+		close(fd);
64c563
+		free(new_conf_addr);
64c563
 	}
64c563
-	else
64c563
-		trans = conf_begin();
64c563
+	return -1;
64c563
+}
64c563
+
64c563
+/* Open the config file and map it into our address space, then parse it.  */
64c563
+void
64c563
+conf_reinit(void)
64c563
+{
64c563
+	struct conf_binding *cb = 0;
64c563
+	int trans;
64c563
+	unsigned int i;
64c563
+
64c563
+	trans = conf_begin();
64c563
+	if (conf_load(trans, conf_path) < 0)
64c563
+		return;
64c563
 
64c563
 	/* Load default configuration values.  */
64c563
 	conf_load_defaults();
64c563
 
64c563
 	/* Free potential existing configuration.  */
64c563
-	if (conf_addr) {
64c563
-		for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++) {
64c563
-			cb = LIST_FIRST (&conf_bindings[i]);
64c563
-			for (; cb; cb = LIST_FIRST (&conf_bindings[i]))
64c563
-				conf_remove_now(cb->section, cb->tag);
64c563
-		}
64c563
-		free (conf_addr);
64c563
+	for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++) {
64c563
+		cb = LIST_FIRST (&conf_bindings[i]);
64c563
+		for (; cb; cb = LIST_FIRST (&conf_bindings[i]))
64c563
+			conf_remove_now(cb->section, cb->tag);
64c563
 	}
64c563
 
64c563
 	conf_end(trans, 1);
64c563
-	conf_addr = new_conf_addr;
64c563
 	return;
64c563
-
64c563
-fail:
64c563
-	if (new_conf_addr)
64c563
-		free(new_conf_addr);
64c563
-	close (fd);
64c563
 }
64c563
 
64c563
 /*
64c563
@@ -446,6 +461,38 @@ conf_get_num(char *section, char *tag, i
64c563
 	return def;
64c563
 }
64c563
 
64c563
+/*
64c563
+ * Return the Boolean value denoted by TAG in section SECTION, or DEF
64c563
+ * if that tags does not exist.
64c563
+ * FALSE is returned for case-insensitve comparisons with 0, f, false, n, no, off
64c563
+ * TRUE is returned for 1, t, true, y, yes, on
64c563
+ * A failure to match one of these results in DEF
64c563
+ */
64c563
+_Bool
64c563
+conf_get_bool(char *section, char *tag, _Bool def)
64c563
+{
64c563
+	char *value = conf_get_str(section, tag);
64c563
+
64c563
+	if (!value)
64c563
+		return def;
64c563
+	if (strcasecmp(value, "1") == 0 ||
64c563
+	    strcasecmp(value, "t") == 0 ||
64c563
+	    strcasecmp(value, "true") == 0 ||
64c563
+	    strcasecmp(value, "y") == 0 ||
64c563
+	    strcasecmp(value, "yes") == 0 ||
64c563
+	    strcasecmp(value, "on") == 0)
64c563
+		return true;
64c563
+
64c563
+	if (strcasecmp(value, "0") == 0 ||
64c563
+	    strcasecmp(value, "f") == 0 ||
64c563
+	    strcasecmp(value, "false") == 0 ||
64c563
+	    strcasecmp(value, "n") == 0 ||
64c563
+	    strcasecmp(value, "no") == 0 ||
64c563
+	    strcasecmp(value, "off") == 0)
64c563
+		return false;
64c563
+	return def;
64c563
+}
64c563
+
64c563
 /* Validate X according to the range denoted by TAG in section SECTION.  */
64c563
 int
64c563
 conf_match_num(char *section, char *tag, int x)
64c563
@@ -476,12 +523,24 @@ char *
64c563
 conf_get_str(char *section, char *tag)
64c563
 {
64c563
 	struct conf_binding *cb;
64c563
-
64c563
+retry:
64c563
 	cb = LIST_FIRST (&conf_bindings[conf_hash (section)]);
64c563
 	for (; cb; cb = LIST_NEXT (cb, link)) {
64c563
 		if (strcasecmp (section, cb->section) == 0
64c563
-				&& strcasecmp (tag, cb->tag) == 0)
64c563
+		    && strcasecmp (tag, cb->tag) == 0) {
64c563
+			if (cb->value[0] == '$') {
64c563
+				/* expand $name from [environment] section,
64c563
+				 * or from environment
64c563
+				 */
64c563
+				char *env = getenv(cb->value+1);
64c563
+				if (env && *env)
64c563
+					return env;
64c563
+				section = "environment";
64c563
+				tag = cb->value + 1;
64c563
+				goto retry;
64c563
+			}
64c563
 			return cb->value;
64c563
+		}
64c563
 	}
64c563
 	return 0;
64c563
 }
64c563
@@ -705,6 +764,8 @@ conf_set(int transaction, char *section,
64c563
 {
64c563
 	struct conf_trans *node;
64c563
 
64c563
+	if (!value || !*value)
64c563
+		return 0;
64c563
 	node = conf_trans_node(transaction, CONF_SET);
64c563
 	if (!node)
64c563
 		return 1;
64c563
diff -up nfs-utils-1.3.0/support/nfs/xlog.c.orig nfs-utils-1.3.0/support/nfs/xlog.c
64c563
--- nfs-utils-1.3.0/support/nfs/xlog.c.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/support/nfs/xlog.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -29,6 +29,7 @@
64c563
 #include <syslog.h>
64c563
 #include <errno.h>
64c563
 #include "nfslib.h"
64c563
+#include "conffile.h"
64c563
 
64c563
 #undef	VERBOSE_PRINTF
64c563
 
64c563
@@ -125,6 +126,19 @@ xlog_sconfig(char *kind, int on)
64c563
 	xlog_config(tbl->df_fac, on);
64c563
 }
64c563
 
64c563
+void
64c563
+xlog_from_conffile(char *service)
64c563
+{
64c563
+	struct conf_list *kinds;
64c563
+	struct conf_list_node *n;
64c563
+
64c563
+	kinds = conf_get_list(service, "debug");
64c563
+	if (!kinds || !kinds->cnt)
64c563
+		return;
64c563
+	TAILQ_FOREACH(n, &(kinds->fields), link)
64c563
+		xlog_sconfig(n->field, 1);
64c563
+}
64c563
+
64c563
 int
64c563
 xlog_enabled(int fac)
64c563
 {
64c563
diff -up nfs-utils-1.3.0/systemd/Makefile.am.orig nfs-utils-1.3.0/systemd/Makefile.am
64c563
--- nfs-utils-1.3.0/systemd/Makefile.am.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/systemd/Makefile.am	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -20,7 +20,9 @@ unit_files =  \
64c563
     proc-fs-nfsd.mount \
64c563
     var-lib-nfs-rpc_pipefs.mount
64c563
 
64c563
-EXTRA_DIST = $(unit_files)
64c563
+man5_MANS	= nfs.conf.man
64c563
+man7_MANS	= nfs.systemd.man
64c563
+EXTRA_DIST = $(unit_files) $(man5_MANS) $(man7_MANS)
64c563
 
64c563
 unit_dir = /usr/lib/systemd/system
64c563
 
64c563
diff -up nfs-utils-1.3.0/systemd/nfs.conf.man.orig nfs-utils-1.3.0/systemd/nfs.conf.man
64c563
--- nfs-utils-1.3.0/systemd/nfs.conf.man.orig	2017-03-28 13:43:53.000000000 -0400
64c563
+++ nfs-utils-1.3.0/systemd/nfs.conf.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -0,0 +1,231 @@
64c563
+.TH NFS.CONF 5
64c563
+.SH NAME
64c563
+nfs.conf \- general configuration for NFS daemons and tools
64c563
+.SH SYNOPSIS
64c563
+.I /etc/nfs.conf
64c563
+.SH DESCRIPTION
64c563
+.PP
64c563
+This file contains site-specific configuration for various NFS daemons
64c563
+and other processes.  Most configuration can also be passed to
64c563
+processes via command line arguments, but it can be more convenient to
64c563
+have a central file.  In particular, this encourages consistent
64c563
+configuration across different processes.
64c563
+.PP
64c563
+When command line options are provided, they override values set in
64c563
+this file.  When this file does not specify a particular parameter,
64c563
+and no command line option is provided, each tool provides its own
64c563
+default values.
64c563
+.PP
64c563
+The file format supports multiple sections, each of which can contain
64c563
+multiple value assignments.  A section is introduced by a line
64c563
+containing the section name enclosed in square brackets, so
64c563
+.RS
64c563
+.B [global]
64c563
+.RE
64c563
+would introduce a section called
64c563
+.BR global .
64c563
+A value assignment is a single line that has the name of the value, an
64c563
+equals sign, and a setting for the value, so
64c563
+.RS
64c563
+.B threads = 4
64c563
+.RE
64c563
+would set the value named
64c563
+.B threads
64c563
+in the current section to
64c563
+.BR 4 .
64c563
+Leading and trailing spaces and tab
64c563
+are ignored, as are spaces and tabs surrounding the equals sign.
64c563
+Single and double quotes surrounding the assigned value are also
64c563
+removed.  If the resulting string is empty, the whole assignment
64c563
+is ignored.
64c563
+.PP
64c563
+Any line starting with
64c563
+.RB \*(lq # \*(rq
64c563
+or
64c563
+.RB \*(lq ; \*(rq
64c563
+is ignored, as is any blank line.
64c563
+.PP
64c563
+If the assigned value started with a
64c563
+.RB \*(lq $ \*(rq
64c563
+then the remainder is treated as a name and looked for in the section
64c563
+.B [environment]
64c563
+or in the processes environment (see
64c563
+.BR environ (7)).
64c563
+The value found is used for this value.
64c563
+.PP
64c563
+The value name
64c563
+.B include
64c563
+is special.  If a section contains
64c563
+.RS
64c563
+.B include = /some/file/name
64c563
+.RE
64c563
+then the named file will be read, and any value assignments found
64c563
+there-in will be added to the current section.  If the file contains
64c563
+section headers, then new sections will be created just as if the
64c563
+included file appeared in place of the
64c563
+.B include
64c563
+line.
64c563
+.PP
64c563
+Lookup of section and value names is case-insensitive.
64c563
+
64c563
+Where a Boolean value is expected, any of
64c563
+.BR true ,
64c563
+.BR t ,
64c563
+.BR yes ,
64c563
+.BR y ,
64c563
+.BR on ", or"
64c563
+.B 1
64c563
+can be used for "true", while
64c563
+.BR false ,
64c563
+.BR f ,
64c563
+.BR no ,
64c563
+.BR n ,
64c563
+.BR off ", or"
64c563
+.B 0
64c563
+can be used for "false".  Comparisons are case-insensitive.
64c563
+
64c563
+.SH SECTIONS
64c563
+The following sections are known to various programs, and can contain
64c563
+the given named values.  Most sections can also contain a
64c563
+.B debug
64c563
+value, which can be one or more from the list
64c563
+.BR general ,
64c563
+.BR call ,
64c563
+.BR auth ,
64c563
+.BR parse ,
64c563
+.BR all .
64c563
+When a list is given, the members should be comma-separated.
64c563
+.TP
64c563
+.B nfsdcltrack
64c563
+Recognized values:
64c563
+.BR storagedir .
64c563
+
64c563
+The
64c563
+.B nfsdcltrack
64c563
+program is run directly by the Linux kernel and there is no
64c563
+opportunity to provide command line arguments, so the configuration
64c563
+file is the only way to configure this program.  See
64c563
+.BR nfsdcltrack (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B nfsd
64c563
+Recognized values:
64c563
+.BR threads ,
64c563
+.BR host ,
64c563
+.BR port ,
64c563
+.BR grace-time ,
64c563
+.BR lease-time ,
64c563
+.BR udp ,
64c563
+.BR tcp ,
64c563
+.BR vers2 ,
64c563
+.BR vers3 ,
64c563
+.BR vers4 ,
64c563
+.BR vers4.0 ,
64c563
+.BR vers4.1 ,
64c563
+.BR vers4.2 ,
64c563
+.BR rdma .
64c563
+
64c563
+Version and protocol values are Boolean values as described above,
64c563
+and are also used by
64c563
+.BR rpc.mountd .
64c563
+Threads and the two times are integers.
64c563
+.B port
64c563
+and
64c563
+.B rdma
64c563
+are service names or numbers.  See
64c563
+.BR rpc.nfsd (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B mountd
64c563
+Recognized values:
64c563
+.BR manage-gids ,
64c563
+.BR descriptors ,
64c563
+.BR port ,
64c563
+.BR threads ,
64c563
+.BR reverse-lookup ,
64c563
+.BR state-directory-path ,
64c563
+.BR ha-callout .
64c563
+
64c563
+These, together with the protocol and version values in the
64c563
+.B [nfsd]
64c563
+section, are used to configure mountd.  See
64c563
+.BR rpc.mountd (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B statd
64c563
+Recognized values:
64c563
+.BR port ,
64c563
+.BR outgoing-port ,
64c563
+.BR name ,
64c563
+.BR state-directory-path ,
64c563
+.BR ha-callout .
64c563
+
64c563
+See
64c563
+.BR rpc.statd (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B lockd
64c563
+Recognized values:
64c563
+.B port
64c563
+and
64c563
+.BR udp-port .
64c563
+
64c563
+See
64c563
+.BR rpc.statd (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B sm-notify
64c563
+Recognized values:
64c563
+.BR retry-time ,
64c563
+.BR outgoing-port ", and"
64c563
+.BR outgoing-addr .
64c563
+
64c563
+See
64c563
+.BR sm-notify (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B gssd
64c563
+Recognized values:
64c563
+.BR use-memcache ,
64c563
+.BR use-machine-creds ,
64c563
+.BR avoid-dns ,
64c563
+.BR limit-to-legacy-enctypes ,
64c563
+.BR context-timeout ,
64c563
+.BR rpc-timeout ,
64c563
+.BR pipefs-directory ,
64c563
+.BR keytab-file ,
64c563
+.BR cred-cache-directory ,
64c563
+.BR preferred-realm .
64c563
+
64c563
+See
64c563
+.BR rpc.gssd (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B svcgssd
64c563
+Recognized values:
64c563
+.BR principal .
64c563
+
64c563
+See
64c563
+.BR rpc.svcgssd (8)
64c563
+for details.
64c563
+
64c563
+.TP
64c563
+.B exportfs
64c563
+Only
64c563
+.B debug=
64c563
+is recognized.
64c563
+
64c563
+.SH FILES
64c563
+.I /etc/nfs.conf
64c563
+.SH SEE ALSO
64c563
+.BR nfsdcltrack (8),
64c563
+.BR rpc.nfsd (8),
64c563
+.BR rpc.mountd (8),
64c563
+.BR nfsmount.conf (5).
64c563
diff -up nfs-utils-1.3.0/systemd/nfs.systemd.man.orig nfs-utils-1.3.0/systemd/nfs.systemd.man
64c563
--- nfs-utils-1.3.0/systemd/nfs.systemd.man.orig	2017-03-28 13:45:11.000000000 -0400
64c563
+++ nfs-utils-1.3.0/systemd/nfs.systemd.man	2017-03-28 13:45:11.000000000 -0400
64c563
@@ -0,0 +1,167 @@
64c563
+.TH NFS.SYSTEMD 7
64c563
+.SH NAME
64c563
+nfs.systemd \- managing NFS services through systemd.
64c563
+.SH SYNOPSIS
64c563
+nfs-utils.service
64c563
+.br
64c563
+nfs-server.service
64c563
+.br
64c563
+nfs-client.target
64c563
+.br
64c563
+.I etc
64c563
+.SH DESCRIPTION
64c563
+The
64c563
+.I nfs-utils
64c563
+package provides a suite of
64c563
+.I systemd
64c563
+unit files which allow the various services to be started and
64c563
+managed.  These unit files ensure that the services are started in the
64c563
+correct order, and the prerequisites are active before dependant
64c563
+services start.  As there are quite  few unit files, it is not
64c563
+immediately obvious how best to achieve certain results.  The
64c563
+following subsections attempt to cover the issues that are most likely
64c563
+to come up.
64c563
+.SS Configuration
64c563
+The standard systemd unit files do not provide any easy way to pass
64c563
+any command line arguments to daemons so as to configure their
64c563
+behavior.  In many case such configuration can be performed by making
64c563
+changes to
64c563
+.I /etc/nfs.conf
64c563
+or other configuration files.  When that is not convenient, a
64c563
+distribution might provide systemd "drop-in" files which replace the
64c563
+.B ExecStart=
64c563
+setting to start the program with different arguments.  For example a
64c563
+drop-in file
64c563
+.B systemd/system/nfs-mountd.service.d/local.conf
64c563
+containing
64c563
+.RS
64c563
+.nf
64c563
+[Service]
64c563
+EnvironmentFile=/etc/sysconfig/nfs
64c563
+ExecStart=
64c563
+ExecStart= /usr/sbin/rpc.mountd $RPCMOUNTDOPTS
64c563
+.fi
64c563
+.RE
64c563
+would cause the
64c563
+.B nfs-mountd.service
64c563
+unit to run the
64c563
+.I rpc.mountd
64c563
+program using, for arguments, the value given for
64c563
+.B RPCMOUNTDOPTS
64c563
+in
64c563
+.IR /etc/sysconfig/nfs .
64c563
+This allows for seamless integration with existing configuration
64c563
+tools.
64c563
+.SS Enabling unit files
64c563
+There are three unit files which are designed to be manually enabled.
64c563
+All others are automatically run as required.  The three are:
64c563
+.TP
64c563
+.B nfs-client.target
64c563
+This should be enabled on any host which ever serves as an NFS client.
64c563
+There is little cost in transparently enabling it whenever NFS client
64c563
+software is installed.
64c563
+.TP
64c563
+.B nfs-server.service
64c563
+This must be enabled to provide NFS service to clients.  It starts and
64c563
+configures the required daemons in the required order.
64c563
+.TP
64c563
+.B nfs-blkmap.service
64c563
+The
64c563
+.B blkmapd
64c563
+daemon is only required on NFS clients which are using pNFS (parallel
64c563
+NFS), and particularly using the
64c563
+.B blocklayout
64c563
+layout protocol.  If you might use this particular extension to NFS,
64c563
+the
64c563
+.B nfs-blkmap.service
64c563
+unit should be enabled.
64c563
+.PP
64c563
+Several other units which might be considered to be optional, such as
64c563
+.I rpc-gssd.service
64c563
+are careful to only start if the required configuration file exists.
64c563
+.I rpc-gsdd.service
64c563
+will not start if the
64c563
+.I krb5.keytab
64c563
+file does not exist (typically in
64c563
+.IR /etc ).
64c563
+.SS Restarting NFS services
64c563
+Most NFS daemons can be restarted at any time.  They will reload any
64c563
+state that they need, and continue servicing requests.  This is rarely
64c563
+necessary though.
64c563
+.PP
64c563
+When configuration changesare make, it can be hard to know exactly
64c563
+which services need to be restarted to ensure that the configuration
64c563
+takes effect.  The simplest approach, which is often the best, is to
64c563
+restart everything.  To help with this, the
64c563
+.B nfs-utils.service
64c563
+unit is provided.  It declares appropriate dependencies with other
64c563
+unit files so that
64c563
+.RS
64c563
+.B systemctl restart nfs-utils
64c563
+.RE
64c563
+will restart all NFS daemons that are running.  This will cause all
64c563
+configuration changes to take effect
64c563
+.I except
64c563
+for changes to mount options lists in
64c563
+.I /etc/fstab
64c563
+or
64c563
+.IR /etc/nfsmount.conf .
64c563
+Mount options can only be changed by unmounting and remounting
64c563
+filesystem.  This can be a disruptive operation so it should only be
64c563
+done when the value justifies the cost.  The command
64c563
+.RS
64c563
+.B umount -a -t nfs; mount -a -t nfs
64c563
+.RE
64c563
+should unmount and remount all NFS filesystems.
64c563
+.SS Masking unwanted services
64c563
+Rarely there may be a desire to prohibit some services from running
64c563
+even though there are normally part of a working NFS system.  This may
64c563
+be needed to reduce system load to an absolute minimum, or to reduce
64c563
+attack surface by not running daemons that are not absolutely
64c563
+required.
64c563
+.PP
64c563
+Two particular services which this can apply to are
64c563
+.I rpcbind
64c563
+and
64c563
+.IR idmapd .
64c563
+.I rpcbind
64c563
+is not part of the
64c563
+.I nfs-utils
64c563
+package, but it used by several NFS services.  However it is
64c563
+.B not
64c563
+needed when only NFSv4 is in use.  If a site will never use NFSv3 (or
64c563
+NFSv2) and does not want
64c563
+.I rpcbind
64c563
+to be running, the correct approach is to run
64c563
+.RS
64c563
+.B systemctl mask rpcbind
64c563
+.RE
64c563
+This will disable
64c563
+.IR rpcbind ,
64c563
+and the various NFS services which depend on it (and are only needed
64c563
+for NFSv3) will refuse to start, without interfering with the
64c563
+operation of NFSv4 services.  In particular,
64c563
+.I rpc.statd
64c563
+will not run when
64c563
+.I rpcbind
64c563
+is masked.
64c563
+.PP
64c563
+.I idmapd
64c563
+is only needed for NFSv4, and even then is not needed when the client
64c563
+and server agree to use user-ids rather than user-names to identify the
64c563
+owners of files.  If
64c563
+.I idmapd
64c563
+is not needed and not wanted, it can be masked with
64c563
+.RS
64c563
+.B systemctl mask idmapd
64c563
+.RE
64c563
+.SH FILES
64c563
+/etc/nfs.conf
64c563
+.br
64c563
+/etc/nfsmount.conf
64c563
+.br
64c563
+/etc/idmapd.conf
64c563
+.SH SEE ALSO
64c563
+.BR systemd.unit (5),
64c563
+.BR nfs.conf (5),
64c563
+.BR nfsmount.conf (5).
64c563
diff -up nfs-utils-1.3.0/systemd/rpc-statd.service.orig nfs-utils-1.3.0/systemd/rpc-statd.service
64c563
--- nfs-utils-1.3.0/systemd/rpc-statd.service.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/systemd/rpc-statd.service	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -11,7 +11,8 @@ Wants=nfs-config.service
64c563
 After=nfs-config.service
64c563
 
64c563
 [Service]
64c563
+Environment=RPC_STATD_NO_NOTIFY=1
64c563
 EnvironmentFile=-/run/sysconfig/nfs-utils
64c563
 Type=forking
64c563
 PIDFile=/var/run/rpc.statd.pid
64c563
-ExecStart=/usr/sbin/rpc.statd --no-notify $STATDARGS
64c563
+ExecStart=/usr/sbin/rpc.statd $STATDARGS
64c563
diff -up nfs-utils-1.3.0/utils/exportfs/exportfs.c.orig nfs-utils-1.3.0/utils/exportfs/exportfs.c
64c563
--- nfs-utils-1.3.0/utils/exportfs/exportfs.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/exportfs/exportfs.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -37,6 +37,7 @@
64c563
 #include "nfslib.h"
64c563
 #include "exportfs.h"
64c563
 #include "xlog.h"
64c563
+#include "conffile.h"
64c563
 
64c563
 static void	export_all(int verbose);
64c563
 static void	exportfs(char *arg, char *options, int verbose);
64c563
@@ -53,6 +54,7 @@ static void release_lockfile(void);
64c563
 
64c563
 static const char *lockfile = EXP_LOCKFILE;
64c563
 static int _lockfd = -1;
64c563
+char *conf_path = NFS_CONFFILE;
64c563
 
64c563
 /*
64c563
  * If we aren't careful, changes made by exportfs can be lost
64c563
@@ -108,6 +110,9 @@ main(int argc, char **argv)
64c563
 	xlog_stderr(1);
64c563
 	xlog_syslog(0);
64c563
 
64c563
+	conf_init();
64c563
+	xlog_from_conffile("exportfs");
64c563
+
64c563
 	while ((c = getopt(argc, argv, "ad:fhio:ruvs")) != EOF) {
64c563
 		switch(c) {
64c563
 		case 'a':
64c563
diff -up nfs-utils-1.3.0/utils/exportfs/exportfs.man.orig nfs-utils-1.3.0/utils/exportfs/exportfs.man
64c563
--- nfs-utils-1.3.0/utils/exportfs/exportfs.man.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/exportfs/exportfs.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -90,6 +90,13 @@ to be added to the kernel's export table
64c563
 .TP
64c563
 .B \-d kind " or " \-\-debug kind
64c563
 Turn on debugging. Valid kinds are: all, auth, call, general and parse.
64c563
+Debugging can also be turned on by setting
64c563
+.B debug=
64c563
+in the
64c563
+.B [exportfs]
64c563
+section of
64c563
+.IR /etc/nfs.conf .
64c563
+
64c563
 .TP
64c563
 .B -a
64c563
 Export or unexport all directories.
64c563
@@ -295,6 +302,7 @@ master table of exports
64c563
 table of clients accessing server's exports
64c563
 .SH SEE ALSO
64c563
 .BR exports (5),
64c563
+.BR nfs.conf (5),
64c563
 .BR rpc.mountd (8),
64c563
 .BR netgroup (5)
64c563
 .SH AUTHORS
64c563
diff -up nfs-utils-1.3.0/utils/gssd/gssd.c.orig nfs-utils-1.3.0/utils/gssd/gssd.c
64c563
--- nfs-utils-1.3.0/utils/gssd/gssd.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/gssd/gssd.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -71,6 +71,7 @@
64c563
 #include "gss_util.h"
64c563
 #include "krb5_util.h"
64c563
 #include "nfslib.h"
64c563
+#include "conffile.h"
64c563
 
64c563
 static char *pipefs_path = GSSD_PIPEFS_DIR;
64c563
 static DIR *pipefs_dir;
64c563
@@ -78,6 +79,7 @@ static int pipefs_fd;
64c563
 static int inotify_fd;
64c563
 struct event inotify_ev;
64c563
 
64c563
+char *conf_path = NFS_CONFFILE;
64c563
 char *keytabfile = GSSD_DEFAULT_KEYTAB_FILE;
64c563
 char **ccachesearch;
64c563
 int  use_memcache = 0;
64c563
@@ -831,6 +833,33 @@ main(int argc, char *argv[])
64c563
 	char *progname;
64c563
 	char *ccachedir = NULL;
64c563
 	struct event sighup_ev;
64c563
+	char *s;
64c563
+
64c563
+	conf_init();
64c563
+	use_memcache = conf_get_bool("gssd", "use-memcache", use_memcache);
64c563
+	root_uses_machine_creds = conf_get_bool("gssd", "use-machine-creds",
64c563
+						root_uses_machine_creds);
64c563
+	avoid_dns = conf_get_bool("gssd", "avoid-dns", avoid_dns);
64c563
+#ifdef HAVE_SET_ALLOWABLE_ENCTYPES
64c563
+	limit_to_legacy_enctypes = conf_get_bool("gssd", "limit-to-legacy-enctypes",
64c563
+						 limit_to_legacy_enctypes);
64c563
+#endif
64c563
+	context_timeout = conf_get_num("gssd", "context-timeout", context_timeout);
64c563
+	rpc_timeout = conf_get_num("gssd", "rpc-timeout", rpc_timeout);
64c563
+	s = conf_get_str("gssd", "pipefs-directory");
64c563
+	if (!s)
64c563
+		s = conf_get_str("general", "pipefs-directory");
64c563
+	if (s)
64c563
+		pipefs_path = s;
64c563
+	s = conf_get_str("gssd", "keytab-file");
64c563
+	if (s)
64c563
+		keytabfile = s;
64c563
+	s = conf_get_str("gssd", "cred-cache-directory");
64c563
+	if (s)
64c563
+		ccachedir = s;
64c563
+	s = conf_get_str("gssd", "preferred-realm");
64c563
+	if (s)
64c563
+		preferred_realm = s;
64c563
 
64c563
 	while ((opt = getopt(argc, argv, "DfvrlmnMp:k:d:t:T:R:")) != -1) {
64c563
 		switch (opt) {
64c563
diff -up nfs-utils-1.3.0/utils/gssd/gssd.man.orig nfs-utils-1.3.0/utils/gssd/gssd.man
64c563
--- nfs-utils-1.3.0/utils/gssd/gssd.man.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/gssd/gssd.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -297,6 +297,60 @@ The default timeout is set to 5 seconds.
64c563
 If you get messages like "WARNING: can't create tcp rpc_clnt to server
64c563
 %servername% for user with uid %uid%: RPC: Remote system error -
64c563
 Connection timed out", you should consider an increase of this timeout.
64c563
+.SH CONFIGURATION FILE
64c563
+Many of the options that can be set on the command line can also be
64c563
+controlled through values set in the
64c563
+.B [gssd]
64c563
+section of the
64c563
+.I /etc/nfs.conf
64c563
+configuration file.  Values recognized include:
64c563
+.TP
64c563
+.B use-memcache
64c563
+A Boolean flag equivalent to
64c563
+.BR -M .
64c563
+.TP
64c563
+.B use-machine-creds
64c563
+A Boolean flag. Setting to
64c563
+.B false
64c563
+is equivalent to giving the
64c563
+.B -n
64c563
+flag.
64c563
+.TP
64c563
+.B avoid-dns
64c563
+Setting to
64c563
+.B false
64c563
+is equivalent to providing the
64c563
+.B -D
64c563
+flag.
64c563
+.TP
64c563
+.B limit-to-legacy-enctypes
64c563
+Equivalent to
64c563
+.BR -l .
64c563
+.TP
64c563
+.B context-timeout
64c563
+Equivalent to
64c563
+.BR -T .
64c563
+.TP
64c563
+.B rpc-timeout
64c563
+Equivalent to
64c563
+.BR -t .
64c563
+.TP
64c563
+.B pipefs-directory
64c563
+Equivalent to
64c563
+.BR -p .
64c563
+.TP
64c563
+.B keytab-file
64c563
+Equivalent to
64c563
+.BR -k .
64c563
+.TP
64c563
+.BR cred-cache-directory
64c563
+Equivalent to
64c563
+.BR -d .
64c563
+.TP
64c563
+.B preferred-realm
64c563
+Equivalent to
64c563
+.BR -R .
64c563
+
64c563
 .SH SEE ALSO
64c563
 .BR rpc.svcgssd (8),
64c563
 .BR kerberos (1),
64c563
diff -up nfs-utils-1.3.0/utils/gssd/svcgssd.c.orig nfs-utils-1.3.0/utils/gssd/svcgssd.c
64c563
--- nfs-utils-1.3.0/utils/gssd/svcgssd.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/gssd/svcgssd.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -61,6 +61,9 @@
64c563
 #include "svcgssd.h"
64c563
 #include "gss_util.h"
64c563
 #include "err_util.h"
64c563
+#include "conffile.h"
64c563
+
64c563
+char *conf_path = NFS_CONFFILE;
64c563
 
64c563
 void
64c563
 sig_die(int signal)
64c563
@@ -98,6 +101,17 @@ main(int argc, char *argv[])
64c563
 	extern char *optarg;
64c563
 	char *progname;
64c563
 	char *principal = NULL;
64c563
+	char *s;
64c563
+
64c563
+	conf_init();
64c563
+
64c563
+	s = conf_get_str("svcgssd", "principal");
64c563
+	if (!s)
64c563
+		;
64c563
+	else if (strcmp(s, "system")== 0)
64c563
+		get_creds = 0;
64c563
+	else
64c563
+		principal = s;
64c563
 
64c563
 	while ((opt = getopt(argc, argv, "fivrnp:")) != -1) {
64c563
 		switch (opt) {
64c563
diff -up nfs-utils-1.3.0/utils/gssd/svcgssd.man.orig nfs-utils-1.3.0/utils/gssd/svcgssd.man
64c563
--- nfs-utils-1.3.0/utils/gssd/svcgssd.man.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/gssd/svcgssd.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -45,6 +45,23 @@ Use the system default credentials
64c563
 .RI (host/ FQDN @ REALM )
64c563
 rather than the default
64c563
 .RI nfs/ FQDN @ REALM .
64c563
+.SH CONFIGURATION FILE
64c563
+Some of the options that can be set on the command line can also be
64c563
+controlled through values set in the
64c563
+.B [svcgssd]
64c563
+section of the
64c563
+.I /etc/nfs.conf
64c563
+configuration file.  Values recognized include:
64c563
+.TP
64c563
+.B principal
64c563
+If set to
64c563
+.B system
64c563
+this is equivalent to the
64c563
+.B -n
64c563
+option.  If set to any other value, that is used like the
64c563
+.B -p
64c563
+option.
64c563
+
64c563
 .SH SEE ALSO
64c563
 .BR rpc.gssd(8),
64c563
 .SH AUTHORS
64c563
diff -up nfs-utils-1.3.0/utils/mountd/mountd.c.orig nfs-utils-1.3.0/utils/mountd/mountd.c
64c563
--- nfs-utils-1.3.0/utils/mountd/mountd.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/mountd/mountd.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -22,6 +22,8 @@
64c563
 #include <fcntl.h>
64c563
 #include <sys/resource.h>
64c563
 #include <sys/wait.h>
64c563
+
64c563
+#include "conffile.h"
64c563
 #include "xmalloc.h"
64c563
 #include "misc.h"
64c563
 #include "mountd.h"
64c563
@@ -39,6 +41,8 @@ int new_cache = 0;
64c563
 int manage_gids;
64c563
 int use_ipaddr = -1;
64c563
 
64c563
+char *conf_path = NFS_CONFFILE;
64c563
+
64c563
 /* PRC: a high-availability callout program can be specified with -H
64c563
  * When this is done, the program will receive callouts whenever clients
64c563
  * send mount or unmount requests -- the callout is not needed for 2.6 kernel */
64c563
@@ -692,6 +696,7 @@ main(int argc, char **argv)
64c563
 	char	*export_file = _PATH_EXPORTS;
64c563
 	char    *state_dir = NFS_STATEDIR;
64c563
 	char	*progname;
64c563
+	char	*s;
64c563
 	unsigned int listeners = 0;
64c563
 	int	foreground = 0;
64c563
 	int	port = 0;
64c563
@@ -707,6 +712,38 @@ main(int argc, char **argv)
64c563
 	else
64c563
 		progname = argv[0];
64c563
 
64c563
+	conf_init();
64c563
+	xlog_from_conffile("mountd");
64c563
+	manage_gids = conf_get_bool("mountd", "manage-gids", manage_gids);
64c563
+	descriptors = conf_get_num("mountd", "descriptors", descriptors);
64c563
+	port = conf_get_num("mountd", "port", port);
64c563
+	num_threads = conf_get_num("mountd", "threads", num_threads);
64c563
+	reverse_resolve = conf_get_bool("mountd", "reverse-lookup", reverse_resolve);
64c563
+	ha_callout_prog = conf_get_str("mountd", "ha-callout");
64c563
+
64c563
+	s = conf_get_str("mountd", "state-directory-path");
64c563
+	if (s)
64c563
+		state_dir = s;
64c563
+
64c563
+	/* NOTE: following uses "nfsd" section of nfs.conf !!!! */
64c563
+	if (conf_get_bool("nfsd", "udp", NFSCTL_UDPISSET(_rpcprotobits)))
64c563
+		NFSCTL_UDPSET(_rpcprotobits);
64c563
+	else
64c563
+		NFSCTL_UDPUNSET(_rpcprotobits);
64c563
+	if (conf_get_bool("nfsd", "tcp", NFSCTL_TCPISSET(_rpcprotobits)))
64c563
+		NFSCTL_TCPSET(_rpcprotobits);
64c563
+	else
64c563
+		NFSCTL_TCPUNSET(_rpcprotobits);
64c563
+	for (vers = 2; vers <= 4; vers++) {
64c563
+		char tag[10];
64c563
+		sprintf(tag, "vers%d", vers);
64c563
+		if (conf_get_bool("nfsd", tag, NFSCTL_VERISSET(nfs_version, vers)))
64c563
+			NFSCTL_VERSET(nfs_version, vers);
64c563
+		else
64c563
+			NFSCTL_VERUNSET(nfs_version, vers);
64c563
+	}
64c563
+
64c563
+
64c563
 	/* Parse the command line options and arguments. */
64c563
 	opterr = 0;
64c563
 	while ((c = getopt_long(argc, argv, "o:nFd:f:p:P:hH:N:V:vurs:t:g", longopts, NULL)) != EOF)
64c563
diff -up nfs-utils-1.3.0/utils/mountd/mountd.man.orig nfs-utils-1.3.0/utils/mountd/mountd.man
64c563
--- nfs-utils-1.3.0/utils/mountd/mountd.man.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/mountd/mountd.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -207,6 +207,39 @@ the server. Note that the 'primary' grou
64c563
 .B newgroup
64c563
 command on the client will still be effective.  This function requires
64c563
 a Linux Kernel with version at least 2.6.21.
64c563
+
64c563
+.SH CONFIGURATION FILE
64c563
+Many of the options that can be set on the command line can also be
64c563
+controlled through values set in the
64c563
+.B [mountd]
64c563
+or, in some cases, the
64c563
+.B [nfsd]
64c563
+sections of the
64c563
+.I /etc/nfs.conf
64c563
+configuration file.
64c563
+Values recognized in the
64c563
+.B [mountd]
64c563
+section include
64c563
+.BR manage-gids ,
64c563
+.BR descriptors ,
64c563
+.BR port ,
64c563
+.BR threads ,
64c563
+.BR reverse-lookup ", and"
64c563
+.BR state-directory-path ,
64c563
+.B ha-callout
64c563
+which each have the same effect as the option with the same name.
64c563
+
64c563
+The values recognized in the
64c563
+.B [nfsd]
64c563
+section include
64c563
+.BR TCP ,
64c563
+.BR UDP ,
64c563
+.BR vers2 ,
64c563
+.BR vers3 ", and"
64c563
+.B vers4
64c563
+which each have same same meaning as given by
64c563
+.BR rpc.nfsd (8).
64c563
+
64c563
 .SH TCP_WRAPPERS SUPPORT
64c563
 You can protect your
64c563
 .B rpc.mountd
64c563
@@ -261,6 +294,7 @@ table of clients accessing server's expo
64c563
 .BR rpc.nfsd (8),
64c563
 .BR rpc.rquotad (8),
64c563
 .BR nfs (5),
64c563
+.BR nfs.conf (5),
64c563
 .BR tcpd (8),
64c563
 .BR hosts_access (5),
64c563
 .BR iptables (8),
64c563
diff -up nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.c.orig nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.c
64c563
--- nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -43,6 +43,7 @@
64c563
 #include <sys/capability.h>
64c563
 #endif
64c563
 
64c563
+#include "conffile.h"
64c563
 #include "xlog.h"
64c563
 #include "sqlite.h"
64c563
 
64c563
@@ -55,6 +56,8 @@
64c563
 /* defined by RFC 3530 */
64c563
 #define NFS4_OPAQUE_LIMIT	1024
64c563
 
64c563
+char *conf_path = NFS_CONFFILE;
64c563
+
64c563
 /* private data structures */
64c563
 struct cltrack_cmd {
64c563
 	char *name;
64c563
@@ -553,6 +556,7 @@ int
64c563
 main(int argc, char **argv)
64c563
 {
64c563
 	char arg;
64c563
+	char *val;
64c563
 	int rc = 0;
64c563
 	char *progname, *cmdarg = NULL;
64c563
 	struct cltrack_cmd *cmd;
64c563
@@ -562,6 +566,15 @@ main(int argc, char **argv)
64c563
 	xlog_syslog(1);
64c563
 	xlog_stderr(0);
64c563
 
64c563
+	conf_init();
64c563
+	xlog_from_conffile("nfsdcltrack");
64c563
+	val = conf_get_str("nfsdcltrack", "storagedir");
64c563
+	if (val)
64c563
+		storagedir = val;
64c563
+	rc = conf_get_num("nfsdcltrack", "debug", 0);
64c563
+	if (rc > 0)
64c563
+		xlog_config(D_ALL, 1);
64c563
+
64c563
 	/* process command-line options */
64c563
 	while ((arg = getopt_long(argc, argv, "hdfs:", longopts,
64c563
 				  NULL)) != EOF) {
64c563
diff -up nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.man.orig nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.man
64c563
--- nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.man.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/nfsdcltrack/nfsdcltrack.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -66,6 +66,20 @@ Check to see if a nfs_client_id4 is allo
64c563
 .IP "\fBgracedone\fR" 4
64c563
 .IX Item "gracedone"
64c563
 Remove any unreclaimed client records from the database. This command requires a epoch boot time as an argument.
64c563
+.SH "EXTERNAL CONFIGURATION"
64c563
+The directory for stable storage information can be set via the file
64c563
+.B /etc/nfs.conf
64c563
+by setting the
64c563
+.B storagedir
64c563
+value in the
64c563
+.B nfsdcltrack
64c563
+section.  For example:
64c563
+.in +5
64c563
+[nfsdcltrack]
64c563
+.br
64c563
+  storagedir = /shared/nfs/nfsdcltrack
64c563
+.in -5
64c563
+Debuging to syslog can also be enabled by setting "debug = 1" in this file.
64c563
 .SH "LEGACY TRANSITION MECHANISM"
64c563
 .IX Header "LEGACY TRANSITION MECHANISM"
64c563
 The Linux kernel NFSv4 server has historically tracked this information
64c563
diff -up nfs-utils-1.3.0/utils/nfsd/nfsd.c.orig nfs-utils-1.3.0/utils/nfsd/nfsd.c
64c563
--- nfs-utils-1.3.0/utils/nfsd/nfsd.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/nfsd/nfsd.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -23,14 +23,18 @@
64c563
 #include <netinet/in.h>
64c563
 #include <arpa/inet.h>
64c563
 
64c563
+#include "conffile.h"
64c563
 #include "nfslib.h"
64c563
 #include "nfssvc.h"
64c563
 #include "xlog.h"
64c563
+#include "xcommon.h"
64c563
 
64c563
 #ifndef NFSD_NPROC
64c563
 #define NFSD_NPROC 8
64c563
 #endif
64c563
 
64c563
+char *conf_path = NFS_CONFFILE;
64c563
+
64c563
 static void	usage(const char *);
64c563
 
64c563
 static struct option longopts[] =
64c563
@@ -51,50 +55,6 @@ static struct option longopts[] =
64c563
 	{ NULL, 0, 0, 0 }
64c563
 };
64c563
 
64c563
-/* given a family and ctlbits, disable any that aren't listed in netconfig */
64c563
-#ifdef HAVE_LIBTIRPC
64c563
-static void
64c563
-nfsd_enable_protos(unsigned int *proto4, unsigned int *proto6)
64c563
-{
64c563
-	struct netconfig *nconf;
64c563
-	unsigned int *famproto;
64c563
-	void *handle;
64c563
-
64c563
-	xlog(D_GENERAL, "Checking netconfig for visible protocols.");
64c563
-
64c563
-	handle = setnetconfig();
64c563
-	while((nconf = getnetconfig(handle))) {
64c563
-		if (!(nconf->nc_flag & NC_VISIBLE))
64c563
-			continue;
64c563
-
64c563
-		if (!strcmp(nconf->nc_protofmly, NC_INET))
64c563
-			famproto = proto4;
64c563
-		else if (!strcmp(nconf->nc_protofmly, NC_INET6))
64c563
-			famproto = proto6;
64c563
-		else
64c563
-			continue;
64c563
-
64c563
-		if (!strcmp(nconf->nc_proto, NC_TCP))
64c563
-			NFSCTL_TCPSET(*famproto);
64c563
-		else if (!strcmp(nconf->nc_proto, NC_UDP))
64c563
-			NFSCTL_UDPSET(*famproto);
64c563
-
64c563
-		xlog(D_GENERAL, "Enabling %s %s.", nconf->nc_protofmly,
64c563
-			nconf->nc_proto);
64c563
-	}
64c563
-	endnetconfig(handle);
64c563
-	return;
64c563
-}
64c563
-#else /* HAVE_LIBTIRPC */
64c563
-static void
64c563
-nfsd_enable_protos(unsigned int *proto4, unsigned int *proto6)
64c563
-{
64c563
-	/* Enable all IPv4 protocols if no TIRPC support */
64c563
-	*proto4 = NFSCTL_ALLBITS;
64c563
-	*proto6 = 0;
64c563
-}
64c563
-#endif /* HAVE_LIBTIRPC */
64c563
-
64c563
 int
64c563
 main(int argc, char **argv)
64c563
 {
64c563
@@ -102,44 +62,91 @@ main(int argc, char **argv)
64c563
 	char *p, *progname, *port, *rdma_port = NULL;
64c563
 	char **haddr = NULL;
64c563
 	int hcounter = 0;
64c563
+	struct conf_list *hosts;
64c563
 	int	socket_up = 0;
64c563
 	unsigned int minorvers = 0;
64c563
 	unsigned int minorversset = 0;
64c563
 	unsigned int versbits = NFSCTL_VERDEFAULT;
64c563
 	unsigned int protobits = NFSCTL_ALLBITS;
64c563
-	unsigned int proto4 = 0;
64c563
-	unsigned int proto6 = 0;
64c563
 	int grace = -1;
64c563
 	int lease = -1;
64c563
 
64c563
-	progname = strdup(basename(argv[0]));
64c563
-	if (!progname) {
64c563
-		fprintf(stderr, "%s: unable to allocate memory.\n", argv[0]);
64c563
-		exit(1);
64c563
-	}
64c563
-
64c563
-	port = strdup("nfs");
64c563
-	if (!port) {
64c563
-		fprintf(stderr, "%s: unable to allocate memory.\n", progname);
64c563
-		exit(1);
64c563
-	}
64c563
-
64c563
-	haddr = malloc(sizeof(char *));
64c563
-	if (!haddr) {
64c563
-		fprintf(stderr, "%s: unable to allocate memory.\n", progname);
64c563
-		exit(1);
64c563
-	}
64c563
+	progname = basename(argv[0]);
64c563
+	haddr = xmalloc(sizeof(char *));
64c563
 	haddr[0] = NULL;
64c563
 
64c563
 	xlog_syslog(0);
64c563
 	xlog_stderr(1);
64c563
 
64c563
+	conf_init();
64c563
+	xlog_from_conffile("nfsd");
64c563
+	count = conf_get_num("nfsd", "threads", count);
64c563
+	grace = conf_get_num("nfsd", "grace-time", grace);
64c563
+	lease = conf_get_num("nfsd", "lease-time", lease);
64c563
+	port = conf_get_str("nfsd", "port");
64c563
+	if (!port)
64c563
+		port = "nfs";
64c563
+	rdma_port = conf_get_str("nfsd", "rdma");
64c563
+	if (conf_get_bool("nfsd", "udp", NFSCTL_UDPISSET(protobits)))
64c563
+		NFSCTL_UDPSET(protobits);
64c563
+	else
64c563
+		NFSCTL_UDPUNSET(protobits);
64c563
+	if (conf_get_bool("nfsd", "tcp", NFSCTL_TCPISSET(protobits)))
64c563
+		NFSCTL_TCPSET(protobits);
64c563
+	else
64c563
+		NFSCTL_TCPUNSET(protobits);
64c563
+	for (i = 2; i <= 4; i++) {
64c563
+		char tag[10];
64c563
+		sprintf(tag, "vers%d", i);
64c563
+		if (conf_get_bool("nfsd", tag, NFSCTL_VERISSET(versbits, i)))
64c563
+			NFSCTL_VERSET(versbits, i);
64c563
+		else
64c563
+			NFSCTL_VERUNSET(versbits, i);
64c563
+	}
64c563
+	/* We assume the kernel will default all minor versions to 'on',
64c563
+	 * and allow the config file to disable some.
64c563
+	 */
64c563
+	for (i = NFS4_MINMINOR; i <= NFS4_MAXMINOR; i++) {
64c563
+		char tag[20];
64c563
+		sprintf(tag, "vers4.%d", i);
64c563
+		/* The default for minor version support is to let the
64c563
+		 * kernel decide.  We could ask the kernel what that choice
64c563
+		 * will be, but that is needlessly complex.
64c563
+		 * Instead, perform a config-file lookup using each of the
64c563
+		 * two possible default.  If the result is different from the
64c563
+		 * default, then impose that value, else don't make a change
64c563
+		 * (i.e. don't set the bit in minorversset).
64c563
+		 */
64c563
+		if (!conf_get_bool("nfsd", tag, 1)) {
64c563
+			NFSCTL_VERSET(minorversset, i);
64c563
+			NFSCTL_VERUNSET(minorvers, i);
64c563
+		}
64c563
+		if (conf_get_bool("nfsd", tag, 0)) {
64c563
+			NFSCTL_VERSET(minorversset, i);
64c563
+			NFSCTL_VERSET(minorvers, i);
64c563
+		}
64c563
+	}
64c563
+
64c563
+	hosts = conf_get_list("nfsd", "host");
64c563
+	if (hosts && hosts->cnt) {
64c563
+		struct conf_list_node *n;
64c563
+		haddr = realloc(haddr, sizeof(char*) * hosts->cnt);
64c563
+		TAILQ_FOREACH(n, &(hosts->fields), link) {
64c563
+			haddr[hcounter] = n->field;
64c563
+			hcounter++;
64c563
+		}
64c563
+	}
64c563
+
64c563
 	while ((c = getopt_long(argc, argv, "dH:hN:V:p:P:sTUrG:L:", longopts, NULL)) != EOF) {
64c563
 		switch(c) {
64c563
 		case 'd':
64c563
 			xlog_config(D_ALL, 1);
64c563
 			break;
64c563
 		case 'H':
64c563
+			if (hosts) {
64c563
+				hosts = NULL;
64c563
+				hcounter = 0;
64c563
+			}
64c563
 			if (hcounter) {
64c563
 				haddr = realloc(haddr, sizeof(char*) * hcounter+1);
64c563
 				if(!haddr) {
64c563
@@ -148,30 +155,13 @@ main(int argc, char **argv)
64c563
 					exit(1);
64c563
 				}
64c563
 			}
64c563
-			haddr[hcounter] = strdup(optarg);
64c563
-			if (!haddr[hcounter]) {
64c563
-				fprintf(stderr, "%s: unable to allocate "
64c563
-					"memory.\n", progname);
64c563
-				exit(1);
64c563
-			}
64c563
+			haddr[hcounter] = optarg;
64c563
 			hcounter++;
64c563
 			break;
64c563
 		case 'P':	/* XXX for nfs-server compatibility */
64c563
 		case 'p':
64c563
 			/* only the last -p option has any effect */
64c563
-			portnum = atoi(optarg);
64c563
-			if (portnum <= 0 || portnum > 65535) {
64c563
-				fprintf(stderr, "%s: bad port number: %s\n",
64c563
-					progname, optarg);
64c563
-				usage(progname);
64c563
-			}
64c563
-			free(port);
64c563
-			port = strdup(optarg);
64c563
-			if (!port) {
64c563
-				fprintf(stderr, "%s: unable to allocate "
64c563
-						"memory.\n", progname);
64c563
-				exit(1);
64c563
-			}
64c563
+			port = optarg;
64c563
 			break;
64c563
 		case 'r':
64c563
 			rdma_port = "nfsrdma";
64c563
@@ -188,7 +178,7 @@ main(int argc, char **argv)
64c563
 			case 4:
64c563
 				if (*p == '.') {
64c563
 					int i = atoi(p+1);
64c563
-					if (i > NFS4_MAXMINOR) {
64c563
+					if (i < NFS4_MINMINOR || i > NFS4_MAXMINOR) {
64c563
 						fprintf(stderr, "%s: unsupported minor version\n", optarg);
64c563
 						exit(1);
64c563
 					}
64c563
@@ -210,7 +200,7 @@ main(int argc, char **argv)
64c563
 			case 4:
64c563
 				if (*p == '.') {
64c563
 					int i = atoi(p+1);
64c563
-					if (i > NFS4_MAXMINOR) {
64c563
+					if (i < NFS4_MINMINOR || i > NFS4_MAXMINOR) {
64c563
 						fprintf(stderr, "%s: unsupported minor version\n", optarg);
64c563
 						exit(1);
64c563
 					}
64c563
@@ -277,18 +267,6 @@ main(int argc, char **argv)
64c563
 
64c563
 	xlog_open(progname);
64c563
 
64c563
-	nfsd_enable_protos(&proto4, &proto6);
64c563
-
64c563
-	if (!NFSCTL_TCPISSET(protobits)) {
64c563
-		NFSCTL_TCPUNSET(proto4);
64c563
-		NFSCTL_TCPUNSET(proto6);
64c563
-	}
64c563
-
64c563
-	if (!NFSCTL_UDPISSET(protobits)) {
64c563
-		NFSCTL_UDPUNSET(proto4);
64c563
-		NFSCTL_UDPUNSET(proto6);
64c563
-	}
64c563
-
64c563
 	/* make sure that at least one version is enabled */
64c563
 	found_one = 0;
64c563
 	for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) {
64c563
@@ -301,8 +279,7 @@ main(int argc, char **argv)
64c563
 	}
64c563
 
64c563
 	if (NFSCTL_VERISSET(versbits, 4) &&
64c563
-	    !NFSCTL_TCPISSET(proto4) &&
64c563
-	    !NFSCTL_TCPISSET(proto6)) {
64c563
+	    !NFSCTL_TCPISSET(protobits)) {
64c563
 		xlog(L_ERROR, "version 4 requires the TCP protocol");
64c563
 		exit(1);
64c563
 	}
64c563
@@ -336,15 +313,10 @@ main(int argc, char **argv)
64c563
 
64c563
 	i = 0;
64c563
 	do {
64c563
-		error = nfssvc_set_sockets(AF_INET, proto4, haddr[i], port);
64c563
-		if (!error)
64c563
-			socket_up = 1;
64c563
-#ifdef IPV6_SUPPORTED
64c563
-		error = nfssvc_set_sockets(AF_INET6, proto6, haddr[i], port);
64c563
+		error = nfssvc_set_sockets(protobits, haddr[i], port);
64c563
 		if (!error)
64c563
 			socket_up = 1;
64c563
-#endif /* IPV6_SUPPORTED */
64c563
-	} while (++i < hcounter); 
64c563
+	} while (++i < hcounter);
64c563
 
64c563
 	if (rdma_port) {
64c563
 		error = nfssvc_set_rdmaport(rdma_port);
64c563
@@ -381,11 +353,7 @@ set_threads:
64c563
 	if ((error = nfssvc_threads(portnum, count)) < 0)
64c563
 		xlog(L_ERROR, "error starting threads: errno %d (%m)", errno);
64c563
 out:
64c563
-	free(port);
64c563
-	for(i=0; i < hcounter; i++)
64c563
-		free(haddr[i]);
64c563
 	free(haddr);
64c563
-	free(progname);
64c563
 	return (error != 0);
64c563
 }
64c563
 
64c563
diff -up nfs-utils-1.3.0/utils/nfsd/nfsd.man.orig nfs-utils-1.3.0/utils/nfsd/nfsd.man
64c563
--- nfs-utils-1.3.0/utils/nfsd/nfsd.man.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/nfsd/nfsd.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -57,7 +57,7 @@ This option can be used to request that
64c563
 .B rpc.nfsd
64c563
 does not offer certain versions of NFS. The current version of
64c563
 .B rpc.nfsd
64c563
-can support NFS versions 2,3,4 and the newer version 4.1.
64c563
+can support major NFS versions 2,3,4 and the minor versions 4.1 and 4.2.
64c563
 .TP
64c563
 .B \-s " or " \-\-syslog
64c563
 By default,
64c563
@@ -82,7 +82,7 @@ This option can be used to request that
64c563
 .B rpc.nfsd
64c563
 offer certain versions of NFS. The current version of
64c563
 .B rpc.nfsd
64c563
-can support NFS versions 2,3,4 and the newer version 4.1.
64c563
+can support major NFS versions 2,3,4 and the minor versions 4.1 and 4.2.
64c563
 .TP
64c563
 .B \-L " or " \-\-lease-time seconds
64c563
 Set the lease-time used for NFSv4.  This corresponds to how often
64c563
@@ -95,11 +95,11 @@ New file open requests (NFSv4) and new f
64c563
 allowed until after this time has passed to allow clients to recover state.
64c563
 .TP
64c563
 .I nproc
64c563
-specify the number of NFS server threads. By default, just one
64c563
-thread is started. However, for optimum performance several threads
64c563
+specify the number of NFS server threads. By default, eight
64c563
+threads are started. However, for optimum performance several threads
64c563
 should be used. The actual figure depends on the number of and the work
64c563
 load created by the NFS clients, but a useful starting point is
64c563
-8 threads. Effects of modifying that number can be checked using
64c563
+eight threads. Effects of modifying that number can be checked using
64c563
 the
64c563
 .BR nfsstat (8)
64c563
 program.
64c563
@@ -114,6 +114,58 @@ In particular
64c563
 .B rpc.nfsd 0
64c563
 will stop all threads and thus close any open connections.
64c563
 
64c563
+.SH CONFIGURATION FILE
64c563
+Many of the options that can be set on the command line can also be
64c563
+controlled through values set in the
64c563
+.B [nfsd]
64c563
+section of the
64c563
+.I /etc/nfs.conf
64c563
+configuration file.  Values recognized include:
64c563
+.TP
64c563
+.B threads
64c563
+The number of threads to start.
64c563
+.TP
64c563
+.B host
64c563
+A host name, or comma separated list of host names, that
64c563
+.I rpc.nfsd
64c563
+will listen on.  Use of the
64c563
+.B --host
64c563
+option replaces all host names listed here.
64c563
+.TP
64c563
+.B grace-time
64c563
+The grace time, for both NFSv4 and NLM, in seconds.
64c563
+.TP
64c563
+.B lease-time
64c563
+The lease time for NFSv4, in seconds.
64c563
+.TP
64c563
+.B port
64c563
+Set the port for TCP/UDP to bind to.
64c563
+.TP
64c563
+.B rdma
64c563
+Set RDMA port.  Use "rdma=nfsrdma" to enable standard port.
64c563
+.TP
64c563
+.B UDP
64c563
+Enable (with "on" or "yes" etc) or disable ("off", "no") UDP support.
64c563
+.TP
64c563
+.B TCP
64c563
+Enable or disable TCP support.
64c563
+.TP
64c563
+.B vers2
64c563
+.TP
64c563
+.B vers3
64c563
+.TP
64c563
+.B vers4
64c563
+Enable or disable a major NFS version.  3 and 4 are normally enabled
64c563
+by default.
64c563
+.TP
64c563
+.B vers4.1
64c563
+.TP
64c563
+.B vers4.2
64c563
+Setting these to "off" or similar will disable the selected minor
64c563
+versions.  Setting to "on" will enable them.  The default values
64c563
+are determined by the kernel, and usually minor versions default to
64c563
+being enabled once the implementation is sufficiently complete.
64c563
+
64c563
 .SH NOTES
64c563
 If the program is built with TI-RPC support, it will enable any protocol and
64c563
 address family combinations that are marked visible in the
64c563
@@ -124,6 +176,7 @@ database.
64c563
 .BR rpc.mountd (8),
64c563
 .BR exports (5),
64c563
 .BR exportfs (8),
64c563
+.BR nfs.conf (5),
64c563
 .BR rpc.rquotad (8),
64c563
 .BR nfsstat (8),
64c563
 .BR netconfig(5).
64c563
diff -up nfs-utils-1.3.0/utils/nfsd/nfssvc.c.orig nfs-utils-1.3.0/utils/nfsd/nfssvc.c
64c563
--- nfs-utils-1.3.0/utils/nfsd/nfssvc.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/nfsd/nfssvc.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -23,6 +23,7 @@
64c563
 
64c563
 #include "nfslib.h"
64c563
 #include "xlog.h"
64c563
+#include "nfssvc.h"
64c563
 
64c563
 #ifndef NFSD_FS_DIR
64c563
 #define NFSD_FS_DIR	  "/proc/fs/nfsd"
64c563
@@ -123,22 +124,6 @@ nfssvc_setfds(const struct addrinfo *hin
64c563
 	if (fd < 0)
64c563
 		return 0;
64c563
 
64c563
-	switch(hints->ai_family) {
64c563
-	case AF_INET:
64c563
-		family = "inet";
64c563
-		break;
64c563
-#ifdef IPV6_SUPPORTED
64c563
-	case AF_INET6:
64c563
-		family = "inet6";
64c563
-		break;
64c563
-#endif /* IPV6_SUPPORTED */
64c563
-	default:
64c563
-		xlog(L_ERROR, "Unknown address family specified: %d\n",
64c563
-				hints->ai_family);
64c563
-		rc = EAFNOSUPPORT;
64c563
-		goto error;
64c563
-	}
64c563
-
64c563
 	rc = getaddrinfo(node, port, hints, &addrhead);
64c563
 	if (rc == EAI_NONAME && !strcmp(port, "nfs")) {
64c563
 		snprintf(buf, sizeof(buf), "%d", NFS_PORT);
64c563
@@ -146,10 +131,10 @@ nfssvc_setfds(const struct addrinfo *hin
64c563
 	}
64c563
 
64c563
 	if (rc != 0) {
64c563
-		xlog(L_ERROR, "unable to resolve %s:%s to %s address: "
64c563
-				"%s", node ? node : "ANYADDR", port, family,
64c563
-				rc == EAI_SYSTEM ? strerror(errno) :
64c563
-					gai_strerror(rc));
64c563
+		xlog(L_ERROR, "unable to resolve %s:%s: %s",
64c563
+			node ? node : "ANYADDR", port,
64c563
+			rc == EAI_SYSTEM ? strerror(errno) :
64c563
+				gai_strerror(rc));
64c563
 		goto error;
64c563
 	}
64c563
 
64c563
@@ -168,6 +153,20 @@ nfssvc_setfds(const struct addrinfo *hin
64c563
 			continue;
64c563
 		}
64c563
 
64c563
+		switch(addr->ai_addr->sa_family) {
64c563
+		case AF_INET:
64c563
+			family = "AF_INET";
64c563
+			break;
64c563
+#ifdef IPV6_SUPPORTED
64c563
+		case AF_INET6:
64c563
+			family = "AF_INET6";
64c563
+			break;
64c563
+#endif /* IPV6_SUPPORTED */
64c563
+		default:
64c563
+			addr = addr->ai_next;
64c563
+			continue;
64c563
+		}
64c563
+
64c563
 		xlog(D_GENERAL, "Creating %s %s socket.", family, proto);
64c563
 
64c563
 		/* open socket and prepare to hand it off to kernel */
64c563
@@ -251,12 +250,16 @@ error:
64c563
 }
64c563
 
64c563
 int
64c563
-nfssvc_set_sockets(const int family, const unsigned int protobits,
64c563
+nfssvc_set_sockets(const unsigned int protobits,
64c563
 		   const char *host, const char *port)
64c563
 {
64c563
 	struct addrinfo hints = { .ai_flags = AI_PASSIVE };
64c563
 
64c563
-	hints.ai_family = family;
64c563
+#ifdef IPV6_SUPPORTED
64c563
+	hints.ai_family = AF_UNSPEC;
64c563
+#else  /* IPV6_SUPPORTED */
64c563
+	hints.ai_family = AF_INET;
64c563
+#endif /* IPV6_SUPPORTED */
64c563
 
64c563
 	if (!NFSCTL_ANYPROTO(protobits))
64c563
 		return EPROTOTYPE;
64c563
diff -up nfs-utils-1.3.0/utils/nfsd/nfssvc.h.orig nfs-utils-1.3.0/utils/nfsd/nfssvc.h
64c563
--- nfs-utils-1.3.0/utils/nfsd/nfssvc.h.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/nfsd/nfssvc.h	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -22,7 +22,7 @@
64c563
 
64c563
 void	nfssvc_mount_nfsdfs(char *progname);
64c563
 int	nfssvc_inuse(void);
64c563
-int	nfssvc_set_sockets(const int family, const unsigned int protobits,
64c563
+int	nfssvc_set_sockets(const unsigned int protobits,
64c563
 			   const char *host, const char *port);
64c563
 void	nfssvc_set_time(const char *type, const int seconds);
64c563
 int	nfssvc_set_rdmaport(const char *port);
64c563
diff -up nfs-utils-1.3.0/utils/statd/sm-notify.c.orig nfs-utils-1.3.0/utils/statd/sm-notify.c
64c563
--- nfs-utils-1.3.0/utils/statd/sm-notify.c.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/statd/sm-notify.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -29,6 +29,7 @@
64c563
 #include <errno.h>
64c563
 #include <grp.h>
64c563
 
64c563
+#include "conffile.h"
64c563
 #include "sockaddr.h"
64c563
 #include "xlog.h"
64c563
 #include "nsm.h"
64c563
@@ -64,6 +65,7 @@ static _Bool		opt_update_state = true;
64c563
 static unsigned int	opt_max_retry = 15 * 60;
64c563
 static char *		opt_srcaddr = NULL;
64c563
 static char *		opt_srcport = NULL;
64c563
+char *			conf_path = NFS_CONFFILE;
64c563
 
64c563
 static void		notify(const int sock);
64c563
 static int		notify_host(int, struct nsm_host *);
64c563
@@ -455,6 +457,7 @@ main(int argc, char **argv)
64c563
 {
64c563
 	int	c, sock, force = 0;
64c563
 	char *	progname;
64c563
+	char *	s;
64c563
 
64c563
 	progname = strrchr(argv[0], '/');
64c563
 	if (progname != NULL)
64c563
@@ -462,6 +465,15 @@ main(int argc, char **argv)
64c563
 	else
64c563
 		progname = argv[0];
64c563
 
64c563
+	conf_init();
64c563
+	xlog_from_conffile("sm-notify");
64c563
+	opt_max_retry = conf_get_num("sm-notify", "retry-time", opt_max_retry / 60) * 60;
64c563
+	opt_srcport = conf_get_str("sm-notify", "outgoing-port");
64c563
+	opt_srcaddr = conf_get_str("sm-notify", "outgoing-addr");
64c563
+	s = conf_get_str("statd", "state-directory-path");
64c563
+	if (s && !nsm_setup_pathnames(argv[0], s))
64c563
+		exit(1);
64c563
+
64c563
 	while ((c = getopt(argc, argv, "dm:np:v:P:f")) != -1) {
64c563
 		switch (c) {
64c563
 		case 'f':
64c563
diff -up nfs-utils-1.3.0/utils/statd/sm-notify.man.orig nfs-utils-1.3.0/utils/statd/sm-notify.man
64c563
--- nfs-utils-1.3.0/utils/statd/sm-notify.man.orig	2014-03-25 11:12:07.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/statd/sm-notify.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -219,6 +219,33 @@ argument when sending SM_NOTIFY requests
64c563
 .IP
64c563
 This option can be useful in multi-homed configurations where
64c563
 the remote requires notification from a specific network address.
64c563
+.SH CONFIGURATION FILE
64c563
+Many of the options that can be set on the command line can also be
64c563
+controlled through values set in the
64c563
+.B [sm-notify]
64c563
+or, in one case, the
64c563
+.B [statd]
64c563
+section of the
64c563
+.I /etc/nfs.conf
64c563
+configuration file.
64c563
+
64c563
+Values recognized in the
64c563
+.B [sm-notify]
64c563
+section include:
64c563
+.BR retry-time ,
64c563
+.BR outgoing-port ", and"
64c563
+.BR outgoing-addr .
64c563
+These have the same effect as the command line options
64c563
+.BR m ,
64c563
+.BR p ", and"
64c563
+.B v
64c563
+respectively.
64c563
+
64c563
+The value recognized in the
64c563
+.B [statd]
64c563
+section is
64c563
+.BR state-directory-path .
64c563
+
64c563
 .SH SECURITY
64c563
 The
64c563
 .B sm-notify
64c563
diff -up nfs-utils-1.3.0/utils/statd/statd.c.orig nfs-utils-1.3.0/utils/statd/statd.c
64c563
--- nfs-utils-1.3.0/utils/statd/statd.c.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/statd/statd.c	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -26,6 +26,7 @@
64c563
 #include <sys/wait.h>
64c563
 #include <grp.h>
64c563
 
64c563
+#include "conffile.h"
64c563
 #include "statd.h"
64c563
 #include "nfslib.h"
64c563
 #include "nfsrpc.h"
64c563
@@ -36,6 +37,7 @@
64c563
 #include <sys/socket.h>
64c563
 
64c563
 int	run_mode = 0;		/* foreground logging mode */
64c563
+char	*conf_path = NFS_CONFFILE;
64c563
 
64c563
 /* LH - I had these local to main, but it seemed silly to have 
64c563
  * two copies of each - one in main(), one static in log.c... 
64c563
@@ -242,15 +244,21 @@ static void set_nlm_port(char *type, int
64c563
 int main (int argc, char **argv)
64c563
 {
64c563
 	extern char *optarg;
64c563
+	char *s;
64c563
 	int pid;
64c563
 	int arg;
64c563
 	int port = 0, out_port = 0;
64c563
 	int nlm_udp = 0, nlm_tcp = 0;
64c563
 	struct rlimit rlim;
64c563
+	char *env;
64c563
 
64c563
 	/* Default: daemon mode, no other options */
64c563
 	run_mode = 0;
64c563
 
64c563
+	env = getenv("RPC_STATD_NO_NOTIFY");
64c563
+	if (env && atoi(env) > 0)
64c563
+		run_mode |= MODE_NO_NOTIFY;
64c563
+
64c563
 	/* Log to stderr if there's an error during startup */
64c563
 	xlog_stderr(1);
64c563
 	xlog_syslog(0);
64c563
@@ -265,6 +273,24 @@ int main (int argc, char **argv)
64c563
 	/* Set hostname */
64c563
 	MY_NAME = NULL;
64c563
 
64c563
+	conf_init();
64c563
+	xlog_from_conffile("statd");
64c563
+	out_port = conf_get_num("statd", "outgoing-port", out_port);
64c563
+	port = conf_get_num("statd", "port", port);
64c563
+	MY_NAME = conf_get_str("statd", "name");
64c563
+	if (MY_NAME)
64c563
+		run_mode |= STATIC_HOSTNAME;
64c563
+	s = conf_get_str("statd", "state-directory-path");
64c563
+	if (s && !nsm_setup_pathnames(argv[0], s))
64c563
+		exit(1);
64c563
+	s = conf_get_str("statd", "ha-callout");
64c563
+	if (s)
64c563
+		ha_callout_prog = s;
64c563
+
64c563
+	nlm_tcp = conf_get_num("lockd", "port", nlm_tcp);
64c563
+	/* udp defaults to the same as tcp ! */
64c563
+	nlm_udp = conf_get_num("lockd", "udp-port", nlm_tcp);
64c563
+
64c563
 	/* Process command line switches */
64c563
 	while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:LT:U:", longopts, NULL)) != EOF) {
64c563
 		switch (arg) {
64c563
diff -up nfs-utils-1.3.0/utils/statd/statd.man.orig nfs-utils-1.3.0/utils/statd/statd.man
64c563
--- nfs-utils-1.3.0/utils/statd/statd.man.orig	2017-03-28 13:43:36.000000000 -0400
64c563
+++ nfs-utils-1.3.0/utils/statd/statd.man	2017-03-28 13:43:53.000000000 -0400
64c563
@@ -8,7 +8,7 @@
64c563
 .\" Rewritten by Chuck Lever <chuck.lever@oracle.com>, 2009.
64c563
 .\" Copyright 2009 Oracle.  All rights reserved.
64c563
 .\"
64c563
-.TH RPC.STATD 8 "1 November 2009
64c563
+.TH RPC.STATD 8 "1 November 2009"
64c563
 .SH NAME
64c563
 rpc.statd \- NSM service daemon
64c563
 .SH SYNOPSIS
64c563
@@ -247,7 +247,7 @@ should listen on for
64c563
 .B NLM
64c563
 requests.
64c563
 .TP
64c563
-.BI "\-P, " "" \-\-state\-directory\-path " pathname
64c563
+.BI "\-P, " "" \-\-state\-directory\-path " pathname"
64c563
 Specifies the pathname of the parent directory
64c563
 where NSM state information resides.
64c563
 If this option is not specified,
64c563
@@ -267,6 +267,37 @@ Causes
64c563
 to display version information on
64c563
 .I stderr
64c563
 and then exit.
64c563
+.SH CONFIGURATION FILE
64c563
+Many of the options that can be set on the command line can also be
64c563
+controlled through values set in the
64c563
+.B [statd]
64c563
+or, in some cases, the
64c563
+.B [lockd]
64c563
+sections of the
64c563
+.I /etc/nfs.conf
64c563
+configuration file.
64c563
+Values recognized in the
64c563
+.B [statd]
64c563
+section include
64c563
+.BR port ,
64c563
+.BR outgoing-port ,
64c563
+.BR name ,
64c563
+.BR state-directory-path ", and"
64c563
+.B ha-callout
64c563
+which each have the same effect as the option with the same name.
64c563
+
64c563
+The values recognized in the
64c563
+.B [lockd]
64c563
+section include
64c563
+.B port
64c563
+and
64c563
+.B udp-port
64c563
+which have the same effect as the
64c563
+.B --nlm-port
64c563
+and
64c563
+.B --nlm-udp-port
64c563
+options, respectively.
64c563
+
64c563
 .SH SECURITY
64c563
 The
64c563
 .B rpc.statd
64c563
@@ -387,6 +418,11 @@ it attempts to start listeners on networ
64c563
 As long as at least one network transport listener starts successfully,
64c563
 .B rpc.statd
64c563
 will operate.
64c563
+.SH ENVIRONMENT
64c563
+.TP
64c563
+.B RPC_STATD_NO_NOTIFY=
64c563
+If set to a positive integer, has the same effect as
64c563
+.IR \-\-no\-notify .
64c563
 .SH FILES
64c563
 .TP 2.5i
64c563
 .I /var/lib/nfs/sm