librestart.h revision 870ad75a2b67a92c3449d93b4fef8a0baa982b4a
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The contents of this file are subject to the terms of the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Common Development and Distribution License (the "License").
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You may not use this file except in compliance with the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * or http://www.opensolaris.org/os/licensing.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * See the License for the specific language governing permissions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and limitations under the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * When distributing Covered Code, include this CDDL HEADER in each
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * If applicable, add the following below this CDDL HEADER, with the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * fields enclosed by brackets "[]" replaced with your own identifying
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * information: Portions Copyright [yyyy] [name of copyright owner]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER END
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
07925104db56e5c3eacc4865b918bd16af5cec59gww * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Use is subject to license terms.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifndef _LIBRESTART_H
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _LIBRESTART_H
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <libsysevent.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <libcontract.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <libscf.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <limits.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <priv.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <pwd.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <sys/types.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifdef __cplusplus
cb5caa98562cf06753163f558cbcfe30b8f4673adjlextern "C" {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * There are 3 parts to librestart.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 1) The event protocol from the master restarter to its delegates.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 2) A functional interface for updating the repository.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * 3) Convenience functions for common restarter tasks.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Event protocol
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * We need a reliable event protocol, as there's no way to define
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * restarter events as idempotent.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Currently using sysevent channels as the reliable event implementation.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * This could change if the implementation proves unsuitable, but
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the API defined here should abstract anything but a change in
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the fundamental event model.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * We offer functions to tease apart the event rather than generic
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * nvpair interfaces. This is because each event type has a well-
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * defined set of fields.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Some of the functions have external contracted consumers, review contracts
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * when making incompatible changes.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct restarter_event_handle restarter_event_handle_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef struct restarter_event restarter_event_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef uint32_t restarter_event_type_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Define an event protocol version. In theory, we could use this in
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * the future to support delegated restarters which use an older
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * protocol. In practice, increment RESTARTER_EVENT_VERSION whenever the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * protocol might have changed.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_VERSION 4
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_FLAG_DEBUG 1
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_ERRMSGSZ 1024
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Event types
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADD_INSTANCE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * responsible for a new (stopped) instance
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_REMOVE_INSTANCE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * no longer responsible for this instance; stop it and return
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ENABLE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * no guarantee that dependencies are met; see
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_DISABLE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * no guarantee that instance was running
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_DEGRADED
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_REFRESH
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_RESTART
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_STOP
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * dependencies are, or are becoming, unsatisfied
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * dependencies have become satisfied
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * instance caused a dependency cycle
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * instance has an invalid dependency
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_INVALID 0
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADD_INSTANCE 1
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_REMOVE_INSTANCE 2
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ENABLE 3
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_DISABLE 4
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_DEGRADED 5
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_REFRESH 6
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_RESTART 7
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF 8
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON 9
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE 10
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_STOP 11
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_START 12
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE 13
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY 14
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_TYPE_ADMIN_DISABLE 15
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_ERROR -1
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_INSTANCE_DISABLED 0
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_EVENT_INSTANCE_ENABLED 1
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef enum {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_NONE,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_UNINIT,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_MAINT,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_OFFLINE,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_DISABLED,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_ONLINE,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_STATE_DEGRADED
cb5caa98562cf06753163f558cbcfe30b8f4673adjl} restarter_instance_state_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * These values are ordered by severity of required restart, as we use
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * integer comparisons to determine error flow.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef enum {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RERR_UNSUPPORTED = -1,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RERR_NONE = 0, /* no error, restart, refresh */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RERR_FAULT, /* fault occurred */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RERR_RESTART, /* transition due to restart */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RERR_REFRESH /* transition due to refresh */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl} restarter_error_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * restarter_store_contract() and restarter_remove_contract() types
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjltypedef enum {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_CONTRACT_PRIMARY,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl RESTARTER_CONTRACT_TRANSIENT
cb5caa98562cf06753163f558cbcfe30b8f4673adjl} restarter_contract_type_t;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * restarter_bind_handle() registers a delegate with svc.startd to
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * begin consuming events.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * On initial bind, the delgated restarter receives an event for each
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * instance it is responsible for, as if that instance was new.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * callers must have superuser privileges
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The event handler can return 0 for success, or EAGAIN to request
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * retry of event delivery. EAGAIN may be returned 3 times before the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * event is discarded.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_bind_handle(uint32_t, const char *,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int (*event_handler)(restarter_event_t *), int,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl restarter_event_handle_t **);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlrestarter_event_type_t restarter_event_get_type(restarter_event_t *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjluint64_t restarter_event_get_seq(restarter_event_t *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlvoid restarter_event_get_time(restarter_event_t *, hrtime_t *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlssize_t restarter_event_get_instance(restarter_event_t *, char *, size_t);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlrestarter_event_handle_t *restarter_event_get_handle(restarter_event_t *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The following functions work only on certain types of events.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * They fail with a return of -1 if they're called on an inappropriate event.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_event_get_enabled(restarter_event_t *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_event_get_current_states(restarter_event_t *,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl restarter_instance_state_t *, restarter_instance_state_t *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Functions for updating the repository.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * When setting state to "maintenance", callers of restarter_set_states() can
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * set aux_state to "service_request" to communicate that another service has
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * requested maintenance state for the target service.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Callers should use restarter_inst_validate_aux_fmri() to validate the fmri
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * of the requested service and pass "service_request" for aux_state when
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * calling restarter_set_states(). See inetd and startd for examples.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_set_states(restarter_event_handle_t *, const char *,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl restarter_instance_state_t, restarter_instance_state_t,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl restarter_instance_state_t, restarter_instance_state_t, restarter_error_t,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl const char *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_event_publish_retry(evchan_t *, const char *, const char *,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl const char *, const char *, nvlist_t *, uint32_t);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_store_contract(scf_instance_t *, ctid_t,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl restarter_contract_type_t);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint restarter_remove_contract(scf_instance_t *, ctid_t,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl restarter_contract_type_t);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlssize_t restarter_state_to_string(restarter_instance_state_t, char *, size_t);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlrestarter_instance_state_t restarter_string_to_state(char *);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define RESTARTER_METHOD_CONTEXT_VERSION 7
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlstruct method_context {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* Stable */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl uid_t uid, euid;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl gid_t gid, egid;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int ngroups; /* -1 means use initgroups(). */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl gid_t groups[NGROUPS_MAX];
cb5caa98562cf06753163f558cbcfe30b8f4673adjl priv_set_t *lpriv_set, *priv_set;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *corefile_pattern; /* Optional. */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *project; /* NULL for no change */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *resource_pool; /* NULL for project default */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *working_dir; /* NULL for :default */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char **env; /* NULL for no env */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl size_t env_sz; /* size of env array */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl /* Private */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *vbuf;
07925104db56e5c3eacc4865b918bd16af5cec59gww ssize_t vbuf_sz;
07925104db56e5c3eacc4865b918bd16af5cec59gww struct passwd pwd;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl char *pwbuf;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ssize_t pwbufsz;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl};
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
* An error structure that contains a message string, and a type
* that can be used to determine course of action by the reciever
* of the error structure.
*
* type - usually will be an errno equivalent but could contain
* defined error types for exampe SCF_ERROR_XXX
* msg - must be at the end of the structure as if the message is
* longer than EMSGSIZE we will reallocate the structure to
* handle the overflow
*/
typedef struct mc_error {
int destroy; /* Flag to indicate destruction steps */
int type; /* Type of error for decision making */
int size; /* The size of the error message string */
char msg[RESTARTER_ERRMSGSZ];
} mc_error_t;
int restarter_rm_libs_loadable(void);
/* instance, restarter name, method name, command line, structure pointer */
mc_error_t *restarter_get_method_context(uint_t, scf_instance_t *,
scf_snapshot_t *, const char *, const char *, struct method_context **);
void restarter_mc_error_destroy(mc_error_t *);
int restarter_set_method_context(struct method_context *, const char **);
void restarter_free_method_context(struct method_context *);
int restarter_is_null_method(const char *);
int restarter_is_kill_method(const char *);
int restarter_is_kill_proc_method(const char *);
/* Validate the inst fmri specified in restarter_actions/auxiliary_fmri */
int restarter_inst_validate_ractions_aux_fmri(scf_instance_t *);
/* Delete instance's restarter_actions/auxiliary_fmri property */
int restarter_inst_reset_ractions_aux_fmri(scf_instance_t *);
/* Get boolean value from instance's restarter_actions/auxiliary_tty */
int restarter_inst_ractions_from_tty(scf_instance_t *);
/* Delete instance's restarter/auxiliary_fmri property */
int restarter_inst_reset_aux_fmri(scf_instance_t *);
/*
* Set instance's restarter/auxiliary_fmri, value come from
* restarter_actions/auxliary_fmri
*/
int restarter_inst_set_aux_fmri(scf_instance_t *);
#ifdef __cplusplus
}
#endif
#endif /* _LIBRESTART_H */