/*
* 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
*/
/*
*/
#include <libintl.h>
#include <librestart.h>
#include <librestart_priv.h>
#include <libscf.h>
#include <libscf_priv.h>
#include <assert.h>
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <exec_attr.h>
#include <grp.h>
#include <libsysevent.h>
#include <libuutil.h>
#include <limits.h>
#include <link.h>
#include <malloc.h>
#include <pool.h>
#include <priv.h>
#include <project.h>
#include <pthread.h>
#include <pwd.h>
#include <secdb.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <ucontext.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
/*
* bad_fail() catches bugs in this and lower layers by reporting supposedly
* impossible function failures. The NDEBUG case keeps the strings out of the
* library but still calls abort() so we can root-cause from the coredump.
*/
#ifndef NDEBUG
"At %s:%d, %s() failed with unexpected error %d. Aborting.\n", \
abort(); \
}
#else
#endif
struct restarter_event_handle {
char *reh_restarter_name;
char *reh_delegate_channel_name;
char *reh_delegate_subscriber_id;
char *reh_master_channel_name;
char *reh_master_subscriber_id;
};
struct restarter_event {
char *re_instance_name;
};
/*
*
* "A service instance transitioned state: %s."
* "A service failed: %s."
* "Reason: %s."
* "The service transitioned state (%s) and ..."
*
* With the exception of restart_str_none they must also fit the following
* moulds:
*
* "An instance transitioned because %s, and ..."
* "An instance transitioned to <new-state> because %s, and ..."
*
* Note that whoever is rendering the long message must provide the
* terminal punctuation - don't include it here. Similarly, do not
* provide an initial capital letter in reason-long.
*
* The long reason strings are Volatile - within the grammatical constraints
* above we may improve them as need be. The intention is that a consumer
* may blindly render the string along the lines of the above examples,
* but has no other guarantees as to the exact wording. Long reasons
* are localized.
*
* We define revisions of the set of short reason strings in use. Within
* a given revision, all short reasons are Committed. Consumers must check
* the revision in use before relying on the semantics of the short reason
* codes - if the version exceeds that which they are familiar with they should
* fail gracefully. Having checked for version compatibility, a consumer
* is assured that
*
* "short_reason_A iff semantic_A", provided:
*
* . the restarter uses this short reason code at all,
* . the short reason is not "none" (which a restarter could
* specifiy for any transition semantics)
*
* we are required to bump the revision number. This should be an
* infrequent occurence. If you bump the revision number you may
* need to make corresponding changes in any source that calls
* restarter_str_version (e.g., FMA event generation).
*
* To add additional reasons to the set you must also bump the version
* number.
*/
/*
* The following describes revision 1 of the set of transition reasons.
* Read the preceding block comment before making any changes.
*/
/*
* Any transition for which the restarter has not provided a reason.
*/
{
"none",
"the restarter gave no reason"
},
/*
* A transition to maintenance state due to a
* 'svcadm mark maintenance <fmri>'. *Not* used if the libscf
* interface smf_maintain_instance(3SCF) is used to request maintenance.
*/
{
"administrative_request",
"maintenance was requested by an administrator"
},
/*
* A transition to maintenance state if a repository inconsistency
* into the graph engine (this can also happen during startd restart).
*/
{
"bad_repo_state",
"an SMF repository inconsistecy exists"
},
/*
* A transition 'maintenance -> uninitialized' resulting always
* from 'svcadm clear <fmri>'. *Not* used if the libscf interface
* smf_restore_instance(3SCF) is used.
*/
{
"clear_request",
"maintenance clear was requested by an administrator"
},
/*
* A transition 'online -> offline' due to a process core dump.
*/
{
"ct_ev_core",
"a process dumped core"
},
/*
* A transition 'online -> offline' due to an empty process contract,
* i.e., the last process in a contract type service has exited.
*/
{
"ct_ev_exit",
"all processes in the service have exited"
},
/*
* A transition 'online -> offline' due to a hardware error.
*/
{
"ct_ev_hwerr",
"a process was killed due to uncorrectable hardware error"
},
/*
* A transition 'online -> offline' due to a process in the service
* having received a fatal signal originating from outside the
* service process contract.
*/
{
"ct_ev_signal",
"a process received a fatal signal from outside the service"
},
/*
* A transition 'offline -> online' when all dependencies for the
* service have been met.
*/
{
"dependencies_satisfied",
"all dependencies have been satisfied"
},
/*
* A transition 'online -> offline' because some dependency for the
* service is no-longer met.
*/
{
"dependency_activity",
"a dependency activity required a stop"
},
/*
* A transition to maintenance state due to a cycle in the
* service dependencies.
*/
{
"dependency_cycle",
"a dependency cycle exists"
},
/*
* A transition 'online -> offline -> disabled' due to a
* 'svcadm disable [-t] <fmri>' or smf_disable_instance(3SCF) call.
*/
{
"disable_request",
"a disable was requested"
},
/*
* A transition 'disabled -> offline' due to a
* 'svcadm enable [-t] <fmri>' or smf_enable_instance(3SCF) call.
*/
{
"enable_request",
"an enable was requested"
},
/*
* A transition to maintenance state when a method fails
* repeatedly for a retryable reason.
*/
{
"fault_threshold_reached",
"a method is failing in a retryable manner but too often"
},
/*
* A transition to uninitialized state when startd reads the service
* configuration and inserts it into the graph engine.
*/
{
"insert_in_graph",
"the instance was inserted in the graph"
},
/*
* A transition to maintenance state due to an invalid dependency
* declared for the service.
*/
{
"invalid_dependency",
"a service has an invalid dependency"
},
/*
* A transition to maintenance state because the service-declared
* restarter is invalid.
*/
{
"invalid_restarter",
"the service restarter is invalid"
},
/*
* A transition to maintenance state because a restarter method
* exited with one of SMF_EXIT_ERR_CONFIG, SMF_EXIT_ERR_NOSMF,
* SMF_EXIT_ERR_PERM, or SMF_EXIT_ERR_FATAL.
*/
{
"method_failed",
"a start, stop or refresh method failed"
},
/*
* A transition 'uninitialized -> {disabled|offline}' after
* "insert_in_graph" to match the state configured in the
* repository.
*/
{
"per_configuration",
"the SMF repository configuration specifies this state"
},
/*
* Refresh requested - no state change.
*/
{
NULL,
"a refresh was requested (no change of state)"
},
/*
* A transition 'online -> offline -> online' due to a
* 'svcadm restart <fmri> or equivlaent libscf API call.
* Both the 'online -> offline' and 'offline -> online' transtions
* specify this reason.
*/
{
"restart_request",
"a restart was requested"
},
/*
* A transition to maintenance state because the start method is
* being executed successfully but too frequently.
*/
{
"restarting_too_quickly",
"the instance is restarting too quickly"
},
/*
* A transition to maintenance state due a service requesting
* 'svcadm mark maintenance <fmri>' or equivalent libscf API call.
* A command line 'svcadm mark maintenance <fmri>' does not produce
* this reason - it produces administrative_request instead.
*/
{
"service_request",
"maintenance was requested by another service"
},
/*
* An instanced inserted into the graph at its existing state
* during a startd restart - no state change.
*/
{
NULL,
"the instance was inserted in the graph due to startd restart"
},
/*
* An instance is found to be in conflict either at the instance
* level or at the instance parent's level.
*/
{
"instance_conflict",
"the instance is in conflict"
},
/*
* A method defined its own, custom messages
*/
{
"custom",
"the instance method supplied its own reasons"
}
};
restarter_str_version(void)
{
return (RESTARTER_STRING_VERSION);
}
const char *
{
int i;
for (i = 0; i < sizeof (restarter_str) /
sizeof (struct restarter_state_transition_reason); i++)
return (restarter_str[i].str_short);
return (NULL);
}
const char *
{
int i;
for (i = 0; i < sizeof (restarter_str) /
sizeof (struct restarter_state_transition_reason); i++)
return (dgettext(TEXT_DOMAIN,
restarter_str[i].str_long));
return (NULL);
}
/*
* A static no memory error message mc_error_t structure
* to be used in cases when memory errors are to be returned
* This avoids the need to attempt to allocate memory for the
* message, therefore getting into a cycle of no memory failures.
*/
};
/* PRINTFLIKE3 */
static mc_error_t *
{
int size;
/*
* If the type is ENOMEM and format is NULL, then
* go ahead and return the default nomem error.
* Otherwise, attempt to allocate the memory and if
* that fails then there is no reason to continue.
*/
return (&mc_nomem_err);
return (&mc_nomem_err);
else
le = e;
if (size >= RESTARTER_ERRMSGSZ) {
le = e;
}
}
return (le);
}
void
{
return;
/*
* If the error messages was allocated then free.
*/
}
}
static void
{
if (h == NULL)
return;
/*
* Just free the memory -- don't unbind the sysevent handle,
* as otherwise events may be lost if this is just a restarter
* restart.
*/
if (h->reh_restarter_name != NULL)
free(h->reh_restarter_name);
if (h->reh_delegate_channel_name != NULL)
if (h->reh_delegate_subscriber_id != NULL)
if (h->reh_master_channel_name != NULL)
if (h->reh_master_subscriber_id != NULL)
free(h);
}
char *
{
char *name;
int i;
return (NULL);
if (type == RESTARTER_CHANNEL_DELEGATE)
else if (type == RESTARTER_CHANNEL_MASTER)
else {
return (NULL);
}
/*
* Create a unique name
*
* Use the entire name, using a replacement of the /
* characters to get a better name.
*
* Remove the svc:/ from the beginning as this really
* isn't going to provide any uniqueness...
*
* An fmri name greater than MAX_CHNAME_LEN is going
* to be rejected as too long for the chan_name below
* in the snprintf call.
*/
return (NULL);
}
i = 0;
while (name[i]) {
if (name[i] == '/') {
name[i] = '_';
}
i++;
}
/*
* Should check for [a-z],[A-Z],[0-9],.,_,-,:
*/
}
return (chan_name);
}
int
{
int ret = 0;
e = uu_zalloc(sizeof (restarter_event_t));
if (e == NULL)
e->re_event_handle = h;
e->re_sysevent = syse;
&(e->re_type)) != 0) ||
RESTARTER_NAME_INSTANCE, &(e->re_instance_name)) != 0) ||
&state) != 0) ||
&next_state) != 0)) {
uu_warn("%s: Can't decode nvlist for event %p\n",
h->reh_restarter_name, (void *)syse);
ret = 0;
} else {
e->re_next_state = next_state;
ret = h->reh_handler(e);
}
uu_free(e);
return (ret);
}
/*
* restarter_bind_handle(uint32_t, char *, int (*)(restarter_event_t *), int,
* restarter_event_handle_t **)
*
* Bind to a delegated restarter event channel.
* Each delegated restarter gets its own channel for resource management.
*
* Returns 0 on success or
* ENOTSUP version mismatch
* EINVAL restarter_name or event_handle is NULL
* ENOMEM out of memory, too many channels, or too many subscriptions
* EBUSY sysevent_evc_bind() could not establish binding
* EFAULT internal sysevent_evc_bind()/sysevent_evc_subscribe() error
* EMFILE out of file descriptors
* EPERM insufficient privilege for sysevent_evc_bind()
* EEXIST already subscribed
*/
int
{
int err;
if (version != RESTARTER_EVENT_VERSION)
return (ENOTSUP);
return (EINVAL);
if (flags & RESTARTER_FLAG_DEBUG)
ndebug++;
return (ENOMEM);
if (h->reh_delegate_subscriber_id == NULL ||
h->reh_master_subscriber_id == NULL ||
h->reh_restarter_name == NULL) {
return (ENOMEM);
}
if (h->reh_delegate_channel_name == NULL ||
h->reh_master_channel_name == NULL) {
return (ENOMEM);
}
return (err);
}
return (err);
}
h->reh_handler = event_handler;
return (err);
}
*rehp = h;
return (0);
}
{
return (e->re_event_handle);
}
{
return (e->re_type);
}
{
}
int
{
if (e == NULL)
return (-1);
*next_state = e->re_next_state;
return (0);
}
/*
* restarter_event_publish_retry() is a wrapper around sysevent_evc_publish().
* In case, the event cannot be sent at the first attempt (sysevent_evc_publish
* returned EAGAIN - sysevent queue full), this function retries a few time
* and return ENOSPC if it reaches the retry limit.
*
* The arguments to this function map the arguments of sysevent_evc_publish().
*
* On success, return 0. On error, return
*
* EFAULT - internal sysevent_evc_publish() error
* ENOMEM - internal sysevent_evc_publish() error
* EBADF - scp is invalid (sysevent_evc_publish() returned EINVAL)
* ENOSPC - sysevent queue full (sysevent_evc_publish() returned EAGAIN)
*/
int
{
if (ret == 0)
break;
switch (ret) {
case EAGAIN:
/* Queue is full */
break;
case EINVAL:
/* FALLTHROUGH */
case EFAULT:
case ENOMEM:
return (ret);
case EOVERFLOW:
default:
/* internal error - abort */
}
}
if (retries == MAX_COMMIT_RETRIES)
return (ret);
}
/*
* Commit the state, next state, and auxiliary state into the repository.
* Let the graph engine know about the state change and error. On success,
* return 0. On error, return
* EPROTO - librestart compiled against different libscf
* ENOMEM - out of memory
* - repository server out of resources
* ENOTACTIVE - repository server not running
* ECONNABORTED - repository connection established, but then broken
* - unknown libscf error
* ENOENT - inst does not exist in the repository
* EPERM - insufficient permissions
* EACCESS - backend access denied
* EROFS - backend is readonly
* EFAULT - internal sysevent_evc_publish() error
* EBADF - h is invalid (sysevent_evc_publish() returned EINVAL)
* ENOSPC - sysevent queue full (sysevent_evc_publish() returned EAGAIN)
*/
int
{
int ret = 0;
const char *p = restarter_get_str_short(aux);
switch (scf_error()) {
return (EPROTO);
case SCF_ERROR_NO_MEMORY:
return (ENOMEM);
default:
}
}
switch (scf_error()) {
case SCF_ERROR_NO_SERVER:
return (ENOTACTIVE);
case SCF_ERROR_NO_RESOURCES:
return (ENOMEM);
case SCF_ERROR_IN_USE:
default:
}
}
!= 0 ||
} else {
new_next_state, p);
if (ret == 0) {
}
}
(void) scf_handle_unbind(scf_h);
return (ret);
}
{
return (RESTARTER_STATE_NONE);
return (RESTARTER_STATE_UNINIT);
return (RESTARTER_STATE_MAINT);
return (RESTARTER_STATE_OFFLINE);
return (RESTARTER_STATE_DISABLED);
return (RESTARTER_STATE_ONLINE);
return (RESTARTER_STATE_DEGRADED);
else {
return (RESTARTER_STATE_NONE);
}
}
{
if (state == RESTARTER_STATE_NONE)
else if (state == RESTARTER_STATE_UNINIT)
else if (state == RESTARTER_STATE_MAINT)
else if (state == RESTARTER_STATE_OFFLINE)
len));
else if (state == RESTARTER_STATE_DISABLED)
len));
else if (state == RESTARTER_STATE_ONLINE)
else if (state == RESTARTER_STATE_DEGRADED)
len));
else
}
/*
* Sets pg to the name property group of s_inst. If it doesn't exist, it is
* added.
*
* Fails with
* ECONNABORTED - repository disconnection or unknown libscf error
* EBADF - inst is not set
* ECANCELED - inst is deleted
* EPERM - permission is denied
* EACCES - backend denied access
* EROFS - backend readonly
*/
static int
{
return (0);
switch (scf_error()) {
default:
return (ECONNABORTED);
case SCF_ERROR_NOT_SET:
return (EBADF);
case SCF_ERROR_DELETED:
return (ECANCELED);
case SCF_ERROR_NOT_FOUND:
break;
}
return (0);
switch (scf_error()) {
default:
return (ECONNABORTED);
case SCF_ERROR_DELETED:
return (ECANCELED);
case SCF_ERROR_EXISTS:
goto again;
return (EPERM);
case SCF_ERROR_BACKEND_ACCESS:
return (EACCES);
return (EROFS);
case SCF_ERROR_NOT_SET: /* should be caught above */
}
}
/*
* Fails with
* ECONNABORTED
* ECANCELED - pg was deleted
*/
static int
{
int r;
for (;;) {
ty) == 0)
break;
switch (scf_error()) {
default:
return (ECONNABORTED);
case SCF_ERROR_DELETED:
return (ECANCELED);
case SCF_ERROR_NOT_FOUND:
break;
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
bad_fail("scf_transaction_property_change_type",
scf_error());
}
break;
switch (scf_error()) {
default:
return (ECONNABORTED);
case SCF_ERROR_DELETED:
return (ECANCELED);
case SCF_ERROR_EXISTS:
break;
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
}
}
assert(r == 0);
return (0);
}
/*
* Fails with
* ECONNABORTED
* ECANCELED - pg was deleted
*/
static int
const char *pname)
{
switch (scf_error()) {
default:
return (ECONNABORTED);
case SCF_ERROR_DELETED:
return (ECANCELED);
case SCF_ERROR_NOT_FOUND:
return (0);
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
bad_fail("scf_transaction_property_delete",
scf_error());
}
}
return (0);
}
/*
* Commit new_state, new_next_state, and aux to the repository for id.
*
* If aux == "custom":
* - process three additional, optional args
* - set aux_state_custom and aux_reason in repository
* - if non-NULL, set aux_textdomain in repository
*
* If aux != "custom":
* - clear aux_state_custom, aux_reason, and aux_textdomain from repository
*
* All property updates (additions, value changes, or deletions) are done in a
* single transaction on the restarter property group.
*
* If successful, also set id's state and next-state as given, and return 0.
*
* Fails with
* ENOMEM - out of memory
* ECONNABORTED - repository connection broken
* - unknown libscf error
* EINVAL - id->i_fmri is invalid or not an instance FMRI
* ENOENT - id->i_fmri does not exist
* EPERM - insufficient permissions
* EACCES - backend access denied
* EROFS - backend is readonly
*/
static int
{
int ret = 0, r;
scf_transaction_t *t = NULL;
(t = scf_transaction_create(h)) == NULL ||
goto out;
}
sizeof (str_new_state));
sizeof (str_new_state_next));
sizeof (str_state));
sizeof (str_state_next));
switch (scf_error()) {
default:
ret = ECONNABORTED;
break;
break;
case SCF_ERROR_NOT_FOUND:
break;
}
goto out;
}
if (aux_custom) {
(aux_textdomain != NULL &&
!= 0))
}
case 0:
break;
case ECONNABORTED:
case EPERM:
case EACCES:
case EROFS:
ret = r;
goto out;
case ECANCELED:
goto out;
case EBADF:
default:
bad_fail("instance_get_or_add_pg", r);
}
for (;;) {
if (scf_transaction_start(t, pg) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_NOT_SET:
goto add_pg;
goto out;
case SCF_ERROR_BACKEND_ACCESS:
goto out;
goto out;
case SCF_ERROR_IN_USE:
}
}
SCF_TYPE_ASTRING, v_state)) != 0 ||
SCF_TYPE_ASTRING, v_state_next)) != 0 ||
SCF_TYPE_TIME, v_stime)) != 0) {
switch (r) {
case ECONNABORTED:
ret = ECONNABORTED;
goto out;
case ECANCELED:
goto add_pg;
default:
bad_fail("tx_set_value", r);
}
}
if (aux) {
SCF_TYPE_ASTRING, v_aux)) != 0) {
switch (r) {
case ECONNABORTED:
ret = ECONNABORTED;
goto out;
case ECANCELED:
goto add_pg;
default:
bad_fail("tx_set_value", r);
}
}
}
if ((aux_custom == 1) &&
((r = tx_set_value(t, t_aux_state_custom,
v_aux_state_custom)) != 0 ||
SCF_TYPE_ASTRING, v_aux_reason)) != 0 ||
SCF_TYPE_ASTRING, v_aux_textdomain)) != 0))) {
switch (r) {
case ECONNABORTED:
ret = ECONNABORTED;
goto out;
case ECANCELED:
goto add_pg;
default:
bad_fail("tx_set_value", r);
}
}
if ((aux_custom == 0) &&
((r = tx_delete_prop(t, t_aux_state_custom,
SCF_PROPERTY_AUX_STATE_CUSTOM)) != 0 ||
(r = tx_delete_prop(t, t_aux_reason,
SCF_PROPERTY_AUX_REASON)) != 0 ||
(r = tx_delete_prop(t, t_aux_textdomain,
SCF_PROPERTY_AUX_TEXTDOMAIN)) != 0)) {
switch (r) {
case ECONNABORTED:
ret = ECONNABORTED;
goto out;
case ECANCELED:
goto add_pg;
default:
bad_fail("tx_delete_prop", r);
}
}
ret = scf_transaction_commit(t);
if (ret == 1)
break;
if (ret == -1) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
goto out;
case SCF_ERROR_BACKEND_ACCESS:
goto out;
goto out;
case SCF_ERROR_NOT_SET:
}
}
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_NOT_SET:
goto add_pg;
}
}
}
ret = 0;
out:
return (ret);
}
int
{
uu_warn("%s: restarter set auxiliary state to \"%s\" without "
}
}
int
{
uu_warn("%s: restarter supplied NULL custom state "
}
1, s, l, aux_textdomain));
}
/*
* Fails with
* EINVAL - type is invalid
* ENOMEM
* ECONNABORTED - repository connection broken
* EBADF - s_inst is not set
* ECANCELED - s_inst is deleted
* EPERM - permission denied
* EACCES - backend access denied
* EROFS - backend readonly
*/
int
{
scf_handle_t *h;
scf_transaction_t *t = NULL;
const char *pname;
uint64_t c;
switch (type) {
primary = 1;
break;
primary = 0;
break;
default:
return (EINVAL);
}
h = scf_instance_handle(s_inst);
pg = scf_pg_create(h);
prop = scf_property_create(h);
iter = scf_iter_create(h);
t = scf_transaction_create(h);
goto remove_contract_cleanup;
}
add:
if (ret != 0)
goto remove_contract_cleanup;
for (;;) {
if (scf_transaction_start(t, pg) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
goto remove_contract_cleanup;
case SCF_ERROR_BACKEND_ACCESS:
goto remove_contract_cleanup;
goto remove_contract_cleanup;
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
}
}
t_cid = scf_entry_create(h);
pname, SCF_TYPE_COUNT) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_NOT_FOUND:
goto new;
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
"scf_transaction_property_changetype",
scf_error());
}
}
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_NOT_SET:
"scf_iter_property_values",
scf_error());
}
}
val = scf_value_create(h);
goto remove_contract_cleanup;
}
if (ret == -1) {
switch (scf_error()) {
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
default:
bad_fail("scf_iter_next_value",
scf_error());
}
}
if (ret == 1) {
if (c != contract_id) {
val);
} else {
}
goto next_val;
}
} else {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_TYPE_MISMATCH:
break;
case SCF_ERROR_NOT_SET:
bad_fail("scf_property_is_type",
scf_error());
}
}
} else {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_NOT_FOUND:
break;
case SCF_ERROR_NOT_SET:
}
new:
SCF_TYPE_COUNT) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_EXISTS:
goto replace;
case SCF_ERROR_NOT_SET:
bad_fail("scf_transaction_property_new",
scf_error());
}
}
}
ret = scf_transaction_commit(t);
if (ret == -1) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
goto remove_contract_cleanup;
case SCF_ERROR_BACKEND_ACCESS:
goto remove_contract_cleanup;
goto remove_contract_cleanup;
case SCF_ERROR_NOT_SET:
}
}
if (ret == 1) {
ret = 0;
break;
}
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto remove_contract_cleanup;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_NOT_SET:
}
}
}
return (ret);
}
/*
* Fails with
* EINVAL - type is invalid
* ENOMEM
* ECONNABORTED - repository disconnection
* EBADF - s_inst is not set
* ECANCELED - s_inst is deleted
* EPERM
* EACCES
* EROFS
*/
int
{
scf_handle_t *h;
scf_transaction_t *t = NULL;
const char *pname;
if (type == RESTARTER_CONTRACT_PRIMARY)
primary = 1;
else if (type == RESTARTER_CONTRACT_TRANSIENT)
primary = 0;
else
return (EINVAL);
h = scf_instance_handle(s_inst);
pg = scf_pg_create(h);
prop = scf_property_create(h);
iter = scf_iter_create(h);
t = scf_transaction_create(h);
goto out;
}
add:
if (ret != 0)
goto out;
for (;;) {
if (scf_transaction_start(t, pg) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
goto out;
case SCF_ERROR_BACKEND_ACCESS:
goto out;
goto out;
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
}
}
t_cid = scf_entry_create(h);
goto out;
}
pname, SCF_TYPE_COUNT) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_NOT_FOUND:
goto new;
case SCF_ERROR_IN_USE:
case SCF_ERROR_NOT_SET:
"scf_transaction_propert_change_type",
scf_error());
}
}
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_NOT_SET:
"scf_iter_property_values",
scf_error());
}
}
val = scf_value_create(h);
goto out;
}
if (ret == -1) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
"scf_iter_next_value",
scf_error());
}
}
if (ret == 1) {
goto next_val;
}
} else {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_TYPE_MISMATCH:
break;
case SCF_ERROR_NOT_SET:
bad_fail("scf_property_is_type",
scf_error());
}
}
} else {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_NOT_FOUND:
break;
case SCF_ERROR_NOT_SET:
}
new:
SCF_TYPE_COUNT) != 0) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_EXISTS:
goto replace;
case SCF_ERROR_NOT_SET:
bad_fail("scf_transaction_property_new",
scf_error());
}
}
}
val = scf_value_create(h);
goto out;
}
ret = scf_transaction_commit(t);
if (ret == -1) {
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
goto out;
case SCF_ERROR_BACKEND_ACCESS:
goto out;
goto out;
case SCF_ERROR_NOT_SET:
}
}
if (ret == 1) {
ret = 0;
break;
}
switch (scf_error()) {
default:
ret = ECONNABORTED;
goto out;
case SCF_ERROR_DELETED:
goto add;
case SCF_ERROR_NOT_SET:
}
}
}
out:
return (ret);
}
int
{
void *libhndl;
return (1);
return (0);
return (0);
return (1);
}
static int
{
return (-1);
if (scf_error() == SCF_ERROR_CONNECTION_BROKEN)
return (-1);
}
if (scf_error() == SCF_ERROR_CONNECTION_BROKEN)
return (-1);
}
return (szret >= 0 ? 0 : -1);
}
static int
{
if (scf_error() == SCF_ERROR_CONNECTION_BROKEN)
return (-1);
}
if (scf_error() == SCF_ERROR_CONNECTION_BROKEN)
return (-1);
}
if (scf_value_get_boolean(val, b))
return (-1);
return (0);
}
/*
* Try to load mcp->pwd, if it isn't already.
* Fails with
* ENOMEM - malloc() failed
* ENOENT - no entry found
* EIO - I/O error
* EMFILE - process out of file descriptors
* ENFILE - system out of file handles
*/
static int
{
return (0);
return (ENOMEM);
}
do {
errno = 0;
return (0);
switch (errno) {
case 0:
default:
/*
* Until bug 5065780 is fixed, getpwuid_r() can fail with
* ENOENT, particularly on the miniroot. Since the
* documentation is inaccurate, we'll return ENOENT for unknown
* errors.
*/
return (ENOENT);
case EIO:
case EMFILE:
case ENFILE:
return (errno);
case ERANGE:
/* NOTREACHED */
}
}
/*
* Get the user id for str. Returns 0 on success or
* ERANGE the uid is too big
* EINVAL the string starts with a digit, but is not a valid uid
* ENOMEM out of memory
* ENOENT no passwd entry for str
* EIO an I/O error has occurred
*/
int
{
char *cp;
errno = 0;
return (errno);
}
return (EINVAL);
return (EINVAL);
return (0);
} else {
return (ENOMEM);
}
do {
errno = 0;
pwdp =
return (0);
} else {
switch (errno) {
case 0:
return (ENOENT);
case ENOENT:
case EIO:
case EMFILE:
case ENFILE:
return (errno);
case ERANGE:
default:
/* NOTREACHED */
}
}
}
}
{
char *cp;
errno = 0;
return ((gid_t)-1);
return ((gid_t)-1);
return (gid);
} else {
char *buffer;
errno = 0;
}
}
/*
* Fails with
* ENOMEM - out of memory
* ENOENT - no passwd entry
* no project entry
* EIO - an I/O error occurred
* EMFILE - the process is out of file descriptors
* ENFILE - the system is out of file handles
* ERANGE - the project id is out of range
* EINVAL - str is invalid
* E2BIG - the project entry was too big
* -1 - the name service switch is misconfigured
*/
int
{
int ret;
void *buf;
/* Don't change project for root services */
return (0);
}
case 0:
break;
case ENOMEM:
case ENOENT:
case EIO:
case EMFILE:
case ENFILE:
return (ret);
default:
}
return (ENOMEM);
do {
errno = 0;
bufsz);
/* to be continued ... */
} else {
char *cp;
}
errno = 0;
return (errno);
}
return (EINVAL);
return (ERANGE);
return (ENOMEM);
do {
errno = 0;
}
if (pp) {
}
switch (errno) {
case 0:
return (ENOENT);
case EIO:
case EMFILE:
case ENFILE:
return (errno);
case ERANGE:
return (E2BIG);
default:
return (-1);
}
}
/*
* Parse the supp_groups property value and populate ci->groups. Returns
* EINVAL (get_gid() failed for one of the components), E2BIG (the property has
* more than NGROUPS_MAX-1 groups), or 0 on success.
*/
int
{
uint_t i;
if (str[0] == '\0') {
return (0);
}
/* skip whitespace */
/* find the end */
/* skip whitespace after end */
/* if there's a comma, it separates the fields */
if (*next == ',')
++next;
*end = '\0';
return (EINVAL);
}
++i;
if (i > NGROUPS_MAX - 1) {
return (E2BIG);
}
}
return (0);
}
/*
* Return an error message structure containing the error message
* with context, and the error so the caller can make a decision
* on what to do next.
*
* Because get_ids uses the mc_error_create() function which can
* reallocate the merr, this function must return the merr pointer
* in case it was reallocated.
*/
static mc_error_t *
{
const char *cmdp;
int r;
"Method context requires a profile, but the \"%s\" "
"property could not be read. scf_error is %s",
/* Extract the command from the command line. */
} else {
}
/* Require that cmdp[0] == '/'? */
"Could not find the execution profile \"%s\", "
/* Based on pfexec.c */
/* Get the euid first so we don't override ci->pwd for the uid. */
"Could not interpret profile euid value \"%s\", "
"from the execution profile \"%s\", error %d.",
goto out;
}
}
"Could not interpret profile uid value \"%s\", "
"from the execution profile \"%s\", error %d.",
goto out;
}
}
"Could not interpret profile gid value \"%s\", "
goto out;
}
}
"Could not interpret profile egid value \"%s\", "
goto out;
}
}
else
"Could not interpret profile "
"limitprivs value \"%s\", from "
"the execution profile \"%s\".",
goto out;
}
}
else
"Could not interpret profile privs value "
"\"%s\", from the execution profile "
goto out;
}
/*
* The exec_attr privs keyword only lists additional
* privileges; we need to add the inheritable set.
*/
goto out;
}
"Could not get the inheritable privset");
goto out;
}
}
}
out:
return (err);
}
/*
* Return an error message structure containing the error message
* with context, and the error so the caller can make a decision
* on what to do next.
*
* Because get_ids uses the mc_error_create() function which can
* reallocate the merr, this function must return the merr pointer
* in case it was reallocated.
*/
static mc_error_t *
{
int r;
/*
* This should never happen because the caller should fall through
* another path of just setting the ids to defaults, instead of
* attempting to get the ids here.
*/
"No property groups to get ids from."));
val) == 0))
"Could not get \"%s\" property.", SCF_PROPERTY_USER));
return (mc_error_create(merr, r,
"Could not interpret \"%s\" property value \"%s\", "
}
if (scf_error() == SCF_ERROR_NOT_FOUND) {
} else {
"Could not get \"%s\" property.",
}
}
"Could not interpret \"%s\" property value \"%s\".",
}
} else {
switch (r = lookup_pwd(ci)) {
case 0:
break;
case ENOENT:
case ENOMEM:
"Out of memory."));
case EIO:
case EMFILE:
case ENFILE:
"getpwuid_r() failed, error %d.", r));
default:
bad_fail("lookup_pwd", r);
}
}
if (scf_error() == SCF_ERROR_NOT_FOUND) {
} else {
"Could not get supplemental groups (\"%s\") "
"property.", SCF_PROPERTY_SUPP_GROUPS));
}
}
case 0:
break;
case EINVAL:
"Could not interpret supplemental groups (\"%s\") "
"property value \"%s\".", SCF_PROPERTY_SUPP_GROUPS,
vbuf));
case E2BIG:
"Too many supplemental groups values in \"%s\".",
vbuf));
default:
bad_fail("get_groups", r);
}
} else {
}
if (scf_error() == SCF_ERROR_NOT_FOUND) {
} else {
"Could not get \"%s\" property.",
}
}
/*
* For default privs, we need to keep priv_set == NULL, as
* we use this test elsewhere.
*/
ALLOCFAIL));
} else {
"Could not interpret \"%s\" "
"property value \"%s\".",
}
}
}
if (scf_error() == SCF_ERROR_NOT_FOUND) {
} else {
"Could not get \"%s\" property.",
}
}
/*
* L must default to all privileges so root NPA services see
* iE = all. "zone" is all privileges available in the current
* zone, equivalent to "all" in the global zone.
*/
} else {
"Could not interpret \"%s\" property value \"%s\".",
}
}
return (merr);
}
static int
{
size_t i = 0;
int ret;
if (scf_error() == SCF_ERROR_NOT_FOUND)
return (ENOENT);
return (scf_error());
}
return (scf_error());
if (type != SCF_TYPE_ASTRING)
return (EINVAL);
return (scf_error());
return (ret);
}
goto out;
}
if (ret == -1) {
goto out;
}
goto out;
}
char **env;
goto out;
}
}
}
if (ret == -1)
out:
return (ret);
}
/*
* Fetch method context information from the repository, allocate and fill
* a method_context structure, return it in *mcpp, and return NULL.
*
* If no method_context is defined, original init context is provided, where
* is defined at any level the smf_method(5) method_context defaults are used.
*
* Return an error message structure containing the error message
* with context, and the error so the caller can make a decision
* on what to do next.
*
* Error Types :
* E2BIG Too many values or entry is too big
* EINVAL Invalid value
* EIO an I/O error has occured
* ENOENT no entry for value
* ENOMEM out of memory
* ENOTSUP Version mismatch
* ERANGE value is out of range
*
* SCF_ERROR_BACKEND_ACCESS
* SCF_ERROR_CONNECTION_BROKEN
* SCF_ERROR_DELETED
* SCF_ERROR_CONSTRAINT_VIOLATED
* SCF_ERROR_HANDLE_DESTROYED
* SCF_ERROR_INTERNAL
* SCF_ERROR_INVALID_ARGUMENT
* SCF_ERROR_NO_MEMORY
* SCF_ERROR_NO_RESOURCES
* SCF_ERROR_NOT_BOUND
* SCF_ERROR_NOT_FOUND
* SCF_ERROR_NOT_SET
* SCF_ERROR_TYPE_MISMATCH
*
*/
struct method_context **mcpp)
{
scf_handle_t *h;
int ret = 0;
int mc_used = 0;
/* Set the type to zero to track if an error occured. */
"Invalid client version %d. (Expected %d)",
/* Get the handle before we allocate anything. */
h = scf_instance_handle(inst);
if (h == NULL)
scf_strerror(scf_error())));
}
"Failed to create repository object: %s\n",
scf_strerror(scf_error()));
goto out;
}
/*
* The method environment, and the credentials/profile data,
* may be found either in the pg for the method (methpg),
* instpg below).
*/
SCF_SUCCESS) {
goto out;
}
instpg) != SCF_SUCCESS) {
if (scf_error() != SCF_ERROR_NOT_FOUND) {
"Unable to retrieve the \"%s\" property group, %s",
goto out;
}
} else {
mc_used++;
}
}
switch (ret) {
case 0:
mc_used++;
break;
case ENOENT:
break;
case ENOMEM:
goto out;
case EINVAL:
goto out;
default:
goto out;
}
prop);
}
if (ret) {
switch (scf_error()) {
case SCF_ERROR_NOT_FOUND:
/* No profile context: use default credentials */
break;
RCBROKEN);
goto out;
case SCF_ERROR_DELETED:
"Could not find property group \"%s\"",
goto out;
case SCF_ERROR_NOT_SET:
default:
}
} else {
switch (ret) {
break;
case SCF_ERROR_DELETED:
"Could not find property group \"%s\"",
break;
case SCF_ERROR_NOT_SET:
default:
}
goto out;
}
if (ty != SCF_TYPE_BOOLEAN) {
"\"%s\" property is not boolean in property group "
"\"%s\".", SCF_PROPERTY_USE_PROFILE,
goto out;
}
switch (ret) {
break;
"\"%s\" property has multiple values.",
break;
case SCF_ERROR_NOT_FOUND:
"\"%s\" property has no values.",
break;
default:
}
goto out;
}
mc_used++;
/* get ids & privileges */
if (use_profile)
else
goto out;
}
/* get working directory */
switch (ret) {
break;
"\"%s\" property has multiple values.",
break;
case SCF_ERROR_NOT_FOUND:
"\"%s\" property has no values.",
break;
default:
}
goto out;
}
mc_used++;
} else {
switch (ret) {
case SCF_ERROR_NOT_FOUND:
/* okay if missing. */
break;
goto out;
case SCF_ERROR_DELETED:
"Property group could not be found");
goto out;
case SCF_ERROR_NOT_SET:
default:
}
}
case 0:
break;
case ENOMEM:
goto out;
case ENOENT:
case EIO:
case EMFILE:
case ENFILE:
"Could not get passwd entry.");
goto out;
default:
}
goto out;
}
} else {
goto out;
}
}
/* get (optional) corefile pattern */
switch (ret) {
break;
"\"%s\" property has multiple values.",
break;
case SCF_ERROR_NOT_FOUND:
"\"%s\" property has no values.",
break;
default:
}
} else {
goto out;
}
}
mc_used++;
} else {
switch (ret) {
case SCF_ERROR_NOT_FOUND:
/* okay if missing. */
break;
goto out;
case SCF_ERROR_DELETED:
"Property group could not be found");
goto out;
case SCF_ERROR_NOT_SET:
default:
}
}
if (restarter_rm_libs_loadable()) {
/* get project */
switch (ret) {
RCBROKEN);
break;
"\"%s\" property has multiple "
"values.", SCF_PROPERTY_PROJECT);
break;
case SCF_ERROR_NOT_FOUND:
"\"%s\" property has no values.",
break;
default:
}
} else {
}
mc_used++;
} else {
}
case 0:
break;
case ENOMEM:
goto out;
case ENOENT:
"Missing passwd or project entry for \"%s\".",
goto out;
case EIO:
goto out;
case EMFILE:
case ENFILE:
"Out of file descriptors.");
goto out;
case -1:
"Name service switch is misconfigured.");
goto out;
case ERANGE:
case E2BIG:
goto out;
case EINVAL:
goto out;
default:
}
/* get resource pool */
switch (ret) {
RCBROKEN);
break;
"\"%s\" property has multiple "
"values.",
break;
case SCF_ERROR_NOT_FOUND:
"\"%s\" property has no "
"values.",
break;
default:
}
} else {
}
mc_used++;
} else {
switch (ret) {
case SCF_ERROR_NOT_FOUND:
/* okay if missing. */
break;
goto out;
case SCF_ERROR_DELETED:
"property group could not be found.");
goto out;
case SCF_ERROR_NOT_SET:
default:
}
}
goto out;
}
}
}
/*
* A method_context was not used for any configurable
* elements or attributes, so reset and use the simple
* defaults that provide historic init behavior.
*/
if (mc_used == 0) {
}
out:
(void) scf_value_destroy(val);
} else {
}
return (err);
}
/*
* Modify the current process per the given method_context. On success, returns
* 0. Note that the environment is not modified by this function to include the
* environment variables in cip->env.
*
* On failure, sets *fp to NULL or the name of the function which failed,
* and returns one of the following error codes. The words in parentheses are
* the values to which *fp may be set for the error case.
* ENOMEM - malloc() failed
* EIO - an I/O error occurred (getpwuid_r, chdir)
* EMFILE - process is out of file descriptors (getpwuid_r)
* ENFILE - system is out of file handles (getpwuid_r)
* EINVAL - gid or egid is out of range (setregid)
* ngroups is too big (setgroups)
* project's project id is bad (setproject)
* uid or euid is out of range (setreuid)
* poolname is invalid (pool_set_binding)
* EPERM - insufficient privilege (setregid, initgroups, setgroups, setppriv,
* setproject, setreuid, settaskid)
* ENOENT - uid has a passwd entry but no shadow entry
* working_dir does not exist (chdir)
* uid has no passwd entry
* the pool could not be found (pool_set_binding)
* EFAULT - lpriv_set or priv_set has a bad address (setppriv)
* working_dir has a bad address (chdir)
* EACCES - could not access working_dir (chdir)
* in a TASK_FINAL task (setproject, settaskid)
* no resource pool accepting default binding exists (setproject)
* ELOOP - too many symbolic links in working_dir (chdir)
* ENAMETOOLONG - working_dir is too long (chdir)
* ENOLINK - working_dir is on an inaccessible remote machine (chdir)
* ENOTDIR - working_dir is not a directory (chdir)
* ESRCH - uid is not a user of project (setproject)
* project is invalid (setproject)
* the resource pool specified for project is unknown (setproject)
* EBADF - the configuration for the pool is invalid (pool_set_binding)
* -1 - core_set_process_path() failed (core_set_process_path)
* a resource control assignment failed (setproject)
* a system error occurred during pool_set_binding (pool_set_binding)
*/
int
{
int r, ret;
*fp = "setregid";
goto out;
}
} else {
case 0:
break;
case ENOMEM:
case ENOENT:
goto out;
case EIO:
case EMFILE:
case ENFILE:
*fp = "getpwuid_r";
goto out;
default:
}
}
*fp = "setregid";
goto out;
}
}
case 0:
break;
case ENOMEM:
case ENOENT:
goto out;
case EIO:
case EMFILE:
case ENFILE:
*fp = "getpwuid_r";
goto out;
default:
}
}
/* Ok if cip->gid == -1 */
*fp = "initgroups";
goto out;
}
*fp = "setgroups";
goto out;
}
*fp = "core_set_process_path";
ret = -1;
goto out;
}
}
if (restarter_rm_libs_loadable()) {
switch (errno) {
case EACCES:
case EPERM:
*fp = "settaskid";
goto out;
case EINVAL:
default:
}
}
} else {
case 0:
break;
case ENOMEM:
case ENOENT:
goto out;
case EIO:
case EMFILE:
case ENFILE:
*fp = "getpwuid_r";
goto out;
default:
}
*fp = "setproject";
TASK_NORMAL)) {
case 0:
break;
case SETPROJ_ERR_TASK:
case SETPROJ_ERR_POOL:
goto out;
default:
ret = -1;
goto out;
}
}
if (mypid == -1)
*fp = "pool_set_binding";
mypid) != PO_SUCCESS) {
switch (pool_error()) {
case POE_INVALID_SEARCH:
break;
case POE_BADPARAM:
break;
case POE_INVALID_CONF:
break;
case POE_SYSTEM:
ret = -1;
break;
default:
bad_fail("pool_set_binding",
pool_error());
}
goto out;
}
}
}
/*
* Now, we have to assume our ID. If the UID is 0, we want it to be
* privilege-aware, otherwise the limit set gets used instead of E/P.
* We can do this by setting P as well, which keeps
* PA status (see priv_can_clear_PA()).
*/
*fp = "setppriv";
goto out;
}
}
goto out;
}
}
goto out;
goto out;
}
goto out;
}
}
/*
* If the limit privset is already set, then must be privilege
* aware. Otherwise, don't assume anything, and force privilege
* aware status.
*/
}
*fp = "setreuid";
goto out;
}
*fp = "setppriv";
goto out;
}
}
/*
* The last thing to do is chdir to the specified working directory.
* This should come after the uid switching as only the user might
* have access to the specified directory.
*/
do {
if (r != 0) {
*fp = "chdir";
goto out;
}
}
ret = 0;
out:
return (ret);
}
void
{
size_t i;
}
}
/*
* Method keyword functions
*/
int
{
}
static int
{
const char *cp;
int sig;
return (-1);
++cp;
if (*cp == '\0')
return (SIGTERM);
if (*cp != '-')
return (-1);
}
int
{
sizeof (MKW_KILL_PROC) - 1));
}
int
{
}
/*
* Stubs for now.
*/
/* ARGSUSED */
int
{
return (-1);
}
/* ARGSUSED */
{
return (-1);
}
/* ARGSUSED */
void
{
}
/*
* Check for and validate fmri specified in restarter_actions/auxiliary_fmri
* 0 - Success
* 1 - Failure
*/
int
{
scf_handle_t *h;
char *aux_fmri;
return (1);
h = scf_instance_handle(inst);
pg = scf_pg_create(h);
prop = scf_property_create(h);
val = scf_value_create(h);
goto out;
pg) != SCF_SUCCESS)
goto out;
goto out;
NULL) != SCF_SUCCESS)
goto out;
ret = 0;
out:
return (ret);
}
/*
* Get instance's boolean value in restarter_actions/auxiliary_tty
* Return -1 on failure
*/
int
{
scf_handle_t *h;
h = scf_instance_handle(inst);
pg = scf_pg_create(h);
prop = scf_property_create(h);
val = scf_value_create(h);
goto out;
pg) != SCF_SUCCESS)
goto out;
val) != SCF_SUCCESS)
goto out;
out:
return (ret);
}
static int
{
scf_handle_t *h;
scf_value_t *v;
h = scf_instance_handle(inst);
pg = scf_pg_create(h);
t = scf_transaction_create(h);
e = scf_entry_create(h);
v = scf_value_create(h);
goto out;
goto out;
goto out;
for (;;) {
if (scf_transaction_start(t, pg) != 0)
goto out;
goto out;
if ((r = scf_transaction_commit(t)) == 1)
break;
if (r == -1)
goto out;
goto out;
}
ret = 0;
out:
return (ret);
}
int
{
scf_handle_t *h;
char *aux_fmri;
return (1);
h = scf_instance_handle(inst);
pg = scf_pg_create(h);
prop = scf_property_create(h);
val = scf_value_create(h);
goto out;
/*
* Get auxiliary_fmri value from restarter_actions pg
*/
pg) != SCF_SUCCESS)
goto out;
goto out;
/*
* Populate restarter/auxiliary_fmri with the obtained fmri.
*/
out:
return (ret);
}
int
{
return (scf_instance_delete_prop(inst,
}
int
{
return (scf_instance_delete_prop(inst,
}