2f30de5
commit 8d9bf479441d9d7a44a86b69026a7e9d431d3ade
2f30de5
Author: Justin Mitchell <jumitche@redhat.com>
2f30de5
Date:   Tue Nov 7 09:28:25 2017 -0500
2f30de5
2f30de5
    nfs-utils: Restore ABI compat with pre-merge libnfsidmap
2f30de5
    
2f30de5
    Prior to merge libnfsidmap leaked many private symbols that were
2f30de5
    not defined in its API, creating an accidental ABI.
2f30de5
    This patch renames and unhides symbols in order to match that ABI
2f30de5
    until a cleaned up API can be established and released.
2f30de5
    
2f30de5
    Signed-off-by: Steve Dickson <steved@redhat.com>
2f30de5
2f30de5
diff --git a/support/include/conffile.h b/support/include/conffile.h
2f30de5
index d4cb6b4..ad20067 100644
2f30de5
--- a/support/include/conffile.h
2f30de5
+++ b/support/include/conffile.h
2f30de5
@@ -60,7 +60,7 @@ extern _Bool    conf_get_bool(const char *, const char *, _Bool);
2f30de5
 extern char    *conf_get_str(const char *, const char *);
2f30de5
 extern char    *conf_get_str_with_def(const char *, const char *, char *);
2f30de5
 extern char    *conf_get_section(const char *, const char *, const char *);
2f30de5
-extern void     conf_init(const char *);
2f30de5
+extern void     conf_init_file(const char *);
2f30de5
 extern void     conf_cleanup(void);
2f30de5
 extern int      conf_match_num(const char *, const char *, int);
2f30de5
 extern int      conf_remove(int, const char *, const char *);
2f30de5
diff --git a/support/nfs/Makefile.am b/support/nfs/Makefile.am
2f30de5
index c037c46..e573b69 100644
2f30de5
--- a/support/nfs/Makefile.am
2f30de5
+++ b/support/nfs/Makefile.am
2f30de5
@@ -7,10 +7,10 @@ libnfs_la_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \
2f30de5
 		   xcommon.c wildmat.c mydaemon.c \
2f30de5
 		   rpc_socket.c getport.c \
2f30de5
 		   svc_socket.c cacheio.c closeall.c nfs_mntent.c \
2f30de5
-		   svc_create.c atomicio.c strlcpy.c strlcat.c
2f30de5
+		   svc_create.c atomicio.c strlcat.c
2f30de5
 libnfs_la_LIBADD = libnfsconf.la
2f30de5
 
2f30de5
-libnfsconf_la_SOURCES = conffile.c xlog.c
2f30de5
+libnfsconf_la_SOURCES = conffile.c xlog.c strlcpy.c
2f30de5
 
2f30de5
 MAINTAINERCLEANFILES = Makefile.in
2f30de5
 
2f30de5
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
2f30de5
index 9c5ed8e..dce8148 100644
2f30de5
--- a/support/nfs/conffile.c
2f30de5
+++ b/support/nfs/conffile.c
2f30de5
@@ -53,11 +53,9 @@
2f30de5
 #include "conffile.h"
2f30de5
 #include "xlog.h"
2f30de5
 
2f30de5
-#pragma GCC visibility push(hidden)
2f30de5
-
2f30de5
 static void conf_load_defaults(void);
