File 0001-nfs-server-generator-avoid-using-external-services.patch of Package nfs-utils.3350

From e2e45d6d06878449a46386355cd5caf83b81d64a Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Thu, 13 Oct 2016 17:46:03 +1100
Subject: [PATCH] nfs-server-generator: avoid using external services.

nfs-server-generator is run very early when a lot of services
are not yet started, so it mustn't depend on them.
Currently it can try to use hostname lookup and syslog.

Hostname-lookup is not needed, as we don't use the host issue,
and sending message to stderr is sufficient for the generator.

Disabling syslog is easy - call a function that sets a static variable.

Disabling hostname lookup isn't quite so easy, so add a static variable
which can be set to disable it.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 support/export/export.c        |   12 ++++++++++--
 support/include/exportfs.h     |    1 +
 systemd/nfs-server-generator.c |    4 ++++
 3 files changed, 15 insertions(+), 2 deletions(-)

--- a/support/export/export.c
+++ b/support/export/export.c
@@ -67,6 +67,14 @@ static void warn_duplicated_exports(nfs_
 	}
 }
 
+static int assume_canonical = 0;
+
+void
+export_avoid_host_lookup(int i)
+{
+	assume_canonical = i;
+}
+
 /**
  * export_read - read entries from /etc/exports
  * @fname: name of file to read from
@@ -80,9 +88,9 @@ export_read(char *fname)
 
 	setexportent(fname, "r");
 	while ((eep = getexportent(0,1)) != NULL) {
-		exp = export_lookup(eep->e_hostname, eep->e_path, 0);
+		exp = export_lookup(eep->e_hostname, eep->e_path, assume_canonical);
 		if (!exp)
-			export_create(eep, 0);
+			export_create(eep, assume_canonical);
 		else
 			warn_duplicated_exports(exp, eep);
 	}
--- a/support/include/exportfs.h
+++ b/support/include/exportfs.h
@@ -133,6 +133,7 @@ struct addrinfo *		client_resolve(const
 int 				client_member(const char *client,
 						const char *name);
 
+void				export_avoid_host_lookup(int i);
 void				export_read(char *fname);
 void				export_d_read(const char *dname);
 void				export_reset(nfs_export *);
--- a/systemd/nfs-server-generator.c
+++ b/systemd/nfs-server-generator.c
@@ -93,6 +93,10 @@ int main(int argc, char *argv[])
 	FILE		*f, *fstab;
 	struct mntent	*mnt;
 
+	/* Avoid using any external services */
+	xlog_syslog(0);
+	export_avoid_host_lookup(1);
+
 	if (argc != 4 || argv[1][0] != '/') {
 		fprintf(stderr, "nfs-server-generator: create systemd dependencies for nfs-server\n");
 		fprintf(stderr, "Usage: normal-dir early-dir late-dir\n");