summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2015-01-01 13:15:45 +0100
committerVijay Bellur <vbellur@redhat.com>2015-03-18 22:16:34 -0700
commita1755ee2765f3d1c9c26d51a49ad63d133932710 (patch)
tree71982c048f2c6deb8d05e894f14d568a1da978a4
parent5394f3cf60b0815d2919d24e9945ba47e3bb1f9b (diff)
glusterfsd: add "print-netgroups" and "print-exports" command
NFS now has the ability to use a separate file for "netgroups" and "exports". An administrator should have the ability to check the validity of the files before applying the configuration. The "glusterfsd" command now has the following additional arguments that can be used to check the configuration: --print-netgroups: Validate the netgroups file and print it out --print-exports: Validate the exports file and print it out BUG: 1143880 Change-Id: I24c40d50110d49d8290f9fd916742f7e4d0df85f URL: http://www.gluster.org/community/documentation/index.php/Features/Exports_Netgroups_Authentication Original-author: Shreyas Siravara <shreyas.siravara@gmail.com> CC: Richard Wareing <rwareing@fb.com> CC: Jiffin Tony Thottan <jthottan@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/9365 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--glusterfsd/src/Makefile.am6
-rw-r--r--glusterfsd/src/glusterfsd.c241
-rw-r--r--glusterfsd/src/glusterfsd.h2
-rw-r--r--libglusterfs/src/glusterfs.h2
-rw-r--r--libglusterfs/src/mem-types.h3
-rw-r--r--tests/basic/exports_parsing.t44
-rw-r--r--tests/basic/netgroup_parsing.t50
-rw-r--r--tests/configfiles/bad_exports9
-rw-r--r--tests/configfiles/bad_netgroups5
-rw-r--r--tests/configfiles/big_exports10
-rw-r--r--tests/configfiles/exports1
-rw-r--r--tests/configfiles/exports_bad_opt1
-rw-r--r--tests/configfiles/netgroups3
-rw-r--r--xlators/nfs/server/src/exports.c14
-rw-r--r--xlators/nfs/server/src/netgroups.c6
-rw-r--r--xlators/nfs/server/src/nfs-mem-types.h2
16 files changed, 385 insertions, 14 deletions
diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am
index 66ede7a336f..0f83622bb37 100644
--- a/glusterfsd/src/Makefile.am
+++ b/glusterfsd/src/Makefile.am
@@ -10,8 +10,10 @@ noinst_HEADERS = glusterfsd.h glusterfsd-mem-types.h glusterfsd-messages.h
AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_srcdir)/libglusterfs/src -DDATADIR=\"$(localstatedir)\" \
- -DCONFDIR=\"$(sysconfdir)/glusterfs\" \
- -I$(top_srcdir)/rpc/rpc-lib/src -I$(top_srcdir)/rpc/xdr/src
+ -DCONFDIR=\"$(sysconfdir)/glusterfs\" $(GF_GLUSTERFS_CFLAGS) \
+ -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \
+ -I$(top_srcdir)/rpc/rpc-lib/src -I$(top_srcdir)/rpc/xdr/src \
+ -I$(top_srcdir)/xlators/nfs/server/src
AM_CFLAGS = -Wall $(GF_CFLAGS)
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index c410ffd40d9..9a174c4bdae 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -19,6 +19,7 @@
#include <netdb.h>
#include <signal.h>
#include <libgen.h>
+#include <dlfcn.h>
#include <sys/utsname.h>
@@ -69,6 +70,8 @@
#include "rpc-clnt.h"
#include "syncop.h"
#include "client_t.h"
+#include "netgroups.h"
+#include "exports.h"
#include "daemon.h"
@@ -152,6 +155,12 @@ static struct argp_option gf_options[] = {
"Mount the filesystem with POSIX ACL support"},
{"selinux", ARGP_SELINUX_KEY, 0, 0,
"Enable SELinux label (extened attributes) support on inodes"},
+
+ {"print-netgroups", ARGP_PRINT_NETGROUPS, "NETGROUP-FILE", 0,
+ "Validate the netgroups file and print it out"},
+ {"print-exports", ARGP_PRINT_EXPORTS, "EXPORTS-FILE", 0,
+ "Validate the exports file and print it out"},
+
{"volfile-max-fetch-attempts", ARGP_VOLFILE_MAX_FETCH_ATTEMPTS, "0",
OPTION_HIDDEN, "Maximum number of attempts to fetch the volfile"},
{"aux-gfid-mount", ARGP_AUX_GFID_MOUNT_KEY, 0, 0,
@@ -787,6 +796,14 @@ parse_opts (int key, char *arg, struct argp_state *state)
cmd_args->worm = 1;
break;
+ case ARGP_PRINT_NETGROUPS:
+ cmd_args->print_netgroups = arg;
+ break;
+
+ case ARGP_PRINT_EXPORTS:
+ cmd_args->print_exports = arg;
+ break;
+
case ARGP_MAC_COMPAT_KEY:
if (!arg)
arg = "on";
@@ -1519,6 +1536,195 @@ gf_check_and_set_mem_acct (int argc, char *argv[])
}
}
+/**
+ * print_exports_file - Print out & verify the syntax
+ * of the exports file specified
+ * in the parameter.
+ *
+ * @exports_file : Path of the exports file to print & verify
+ *
+ * @return : success: 0 when successfully parsed
+ * failure: 1 when failed to parse one or more lines
+ * -1 when other critical errors (dlopen () etc)
+ * Critical errors are treated differently than parse errors. Critical
+ * errors terminate the program immediately here and print out different
+ * error messages. Hence there are different return values.
+ */
+int
+print_exports_file (const char *exports_file)
+{
+ void *libhandle = NULL;
+ char *libpathfull = NULL;
+ struct exports_file *file = NULL;
+ int ret = 0;
+
+ int (*exp_file_parse)(const char *filepath,
+ struct exports_file **expfile,
+ struct mount3_state *ms) = NULL;
+ void (*exp_file_print)(const struct exports_file *file) = NULL;
+ void (*exp_file_deinit)(struct exports_file *ptr) = NULL;
+
+ /* XLATORDIR passed through a -D flag to GCC */
+ ret = gf_asprintf (&libpathfull, "%s/%s/server.so", XLATORDIR,
+ "nfs");
+ if (ret < 0) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL, "asprintf () failed.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Load up the library */
+ libhandle = dlopen (libpathfull, RTLD_NOW);
+ if (!libhandle) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error loading NFS server library : "
+ "%s\n", dlerror ());
+ ret = -1;
+ goto out;
+ }
+
+ /* Load up the function */
+ exp_file_parse = dlsym (libhandle, "exp_file_parse");
+ if (!exp_file_parse) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error finding function exp_file_parse "
+ "in symbol.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Parse the file */
+ ret = exp_file_parse (exports_file, &file, NULL);
+ if (ret < 0) {
+ ret = 1; /* This means we failed to parse */
+ goto out;
+ }
+
+ /* Load up the function */
+ exp_file_print = dlsym (libhandle, "exp_file_print");
+ if (!exp_file_print) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error finding function exp_file_print in symbol.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Print it out to screen */
+ exp_file_print (file);
+
+ /* Load up the function */
+ exp_file_deinit = dlsym (libhandle, "exp_file_deinit");
+ if (!exp_file_deinit) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error finding function exp_file_deinit in lib.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Free the file */
+ exp_file_deinit (file);
+
+out:
+ if (libhandle)
+ dlclose(libhandle);
+ GF_FREE (libpathfull);
+ return ret;
+}
+
+
+/**
+ * print_netgroups_file - Print out & verify the syntax
+ * of the netgroups file specified
+ * in the parameter.
+ *
+ * @netgroups_file : Path of the netgroups file to print & verify
+ * @return : success: 0 when successfully parsed
+ * failure: 1 when failed to parse one more more lines
+ * -1 when other critical errors (dlopen () etc)
+ *
+ * We have multiple returns here because for critical errors, we abort
+ * operations immediately and exit. For example, if we can't load the
+ * NFS server library, then we have a real bad problem so we don't continue.
+ * Or if we cannot allocate anymore memory, we don't want to continue. Also,
+ * we want to print out a different error messages based on the ret value.
+ */
+int
+print_netgroups_file (const char *netgroups_file)
+{
+ void *libhandle = NULL;
+ char *libpathfull = NULL;
+ struct netgroups_file *file = NULL;
+ int ret = 0;
+
+ struct netgroups_file *(*ng_file_parse)(const char *file_path) = NULL;
+ void (*ng_file_print)(const struct netgroups_file *file) = NULL;
+ void (*ng_file_deinit)(struct netgroups_file *ptr) = NULL;
+
+ /* XLATORDIR passed through a -D flag to GCC */
+ ret = gf_asprintf (&libpathfull, "%s/%s/server.so", XLATORDIR,
+ "nfs");
+ if (ret < 0) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL, "asprintf () failed.");
+ ret = -1;
+ goto out;
+ }
+ /* Load up the library */
+ libhandle = dlopen (libpathfull, RTLD_NOW);
+ if (!libhandle) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error loading NFS server library : %s\n", dlerror ());
+ ret = -1;
+ goto out;
+ }
+
+ /* Load up the function */
+ ng_file_parse = dlsym (libhandle, "ng_file_parse");
+ if (!ng_file_parse) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error finding function ng_file_parse in symbol.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Parse the file */
+ file = ng_file_parse (netgroups_file);
+ if (!file) {
+ ret = 1; /* This means we failed to parse */
+ goto out;
+ }
+
+ /* Load up the function */
+ ng_file_print = dlsym (libhandle, "ng_file_print");
+ if (!ng_file_print) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error finding function ng_file_print in symbol.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Print it out to screen */
+ ng_file_print (file);
+
+ /* Load up the function */
+ ng_file_deinit = dlsym (libhandle, "ng_file_deinit");
+ if (!ng_file_deinit) {
+ gf_log ("glusterfs", GF_LOG_CRITICAL,
+ "Error finding function ng_file_deinit in lib.");
+ ret = -1;
+ goto out;
+ }
+
+ /* Free the file */
+ ng_file_deinit (file);
+
+out:
+ if (libhandle)
+ dlclose(libhandle);
+ GF_FREE (libpathfull);
+ return ret;
+}
+
+
int
parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
{
@@ -1539,6 +1745,22 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
}
argp_parse (&argp, argc, argv, ARGP_IN_ORDER, NULL, cmd_args);
+ if (cmd_args->print_netgroups) {
+ /* When this option is set we don't want to do anything else
+ * except for printing & verifying the netgroups file.
+ */
+ ret = 0;
+ goto out;
+ }
+
+ if (cmd_args->print_exports) {
+ /* When this option is set we don't want to do anything else
+ * except for printing & verifying the exports file.
+ */
+ ret = 0;
+ goto out;
+ }
+
ctx->secure_mgmt = cmd_args->secure_mgmt;
@@ -2006,6 +2228,7 @@ main (int argc, char *argv[])
glusterfs_ctx_t *ctx = NULL;
int ret = -1;
char cmdlinestr[PATH_MAX] = {0,};
+ cmd_args_t *cmd = NULL;
gf_check_and_set_mem_acct (argc, argv);
@@ -2029,6 +2252,23 @@ main (int argc, char *argv[])
ret = parse_cmdline (argc, argv, ctx);
if (ret)
goto out;
+ cmd = &ctx->cmd_args;
+ if (cmd->print_netgroups) {
+ /* If this option is set we want to print & verify the file,
+ * set the return value (exit code in this case) and exit.
+ */
+ ret = print_netgroups_file (cmd->print_netgroups);
+ goto out;
+ }
+
+ if (cmd->print_exports) {
+ /* If this option is set we want to print & verify the file,
+ * set the return value (exit code in this case)
+ * and exit.
+ */
+ ret = print_exports_file (cmd->print_exports);
+ goto out;
+ }
ret = logging_init (ctx, argv[0]);
if (ret)
@@ -2074,6 +2314,5 @@ main (int argc, char *argv[])
out:
// glusterfs_ctx_destroy (ctx);
-
return ret;
}
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 41f7b1d9a38..a16e0a65254 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -52,6 +52,8 @@ enum argp_option_keys {
ARGP_SOCK_FILE_KEY = 'S',
ARGP_NO_DAEMON_KEY = 'N',
ARGP_RUN_ID_KEY = 'r',
+ ARGP_PRINT_NETGROUPS = 'n',
+ ARGP_PRINT_EXPORTS = 'e',
ARGP_DEBUG_KEY = 133,
ARGP_NEGATIVE_TIMEOUT_KEY = 134,
ARGP_ENTRY_TIMEOUT_KEY = 135,
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 5a82d753879..adcff8cd274 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -387,6 +387,8 @@ struct _cmd_args {
uint32_t log_buf_size;
uint32_t log_flush_timeout;
int32_t max_connect_attempts;
+ char *print_exports;
+ char *print_netgroups;
/* advanced options */
uint32_t volfile_server_port;
char *volfile_server_transport;
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h
index 4dd59b002a5..a24e5731114 100644
--- a/libglusterfs/src/mem-types.h
+++ b/libglusterfs/src/mem-types.h
@@ -145,6 +145,9 @@ enum gf_common_mem_types_ {
gf_common_mt_rbuf_t = 127,
gf_common_mt_rlist_t = 128,
gf_common_mt_rvec_t = 129,
+ /* glusterd can load the nfs-xlator dynamically and needs these two */
+ gf_common_mt_nfs_netgroups = 130,
+ gf_common_mt_nfs_exports = 131,
gf_common_mt_end
};
#endif
diff --git a/tests/basic/exports_parsing.t b/tests/basic/exports_parsing.t
new file mode 100644
index 00000000000..fdaf9c2822e
--- /dev/null
+++ b/tests/basic/exports_parsing.t
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+EXP_FILES=$(dirname $0)/../configfiles
+
+cleanup
+
+function test_good_file ()
+{
+ glusterfsd --print-exports $1
+}
+
+function test_long_netgroup()
+{
+ glusterfsd --print-exports $1 2>&1 | sed -n 1p
+}
+
+function test_bad_line ()
+{
+ glusterfsd --print-exports $1 2>&1 | sed -n 1p
+}
+
+function test_big_file ()
+{
+ glusterfsd --print-exports $1 | sed -n 3p
+}
+
+function test_bad_opt ()
+{
+ glusterfsd --print-exports $1 2>&1 | sed -n 1p
+}
+
+EXPECT_KEYWORD "/test @test(rw,anonuid=0,sec=sys,) 10.35.11.31(rw,anonuid=0,sec=sys,)" test_good_file $EXP_FILES/exports
+
+EXPECT_KEYWORD "Error parsing netgroups for:" test_bad_line $EXP_FILES/bad_exports
+EXPECT_KEYWORD "Error parsing netgroups for:" test_long_netgroup $EXP_FILES/bad_exports
+
+EXPECT_KEYWORD "HDCDTY43SXOAH1TNUKB23MO9DE574W(rw,anonuid=0,sec=sys,)" test_big_file $EXP_FILES/big_exports
+
+EXPECT_KEYWORD "Could not find any valid options" test_bad_opt $EXP_FILES/exports_bad_opt
+
+cleanup
diff --git a/tests/basic/netgroup_parsing.t b/tests/basic/netgroup_parsing.t
new file mode 100644
index 00000000000..73a69c44cea
--- /dev/null
+++ b/tests/basic/netgroup_parsing.t
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+NG_FILES=$(dirname $0)/../configfiles
+cleanup;
+
+function test_ng_1 ()
+{
+ glusterfsd --print-netgroups $1 | sed -n 1p
+}
+
+function test_ng_2 ()
+{
+ glusterfsd --print-netgroups $1 | sed -n 2p
+}
+
+function test_ng_3 ()
+{
+ glusterfsd --print-netgroups $1 | sed -n 3p
+}
+
+function test_bad_ng ()
+{
+ glusterfsd --print-netgroups $1 2>&1 | sed -n 1p
+}
+
+function test_large_file ()
+{
+ # The build system needs this path for the test to pass.
+ # This is an important test because this file is ~1800 lines
+ # longs and is a "real-world" netgroups file.
+ glusterfsd --print-netgroups ~/opsfiles/storage/netgroup/netgroup | sed -n 1p
+}
+
+function test_empty_ng ()
+{
+ glusterfsd --print-netgroups $1 2>&1 | sed -n 2p
+}
+
+EXPECT_KEYWORD "ng2 (dev1763.prn2.example.com,,)" test_ng_1 $NG_FILES/netgroups
+EXPECT_KEYWORD "ng1 ng2 (dev1763.prn2.example.com,,)" test_ng_2 $NG_FILES/netgroups
+EXPECT_KEYWORD "asdf ng1 ng2 (dev1763.prn2.example.com,,)" test_ng_3 $NG_FILES/netgroups
+# TODO: get a real-world large netgroup file
+#EXPECT_KEYWORD "wikipedia001.07.prn1 (wikipedia003.prn1.example.com,,)(wikipedia002.prn1.example.com,,)(wikipedia001.prn1.example.com,,)" test_large_file
+EXPECT_KEYWORD "Parse error" test_bad_ng $NG_FILES/bad_netgroups
+EXPECT_KEYWORD "No netgroups were specified except for the parent" test_empty_ng $NG_FILES/bad_netgroups
+
+cleanup;
diff --git a/tests/configfiles/bad_exports b/tests/configfiles/bad_exports
new file mode 100644
index 00000000000..6fd18d9415a
--- /dev/null
+++ b/tests/configfiles/bad_exports
@@ -0,0 +1,9 @@
+#$Id$
+#/0838586658093758013308385866580937580133083858665809375801330838586658093758013308385866580937580133083858665809375801330838586658093758013308385866580937580133 @test(sec=sys,rw,anonuid=0) 10.35.11.32(sec=sys,rw,anonuid=0)
+
+/test @test(sec=sys,rw,anonuid=0) shreyas.facebook.com(sec=sys,rw,anonuid=0) shreyas.s(sec=sys,rw,anonuid=595)
+çççßåß僃
+/asdf @ObVyg571RJaorkGbgVerI9esrck8yiVD7NVqqJvj2H9DuPH3SzHnYLIXjd4zZjuuh2N0O0bYYQf7VYNrYHoxc1llgRU1iEsQRy2XaWnUlhTHKVEL8tt1TrbZCi8qXyg0l058rTnW4msvU5hW83ESwyOE4bBSz4VsW0sJaVd8Gv4waZqojemLN8AIlAoChVOfP1yhuAP1298ejkaf2fjhdfa4t4effhgadff342fdddgasdg42gahgdmnui24290hfjdjadgdkjhg2nvncms(sec=sys,rw,anonuid=1)
+#/vol/root -sec=sys,rw=@storage.prn1:@storage.ash4:@storage.frc1,anon=0
+#/vol/home107 -sec=sys,rw,nosuid,root=@storage.prn1:@storage.ash4:@storage.frc1:@hr.ash3:@hr.prn1:ldap001.prn1.facebook.com:ldap001.frc1.facebook.com
+#/vol/home109 -sec=sys,rw,nosuid,root=@storage.prn1:@storage.ash4:@storage.frc1:@hr.ash3:@hr.prn1:ldap001.prn1.facebook.com:ldap001.frc1.facebook.com
diff --git a/tests/configfiles/bad_netgroups b/tests/configfiles/bad_netgroups
new file mode 100644
index 00000000000..ea27edfef10
--- /dev/null
+++ b/tests/configfiles/bad_netgroups
@@ -0,0 +1,5 @@
+asdf ng1
+ng1 ng2
+ng2 (dev1763.prn2.facebook.com, ,)
+
+emptyng
diff --git a/tests/configfiles/big_exports b/tests/configfiles/big_exports
new file mode 100644
index 00000000000..9ca5d655664
--- /dev/null
+++ b/tests/configfiles/big_exports
@@ -0,0 +1,10 @@
+/75213U8JV58PBY7F0VFGJ080MH3K71 @ZXV3UE7WJSCZSPMPAYUBACCZUOD0XY(sec=sys,rw,anonuid=0) 9PAC2KCTKRIH62CPGAMAUAJGLVQNS3(sec=sys,rw,anonuid=0)
+/O4DYT8D6QVS9EKEHTYOPTYL6IWU4DN @KLBH3LB3UN5LWDWPPQEQWEHYVL3K0A(sec=sys,rw,anonuid=0) B37PXMCQMY5IQPDGV08XC7ITYT650V(sec=sys,rw,anonuid=0)
+/OFHJLTKZMDAN28Q9IQQQIPFUEZ2YAN @UY3K3B8C05OQ4OTX42VXQKJ2CGJ8QX(sec=sys,rw,anonuid=0) AM0ET70HT6YND7D8RKG446LEOW40EC(sec=sys,rw,anonuid=0)
+/3VDZ2JHFQ2JGF2GQGYQH38UPAW6A6T @DEPUVDYZOJFCSQ7KD07NVPAFGEG7YJ(sec=sys,rw,anonuid=0) 5HI538NCEYF7KY7HC1F69UBWFVTIGA(sec=sys,rw,anonuid=0)
+/4ZI3ZRJUNQM21ZM8VB891X4ZCUHK7E @7U8TNSZ55AWJAOPAIV67OGPWLGM4JV(sec=sys,rw,anonuid=0) 8698JR9V4KKENE7UGYHV3T4XG9K0NH(sec=sys,rw,anonuid=0)
+/A4CSZ2FQ3VYPT9R0HYN3QVQ7TK9IHI @G2Z45H649YZ9WNC3OSU7STCLT3VWT9(sec=sys,rw,anonuid=0) 65CA94Z7JXZ0F0JB5EP95I6FBJT673(sec=sys,rw,anonuid=0)
+/G91PI0EX5TUYSX91IAH49M1GEMNKSP @O5IFIYJUENNNK16U0FK0QCDE0DK9G2(sec=sys,rw,anonuid=0) A8AZTTWC7BMTV8YW8XE4R57WUOSUMZ(sec=sys,rw,anonuid=0)
+/YCZFA0ALYC284R60E7QXQN7AVSILFO @7OGJV2J1NOII7UOGN12SUNRW3XBWWG(sec=sys,rw,anonuid=0) HDCDTY43SXOAH1TNUKB23MO9DE574W(sec=sys,rw,anonuid=0)
+/VBGB57O8R87B9N4E8QPGU6D55DVZE5 @F95KY58VAUOUX30QKIN16U987UU9BE(sec=sys,rw,anonuid=0) WGSH35L15FT2IC0IT9PTCU8SCYW9W4(sec=sys,rw,anonuid=0)
+/NTHST2FDSP35BKEEIOQIQX38722AN0 @T9BXSDXF2N5HVOM8P1BN0Q5IQ6RC34(sec=sys,rw,anonuid=0) OLJR1KXJRY14UEZNV1LP7RV68KPIW7(sec=sys,rw,anonuid=0)
diff --git a/tests/configfiles/exports b/tests/configfiles/exports
new file mode 100644
index 00000000000..82ba450403e
--- /dev/null
+++ b/tests/configfiles/exports
@@ -0,0 +1 @@
+/test @test(sec=sys,rw,anonuid=0) 10.35.11.31(sec=sys,rw,anonuid=0)
diff --git a/tests/configfiles/exports_bad_opt b/tests/configfiles/exports_bad_opt
new file mode 100644
index 00000000000..70a56890e4c
--- /dev/null
+++ b/tests/configfiles/exports_bad_opt
@@ -0,0 +1 @@
+/groot asdf(r) @ngtop(r)
diff --git a/tests/configfiles/netgroups b/tests/configfiles/netgroups
new file mode 100644
index 00000000000..a4ed2c53df4
--- /dev/null
+++ b/tests/configfiles/netgroups
@@ -0,0 +1,3 @@
+asdf ng1
+ng1 ng2
+ng2 (dev1763.prn2.example.com,,)
diff --git a/xlators/nfs/server/src/exports.c b/xlators/nfs/server/src/exports.c
index 793e020dd1f..af0cc7c24f2 100644
--- a/xlators/nfs/server/src/exports.c
+++ b/xlators/nfs/server/src/exports.c
@@ -77,7 +77,7 @@ _exports_file_init ()
{
struct exports_file *file = NULL;
- file = GF_CALLOC (1, sizeof (*file), gf_nfs_mt_exports);
+ file = GF_CALLOC (1, sizeof (*file), gf_common_mt_nfs_exports);
if (!file) {
gf_log (GF_EXP, GF_LOG_CRITICAL,
"Failed to allocate file struct!");
@@ -123,8 +123,10 @@ _exp_file_dict_destroy (dict_t *dict, char *key, data_t *val, void *tmp)
if (val) {
dir = (struct export_dir *)val->data;
- _export_dir_deinit (dir);
- val->data = NULL;
+ if (dir) {
+ _export_dir_deinit (dir);
+ val->data = NULL;
+ }
dict_del (dict, key);
}
@@ -175,7 +177,7 @@ static struct export_dir *
_export_dir_init ()
{
struct export_dir *expdir = GF_CALLOC (1, sizeof (*expdir),
- gf_nfs_mt_exports);
+ gf_common_mt_nfs_exports);
if (!expdir)
gf_log (GF_EXP, GF_LOG_CRITICAL,
@@ -234,7 +236,7 @@ static struct export_item *
_export_item_init ()
{
struct export_item *item = GF_CALLOC (1, sizeof (*item),
- gf_nfs_mt_exports);
+ gf_common_mt_nfs_exports);
if (!item)
gf_log (GF_EXP, GF_LOG_CRITICAL,
@@ -273,7 +275,7 @@ static struct export_options *
_export_options_init ()
{
struct export_options *opts = GF_CALLOC (1, sizeof (*opts),
- gf_nfs_mt_exports);
+ gf_common_mt_nfs_exports);
if (!opts)
gf_log (GF_EXP, GF_LOG_CRITICAL,
diff --git a/xlators/nfs/server/src/netgroups.c b/xlators/nfs/server/src/netgroups.c
index f5c966948f7..a505586961c 100644
--- a/xlators/nfs/server/src/netgroups.c
+++ b/xlators/nfs/server/src/netgroups.c
@@ -73,7 +73,7 @@ static struct netgroups_file *
_netgroups_file_init ()
{
struct netgroups_file *file = GF_MALLOC (sizeof (*file),
- gf_nfs_mt_netgroups);
+ gf_common_mt_nfs_netgroups);
if (!file)
goto out;
@@ -179,7 +179,7 @@ static struct netgroup_entry *
_netgroup_entry_init ()
{
struct netgroup_entry *entry = GF_CALLOC (1, sizeof (*entry),
- gf_nfs_mt_netgroups);
+ gf_common_mt_nfs_netgroups);
return entry;
}
@@ -324,7 +324,7 @@ static struct netgroup_host *
_netgroup_host_init ()
{
struct netgroup_host *host = GF_CALLOC (1, sizeof (*host),
- gf_nfs_mt_netgroups);
+ gf_common_mt_nfs_netgroups);
return host;
}
diff --git a/xlators/nfs/server/src/nfs-mem-types.h b/xlators/nfs/server/src/nfs-mem-types.h
index 6d4a2ed9cc2..88c688f74f3 100644
--- a/xlators/nfs/server/src/nfs-mem-types.h
+++ b/xlators/nfs/server/src/nfs-mem-types.h
@@ -47,8 +47,6 @@ enum gf_nfs_mem_types_ {
gf_nfs_mt_aux_gids,
gf_nfs_mt_inode_ctx,
gf_nfs_mt_auth_spec,
- gf_nfs_mt_netgroups,
- gf_nfs_mt_exports,
gf_nfs_mt_arr,
gf_nfs_mt_auth_cache,
gf_nfs_mt_auth_cache_entry,