2f30de5
-static char * conf_load(const char *path);
2f30de5
-static int conf_set(int , const char *, const char *, const char *, 
2f30de5
+static char * conf_readfile(const char *path);
2f30de5
+int conf_set(int , const char *, const char *, const char *, 
2f30de5
 	const char *, int , int );
2f30de5
 static void conf_parse(int trans, char *buf, 
2f30de5
 	char **section, char **subsection);
2f30de5
@@ -79,12 +77,10 @@ TAILQ_HEAD (conf_trans_head, conf_trans) conf_trans_queue;
2f30de5
 /*
2f30de5
  * Radix-64 Encoding.
2f30de5
  */
2f30de5
-#if 0
2f30de5
-static const uint8_t bin2asc[]
2f30de5
+const uint8_t bin2asc[]
2f30de5
   = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2f30de5
-#endif
2f30de5
 
2f30de5
-static const uint8_t asc2bin[] =
2f30de5
+const uint8_t asc2bin[] =
2f30de5
 {
2f30de5
   255, 255, 255, 255, 255, 255, 255, 255,
2f30de5
   255, 255, 255, 255, 255, 255, 255, 255,
2f30de5
@@ -370,7 +366,7 @@ conf_parse_line(int trans, char *line, int lineno, char **section, char **subsec
2f30de5
 
2f30de5
 	if (strcasecmp(line, "include")==0) {
2f30de5
 		/* load and parse subordinate config files */
2f30de5
-		char * subconf = conf_load(val);
2f30de5
+		char * subconf = conf_readfile(val);
2f30de5
 		if (subconf == NULL) {
2f30de5
 			xlog_warn("config file error: line %d: "
2f30de5
 			"error loading included config", lineno);
2f30de5
@@ -435,7 +431,7 @@ conf_load_defaults(void)
2f30de5
 }
2f30de5
 
2f30de5
 static char *
2f30de5
-conf_load(const char *path)
2f30de5
+conf_readfile(const char *path)
2f30de5
 {
2f30de5
 	struct stat sb;
2f30de5
 	if ((stat (path, &sb) == 0) || (errno != ENOENT)) {
2f30de5
@@ -444,19 +440,19 @@ conf_load(const char *path)
2f30de5
 		int fd = open (path, O_RDONLY, 0);
2f30de5
 
2f30de5
 		if (fd == -1) {
2f30de5
-			xlog_warn("conf_reinit: open (\"%s\", O_RDONLY) failed", path);
2f30de5
+			xlog_warn("conf_readfile: open (\"%s\", O_RDONLY) failed", path);
2f30de5
 			return NULL;
2f30de5
 		}
2f30de5
 
2f30de5
 		new_conf_addr = malloc(sz+1);
2f30de5
 		if (!new_conf_addr) {
2f30de5
-			xlog_warn("conf_reinit: malloc (%lu) failed", (unsigned long)sz);
2f30de5
+			xlog_warn("conf_readfile: malloc (%lu) failed", (unsigned long)sz);
2f30de5
 			goto fail;
2f30de5
 		}
2f30de5
 
2f30de5
 		/* XXX I assume short reads won't happen here.  */
2f30de5
 		if (read (fd, new_conf_addr, sz) != (int)sz) {
2f30de5
-			xlog_warn("conf_reinit: read (%d, %p, %lu) failed",
2f30de5
+			xlog_warn("conf_readfile: read (%d, %p, %lu) failed",
2f30de5
 				fd, new_conf_addr, (unsigned long)sz);
2f30de5
 			goto fail;
2f30de5
 		}
2f30de5
@@ -493,15 +489,19 @@ static void conf_free_bindings(void)
2f30de5
 	}
2f30de5
 }
2f30de5
 
2f30de5
+#pragma GCC visibility push(hidden)
2f30de5
+/* these are the real fuinctions, hidden from being exported
2f30de5
+ * by libnfsidmap ABI compatability */
2f30de5
+
2f30de5
 /* Open the config file and map it into our address space, then parse it.  */
2f30de5
 static void
2f30de5
-conf_reinit(const char *conf_file)
2f30de5
+conf_load_file(const char *conf_file)
2f30de5
 {
2f30de5
 	int trans;
2f30de5
 	char * conf_data;
2f30de5
 
2f30de5
 	trans = conf_begin();
2f30de5
-	conf_data = conf_load(conf_file);
2f30de5
+	conf_data = conf_readfile(conf_file);
2f30de5
 
2f30de5
 	if (conf_data == NULL)
2f30de5
 		return;
2f30de5
@@ -526,7 +526,7 @@ conf_reinit(const char *conf_file)
2f30de5
 }
2f30de5
 
2f30de5
 void
2f30de5
-conf_init (const char *conf_file)
2f30de5
+conf_init_file(const char *conf_file)
2f30de5
 {
2f30de5
 	unsigned int i;
2f30de5
 
2f30de5
@@ -536,7 +536,7 @@ conf_init (const char *conf_file)
2f30de5
 	TAILQ_INIT (&conf_trans_queue);
2f30de5
 
2f30de5
 	if (conf_file == NULL) conf_file=NFS_CONFFILE;
2f30de5
-	conf_reinit(conf_file);
2f30de5
+	conf_load_file(conf_file);
2f30de5
 }
2f30de5
 
2f30de5
 /* 
2f30de5
@@ -560,6 +560,8 @@ conf_cleanup(void)
2f30de5
 	TAILQ_INIT(&conf_trans_queue);
2f30de5
 }
2f30de5
 
2f30de5
+#pragma GCC visibility pop
2f30de5
+
2f30de5
 /*
2f30de5
  * Return the numeric value denoted by TAG in section SECTION or DEF
2f30de5
  * if that tag does not exist.
2f30de5
@@ -575,6 +577,7 @@ conf_get_num(const char *section, const char *tag, int def)
2f30de5
 	return def;
2f30de5
 }
2f30de5
 
2f30de5
+#pragma GCC visibility push(hidden)
2f30de5
 /*
2f30de5
  * Return the Boolean value denoted by TAG in section SECTION, or DEF
2f30de5
  * if that tags does not exist.
2f30de5
@@ -606,6 +609,7 @@ conf_get_bool(const char *section, const char *tag, _Bool def)
2f30de5
 		return false;
2f30de5
 	return def;
2f30de5
 }
2f30de5
+#pragma GCC visibility pop
2f30de5
 
2f30de5
 /* Validate X according to the range denoted by TAG in section SECTION.  */
2f30de5
 int
2f30de5
@@ -651,6 +655,7 @@ conf_get_str_with_def(const char *section, const char *tag, char *def)
2f30de5
 	return result;
2f30de5
 }
2f30de5
 
2f30de5
+#pragma GCC visibility push(hidden)
2f30de5
 /*
2f30de5
  * Find a section that may or may not have an argument
2f30de5
  */
2f30de5
@@ -682,6 +687,7 @@ retry:
2f30de5
 	}
2f30de5
 	return 0;
2f30de5
 }
2f30de5
+#pragma GCC visibility pop
2f30de5
 
2f30de5
 /*
2f30de5
  * Build a list of string values out of the comma separated value denoted by
2f30de5
@@ -876,7 +882,7 @@ conf_trans_node(int transaction, enum conf_op op)
2f30de5
 }
2f30de5
 
2f30de5
 /* Queue a set operation.  */
2f30de5
-static int
2f30de5
+int
2f30de5
 conf_set(int transaction, const char *section, const char *arg,
2f30de5
 	const char *tag, const char *value, int override, int is_default)
2f30de5
 {
2f30de5
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
2f30de5
index 931387a..40011ee 100644
2f30de5
--- a/support/nfsidmap/libnfsidmap.c
2f30de5
+++ b/support/nfsidmap/libnfsidmap.c
2f30de5
@@ -89,6 +89,10 @@ gid_t nobody_gid = (gid_t)-1;
2f30de5
 #define NFS4DNSTXTREC "_nfsv4idmapdomain"
2f30de5
 #endif
2f30de5
 
2f30de5
+/* DEPRECATED these are for ABI compatibility only */
2f30de5
+char * conf_path = PATH_IDMAPDCONF;
2f30de5
+void conf_reinit(void);
2f30de5
+void conf_init(void);
2f30de5
 
2f30de5
 /* Default logging fuction */
2f30de5
 static void default_logger(const char *fmt, ...)
2f30de5
@@ -342,7 +346,6 @@ int nfs4_init_name_mapping(char *conffile)
2f30de5
 	char *nobody_user, *nobody_group;
2f30de5
 	char *nostrip;
2f30de5
 	char *reformatgroup;
2f30de5
-	char *conf_path;
2f30de5
 
2f30de5
 	/* XXX: need to be able to reload configurations... */
2f30de5
 	if (nfs4_plugins) /* already succesfully initialized */
2f30de5
@@ -351,7 +354,7 @@ int nfs4_init_name_mapping(char *conffile)
2f30de5
 		conf_path = conffile;
2f30de5
 	else
2f30de5
 		conf_path = PATH_IDMAPDCONF;
2f30de5
-	conf_init(conf_path);
2f30de5
+	conf_init_file(conf_path);
2f30de5
 	default_domain = conf_get_str("General", "Domain");
2f30de5
 	if (default_domain == NULL) {
2f30de5
 		dflt = 1;
2f30de5
@@ -710,3 +713,13 @@ void nfs4_set_debug(int dbg_level, void (*logger)(const char *, ...))
2f30de5
 	idmap_verbosity = dbg_level;
2f30de5
 }
2f30de5
 
2f30de5
+void conf_reinit(void)
2f30de5
+{
2f30de5
+	conf_init_file(conf_path);
2f30de5
+}
2f30de5
+
2f30de5
+void conf_init(void)
2f30de5
+{
2f30de5
+	conf_init_file(conf_path);
2f30de5
+}
2f30de5
+
2f30de5
diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c
2f30de5
index 59eee87..6e1d69c 100644
2f30de5
--- a/systemd/rpc-pipefs-generator.c
2f30de5
+++ b/systemd/rpc-pipefs-generator.c
2f30de5
@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
2f30de5
 		exit(1);
2f30de5
 	}
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	s = conf_get_str("general", "pipefs-directory");
2f30de5
 	if (!s)
2f30de5
 		exit(0);
2f30de5
diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
2f30de5
index 29bafb2..cae8c8d 100644
2f30de5
--- a/utils/blkmapd/device-discovery.c
2f30de5
+++ b/utils/blkmapd/device-discovery.c
2f30de5
@@ -456,7 +456,7 @@ int main(int argc, char **argv)
2f30de5
 	char *xrpcpipe_dir = NULL;
2f30de5
 
2f30de5
 	strncpy(rpcpipe_dir, RPCPIPE_DIR, sizeof(rpcpipe_dir));
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	CONF_SAVE(xrpcpipe_dir, conf_get_str("general", "pipefs-directory"));
2f30de5
 	if (xrpcpipe_dir != NULL)
2f30de5
 		strlcpy(rpcpipe_dir, xrpcpipe_dir, sizeof(rpcpipe_dir));
2f30de5
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
2f30de5
index beed1b3..448f195 100644
2f30de5
--- a/utils/exportfs/exportfs.c
2f30de5
+++ b/utils/exportfs/exportfs.c
2f30de5
@@ -107,7 +107,7 @@ main(int argc, char **argv)
2f30de5
 	xlog_stderr(1);
2f30de5
 	xlog_syslog(0);
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	xlog_from_conffile("exportfs");
2f30de5
 
2f30de5
 	/* NOTE: following uses "mountd" section of nfs.conf !!!! */
2f30de5
diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c
2f30de5
index 053a223..2c14e5f 100644
2f30de5
--- a/utils/gssd/gssd.c
2f30de5
+++ b/utils/gssd/gssd.c
2f30de5
@@ -842,7 +842,7 @@ read_gss_conf(void)
2f30de5
 {
2f30de5
 	char *s;
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	use_memcache = conf_get_bool("gssd", "use-memcache", use_memcache);
2f30de5
 	root_uses_machine_creds = conf_get_bool("gssd", "use-machine-creds",
2f30de5
 						root_uses_machine_creds);
2f30de5
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
2f30de5
index 4cbe148..2b9ecea 100644
2f30de5
--- a/utils/idmapd/idmapd.c
2f30de5
+++ b/utils/idmapd/idmapd.c
2f30de5
@@ -252,7 +252,7 @@ main(int argc, char **argv)
2f30de5
 			warn("Skipping configuration file \"%s\"", conf_path);
2f30de5
 			conf_path = NULL;
2f30de5
 		} else {
2f30de5
-			conf_init(conf_path);
2f30de5
+			conf_init_file(conf_path);
2f30de5
 			verbose = conf_get_num("General", "Verbosity", 0);
2f30de5
 			cache_entry_expiration = conf_get_num("General",
2f30de5
 					"Cache-Expiration", DEFAULT_IDMAP_CACHE_EXPIRY);
2f30de5
@@ -264,13 +264,13 @@ main(int argc, char **argv)
2f30de5
 		}
2f30de5
 	} else {
2f30de5
 		conf_path = NFS_CONFFILE;
2f30de5
-		conf_init(conf_path);
2f30de5
+		conf_init_file(conf_path);
2f30de5
 		CONF_SAVE(xpipefsdir, conf_get_str("General", "Pipefs-Directory"));
2f30de5
 		if (xpipefsdir != NULL)
2f30de5
 			strlcpy(pipefsdir, xpipefsdir, sizeof(pipefsdir));
2f30de5
 
2f30de5
 		conf_path = _PATH_IDMAPDCONF;
2f30de5
-		conf_init(conf_path);
2f30de5
+		conf_init_file(conf_path);
2f30de5
 		verbose = conf_get_num("General", "Verbosity", 0);
2f30de5
 		cache_entry_expiration = conf_get_num("General",
2f30de5
 				"cache-expiration", DEFAULT_IDMAP_CACHE_EXPIRY);
2f30de5
diff --git a/utils/mount/mount_config.h b/utils/mount/mount_config.h
2f30de5
index e4f8511..7cc72fc 100644
2f30de5
--- a/utils/mount/mount_config.h
2f30de5
+++ b/utils/mount/mount_config.h
2f30de5
@@ -32,7 +32,7 @@ static inline void mount_config_init(char *program)
2f30de5
 	/*
2f30de5
 	 * Read the the default mount options
2f30de5
 	 */
2f30de5
-	conf_init(MOUNTOPTS_CONFFILE);
2f30de5
+	conf_init_file(MOUNTOPTS_CONFFILE);
2f30de5
 }
2f30de5
 
2f30de5
 static inline char *mount_config_opts(char *spec,
2f30de5
diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c
2f30de5
index 829f803..4c68702 100644
2f30de5
--- a/utils/mountd/mountd.c
2f30de5
+++ b/utils/mountd/mountd.c
2f30de5
@@ -679,7 +679,7 @@ main(int argc, char **argv)
2f30de5
 	else
2f30de5
 		progname = argv[0];
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	xlog_from_conffile("mountd");
2f30de5
 	manage_gids = conf_get_bool("mountd", "manage-gids", manage_gids);
2f30de5
 	descriptors = conf_get_num("mountd", "descriptors", descriptors);
2f30de5
diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
2f30de5
index f973203..f41a2de 100644
2f30de5
--- a/utils/nfsd/nfsd.c
2f30de5
+++ b/utils/nfsd/nfsd.c
2f30de5
@@ -80,7 +80,7 @@ main(int argc, char **argv)
2f30de5
 	xlog_syslog(0);
2f30de5
 	xlog_stderr(1);
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE); 
2f30de5
+	conf_init_file(NFS_CONFFILE); 
2f30de5
 	xlog_from_conffile("nfsd");
2f30de5
 	count = conf_get_num("nfsd", "threads", count);
2f30de5
 	grace = conf_get_num("nfsd", "grace-time", grace);
2f30de5
diff --git a/utils/nfsdcltrack/nfsdcltrack.c b/utils/nfsdcltrack/nfsdcltrack.c
2f30de5
index 7830cf4..76b06d2 100644
2f30de5
--- a/utils/nfsdcltrack/nfsdcltrack.c
2f30de5
+++ b/utils/nfsdcltrack/nfsdcltrack.c
2f30de5
@@ -564,7 +564,7 @@ main(int argc, char **argv)
2f30de5
 	xlog_syslog(1);
2f30de5
 	xlog_stderr(0);
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE); 
2f30de5
+	conf_init_file(NFS_CONFFILE); 
2f30de5
 	xlog_from_conffile("nfsdcltrack");
