static int sig_auditd(int sig) { scf_simple_prop_t *prop = NULL; uint64_t *cid = NULL; if ((prop = scf_simple_prop_get(NULL, AUDITD_FMRI, SCF_PG_RESTARTER, SCF_PROPERTY_CONTRACT)) == NULL) { display_smf_error(); return (1); } if ((scf_simple_prop_numvalues(prop) < 0) || (cid = scf_simple_prop_next_count(prop)) == NULL) { scf_simple_prop_free(prop); display_smf_error(); return (1); } if (sigsend(P_CTID, (ctid_t)*cid, sig) != 0) { perror("audit: can't signal auditd"); scf_simple_prop_free(prop); return (1); } scf_simple_prop_free(prop); return (0); }
void wait_till_to(char *fmri) { char *state; useconds_t max; useconds_t usecs; uint64_t *cp = NULL; scf_simple_prop_t *sp = NULL; max = DEFAULT_TIMEOUT; if (((sp = scf_simple_prop_get(NULL, fmri, "stop", SCF_PROPERTY_TIMEOUT)) != NULL) && ((cp = scf_simple_prop_next_count(sp)) != NULL) && (*cp != 0)) max = (*cp) * 1000000; /* convert to usecs */ if (sp != NULL) scf_simple_prop_free(sp); for (usecs = INIT_WAIT_USECS; max > 0; max -= usecs) { /* incremental wait */ usecs *= 2; usecs = (usecs > max) ? max : usecs; (void) usleep(usecs); /* Check state after the wait */ if ((state = smf_get_state(fmri)) != NULL) { if (strcmp(state, "disabled") == 0) return; } } (void) fprintf(stderr, gettext("Warning: delete %s timed out.\n"), fmri); }
/*ARGSUSED*/ scf_error_t read_prop(scf_handle_t *h, inetd_prop_t *iprop, int index, const char *inst, const char *pg_name) { scf_simple_prop_t *sprop; uint8_t *tmp_bool; int64_t *tmp_int; uint64_t *tmp_cnt; char *tmp_char; if ((sprop = scf_simple_prop_get(h, inst, pg_name, iprop->ip_name)) == NULL) return (scf_error()); switch (iprop->ip_type) { case INET_TYPE_STRING: if ((tmp_char = scf_simple_prop_next_astring(sprop)) == NULL) goto scf_error; if ((iprop->ip_value.iv_string = strdup(tmp_char)) == NULL) { scf_simple_prop_free(sprop); return (SCF_ERROR_NO_MEMORY); } break; case INET_TYPE_STRING_LIST: { int j = 0; while ((tmp_char = scf_simple_prop_next_astring(sprop)) != NULL) { char **cpp; if ((cpp = realloc( iprop->ip_value.iv_string_list, (j + 2) * sizeof (char *))) == NULL) { scf_simple_prop_free(sprop); return (SCF_ERROR_NO_MEMORY); } iprop->ip_value.iv_string_list = cpp; if ((cpp[j] = strdup(tmp_char)) == NULL) { scf_simple_prop_free(sprop); return (SCF_ERROR_NO_MEMORY); } cpp[++j] = NULL; } if ((j == 0) || (scf_error() != SCF_ERROR_NONE)) goto scf_error; } break; case INET_TYPE_BOOLEAN: if ((tmp_bool = scf_simple_prop_next_boolean(sprop)) == NULL) goto scf_error; iprop->ip_value.iv_boolean = (*tmp_bool == 0) ? B_FALSE : B_TRUE; break; case INET_TYPE_COUNT: if ((tmp_cnt = scf_simple_prop_next_count(sprop)) == NULL) goto scf_error; iprop->ip_value.iv_cnt = *tmp_cnt; break; case INET_TYPE_INTEGER: if ((tmp_int = scf_simple_prop_next_integer(sprop)) == NULL) goto scf_error; iprop->ip_value.iv_int = *tmp_int; break; default: assert(0); } iprop->ip_error = IVE_VALID; scf_simple_prop_free(sprop); return (0); scf_error: scf_simple_prop_free(sprop); if (scf_error() == SCF_ERROR_NONE) return (SCF_ERROR_NOT_FOUND); return (scf_error()); }