17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52c65c8b0Srm  * Common Development and Distribution License (the "License").
62c65c8b0Srm  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22f6e214c7SGavin Maltby  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	_LIBRESTART_H
267c478bd9Sstevel@tonic-gate #define	_LIBRESTART_H
277c478bd9Sstevel@tonic-gate 
282c65c8b0Srm #include <libsysevent.h>
297c478bd9Sstevel@tonic-gate #include <libcontract.h>
307c478bd9Sstevel@tonic-gate #include <libscf.h>
317c478bd9Sstevel@tonic-gate #include <limits.h>
327c478bd9Sstevel@tonic-gate #include <priv.h>
337c478bd9Sstevel@tonic-gate #include <pwd.h>
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*d2a70789SRichard Lowe #include <sys/secflags.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * There are 3 parts to librestart.
437c478bd9Sstevel@tonic-gate  *	1) The event protocol from the master restarter to its delegates.
447c478bd9Sstevel@tonic-gate  *	2) A functional interface for updating the repository.
457c478bd9Sstevel@tonic-gate  *	3) Convenience functions for common restarter tasks.
467c478bd9Sstevel@tonic-gate  *
477c478bd9Sstevel@tonic-gate  * Event protocol
487c478bd9Sstevel@tonic-gate  *	We need a reliable event protocol, as there's no way to define
497c478bd9Sstevel@tonic-gate  *	restarter events as idempotent.
507c478bd9Sstevel@tonic-gate  *
517c478bd9Sstevel@tonic-gate  *	Currently using sysevent channels as the reliable event implementation.
527c478bd9Sstevel@tonic-gate  *	This could change if the implementation proves unsuitable, but
537c478bd9Sstevel@tonic-gate  *	the API defined here should abstract anything but a change in
547c478bd9Sstevel@tonic-gate  *	the fundamental event model.
557c478bd9Sstevel@tonic-gate  *
567c478bd9Sstevel@tonic-gate  *	We offer functions to tease apart the event rather than generic
577c478bd9Sstevel@tonic-gate  *	nvpair interfaces. This is because each event type has a well-
587c478bd9Sstevel@tonic-gate  *	defined set of fields.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate 
61eb1a3463STruong Nguyen /*
62eb1a3463STruong Nguyen  * Some of the functions have external contracted consumers, review contracts
63eb1a3463STruong Nguyen  * when making incompatible changes.
64eb1a3463STruong Nguyen  */
65eb1a3463STruong Nguyen 
667c478bd9Sstevel@tonic-gate typedef struct restarter_event_handle restarter_event_handle_t;
677c478bd9Sstevel@tonic-gate typedef struct restarter_event restarter_event_t;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef uint32_t restarter_event_type_t;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * Define an event protocol version. In theory, we could use this in
737c478bd9Sstevel@tonic-gate  * the future to support delegated restarters which use an older
747c478bd9Sstevel@tonic-gate  * protocol. In practice, increment RESTARTER_EVENT_VERSION whenever the
757c478bd9Sstevel@tonic-gate  * protocol might have changed.
767c478bd9Sstevel@tonic-gate  */
77f6e214c7SGavin Maltby #define	RESTARTER_EVENT_VERSION		5
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #define	RESTARTER_FLAG_DEBUG		1
807c478bd9Sstevel@tonic-gate 
81870ad75aSSean Wilcox #define	RESTARTER_ERRMSGSZ		1024
82870ad75aSSean Wilcox 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * Event types
857c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADD_INSTANCE
867c478bd9Sstevel@tonic-gate  *		responsible for a new (stopped) instance
877c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_REMOVE_INSTANCE
887c478bd9Sstevel@tonic-gate  *		no longer responsible for this instance; stop it and return
897c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ENABLE
907c478bd9Sstevel@tonic-gate  *		no guarantee that dependencies are met; see
917c478bd9Sstevel@tonic-gate  *		RESTARTER_EVENT_TYPE_START
927c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_DISABLE
937c478bd9Sstevel@tonic-gate  *		no guarantee that instance was running
947c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_DEGRADED
957c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_REFRESH
967c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_RESTART
977c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
987c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON
997c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE
1007c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF
1017c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_STOP
1027c478bd9Sstevel@tonic-gate  *		dependencies are, or are becoming, unsatisfied
1037c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_START
1047c478bd9Sstevel@tonic-gate  *		dependencies have become satisfied
1057c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE
1067c478bd9Sstevel@tonic-gate  *		instance caused a dependency cycle
1077c478bd9Sstevel@tonic-gate  *	RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY
1087c478bd9Sstevel@tonic-gate  *		instance has an invalid dependency
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_INVALID			0
1127c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADD_INSTANCE		1
1137c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_REMOVE_INSTANCE		2
1147c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ENABLE			3
1157c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_DISABLE			4
1167c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_DEGRADED		5
1177c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_REFRESH		6
1187c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_RESTART		7
1197c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_MAINT_OFF		8
1207c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON		9
1217c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_MAINT_ON_IMMEDIATE	10
1227c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_STOP			11
1237c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_START			12
1247c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_DEPENDENCY_CYCLE		13
1257c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_INVALID_DEPENDENCY		14
1267c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_TYPE_ADMIN_DISABLE		15
12716ba0facSSean Wilcox #define	RESTARTER_EVENT_TYPE_STOP_RESET			16
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_ERROR			-1
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_INSTANCE_DISABLED	0
1327c478bd9Sstevel@tonic-gate #define	RESTARTER_EVENT_INSTANCE_ENABLED	1
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate typedef enum {
1357c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_NONE,
1367c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_UNINIT,
1377c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_MAINT,
1387c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_OFFLINE,
1397c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_DISABLED,
1407c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_ONLINE,
1417c478bd9Sstevel@tonic-gate 	RESTARTER_STATE_DEGRADED
1427c478bd9Sstevel@tonic-gate } restarter_instance_state_t;
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate /*
1457c478bd9Sstevel@tonic-gate  * These values are ordered by severity of required restart, as we use
1467c478bd9Sstevel@tonic-gate  * integer comparisons to determine error flow.
1477c478bd9Sstevel@tonic-gate  */
1487c478bd9Sstevel@tonic-gate typedef enum {
1497c478bd9Sstevel@tonic-gate 	RERR_UNSUPPORTED = -1,
1507c478bd9Sstevel@tonic-gate 	RERR_NONE = 0,			/* no error, restart, refresh */
1517c478bd9Sstevel@tonic-gate 	RERR_FAULT,			/* fault occurred */
1527c478bd9Sstevel@tonic-gate 	RERR_RESTART,			/* transition due to restart */
1537c478bd9Sstevel@tonic-gate 	RERR_REFRESH			/* transition due to refresh */
1547c478bd9Sstevel@tonic-gate } restarter_error_t;
1557c478bd9Sstevel@tonic-gate /*
1567c478bd9Sstevel@tonic-gate  * restarter_store_contract() and restarter_remove_contract() types
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate typedef enum {
1597c478bd9Sstevel@tonic-gate 	RESTARTER_CONTRACT_PRIMARY,
1607c478bd9Sstevel@tonic-gate 	RESTARTER_CONTRACT_TRANSIENT
1617c478bd9Sstevel@tonic-gate } restarter_contract_type_t;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * restarter_bind_handle() registers a delegate with svc.startd to
1657c478bd9Sstevel@tonic-gate  * begin consuming events.
1667c478bd9Sstevel@tonic-gate  *
1677c478bd9Sstevel@tonic-gate  * On initial bind, the delgated restarter receives an event for each
1687c478bd9Sstevel@tonic-gate  * instance it is responsible for, as if that instance was new.
1697c478bd9Sstevel@tonic-gate  *
1707c478bd9Sstevel@tonic-gate  * callers must have superuser privileges
1717c478bd9Sstevel@tonic-gate  *
1727c478bd9Sstevel@tonic-gate  * The event handler can return 0 for success, or EAGAIN to request
1737c478bd9Sstevel@tonic-gate  * retry of event delivery. EAGAIN may be returned 3 times before the
1747c478bd9Sstevel@tonic-gate  * event is discarded.
1757c478bd9Sstevel@tonic-gate  */
1767c478bd9Sstevel@tonic-gate int restarter_bind_handle(uint32_t, const char *,
1777c478bd9Sstevel@tonic-gate     int (*event_handler)(restarter_event_t *), int,
1787c478bd9Sstevel@tonic-gate     restarter_event_handle_t **);
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate restarter_event_type_t restarter_event_get_type(restarter_event_t *);
1817c478bd9Sstevel@tonic-gate uint64_t restarter_event_get_seq(restarter_event_t *);
1827c478bd9Sstevel@tonic-gate void restarter_event_get_time(restarter_event_t *, hrtime_t *);
1837c478bd9Sstevel@tonic-gate ssize_t restarter_event_get_instance(restarter_event_t *, char *, size_t);
1847c478bd9Sstevel@tonic-gate restarter_event_handle_t *restarter_event_get_handle(restarter_event_t *);
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate /*
1877c478bd9Sstevel@tonic-gate  * The following functions work only on certain types of events.
1887c478bd9Sstevel@tonic-gate  * They fail with a return of -1 if they're called on an inappropriate event.
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate int restarter_event_get_enabled(restarter_event_t *);
1917c478bd9Sstevel@tonic-gate int restarter_event_get_current_states(restarter_event_t *,
1927c478bd9Sstevel@tonic-gate     restarter_instance_state_t *, restarter_instance_state_t *);
1937c478bd9Sstevel@tonic-gate 
194f6e214c7SGavin Maltby /*
195f6e214c7SGavin Maltby  * State transition reasons
196f6e214c7SGavin Maltby  */
197f6e214c7SGavin Maltby 
198f6e214c7SGavin Maltby typedef enum {
199f6e214c7SGavin Maltby 	restarter_str_none,
200f6e214c7SGavin Maltby 	restarter_str_administrative_request,
201f6e214c7SGavin Maltby 	restarter_str_bad_repo_state,
202f6e214c7SGavin Maltby 	restarter_str_clear_request,
203f6e214c7SGavin Maltby 	restarter_str_ct_ev_core,
204f6e214c7SGavin Maltby 	restarter_str_ct_ev_exit,
205f6e214c7SGavin Maltby 	restarter_str_ct_ev_hwerr,
206f6e214c7SGavin Maltby 	restarter_str_ct_ev_signal,
207f6e214c7SGavin Maltby 	restarter_str_dependencies_satisfied,
208f6e214c7SGavin Maltby 	restarter_str_dependency_activity,
209f6e214c7SGavin Maltby 	restarter_str_dependency_cycle,
210f6e214c7SGavin Maltby 	restarter_str_disable_request,
211f6e214c7SGavin Maltby 	restarter_str_enable_request,
212f6e214c7SGavin Maltby 	restarter_str_fault_threshold_reached,
213f6e214c7SGavin Maltby 	restarter_str_insert_in_graph,
214f6e214c7SGavin Maltby 	restarter_str_invalid_dependency,
215f6e214c7SGavin Maltby 	restarter_str_invalid_restarter,
216f6e214c7SGavin Maltby 	restarter_str_method_failed,
217f6e214c7SGavin Maltby 	restarter_str_per_configuration,
218f6e214c7SGavin Maltby 	restarter_str_refresh,
219f6e214c7SGavin Maltby 	restarter_str_restart_request,
220f6e214c7SGavin Maltby 	restarter_str_restarting_too_quickly,
221f6e214c7SGavin Maltby 	restarter_str_service_request,
222f6e214c7SGavin Maltby 	restarter_str_startd_restart
223f6e214c7SGavin Maltby } restarter_str_t;
224f6e214c7SGavin Maltby 
225f6e214c7SGavin Maltby struct restarter_state_transition_reason {
226f6e214c7SGavin Maltby 	restarter_str_t	str_key;
227f6e214c7SGavin Maltby 	const char	*str_short;
228f6e214c7SGavin Maltby 	const char	*str_long;
229f6e214c7SGavin Maltby };
230f6e214c7SGavin Maltby 
2317c478bd9Sstevel@tonic-gate /*
2327c478bd9Sstevel@tonic-gate  * Functions for updating the repository.
2337c478bd9Sstevel@tonic-gate  */
234eb1a3463STruong Nguyen 
235eb1a3463STruong Nguyen /*
236eb1a3463STruong Nguyen  * When setting state to "maintenance", callers of restarter_set_states() can
237eb1a3463STruong Nguyen  * set aux_state to "service_request" to communicate that another service has
238eb1a3463STruong Nguyen  * requested maintenance state for the target service.
239eb1a3463STruong Nguyen  *
240eb1a3463STruong Nguyen  * Callers should use restarter_inst_validate_aux_fmri() to validate the fmri
241eb1a3463STruong Nguyen  * of the requested service and pass "service_request" for aux_state when
242eb1a3463STruong Nguyen  * calling restarter_set_states(). See inetd and startd for examples.
243eb1a3463STruong Nguyen  */
2447c478bd9Sstevel@tonic-gate int restarter_set_states(restarter_event_handle_t *, const char *,
2457c478bd9Sstevel@tonic-gate     restarter_instance_state_t, restarter_instance_state_t,
2467c478bd9Sstevel@tonic-gate     restarter_instance_state_t, restarter_instance_state_t, restarter_error_t,
247f6e214c7SGavin Maltby     restarter_str_t);
2482c65c8b0Srm int restarter_event_publish_retry(evchan_t *, const char *, const char *,
2492c65c8b0Srm     const char *, const char *, nvlist_t *, uint32_t);
2507c478bd9Sstevel@tonic-gate 
251f6e214c7SGavin Maltby /*
252f6e214c7SGavin Maltby  * functions for retrieving the state transition reason messages
253f6e214c7SGavin Maltby  */
254f6e214c7SGavin Maltby 
255f6e214c7SGavin Maltby #define	RESTARTER_STRING_VERSION	1
256f6e214c7SGavin Maltby 
257f6e214c7SGavin Maltby uint32_t restarter_str_version(void);
258f6e214c7SGavin Maltby const char *restarter_get_str_short(restarter_str_t);
259f6e214c7SGavin Maltby const char *restarter_get_str_long(restarter_str_t);
260f6e214c7SGavin Maltby 
2617c478bd9Sstevel@tonic-gate int restarter_store_contract(scf_instance_t *, ctid_t,
2627c478bd9Sstevel@tonic-gate     restarter_contract_type_t);
2637c478bd9Sstevel@tonic-gate int restarter_remove_contract(scf_instance_t *, ctid_t,
2647c478bd9Sstevel@tonic-gate     restarter_contract_type_t);
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate ssize_t restarter_state_to_string(restarter_instance_state_t, char *, size_t);
2677c478bd9Sstevel@tonic-gate restarter_instance_state_t restarter_string_to_state(char *);
2687c478bd9Sstevel@tonic-gate 
269*d2a70789SRichard Lowe #define	RESTARTER_METHOD_CONTEXT_VERSION	8
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate struct method_context {
2727c478bd9Sstevel@tonic-gate 	/* Stable */
2737c478bd9Sstevel@tonic-gate 	uid_t		uid, euid;
2747c478bd9Sstevel@tonic-gate 	gid_t		gid, egid;
2757c478bd9Sstevel@tonic-gate 	int		ngroups;		/* -1 means use initgroups(). */
27613d8aaa1SSean Wilcox 	gid_t		groups[NGROUPS_MAX];
277*d2a70789SRichard Lowe 	scf_secflags_t	def_secflags;
278*d2a70789SRichard Lowe 	secflagdelta_t	secflag_delta;
2797c478bd9Sstevel@tonic-gate 	priv_set_t	*lpriv_set, *priv_set;
2807c478bd9Sstevel@tonic-gate 	char		*corefile_pattern;	/* Optional. */
2817c478bd9Sstevel@tonic-gate 	char		*project;		/* NULL for no change */
2827c478bd9Sstevel@tonic-gate 	char		*resource_pool;		/* NULL for project default */
2837c478bd9Sstevel@tonic-gate 	char		*working_dir;		/* NULL for :default */
2847c478bd9Sstevel@tonic-gate 	char		**env;			/* NULL for no env */
2857c478bd9Sstevel@tonic-gate 	size_t		env_sz;			/* size of env array */
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate 	/* Private */
2887c478bd9Sstevel@tonic-gate 	char		*vbuf;
2897c478bd9Sstevel@tonic-gate 	ssize_t		vbuf_sz;
2907c478bd9Sstevel@tonic-gate 	struct passwd	pwd;
2917c478bd9Sstevel@tonic-gate 	char		*pwbuf;
2927c478bd9Sstevel@tonic-gate 	ssize_t		pwbufsz;
2937c478bd9Sstevel@tonic-gate };
2947c478bd9Sstevel@tonic-gate 
295870ad75aSSean Wilcox /*
296870ad75aSSean Wilcox  * An error structure that contains a message string, and a type
297870ad75aSSean Wilcox  * that can be used to determine course of action by the reciever
298870ad75aSSean Wilcox  * of the error structure.
299870ad75aSSean Wilcox  *
300870ad75aSSean Wilcox  * type - usually will be an errno equivalent but could contain
301870ad75aSSean Wilcox  * 	defined error types for exampe SCF_ERROR_XXX
302870ad75aSSean Wilcox  * msg - must be at the end of the structure as if the message is
303870ad75aSSean Wilcox  * 	longer than EMSGSIZE we will reallocate the structure to
304870ad75aSSean Wilcox  * 	handle the overflow
305870ad75aSSean Wilcox  */
306870ad75aSSean Wilcox typedef struct mc_error {
307870ad75aSSean Wilcox 	int	destroy;	/* Flag to indicate destruction steps */
308870ad75aSSean Wilcox 	int	type;		/* Type of error for decision making */
309870ad75aSSean Wilcox 	int	size;		/* The size of the error message string */
310870ad75aSSean Wilcox 	char 	msg[RESTARTER_ERRMSGSZ];
311870ad75aSSean Wilcox } mc_error_t;
312870ad75aSSean Wilcox 
3137c478bd9Sstevel@tonic-gate int restarter_rm_libs_loadable(void);
3147c478bd9Sstevel@tonic-gate /* instance, restarter name, method name, command line, structure pointer */
315870ad75aSSean Wilcox mc_error_t *restarter_get_method_context(uint_t, scf_instance_t *,
3167c478bd9Sstevel@tonic-gate     scf_snapshot_t *, const char *, const char *, struct method_context **);
317870ad75aSSean Wilcox void restarter_mc_error_destroy(mc_error_t *);
3187c478bd9Sstevel@tonic-gate int restarter_set_method_context(struct method_context *, const char **);
3197c478bd9Sstevel@tonic-gate void restarter_free_method_context(struct method_context *);
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate int restarter_is_null_method(const char *);
3237c478bd9Sstevel@tonic-gate int restarter_is_kill_method(const char *);
3247c478bd9Sstevel@tonic-gate int restarter_is_kill_proc_method(const char *);
3257c478bd9Sstevel@tonic-gate 
326eb1a3463STruong Nguyen /* Validate the inst fmri specified in  restarter_actions/auxiliary_fmri */
327eb1a3463STruong Nguyen int restarter_inst_validate_ractions_aux_fmri(scf_instance_t *);
328eb1a3463STruong Nguyen 
329eb1a3463STruong Nguyen /* Delete instance's restarter_actions/auxiliary_fmri property */
330eb1a3463STruong Nguyen int restarter_inst_reset_ractions_aux_fmri(scf_instance_t *);
331eb1a3463STruong Nguyen 
332eb1a3463STruong Nguyen /* Get boolean value from instance's restarter_actions/auxiliary_tty */
333eb1a3463STruong Nguyen int restarter_inst_ractions_from_tty(scf_instance_t *);
334eb1a3463STruong Nguyen 
335eb1a3463STruong Nguyen /* Delete instance's restarter/auxiliary_fmri property */
336eb1a3463STruong Nguyen int restarter_inst_reset_aux_fmri(scf_instance_t *);
337eb1a3463STruong Nguyen 
338ac0324d2SJerry Jelinek /* Get boolean value from instance's restarter_actions/do_dump */
339ac0324d2SJerry Jelinek int restarter_inst_dump(scf_instance_t *);
340ac0324d2SJerry Jelinek 
341eb1a3463STruong Nguyen /*
342eb1a3463STruong Nguyen  * Set instance's restarter/auxiliary_fmri, value come from
343eb1a3463STruong Nguyen  * restarter_actions/auxliary_fmri
344eb1a3463STruong Nguyen  */
345eb1a3463STruong Nguyen int restarter_inst_set_aux_fmri(scf_instance_t *);
346eb1a3463STruong Nguyen 
3477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3487c478bd9Sstevel@tonic-gate }
3497c478bd9Sstevel@tonic-gate #endif
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate #endif	/* _LIBRESTART_H */
352