--- a/usr/src/cmd/rad/mod/smf/common.c Sun Apr 08 16:04:44 2012 -0400
+++ b/usr/src/cmd/rad/mod/smf/common.c Sun Apr 08 19:52:12 2012 -0400
@@ -165,7 +165,6 @@
return (smfu_rtrun(rt_collect_pgs, &pga, data, error));
}
-
/*ARGSUSED*/
static svcerr_t
rt_read_pgs(scf_handle_t *h, void *arg, data_t **ret, data_t **error)
@@ -267,6 +266,54 @@
/*ARGSUSED*/
static svcerr_t
+rt_invoke_deleteCust(scf_handle_t *h, void *arg, data_t **ret, data_t **error)
+{
+ smfobj_t *smfo = arg;
+ svcerr_t se = SE_OK;
+ smfu_entity_t entity = SMFU_ENTITY_INIT;
+
+ if ((se = smfu_lookup(h, smfo->sname, smfo->iname, &entity)) != SE_OK)
+ goto done;
+
+ int e = (entity.instance != NULL) ?
+ scf_instance_delcust(entity.instance) :
+ scf_service_delcust(entity.service);
+
+ if (e != 0) {
+ switch (scf_error()) {
+ case SCF_ERROR_PERMISSION_DENIED:
+ se = error_scf(error, &e__ErrorCode_DENIED, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_BACKEND_READONLY:
+ se = error_scf(error, &e__ErrorCode_READONLY, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_DELETED:
+ se = error_scf(error, &e__ErrorCode_NOTFOUND, NULL,
+ (entity.instance != NULL) ? smfo->iname :
+ smfo->sname, NULL);
+ break;
+ default:
+ se = smfu_maperr(scf_error());
+ }
+ }
+done:
+ smfu_entity_destroy(&entity);
+ return (se);
+}
+
+/*ARGSUSED*/
+conerr_t
+api_entity_invoke_deleteCust(rad_instance_t *inst, adr_method_t *meth,
+ data_t **ret, data_t **args, int count, data_t **error)
+{
+ return (smfu_rtrun(rt_invoke_deleteCust, instance_getdata(inst), NULL,
+ error));
+}
+
+/*ARGSUSED*/
+static svcerr_t
rt_invoke_createPG(scf_handle_t *h, void *arg, data_t **ret, data_t **error)
{
radarg_t *ra = arg;
@@ -378,6 +425,61 @@
/*ARGSUSED*/
static svcerr_t
+rt_invoke_deletePGCust(scf_handle_t *h, void *arg, data_t **ret, data_t **error)
+{
+ radarg_t *ra = arg;
+ smfobj_t *smfo = instance_getdata(ra->inst);
+ const char *pgname = data_to_string(ra->args[0]);
+ svcerr_t se = SE_OK;
+ smfu_entity_t entity = SMFU_ENTITY_INIT;
+ scf_propertygroup_t *pg = scf_pg_create(h);
+
+ if (pg == NULL) {
+ se = SE_FATAL;
+ goto done;
+ }
+
+ if ((se = smfu_lookup(h, smfo->sname, smfo->iname, &entity)) != SE_OK)
+ goto done;
+
+ if ((se = smfu_get_pg(&entity, pgname, pg, error)) != SE_OK)
+ goto done;
+
+ if (scf_pg_delcust(pg) != 0) {
+ switch (scf_error()) {
+ case SCF_ERROR_PERMISSION_DENIED:
+ se = error_scf(error, &e__ErrorCode_DENIED, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_BACKEND_READONLY:
+ se = error_scf(error, &e__ErrorCode_READONLY, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_DELETED:
+ se = error_scf(error, &e__ErrorCode_NOTFOUND,
+ &e__ErrorTarget_PROPERTYGROUP, pgname, NULL);
+ break;
+ default:
+ se = smfu_maperr(scf_error());
+ }
+ }
+
+done:
+ scf_pg_destroy(pg);
+ smfu_entity_destroy(&entity);
+ return (se);
+}
+
+/*ARGSUSED*/
+conerr_t
+api_entity_invoke_deletePGCust(rad_instance_t *inst, adr_method_t *meth,
+ data_t **ret, data_t **args, int count, data_t **error)
+{
+ radarg_t ra = { .inst = inst, .args = args };
+ return (smfu_rtrun(rt_invoke_deletePGCust, &ra, NULL, error));
+}
+
+static svcerr_t
rt_invoke_readProperties(scf_handle_t *h, void *arg, data_t **ret,
data_t **error)
{
@@ -415,7 +517,7 @@
return (smfu_rtrun(rt_invoke_readProperties, &ra, ret, error));
}
-
+/*ARGSUSED*/
static svcerr_t
tx_write_prop(scf_handle_t *h, scf_transaction_t *tx,
const char *name, scf_type_t type, data_t *values, data_t **error)
@@ -551,8 +653,6 @@
return (smfu_rtrun(rt_invoke_writeProperties, &ra, NULL, error));
}
-
-/*ARGSUSED*/
static svcerr_t
rt_invoke_readProperty(scf_handle_t *h, void *arg, data_t **ret, data_t **error)
{
@@ -781,6 +881,112 @@
return (smfu_rtrun(rt_invoke_deleteProperty, &ra, NULL, error));
}
+static svcerr_t
+tx_delete_propcust(scf_handle_t *h, scf_transaction_t *tx,
+ const char *name, data_t **error)
+{
+ svcerr_t se = SE_OK;
+ scf_transaction_entry_t *entry = scf_entry_create(h);
+
+ if (entry == NULL)
+ return (SE_FATAL);
+
+ if (scf_transaction_property_delcust(tx, entry, name) == -1) {
+ int e = scf_error();
+ scf_entry_destroy(entry);
+ switch (e) {
+ case SCF_ERROR_PERMISSION_DENIED:
+ se = error_scf(error, &e__ErrorCode_DENIED, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_BACKEND_READONLY:
+ se = error_scf(error, &e__ErrorCode_READONLY, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_DELETED:
+ se = error_scf(error, &e__ErrorCode_NOTFOUND,
+ &e__ErrorTarget_PROPERTY, name, NULL);
+ break;
+ default:
+ se = smfu_maperr(e);
+ }
+ }
+ return (se);
+}
+
+/*ARGSUSED*/
+static svcerr_t
+rt_invoke_deletePropertyCust(scf_handle_t *h, void *arg, data_t **ret,
+ data_t **error)
+{
+ radarg_t *ra = arg;
+ smfobj_t *smfo = instance_getdata(ra->inst);
+ const char *pgname = data_to_string(ra->args[0]);
+ const char *propname = data_to_string(ra->args[1]);
+ svcerr_t se = SE_OK;
+ smfu_entity_t entity = SMFU_ENTITY_INIT;
+ scf_propertygroup_t *pg = scf_pg_create(h);
+ scf_transaction_t *tx = scf_transaction_create(h);
+
+ if (pg == NULL || tx == NULL) {
+ se = internal_error(error, NULL);
+ goto done;
+ }
+
+ if ((se = smfu_lookup(h, smfo->sname, smfo->iname, &entity)) != SE_OK)
+ goto done;
+
+ if ((se = smfu_get_pg(&entity, pgname, pg, error)) != SE_OK)
+ goto done;
+
+top:
+ if (scf_transaction_start(tx, pg) == -1)
+ goto txerror;
+
+ if ((se = tx_delete_propcust(h, tx, propname, error)) != SE_OK)
+ goto done;
+
+ int r;
+ if ((r = scf_transaction_commit(tx)) == 1)
+ goto done;
+
+ if (r == 0 && scf_pg_update(pg) != -1) {
+ scf_transaction_destroy_children(tx);
+ scf_transaction_reset(tx);
+ goto top;
+ }
+
+txerror:
+ switch (scf_error()) {
+ case SCF_ERROR_PERMISSION_DENIED:
+ se = error_scf(error, &e__ErrorCode_DENIED, NULL,
+ NULL, NULL);
+ break;
+ case SCF_ERROR_BACKEND_READONLY:
+ se = error_scf(error, &e__ErrorCode_READONLY, NULL,
+ NULL, NULL);
+ break;
+ default:
+ se = smfu_maperr(scf_error());
+ }
+
+done:
+ scf_transaction_destroy_children(tx);
+ scf_transaction_destroy(tx);
+ scf_pg_destroy(pg);
+
+ return (se);
+}
+
+/*ARGSUSED*/
+conerr_t
+api_entity_invoke_deletePropertyCust(rad_instance_t *inst, adr_method_t *meth,
+ data_t **ret, data_t **args, int count, data_t **error)
+{
+ radarg_t ra = { .inst = inst, .args = args };
+ return (smfu_rtrun(rt_invoke_deletePropertyCust, &ra, NULL, error));
+}
+
/*
* Common retry callback for reading old-style template data from
* either a service's directly-attached property groups or an