diff options
-rw-r--r-- | usr/src/cmd/fs.d/nfs/nfsd/nfsd.c | 41 | ||||
-rw-r--r-- | usr/src/lib/libshare/nfs/libshare_nfs.c | 43 |
2 files changed, 51 insertions, 33 deletions
diff --git a/usr/src/cmd/fs.d/nfs/nfsd/nfsd.c b/usr/src/cmd/fs.d/nfs/nfsd/nfsd.c index c34c39a13e..625decfaa8 100644 --- a/usr/src/cmd/fs.d/nfs/nfsd/nfsd.c +++ b/usr/src/cmd/fs.d/nfs/nfsd/nfsd.c @@ -451,7 +451,7 @@ main(int ac, char *av[]) case 0: break; case -1: - fprintf(stderr, "error locking for %s: %s", NFSD, + fprintf(stderr, "error locking for %s: %s\n", NFSD, strerror(errno)); exit(2); default: @@ -466,7 +466,7 @@ main(int ac, char *av[]) */ if (dss_pathnames != NULL && nfs_server_vers_max >= DSS_VERSMIN) { if (dss_init(dss_npaths, dss_pathnames) != 0) { - fprintf(stderr, "%s", "dss_init failed. Exiting."); + fprintf(stderr, "%s", "dss_init failed. Exiting.\n"); exit(1); } } @@ -480,7 +480,7 @@ main(int ac, char *av[]) if (logmaxservers) { fprintf(stderr, - "Number of servers not specified. Using default of %d.", + "Number of servers not specified. Using default of %d.\n", maxservers); } @@ -498,8 +498,8 @@ main(int ac, char *av[]) * Set up kernel RPC thread pool for the NFS server. */ if (nfssvcpool(maxservers)) { - fprintf(stderr, "Can't set up kernel NFS service: %s. Exiting", - strerror(errno)); + fprintf(stderr, "Can't set up kernel NFS service: %s. " + "Exiting.\n", strerror(errno)); exit(1); } @@ -507,7 +507,7 @@ main(int ac, char *av[]) * Set up blocked thread to do LWP creation on behalf of the kernel. */ if (svcwait(NFS_SVCPOOL_ID)) { - fprintf(stderr, "Can't set up NFS pool creator: %s. Exiting", + fprintf(stderr, "Can't set up NFS pool creator: %s. Exiting.\n", strerror(errno)); exit(1); } @@ -524,7 +524,7 @@ main(int ac, char *av[]) if (svcrdma(NFS_SVCPOOL_ID, nfs_server_vers_min, nfs_server_vers_max, nfs_server_delegation)) { fprintf(stderr, - "Can't set up RDMA creator thread : %s", + "Can't set up RDMA creator thread : %s\n", strerror(errno)); } } @@ -558,7 +558,7 @@ main(int ac, char *av[]) if (allflag) { if (do_all(protobp0, nfssvc) == -1) { - fprintf(stderr, "setnetconfig failed : %s", + fprintf(stderr, "setnetconfig failed : %s\n", strerror(errno)); exit(1); } @@ -568,7 +568,7 @@ main(int ac, char *av[]) NCONF_HANDLE *nc; bool_t protoFound = FALSE; if ((nc = setnetconfig()) == (NCONF_HANDLE *) NULL) { - fprintf(stderr, "setnetconfig failed : %s", + fprintf(stderr, "setnetconfig failed : %s\n", strerror(errno)); goto done; } @@ -582,7 +582,7 @@ main(int ac, char *av[]) (void) endnetconfig(nc); if (protoFound == FALSE) { fprintf(stderr, - "couldn't find netconfig entry for protocol %s", + "couldn't find netconfig entry for protocol %s\n", proto); } } else if (provider) @@ -601,7 +601,7 @@ done: if (num_fds == 0) { fprintf(stderr, "Could not start NFS service for any protocol." - " Exiting"); + " Exiting.\n"); exit(1); } @@ -812,8 +812,8 @@ dss_mkleafdir(char *dir, char *leaf, char *tmppath) { /* MAXPATHLEN includes the terminating NUL */ if (strlen(dir) + strlen(leaf) > MAXPATHLEN - 1) { - fprintf(stderr, "stable storage path too long: %s%s. Exiting", - dir, leaf); + fprintf(stderr, "stable storage path too long: %s%s. " + "Exiting.\n", dir, leaf); exit(1); } @@ -822,7 +822,7 @@ dss_mkleafdir(char *dir, char *leaf, char *tmppath) /* the directory may already exist: that's OK */ if (mkdir(tmppath, NFS4_DSS_DIR_MODE) == -1 && errno != EEXIST) { fprintf(stderr, "error creating stable storage directory: " - "%s: %s. Exiting", strerror(errno), tmppath); + "%s: %s. Exiting.\n", strerror(errno), tmppath); exit(1); } } @@ -878,7 +878,8 @@ dss_init(uint_t npaths, char **pathnames) sz = nreal * sizeof (char *); tmp_pathnames = (char **)malloc(sz); if (tmp_pathnames == NULL) { - fprintf(stderr, "tmp_pathnames malloc failed"); + fprintf(stderr, "tmp_pathnames malloc " + "failed\n"); exit(1); } @@ -898,7 +899,7 @@ dss_init(uint_t npaths, char **pathnames) /* Create the name-value pair list */ error = nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0); if (error) { - fprintf(stderr, "nvlist_alloc failed: %s.", strerror(errno)); + fprintf(stderr, "nvlist_alloc failed: %s\n", strerror(errno)); return (1); } @@ -906,7 +907,7 @@ dss_init(uint_t npaths, char **pathnames) error = nvlist_add_string_array(nvl, NFS4_DSS_NVPAIR_NAME, pathnames, npaths); if (error) { - fprintf(stderr, "nvlist_add_string_array failed: %s.", + fprintf(stderr, "nvlist_add_string_array failed: %s\n", strerror(errno)); nvlist_free(nvl); return (1); @@ -921,7 +922,7 @@ dss_init(uint_t npaths, char **pathnames) bufp = NULL; error = nvlist_pack(nvl, &bufp, &buflen, NV_ENCODE_XDR, 0); if (error) { - fprintf(stderr, "nvlist_pack failed: %s.", strerror(errno)); + fprintf(stderr, "nvlist_pack failed: %s\n", strerror(errno)); nvlist_free(nvl); return (1); } @@ -941,7 +942,7 @@ dss_init(uint_t npaths, char **pathnames) error = _nfssys(NFS4_DSS_SETPATHS_SIZE, &bufsize); if (error) { fprintf(stderr, - "_nfssys(NFS4_DSS_SETPATHS_SIZE) failed: %s. ", + "_nfssys(NFS4_DSS_SETPATHS_SIZE) failed: %s\n", strerror(errno)); free(bufp); return (1); @@ -951,7 +952,7 @@ dss_init(uint_t npaths, char **pathnames) error = _nfssys(NFS4_DSS_SETPATHS, bufp); if (error) { fprintf(stderr, - "_nfssys(NFS4_DSS_SETPATHS) failed: %s. ", strerror(errno)); + "_nfssys(NFS4_DSS_SETPATHS) failed: %s\n", strerror(errno)); free(bufp); return (1); } diff --git a/usr/src/lib/libshare/nfs/libshare_nfs.c b/usr/src/lib/libshare/nfs/libshare_nfs.c index a02237dd71..a6ea2e1a39 100644 --- a/usr/src/lib/libshare/nfs/libshare_nfs.c +++ b/usr/src/lib/libshare/nfs/libshare_nfs.c @@ -20,9 +20,9 @@ */ /* - * Copyright 2015 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. */ /* @@ -52,6 +52,7 @@ #include "libshare_nfs.h" #include <nfs/nfs.h> #include <nfs/nfssys.h> +#include <netconfig.h> #include "smfcfg.h" /* should really be in some global place */ @@ -450,7 +451,7 @@ nfs_alistcat(char *str1, char *str2, char sep) static int add_security_prop(struct securities *sec, char *name, char *value, - int persist, int iszfs) + int persist, int iszfs) { sa_property_t prop; int ret = SA_OK; @@ -1329,7 +1330,7 @@ count_security(sa_optionset_t opts) static int nfs_sprint_option(char **rbuff, size_t *rbuffsize, size_t incr, - sa_property_t prop, int sep) + sa_property_t prop, int sep) { char *name; char *value; @@ -1558,8 +1559,7 @@ err: * Append an entry to the nfslogtab file */ static int -nfslogtab_add(dir, buffer, tag) - char *dir, *buffer, *tag; +nfslogtab_add(char *dir, char *buffer, char *tag) { FILE *f; struct logtab_ent lep; @@ -1641,8 +1641,7 @@ out: * Deactivate an entry from the nfslogtab file */ static int -nfslogtab_deactivate(path) - char *path; +nfslogtab_deactivate(char *path) { FILE *f; int error = 0; @@ -3105,13 +3104,31 @@ nfs_validate_proto_prop(int index, char *name, char *value) } break; - case OPT_TYPE_PROTOCOL: - if (strlen(value) != 0 && - strcasecmp(value, "all") != 0 && - strcasecmp(value, "tcp") != 0 && - strcasecmp(value, "udp") != 0) + case OPT_TYPE_PROTOCOL: { + struct netconfig *nconf; + void *nc; + boolean_t pfound = B_FALSE; + + if (strcasecmp(value, "all") == 0) + break; + + if ((nc = setnetconfig()) == NULL) { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "setnetconfig failed: %s\n"), strerror(errno)); + } else { + while ((nconf = getnetconfig(nc)) != NULL) { + if (strcmp(nconf->nc_proto, value) == 0) { + pfound = B_TRUE; + break; + } + } + (void) endnetconfig(nc); + } + + if (!pfound) ret = SA_BAD_VALUE; break; + } default: /* treat as a string */ |