static Boolean_t create_pg(targ_scf_t *h, char *pgname, char *prop) { if (scf_service_get_pg(h->t_service, pgname, h->t_pg) != 0) { if (scf_service_add_pg(h->t_service, pgname, prop, 0, h->t_pg) != 0) { return (False); } } return (True); }
/* * smb_smf_create_service_pgroup(handle, pgroup) * * create a new property group at service level. */ int smb_smf_create_service_pgroup(smb_scfhandle_t *handle, char *pgroup) { int ret = SMBD_SMF_OK; int err; if (handle == NULL) return (SMBD_SMF_SYSTEM_ERR); /* * only create a handle if it doesn't exist. It is ok to exist * since the pg handle will be set as a side effect. */ if (handle->scf_pg == NULL) if ((handle->scf_pg = scf_pg_create(handle->scf_handle)) == NULL) return (SMBD_SMF_SYSTEM_ERR); /* * if the pgroup exists, we are done. If it doesn't, then we * need to actually add one to the service instance. */ if (scf_service_get_pg(handle->scf_service, pgroup, handle->scf_pg) != 0) { /* doesn't exist so create one */ if (scf_service_add_pg(handle->scf_service, pgroup, SCF_GROUP_APPLICATION, 0, handle->scf_pg) != 0) { err = scf_error(); if (err != SCF_ERROR_NONE) smb_smf_scf_log_error(NULL); switch (err) { case SCF_ERROR_PERMISSION_DENIED: ret = SMBD_SMF_NO_PERMISSION; break; default: ret = SMBD_SMF_SYSTEM_ERR; break; } } } return (ret); }
static Boolean_t create_pg(targ_scf_t *h, char *pgname, char *prop) { int len; char *buf = NULL; len = strlen(pgname); buf = (char *)calloc(1, len * PG_FACTOR); if (buf == NULL) return (False); pgname_encode(pgname, buf, len * PG_FACTOR); if (scf_service_get_pg(h->t_service, buf, h->t_pg) != 0) { if (scf_service_add_pg(h->t_service, buf, prop, 0, h->t_pg) != 0) { free(buf); return (False); } } free(buf); return (True); }