libshare_nfs.c revision 6185db853e024a486ff8837e6784dd290d866112
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* NFS specific functions
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <zone.h>
#include <errno.h>
#include <locale.h>
#include <signal.h>
#include "libshare.h"
#include "libshare_impl.h"
#include <pwd.h>
#include <limits.h>
#include <libscf.h>
#include "nfslog_config.h"
#include "nfslogtab.h"
#include "libshare_nfs.h"
#include <rpcsvc/daemon_utils.h>
/* should really be in some global place */
#define DEF_WIN 30000
#define OPT_CHUNK 1024
int debug = 0;
/* internal functions */
static int nfs_init();
static void nfs_fini();
static int nfs_enable_share(sa_share_t);
static int nfs_disable_share(char *);
static int nfs_validate_security_mode(char *);
static int nfs_is_security_opt(char *);
static int nfs_parse_legacy_options(sa_group_t, char *);
static char *nfs_format_options(sa_group_t, int);
static int nfs_set_proto_prop(sa_property_t);
static sa_protocol_properties_t nfs_get_proto_set();
static char *nfs_get_status();
static char *nfs_space_alias(char *);
/*
* ops vector that provides the protocol specific info and operations
* for share management.
*/
struct sa_plugin_ops sa_plugin_ops = {
"nfs",
NULL,
};
/*
* list of support services needed
* defines should come from head/rpcsvc/daemon_utils.h
*/
static char *service_list_default[] =
static char *service_list_logging[] =
/*
* option definitions. Make sure to keep the #define for the option
* index just before the entry it is the index for. Changing the order
* can cause breakage. E.g OPT_RW is index 1 and must precede the
* line that includes the SHOPT_RW and OPT_RW entries.
*/
struct option_defs optdefs[] = {
#define OPT_RO 0
#define OPT_RW 1
#define OPT_ROOT 2
#define OPT_SECURE 3
#define OPT_ANON 4
#define OPT_WINDOW 5
#define OPT_NOSUID 6
#define OPT_ACLOK 7
#define OPT_NOSUB 8
#define OPT_SEC 9
#define OPT_PUBLIC 10
#define OPT_INDEX 11
#define OPT_LOG 12
#define OPT_CKSUM 13
#ifdef VOLATILE_FH_TEST /* XXX added for testing volatile fh's only */
#define OPT_VOLFH 14
{SHOPT_VOLFH, OPT_VOLFH},
#endif /* VOLATILE_FH_TEST */
};
/*
* list of propertye that are related to security flavors.
*/
static char *seclist[] = {
};
/* structure for list of securities */
struct securities {
struct securities *next;
};
/*
* findopt(name)
*
* Lookup option "name" in the option table and return the table
* index.
*/
static int
{
int i;
return (i);
}
}
return (-1);
}
/*
* gettype(name)
*
* Return the type of option "name".
*/
static int
{
int optdef;
if (optdef != -1)
return (OPT_TYPE_ANY);
}
/*
* nfs_validate_security_mode(mode)
*
* is the specified mode string a valid one for use with NFS?
*/
static int
nfs_validate_security_mode(char *mode)
{
int err;
if (err == SC_NOERROR)
return (1);
return (0);
}
/*
* nfs_is_security_opt(tok)
*
* check to see if tok represents an option that is only valid in some
* security flavor.
*/
static int
nfs_is_security_opt(char *tok)
{
int i;
return (1);
}
return (0);
}
/*
* find_security(seclist, sec)
*
* Walk the current list of security flavors and return true if it is
* present, else return false.
*/
static int
{
return (1);
}
return (0);
}
/*
* make_security_list(group, securitymodes, proto)
* go through the list of securitymodes and add them to the
* group's list of security optionsets. We also keep a list of
* those optionsets so we don't have to find them later. All of
* these will get copies of the same properties.
*/
static struct securities *
{
int freetok = 0;
*next++ = '\0';
/* resolve default into the real type */
freetok = 1;
}
/* add to the security list if it isn't there already */
sizeof (struct securities));
proto);
} else {
}
/*
* note that the first time through the loop,
* headp will be NULL and prev will be
* undefined. Since headp is NULL, we set
* both it and prev to the curp (first
* structure to be allocated).
*
* later passes through the loop will have
* headp not being NULL and prev will be used
* to allocate at the end of the list.
*/
} else {
}
}
}
if (freetok) {
freetok = 0;
}
}
return (headp);
}
static void
{
struct securities *next;
}
}
}
/*
* nfs_alistcat(str1, str2, sep)
*
* concatenate str1 and str2 into a new string using sep as a separate
* character. If memory allocation fails, return NULL;
*/
static char *
{
char *newstr;
return (newstr);
}
/*
* add_security_prop(sec, name, value, persist)
*
* Add the property to the securities structure. This accumulates
* properties for as part of parsing legacy options.
*/
static int
{
value = "*";
else
value = "true";
}
char *oldvalue;
char *newvalue;
/*
* multiple times. If they do, the values need to be
* merged into an access list. If it was previously
* empty, the new value alone is added.
*/
(void) sa_remove_property(prop);
}
} else {
}
}
}
return (ret);
}
/*
*/
static int
{
char *type;
int persist = 1;
persist = 0;
return (persist);
}
/*
* invalid_security(options)
*
* search option string for any invalid sec= type.
* return true (1) if any are not valid else false (0)
*/
static int
invalid_security(char *options)
{
int ret = 0;
*value++ = '\0';
/* have security flavors so check them */
*next++ = '\0';
if (ret)
break;
}
}
}
}
return (ret);
}
/*
* nfs_parse_legacy_options(group, options)
*
* Parse the old style options into internal format and store on the
* specified group. Group could be a share for full legacy support.
*/
static int
{
char *base;
char *token;
int iszfs = 0;
int persist = 0;
char *lasts;
/* do we have an existing optionset? */
/* didn't find existing optionset so create one */
} else {
/*
* have an existing optionset so we need to compare
* options in order to detect errors. For now, we
* assume that the first optionset is the correct one
* and the others will be the same. This needs to be
* fixed before the final code is ready.
*/
return (ret);
}
/*
* there is a special case of only the option "rw"
* being the default option. We don't have to do
* anything.
*/
return (ret);
}
/*
* check if security types are present and validate them. If
* any are not legal, fail.
*/
if (invalid_security(options)) {
return (SA_INVALID_SECURITY);
}
/*
* in order to not attempt to change ZFS properties unless
* absolutely necessary, we never do it in the legacy parsing.
*/
if (sa_is_share(group)) {
char *zfs;
iszfs++;
}
}
} else {
}
/*
* we need to step through each option in the string and then
* add either the option or the security option as needed. If
* this is not a persistent share, don't commit to the
* repository.
*/
char *value;
/*
* if the option has a value, it will have an '=' to
* separate the name from the value. The following
* code will result in value != NULL and token
* pointing to just the name if there is a value.
*/
*value++ = '\0';
}
/*
* Once in security parsing, we only
* do security. We do need to move
* between the security node and the
* toplevel. The security tag goes on
* the root while the following ones
* go on the security.
*/
if (security_list != NULL) {
/* have an old list so close it and start the new */
}
value = "dh";
} else {
ret = SA_SYNTAX_ERR;
break;
}
}
} else {
/*
* Note that the "old" syntax allowed a
* default security model This must be
* accounted for and internally converted to
* "standard" security structure.
*/
if (nfs_is_security_opt(token)) {
if (security_list == NULL) {
/*
* need to have a security option. This
* will be "closed" when a defined "sec="
* option is seen. This is technically an
* error but will be allowed with warning.
*/
"default",
"nfs");
}
if (security_list != NULL) {
iszfs);
} else {
ret = SA_NO_MEMORY;
}
} else {
/* regular options */
value = "*";
value = "global";
else
value = "true";
}
break;
}
if (!iszfs) {
}
}
}
}
}
if (security_list != NULL)
return (ret);
}
/*
* is_a_number(number)
*
* is the string a number in one of the forms we want to use?
*/
static int
is_a_number(char *number)
{
int ret = 1;
int hex = 0;
number += 2;
hex = 1;
} else if (*number == '-')
number++; /* skip the minus */
if (hex) {
} else {
}
}
return (ret);
}
/*
* Look for the specified tag in the configuration file. If it is found,
* enable logging and set the logging configuration information for exp.
*/
static void
{
int error = 0;
char globaltag[] = DEFAULTTAG;
/*
* Sends config errors to stderr
*/
/*
* get the list of configuration settings
*/
if (error) {
gettext("Cannot get log configuration: %s\n"),
}
/* bad configuration */
goto err;
}
goto out;
}
goto out;
}
out:
if (configlist != NULL)
err:
if (error != 0) {
gettext("Cannot set log configuration: %s\n"),
}
}
/*
* fill_export_from_optionset(export, optionset)
*
* In order to share, we need to set all the possible general options
* into the export structure. Share info will be filled in by the
* caller. Various property values get turned into structure specific
* values.
*/
static int
{
char *name;
char *value;
/*
* explicit set or clear of the option. This allows defaults
* to be set and then the protocol specifici to override.
*/
case OPT_ANON:
} else {
} else {
val = UID_NOBODY;
}
endpwent();
}
break;
case OPT_NOSUID:
else
break;
case OPT_ACLOK:
else
break;
case OPT_NOSUB:
else
break;
case OPT_PUBLIC:
else
break;
case OPT_INDEX:
/* this is an error */
"must be a filename.\n"),
value);
break;
}
/* valid index file string */
/* left over from "default" */
}
"index property\n"));
break;
}
}
break;
case OPT_LOG:
break;
case OPT_CKSUM:
/* TBD: not ready yet */
break;
default:
/* have a syntactic error */
break;
}
}
return (ret);
}
/*
* cleanup_export(export)
*
* Cleanup the allocated areas so we don't leak memory
*/
static void
{
int i;
}
}
}
/*
* Given a seconfig entry and a colon-separated
* list of names, allocate an array big enough
* to hold the root list, then convert each name to
* a principal name according to the security
* info and assign it to an array element.
* Return the array and its size.
*/
static caddr_t *
{
caddr_t *a;
int c, i;
char *host, *p;
/*
* Count the number of strings in the list.
* This is the number of colon separators + 1.
*/
c = 1;
for (p = list; *p; p++)
if (*p == ':')
c++;
*count = c;
if (a == NULL) {
} else {
for (i = 0; i < c; i++) {
free(a);
a = NULL;
break;
}
}
}
return (a);
}
/*
* fill_security_from_secopts(sp, secopts)
*
* Fill the secinfo structure from the secopts optionset.
*/
static int
{
char *type;
int longform;
int err = 0;
/* named security type needs secinfo to be filled in */
if (err != SC_NOERROR)
return (err);
} else {
/* default case */
if (err != SC_NOERROR)
return (err);
}
char *name;
char *value;
case OPT_RO:
break;
case OPT_RW:
break;
case OPT_ROOT:
/*
* if we are using AUTH_UNIX, handle like other things
*/
continue;
/* not AUTH_UNIX */
break;
case OPT_WINDOW:
}
break;
default:
break;
}
}
return (err);
}
/*
* This is for testing only
* It displays the export structure that
* goes into the kernel.
*/
static void
{
int i, j;
if (debug == 0)
return;
(void) printf("NOSUID ");
(void) printf("ACLOK ");
(void) printf("PUBLIC ");
(void) printf("NOSUB ");
(void) printf("LOG ");
(void) printf("LOG_ALLOPS ");
(void) printf("(none)");
(void) printf("\n");
(void) printf("\tex_log_buffer = %s\n",
(void) printf("\tex_tag = %s\n",
}
(void) printf("\n");
(void) printf("\n");
(void) printf("\n\n");
}
}
/*
* count_security(opts)
*
* Count the number of security types (flavors). The optionset has
* been populated with the security flavors as a holding mechanism.
* We later use this number to allocate data structures.
*/
static int
{
int count = 0;
count++;
}
}
return (count);
}
/*
* nfs_sprint_option(rbuff, rbuffsize, incr, prop, sep)
*
* provides a mechanism to format NFS properties into legacy output
* format. If the buffer would overflow, it is reallocated and grown
* as appropriate. Special cases of converting internal form of values
* to those used by "share" are done. this function does one property
* at a time.
*/
static void
{
char *name;
char *value;
int curlen;
else
curlen = 0;
int len;
/*
* A future RFE would be to replace this with more
* generic code and to possibly handle more types.
*/
case OPT_TYPE_BOOLEAN:
*name = '\0';
}
break;
case OPT_TYPE_ACCLIST:
} else {
}
break;
case OPT_TYPE_LOGTAG:
} else {
}
break;
default:
break;
}
/* need more room */
/* realloc failed so free everything */
}
return;
}
}
return;
else
}
}
/*
* nfs_format_options(group, hier)
*
* format all the options on the group into an old-style option
* string. If hier is non-zero, walk up the tree to get inherited
* options.
*/
static char *
{
char *buff;
/*
* have a an optionset relative to this item, if any. format
* these then add any security definitions.
*/
int sep = 0;
buff[0] = '\0';
/*
* do the default set first but skip any option that is also
* in the protocol specific optionset.
*/
/*
* use this one since we skipped any of these that
* were also in optdefault
*/
/*
* buff could become NULL if there isn't
* enough memory for nfs_sprint_option to
* realloc() as necessary. We can't really do
* anything about it at this point so we
* return NULL. The caller should handle the
* failure. Note that this
*/
return (buff);
}
sep = 1;
}
}
"nfs", hier);
if (secoptions != NULL) {
char *sectype;
"nfs", hier);
(void) sa_remove_property(prop);
sep = 1;
}
/* catastrophic memory failure */
return (buff);
}
sep = 1;
}
}
}
}
}
return (buff);
}
/*
* Append an entry to the nfslogtab file
*/
static int
{
FILE *f;
struct logtab_ent lep;
int error = 0;
/*
* Open the file for update and create it if necessary.
* This may leave the I/O offset at the end of the file,
* so rewind back to the beginning of the file.
*/
if (f == NULL) {
goto out;
}
rewind(f);
"share complete, however failed to lock %s "
error = -1;
goto out;
}
if (logtab_deactivate_after_boot(f) == -1) {
"share complete, however could not deactivate "
"entries in %s\n"), NFSLOGTAB);
error = -1;
goto out;
}
/*
* Remove entries matching buffer and sharepoint since we're
* going to replace it with perhaps an entry with a new tag.
*/
"share complete, however could not remove matching "
"entries in %s\n"), NFSLOGTAB);
error = -1;
goto out;
}
/*
* Deactivate all active entries matching this sharepoint
*/
"share complete, however could not deactivate matching "
"entries in %s\n"), NFSLOGTAB);
error = -1;
goto out;
}
/*
* Add new sharepoint / buffer location to nfslogtab
*/
if (logtab_putent(f, &lep) < 0) {
"share complete, however could not add %s to %s\n"),
error = -1;
}
out:
if (f != NULL)
(void) fclose(f);
return (error);
}
/*
* Deactivate an entry from the nfslogtab file
*/
static int
char *path;
{
FILE *f;
int error = 0;
if (f == NULL) {
goto out;
}
"share complete, however could not lock %s for "
goto out;
}
error = -1;
gettext("share complete, however could not "
goto out;
}
(void) fclose(f);
return (error);
}
/*
* public_exists(share)
*
* check to see if public option is set on any other share than the
* one specified.
*/
static int
{
int exists = 0;
continue;
char *shared;
goto out;
}
}
}
}
}
out:
return (exists);
}
/*
* sa_enable_share at the protocol level, enable_share must tell the
* implementation that it is to enable the share. This entails
* converting the path and options into the appropriate ioctl
* calls. It is assumed that all error checking of paths, etc. were
* done earlier.
*/
static int
{
struct exportdata export;
int num_secinfo;
char *path;
/* Don't drop core if the NFS module isn't loaded. */
/* get the path since it is important in several places */
return (SA_NO_SUCH_PATH);
/*
* find the optionsets and security sets. There may not be
* any or there could be one or two for each of optionset and
* security may have multiple, one per security type per
* protocol type.
*/
if (secoptlist != NULL)
else
num_secinfo = 1;
/*
* walk through the options and fill in the structure
* appropriately.
*/
/*
* do non-security options first since there is only one after
* the derived group is constructed.
*/
/*
* check to see if "public" is set. If it is, then make sure
* no other share has it set. If it is already used, fail.
*/
"system with 'public' property\n"));
goto out;
}
/* failed to alloc memory */
(void) printf("NFS: no memory for security\n");
err = SA_NO_MEMORY;
} else {
int i;
/* get default secinfo */
/*
* since we must have one security option defined, we
* init to the default and then override as we find
* defined security options. This handles the case
* where we have no defined options but we need to set
* up one.
*/
/* setup a default in case no properties defined */
"get default security mode\n"));
err = SA_CONFIG_ERR;
}
if (secoptlist != NULL) {
char *sectype;
/* if sectype is NULL, we can't do anything so skip */
continue;
"nfs", 1);
}
}
/*
* when we get here, we can do the exportfs system call and
* initiate thinsg. We probably want to enable the nfs.server
* service first if it isn't running within SMF.
*/
/* check nfs.server status and start if needed */
/* now add the share to the internal tables */
/*
* call the exportfs system call which is implemented
* via the nfssys() call as the EXPORTFS subfunction.
*/
err = SA_SYSTEM_ERR;
switch (errno) {
case EREMOTE:
"system: %s\n"),
path);
break;
case EPERM:
if (getzoneid() != GLOBAL_ZONEID) {
"in non-global zones: %s\n"), path);
break;
}
/* FALLTHROUGH */
default:
break;
}
} else {
}
}
/*
* enable services as needed. This should probably be
* done elsewhere in order to minimize the calls to
* check services.
*/
/*
* check to see if logging and other services need to
* be triggered, but only if there wasn't an
* error. This is probably where sharetab should be
* updated with the NFS specific entry.
*/
/* enable logging */
gettext("Could not enable logging for %s\n"),
path);
}
} else {
/*
* don't have logging so remove it from file. It might
* not be thre, but that doesn't matter.
*/
(void) nfslogtab_deactivate(path);
}
}
out:
if (secoptlist != NULL)
(void) sa_destroy_optionset(secoptlist);
return (err);
}
/*
* nfs_disable_share(share)
*
* Unshare the specified share. How much error checking should be
* done? We only do basic errors for now.
*/
static int
nfs_disable_share(char *share)
{
int err;
if (err < 0) {
/* TBD: only an error in some cases - need better analysis */
switch (errno) {
case EPERM:
case EACCES:
if (getzoneid() != GLOBAL_ZONEID) {
}
break;
case EINVAL:
case ENOENT:
break;
default:
ret = SA_SYSTEM_ERR;
break;
}
}
/* just in case it was logged */
(void) nfslogtab_deactivate(share);
}
}
return (ret);
}
/*
* check ro vs rw values. Over time this may get beefed up.
* for now it just does simple checks.
*/
static int
{
return (ret);
}
/*
* nfs_validate_property(property, parent)
*
* Check that the property has a legitimate value for its type.
*/
static int
{
char *propname;
char *other;
int optindex;
char *value;
/* need to validate value range here as well */
}
}
/* first basic type checking */
case OPT_TYPE_NUMBER:
/* check that the value is all digits */
if (!is_a_number(value))
ret = SA_BAD_VALUE;
break;
case OPT_TYPE_BOOLEAN:
} else {
ret = SA_BAD_VALUE;
}
break;
case OPT_TYPE_USER:
if (!is_a_number(value)) {
/* in this case it would have to be a user name */
ret = SA_BAD_VALUE;
endpwent();
} else {
ret = SA_BAD_VALUE;
}
break;
case OPT_TYPE_FILE:
ret = SA_BAD_VALUE;
}
break;
case OPT_TYPE_ACCLIST:
/*
* access list handling. Should eventually
* validate that all the values make sense.
* Also, ro and rw may have cross value
* conflicts.
*/
else
/* compare rw(ro) with ro(rw) */
/* only potential confusion if other exists */
char *ovalue;
}
}
}
break;
case OPT_TYPE_LOGTAG:
if (nfsl_getconfig_list(&configlist) == 0) {
int error;
}
ret = SA_BAD_VALUE;
} else {
ret = SA_CONFIG_ERR;
}
break;
case OPT_TYPE_STRING:
/* whatever is here should be ok */
break;
default:
break;
}
/* do the property specific check */
}
}
}
return (ret);
}
/*
* Protocol management functions
*
* properties defined in the default files are defined in
* proto_option_defs for parsing and validation.
*/
struct proto_option_defs {
char *tag;
char *name; /* display name -- remove protocol identifier */
int index;
int type;
union {
int intval;
char *string;
} defvalue;
char *file;
int (*check)(char *);
} proto_options[] = {
#define PROTO_OPT_NFSD_SERVERS 0
{"nfsd_servers",
#define PROTO_OPT_LOCKD_LISTEN_BACKLOG 1
{"lockd_listen_backlog",
"lockd_listen_backlog", PROTO_OPT_LOCKD_LISTEN_BACKLOG,
#define PROTO_OPT_LOCKD_SERVERS 2
{"lockd_servers",
#define PROTO_OPT_LOCKD_RETRANSMIT_TIMEOUT 3
{"lockd_retransmit_timeout",
"lockd_retransmit_timeout", PROTO_OPT_LOCKD_RETRANSMIT_TIMEOUT,
#define PROTO_OPT_GRACE_PERIOD 4
{"grace_period",
#define PROTO_OPT_NFS_SERVER_VERSMIN 5
{"nfs_server_versmin",
#define PROTO_OPT_NFS_SERVER_VERSMAX 6
{"nfs_server_versmax",
#define PROTO_OPT_NFS_CLIENT_VERSMIN 7
{"nfs_client_versmin",
NFSADMIN},
#define PROTO_OPT_NFS_CLIENT_VERSMAX 8
{"nfs_client_versmax",
NFSADMIN},
#define PROTO_OPT_NFS_SERVER_DELEGATION 9
{"nfs_server_delegation",
"server_delegation", PROTO_OPT_NFS_SERVER_DELEGATION,
NFSADMIN},
#define PROTO_OPT_NFSMAPID_DOMAIN 10
{"nfsmapid_domain",
#define PROTO_OPT_NFSD_MAX_CONNECTIONS 11
{"nfsd_max_connections",
"max_connections", PROTO_OPT_NFSD_MAX_CONNECTIONS,
#define PROTO_OPT_NFSD_PROTOCOL 12
{"nfsd_protocol",
#define PROTO_OPT_NFSD_LISTEN_BACKLOG 13
{"nfsd_listen_backlog",
"listen_backlog", PROTO_OPT_NFSD_LISTEN_BACKLOG,
OPT_TYPE_NUMBER, 0,
{NULL}
};
/*
* the protoset holds the defined options so we don't have to read
* them multiple times
*/
static int
{
int i;
if (whichname == 1) {
return (i);
} else {
return (i);
}
}
return (-1);
}
/*
* fixcaselower(str)
*
* convert a string to lower case (inplace).
*/
static void
fixcaselower(char *str)
{
while (*str) {
str++;
}
}
/*
* fixcaseupper(str)
*
* convert a string to upper case (inplace).
*/
static void
fixcaseupper(char *str)
{
while (*str) {
str++;
}
}
/*
* initprotofromdefault()
*
* read the default file(s) and add the defined values to the
* protoset. Note that default values are known from the built in
* table in case the file doesn't have a definition.
*/
static int
{
char *name;
char *value;
int index;
switch (buff[0]) {
case '\n':
case '#':
/* skip */
break;
default:
*value++ = '\0';
value);
}
}
}
}
}
}
return (SA_NO_MEMORY);
return (SA_OK);
}
/*
* add_default()
*
* Add the default values for any property not defined in the parsing
* of the default files.
*/
static void
{
int i;
/* add the default value */
switch (proto_options[i].type) {
case OPT_TYPE_NUMBER:
break;
case OPT_TYPE_BOOLEAN:
"true" : "false");
break;
}
}
}
}
static void
{
}
/*
* nfs_init()
*
* Initialize the NFS plugin.
*/
static int
nfs_init()
{
ret = initprotofromdefault();
add_defaults();
return (ret);
}
/*
* nfs_fini()
*
* uninitialize the NFS plugin. Want to avoid memory leaks.
*/
static void
nfs_fini()
{
}
/*
* nfs_get_proto_set()
*
* Return an optionset with all the protocol specific properties in
* it.
*/
static sa_protocol_properties_t
{
return (protoset);
}
struct deffile {
char *line;
};
/*
* read_default_file(fname)
*
* Read the specified default file. We return a list of entries. This
* get used for adding or removing values.
*/
static struct deffile *
read_default_file(char *fname)
{
} else {
}
}
}
}
return (defs);
}
static void
{
}
}
/*
* write_default_file(fname, defs)
*
* Write the default file back.
*/
static int
{
}
} else {
switch (errno) {
case EPERM:
case EACCES:
break;
default:
ret = SA_SYSTEM_ERR;
}
}
return (ret);
}
/*
* set_default_file_value(tag, value)
*
* Set the default file value for tag to value. Then rewrite the file.
* tag and value are always set. The caller must ensure this.
*/
#define MAX_STRING_LENGTH 256
static int
{
char string[MAX_STRING_LENGTH];
int len;
int update = 0;
else
ret = SA_SYSTEM_ERR;
} else {
/* replace with the new value */
update = 1;
break;
}
}
if (!update) {
/* didn't find, so see if it is a comment */
/* replace with the new value */
update = 1;
break;
}
}
}
if (!update) {
}
}
if (update) {
}
}
return (ret);
}
/*
* restart_service(svcs)
*
* Walk through the bit mask of services that need to be restarted in
* order to use the new property values. Some properties affect
* multiple daemons.
*/
static void
{
case SVC_LOCKD:
(void) smf_restart_instance(LOCKD);
break;
case SVC_STATD:
(void) smf_restart_instance(STATD);
break;
case SVC_NFSD:
(void) smf_restart_instance(NFSD);
break;
case SVC_MOUNTD:
(void) smf_restart_instance(MOUNTD);
break;
case SVC_NFS4CBD:
(void) smf_restart_instance(NFS4CBD);
break;
case SVC_NFSMAPID:
(void) smf_restart_instance(NFSMAPID);
break;
case SVC_RQUOTAD:
(void) smf_restart_instance(RQUOTAD);
break;
case SVC_NFSLOGD:
(void) smf_restart_instance(NFSLOGD);
break;
}
}
}
/*
* nfs_validate_proto_prop(index, name, value)
*
* Verify that the property specifed by name can take the new
* value. This is a sanity check to prevent bad values getting into
* the default files.
*/
static int
{
char *cp;
#ifdef lint
#endif
case OPT_TYPE_NUMBER:
if (!is_a_number(value))
ret = SA_BAD_VALUE;
else {
int val;
ret = SA_BAD_VALUE;
}
break;
case OPT_TYPE_DOMAIN:
/*
* needs to be a qualified domain so will have at least
* one period and other characters on either side of it.
*/
ret = SA_BAD_VALUE;
break;
case OPT_TYPE_BOOLEAN:
} else {
ret = SA_BAD_VALUE;
}
break;
case OPT_TYPE_ONOFF:
ret = SA_BAD_VALUE;
}
break;
case OPT_TYPE_PROTOCOL:
ret = SA_BAD_VALUE;
}
return (ret);
}
/*
* nfs_set_proto_prop(prop)
*
* check that prop is valid.
*/
static int
{
char *name;
char *value;
if (index >= 0) {
/* should test for valid value */
value);
}
}
return (ret);
}
/*
* nfs_get_status()
*
* What is the current status of the nfsd? We use the SMF state here.
* Caller must free the returned value.
*/
static char *
{
char *state;
}
/*
* nfs_space_alias(alias)
*
* Lookup the space (security) name. If it is default, convert to the
* real name.
*/
static char *
nfs_space_alias(char *space)
{
if (nfs_getseconfig_default(&secconf) == 0) {
}
}