/*
* 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 "libshare.h"
#include "libshare_impl.h"
#include <pwd.h>
#include <limits.h>
#include <libscf.h>
#include <strings.h>
#include <libdlpi.h>
#include "smfcfg.h"
static int autofs_init();
static void autofs_fini();
static int autofs_set_proto_prop(sa_property_t);
static sa_protocol_properties_t autofs_get_proto_set();
static char *autofs_get_status();
static uint64_t autofs_features();
static int initautofsprotofromsmf();
/*
* ops vector that provides the protocol specific info and operations
* for share management.
*/
"autofs",
autofs_init, /* Init autofs */
autofs_fini, /* Fini autofs */
NULL, /* Start Sharing */
NULL, /* stop sharing */
NULL, /* valid_space */
NULL, /* security_prop */
NULL, /* parse optstring */
NULL, /* format optstring */
autofs_set_proto_prop, /* Set properties */
autofs_get_proto_set, /* get properties */
autofs_get_status, /* get status */
NULL, /* space_alias */
NULL, /* update_legacy */
NULL, /* delete_legacy */
NULL, /* change notify */
NULL, /* enable resource */
NULL, /* disable resource */
autofs_features, /* features */
NULL, /* transient shares */
NULL, /* notify resource */
NULL, /* rename resource */
NULL, /* run_command */
NULL, /* command_help */
NULL /* delete_proto_section */
};
#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 (*check)(int, char *);
} 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 void
{
int i;
proto_options[i].name);
/* add the default value */
switch (proto_options[i].type) {
case SCF_TYPE_INTEGER:
number);
break;
case SCF_TYPE_BOOLEAN:
"true" : "false");
break;
default:
/* treat as strings of zero length */
"");
break;
}
}
}
}
static int
{
"AUTOFS plugin not installed properly\n"));
return (SA_CONFIG_ERR);
}
"AUTOFS plugin problem with SMF properties: %s\n"),
sa_errorstr(ret));
}
add_defaults();
return (ret);
}
static void
{
}
}
static void
{
}
static int
{
int i;
return (i);
return (-1);
}
static int
{
char *propname;
int optionindex;
char *value;
#ifdef lint
#endif
return (SA_NO_SUCH_PROP);
return (ret);
}
/*
* If any property is added to AUTOFS, which is a different
* type than the below list, a case needs to be added for that
* to check the values. For now AUTOFS type are just integers,
* string and boolean properties. Just taking care of them.
*/
case SCF_TYPE_INTEGER:
case SCF_TYPE_BOOLEAN:
case SCF_TYPE_ASTRING:
value);
break;
default:
break;
}
}
/* Free the value */
return (ret);
}
/*
* 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);
}
static void
{
/*
* 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 AUTOFS
* services ever implement the refresh method.
*/
/*
* 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"),
scf_strerror(scf_error()));
} else {
/*
* Check whether it has gone to "maintenance"
* mode or not. Maintenance implies something
* went wrong.
*/
if (service_in_state(service,
"%s failed to restart\n"),
service);
}
}
}
}
static int
{
int hex = 0;
number += 2;
hex = 1;
} else if (*number == '-') {
number++; /* skip the minus */
}
if (hex) {
} else {
}
}
return (ret);
}
/*
* fixcaselower(str)
*
* convert a string to lower case (inplace).
*/
static void
{
while (*str) {
str++;
}
}
/*
* skipwhitespace(str)
*
* Skip leading white space. It is assumed that it is called with a
* valid pointer.
*/
static char *
{
str++;
return (str);
}
/*
* extractprop()
*
* Extract the property and value out of the line and create the
* property in the optionset.
*/
static int
{
int index;
/*
* Remove any leading
* white space.
*/
if (index >= 0) {
else
ret = SA_NO_MEMORY;
}
return (ret);
}
static int
initautofsprotofromsmf(void)
{
}
}
} else {
ret = SA_NO_MEMORY;
}
return (ret);
}
static int
{
if (!is_a_number(value)) {
ret = SA_BAD_VALUE;
} else {
int val;
errno = 0;
if (errno != 0)
return (SA_BAD_VALUE);
ret = SA_BAD_VALUE;
}
return (ret);
}
static int
{
#ifdef lint
#endif
return (SA_OK);
}
return (SA_BAD_VALUE);
}
static int
{
return (ret);
} else {
return (SA_BAD_VALUE);
}
}
ret = SA_BAD_VALUE;
return (ret);
}
static int
{
#ifdef lint
#endif
}
static int
{
char *name;
if (index >= 0) {
if (sctype == SCF_TYPE_BOOLEAN) {
if (string_to_boolean(value) == 0)
else
}
/*
* Make an instance based FMRI.
* For now its DEFAULT_AUTOFS_FMRI.
*/
}
} else {
}
} else {
ret = SA_CONFIG_ERR;
}
return (ret);
}
static sa_protocol_properties_t
autofs_get_proto_set(void)
{
return (protoset);
}
static uint64_t
autofs_features(void)
{
return (0);
}
static char *
autofs_get_status(void)
{
return (smf_get_state(AUTOFS_DEFAULT_FMRI));
}