/*
* 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
*/
/*
*/
/*
* AUTOMOUNT 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 <fcntl.h>
#include <syslog.h>
#include <pwd.h>
#include <limits.h>
#include <libscf.h>
#include <strings.h>
#include <libdlpi.h>
#include <libshare.h>
#include <libshare_impl.h>
#include "smfcfg.h"
/*
* protocol plugin op routines
*/
static int sa_autofs_init(void);
static void sa_autofs_fini(void);
/* protocol property op routines */
static int sa_autofs_proto_get_features(uint64_t *);
static int sa_autofs_proto_get_proplist(nvlist_t **);
static int sa_autofs_proto_get_status(char **);
static int sa_autofs_proto_get_property(const char *, const char *, char **);
static int sa_autofs_proto_set_property(const char *, const char *,
const char *);
/* protocol property validator routines */
static int range_check_validator(int, char *);
static int true_false_validator(int, char *);
static int strlen_validator(int, char *);
static void autofs_free_proto_proplist(void);
.sap_hdr = {
.pi_name = "autofs",
.pi_flags = 0,
},
.sap_share_parse = NULL,
.sap_share_merge = NULL,
.sap_fs_publish = NULL,
.sap_fs_unpublish = NULL,
};
#define AUTOMOUNT_VERBOSE_DEFAULT 0
#define AUTOMOUNTD_VERBOSE_DEFAULT 0
#define AUTOMOUNT_NOBROWSE_DEFAULT 0
#define AUTOMOUNT_TRACE_DEFAULT 0
/*
* Protocol Management functions
*/
struct proto_option_defs {
char *tag;
int index;
union {
int intval;
char *string;
} defvalue;
int (*validator)(int, char *);
} autofs_proto_options[] = {
#define PROTO_OPT_AUTOMOUNT_TIMEOUT 0
{ "timeout",
"timeout", PROTO_OPT_AUTOMOUNT_TIMEOUT,
{ "automount_verbose",
"automount_verbose", PROTO_OPT_AUTOMOUNT_VERBOSE,
{ "automountd_verbose",
"automountd_verbose", PROTO_OPT_AUTOMOUNTD_VERBOSE,
{ "nobrowse",
{ "trace",
"trace", PROTO_OPT_AUTOMOUNTD_TRACE,
0, 20, range_check_validator},
{ "environment",
};
static int
sa_autofs_init(void)
{
return (SA_OK);
}
static void
sa_autofs_fini(void)
{
}
/*
* service_in_state(service, chkstate)
*
* Want to know if the specified service is in the desired state
* (chkstate) or not. Return true (1) if it is and false (0) if it
* isn't.
*/
static int
{
char *state;
/* got the state so get the equality for the return value */
}
return (ret);
}
/*
* Only attempt to restart the service if it is
* currently running. In the future, it may be
* desirable to use smf_refresh_instance if the NFS
* services ever implement the refresh method.
*/
static void
autofs_restart_service(void)
{
/*
* There are only a few SMF errors at this point, but
* it is also possible that a bad value may have put
* the service into maintenance if there wasn't an
* SMF level error.
*/
if (ret != 0) {
"%s failed to restart: %s\n"),
} else {
/*
* Check whether it has gone to "maintenance"
* mode or not. Maintenance implies something
* went wrong.
*/
"%s failed to restart\n"), service);
}
}
}
}
static int
{
int i;
return (i);
return (-1);
}
static int
{
int hex = 0;
number += 2;
hex = 1;
} else if (*number == '-') {
number++; /* skip the minus */
}
if (hex) {
} else {
}
}
return (ret);
}
static int
{
if (!is_a_number(value)) {
} else {
int val;
}
return (ret);
}
/*ARGSUSED*/
static int
{
return (SA_OK);
}
return (SA_INVALID_PROP_VAL);
}
static int
{
return (SA_OK);
else
return (SA_INVALID_PROP_VAL);
}
return (SA_INVALID_PROP_VAL);
return (SA_OK);
}
/*
* autofs_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
{
return (SA_INVALID_PROP);
return (SA_OK);
}
static void
{
if (autofs_proto_proplist != NULL) {
}
}
static int
{
int ret;
return (SA_INVALID_PROP);
case SCF_TYPE_INTEGER:
break;
case SCF_TYPE_BOOLEAN:
else
break;
case SCF_TYPE_ASTRING:
break;
default:
return (SA_INVALID_PROP);
}
}
static int
{
int i;
int bufsz = 0;
return (SA_NO_MEMORY);
if (ret == 0) {
/* add property to list */
} else {
/* add default value to list */
ret = autofs_add_default_value(i);
}
if (ret != 0) {
return (SA_NO_MEMORY);
}
}
return (ret);
}
/*
* sa_autofs_get_features
*
* return supported features
*/
static int
{
return (SA_OK);
}
static int
{
int ret;
if (autofs_proto_proplist == NULL) {
return (ret);
}
}
return (SA_OK);
else
return (SA_NO_MEMORY);
}
/*
* sa_autofs_proto_get_status()
*
* What is the current status of the AUTOFS_DEFAULT_FMRI?
* We use the SMF state here.
* Caller must free the returned value.
*/
static int
{
if (*status_str == NULL &&
return (SA_NO_MEMORY);
else
return (SA_OK);
}
/*
* sa_autofs_proto_get_property
*/
/*ARGSUSED*/
static int
char **propval)
{
char *val;
if (autofs_proto_proplist == NULL) {
if (autofs_init_proto_proplist() != SA_OK) {
return (SA_NO_MEMORY);
}
}
return (SA_OK);
else
return (SA_NO_MEMORY);
} else {
return (SA_NO_SUCH_PROP);
}
}
/*
* sa_autofs_proto_set_property
*/
/*ARGSUSED*/
static int
const char *propval)
{
int index;
return (SA_INVALID_PROP);
return (SA_INVALID_PROP_VAL);
return (SA_INVALID_PROP);
/* test for valid value */
if (sctype == SCF_TYPE_BOOLEAN)
if (ret == 0) {
(void) autofs_init_proto_proplist();
} else {
ret = SA_SCF_ERROR;
}
}
return (ret);
}