2f30de5
 	val = conf_get_str("nfsdcltrack", "storagedir");
2f30de5
 	if (val)
2f30de5
diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
2f30de5
index d961dc0..6d19ec1 100644
2f30de5
--- a/utils/statd/sm-notify.c
2f30de5
+++ b/utils/statd/sm-notify.c
2f30de5
@@ -494,7 +494,7 @@ main(int argc, char **argv)
2f30de5
 	else
2f30de5
 		progname = argv[0];
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	xlog_from_conffile("sm-notify");
2f30de5
 	opt_max_retry = conf_get_num("sm-notify", "retry-time", opt_max_retry / 60) * 60;
2f30de5
 	opt_srcport = conf_get_str("sm-notify", "outgoing-port");
2f30de5
diff --git a/utils/statd/statd.c b/utils/statd/statd.c
2f30de5
index 1443715..197d853 100644
2f30de5
--- a/utils/statd/statd.c
2f30de5
+++ b/utils/statd/statd.c
2f30de5
@@ -273,7 +273,7 @@ int main (int argc, char **argv)
2f30de5
 	/* Set hostname */
2f30de5
 	MY_NAME = NULL;
2f30de5
 
2f30de5
-	conf_init(NFS_CONFFILE);
2f30de5
+	conf_init_file(NFS_CONFFILE);
2f30de5
 	xlog_from_conffile("statd");
2f30de5
 	out_port = conf_get_num("statd", "outgoing-port", out_port);
2f30de5
 	port = conf_get_num("statd", "port", port);