15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #ifndef _LIBRESTART_H
26 #define _LIBRESTART_H
27
28 #include <libsysevent.h>
29 #include <libcontract.h>
30 #include <libscf.h>
31 #include <limits.h>
32 #include <priv.h>
33 #include <pwd.h>
34 #include <sys/types.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /*
41 * There are 3 parts to librestart.
42 * 1) The event protocol from the master restarter to its delegates.
43 * 2) A functional interface for updating the repository.
44 * 3) Convenience functions for common restarter tasks.
45 *
46 * Event protocol
47 * We need a reliable event protocol, as there's no way to define
48 * restarter events as idempotent.
49 *
50 * Currently using sysevent channels as the reliable event implementation.
51 * This could change if the implementation proves unsuitable, but
52 * the API defined here should abstract anything but a change in
53 * the fundamental event model.
54 *
248 const char *, const char *, nvlist_t *, uint32_t);
249
250 /*
251 * functions for retrieving the state transition reason messages
252 */
253
254 #define RESTARTER_STRING_VERSION 1
255
256 uint32_t restarter_str_version(void);
257 const char *restarter_get_str_short(restarter_str_t);
258 const char *restarter_get_str_long(restarter_str_t);
259
260 int restarter_store_contract(scf_instance_t *, ctid_t,
261 restarter_contract_type_t);
262 int restarter_remove_contract(scf_instance_t *, ctid_t,
263 restarter_contract_type_t);
264
265 ssize_t restarter_state_to_string(restarter_instance_state_t, char *, size_t);
266 restarter_instance_state_t restarter_string_to_state(char *);
267
268 #define RESTARTER_METHOD_CONTEXT_VERSION 7
269
270 struct method_context {
271 /* Stable */
272 uid_t uid, euid;
273 gid_t gid, egid;
274 int ngroups; /* -1 means use initgroups(). */
275 gid_t groups[NGROUPS_MAX];
276 priv_set_t *lpriv_set, *priv_set;
277 char *corefile_pattern; /* Optional. */
278 char *project; /* NULL for no change */
279 char *resource_pool; /* NULL for project default */
280 char *working_dir; /* NULL for :default */
281 char **env; /* NULL for no env */
282 size_t env_sz; /* size of env array */
283
284 /* Private */
285 char *vbuf;
286 ssize_t vbuf_sz;
287 struct passwd pwd;
288 char *pwbuf;
289 ssize_t pwbufsz;
290 };
291
292 /*
293 * An error structure that contains a message string, and a type
294 * that can be used to determine course of action by the reciever
295 * of the error structure.
|
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #ifndef _LIBRESTART_H
26 #define _LIBRESTART_H
27
28 #include <libsysevent.h>
29 #include <libcontract.h>
30 #include <libscf.h>
31 #include <limits.h>
32 #include <priv.h>
33 #include <pwd.h>
34 #include <sys/types.h>
35 #include <sys/secflags.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /*
42 * There are 3 parts to librestart.
43 * 1) The event protocol from the master restarter to its delegates.
44 * 2) A functional interface for updating the repository.
45 * 3) Convenience functions for common restarter tasks.
46 *
47 * Event protocol
48 * We need a reliable event protocol, as there's no way to define
49 * restarter events as idempotent.
50 *
51 * Currently using sysevent channels as the reliable event implementation.
52 * This could change if the implementation proves unsuitable, but
53 * the API defined here should abstract anything but a change in
54 * the fundamental event model.
55 *
249 const char *, const char *, nvlist_t *, uint32_t);
250
251 /*
252 * functions for retrieving the state transition reason messages
253 */
254
255 #define RESTARTER_STRING_VERSION 1
256
257 uint32_t restarter_str_version(void);
258 const char *restarter_get_str_short(restarter_str_t);
259 const char *restarter_get_str_long(restarter_str_t);
260
261 int restarter_store_contract(scf_instance_t *, ctid_t,
262 restarter_contract_type_t);
263 int restarter_remove_contract(scf_instance_t *, ctid_t,
264 restarter_contract_type_t);
265
266 ssize_t restarter_state_to_string(restarter_instance_state_t, char *, size_t);
267 restarter_instance_state_t restarter_string_to_state(char *);
268
269 #define RESTARTER_METHOD_CONTEXT_VERSION 8
270
271 struct method_context {
272 /* Stable */
273 uid_t uid, euid;
274 gid_t gid, egid;
275 int ngroups; /* -1 means use initgroups(). */
276 gid_t groups[NGROUPS_MAX];
277 psecflags_t def_secflags;
278 secflagdelta_t secflag_delta;
279 priv_set_t *lpriv_set, *priv_set;
280 char *corefile_pattern; /* Optional. */
281 char *project; /* NULL for no change */
282 char *resource_pool; /* NULL for project default */
283 char *working_dir; /* NULL for :default */
284 char **env; /* NULL for no env */
285 size_t env_sz; /* size of env array */
286
287 /* Private */
288 char *vbuf;
289 ssize_t vbuf_sz;
290 struct passwd pwd;
291 char *pwbuf;
292 ssize_t pwbufsz;
293 };
294
295 /*
296 * An error structure that contains a message string, and a type
297 * that can be used to determine course of action by the reciever
298 * of the error structure.
|