997 return (0);
998 }
999
1000 static int
1001 lxml_get_method_context(pgroup_t *pg, xmlNodePtr ctx)
1002 {
1003 xmlNodePtr cursor;
1004
1005 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_WORKING_DIRECTORY,
1006 SCF_TYPE_ASTRING, ctx, "working_directory", NULL) != 0)
1007 return (-1);
1008
1009 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_PROJECT,
1010 SCF_TYPE_ASTRING, ctx, "project", NULL) != 0)
1011 return (-1);
1012
1013 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_RESOURCE_POOL,
1014 SCF_TYPE_ASTRING, ctx, "resource_pool", NULL) != 0)
1015 return (-1);
1016
1017 for (cursor = ctx->xmlChildrenNode; cursor != NULL;
1018 cursor = cursor->next) {
1019 if (lxml_ignorable_block(cursor))
1020 continue;
1021
1022 switch (lxml_xlate_element(cursor->name)) {
1023 case SC_METHOD_CREDENTIAL:
1024 (void) lxml_get_method_credential(pg, cursor);
1025 break;
1026 case SC_METHOD_PROFILE:
1027 (void) lxml_get_method_profile(pg, cursor);
1028 break;
1029 case SC_METHOD_ENVIRONMENT:
1030 (void) lxml_get_method_environment(pg, cursor);
1031 break;
1032 default:
1033 semerr(gettext("illegal element \'%s\' in method "
1034 "context\n"), (char *)cursor);
1035 break;
1036 }
1083 * established by inetd(1M).
1084 */
1085 errno = 0;
1086 u_timeout = strtoull((char *)timeout, &endptr, 10);
1087 if (errno != 0 || endptr == (char *)timeout || *endptr)
1088 uu_die(gettext("illegal value \"%s\" for "
1089 "timeout_seconds (%s)\n"),
1090 (char *)timeout, (errno) ? strerror(errno):
1091 gettext("Illegal character"));
1092 p = internal_property_create(SCF_PROPERTY_TIMEOUT,
1093 SCF_TYPE_COUNT, 1, u_timeout);
1094 r = internal_attach_property(pg, p);
1095 xmlFree(timeout);
1096 }
1097 if (r != 0)
1098 return (-1);
1099
1100 /*
1101 * There is a possibility that a method context also exists, in which
1102 * case the following attributes are defined: project, resource_pool,
1103 * working_directory, profile, user, group, privileges, limit_privileges
1104 */
1105 for (cursor = emeth->xmlChildrenNode; cursor != NULL;
1106 cursor = cursor->next) {
1107 if (lxml_ignorable_block(cursor))
1108 continue;
1109
1110 switch (lxml_xlate_element(cursor->name)) {
1111 case SC_STABILITY:
1112 if (lxml_get_pgroup_stability(pg, cursor) != 0)
1113 return (-1);
1114 break;
1115
1116 case SC_METHOD_CONTEXT:
1117 (void) lxml_get_method_context(pg, cursor);
1118 break;
1119
1120 case SC_PROPVAL:
1121 (void) lxml_get_propval(pg, cursor);
1122 break;
1123
3336
3337 /*
3338 * Check to see if the service should allow the upgrade
3339 * process to handle adding of the manifestfiles linkage.
3340 *
3341 * If the service exists and does not have a manifestfiles
3342 * property group then the upgrade process should handle
3343 * the service.
3344 *
3345 * If the service doesn't exist or the service exists
3346 * and has a manifestfiles property group then the import
3347 * process can handle the manifestfiles property group
3348 * work.
3349 *
3350 * This prevents potential cleanup of unaccounted for instances
3351 * in early manifest import due to upgrade process needing
3352 * information that has not yet been supplied by manifests
3353 * that are still located in the /var/svc manifests directory.
3354 */
3355 static int
3356 lxml_check_upgrade(const char *service) {
3357 scf_handle_t *h = NULL;
3358 scf_scope_t *sc = NULL;
3359 scf_service_t *svc = NULL;
3360 scf_propertygroup_t *pg = NULL;
3361 int rc = SCF_FAILED;
3362
3363 if ((h = scf_handle_create(SCF_VERSION)) == NULL ||
3364 (sc = scf_scope_create(h)) == NULL ||
3365 (svc = scf_service_create(h)) == NULL ||
3366 (pg = scf_pg_create(h)) == NULL)
3367 goto out;
3368
3369 if (scf_handle_bind(h) != 0)
3370 goto out;
3371
3372 if (scf_handle_get_scope(h, SCF_FMRI_LOCAL_SCOPE, sc) == -1)
3373 goto out;
3374
3375 if (scf_scope_get_service(sc, service, svc) != SCF_SUCCESS) {
3376 if (scf_error() == SCF_ERROR_NOT_FOUND)
|
997 return (0);
998 }
999
1000 static int
1001 lxml_get_method_context(pgroup_t *pg, xmlNodePtr ctx)
1002 {
1003 xmlNodePtr cursor;
1004
1005 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_WORKING_DIRECTORY,
1006 SCF_TYPE_ASTRING, ctx, "working_directory", NULL) != 0)
1007 return (-1);
1008
1009 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_PROJECT,
1010 SCF_TYPE_ASTRING, ctx, "project", NULL) != 0)
1011 return (-1);
1012
1013 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_RESOURCE_POOL,
1014 SCF_TYPE_ASTRING, ctx, "resource_pool", NULL) != 0)
1015 return (-1);
1016
1017 if (new_opt_str_prop_from_attr(pg, SCF_PROPERTY_SECFLAGS,
1018 SCF_TYPE_ASTRING, ctx, "security_flags", NULL) != 0)
1019 return (-1);
1020
1021 for (cursor = ctx->xmlChildrenNode; cursor != NULL;
1022 cursor = cursor->next) {
1023 if (lxml_ignorable_block(cursor))
1024 continue;
1025
1026 switch (lxml_xlate_element(cursor->name)) {
1027 case SC_METHOD_CREDENTIAL:
1028 (void) lxml_get_method_credential(pg, cursor);
1029 break;
1030 case SC_METHOD_PROFILE:
1031 (void) lxml_get_method_profile(pg, cursor);
1032 break;
1033 case SC_METHOD_ENVIRONMENT:
1034 (void) lxml_get_method_environment(pg, cursor);
1035 break;
1036 default:
1037 semerr(gettext("illegal element \'%s\' in method "
1038 "context\n"), (char *)cursor);
1039 break;
1040 }
1087 * established by inetd(1M).
1088 */
1089 errno = 0;
1090 u_timeout = strtoull((char *)timeout, &endptr, 10);
1091 if (errno != 0 || endptr == (char *)timeout || *endptr)
1092 uu_die(gettext("illegal value \"%s\" for "
1093 "timeout_seconds (%s)\n"),
1094 (char *)timeout, (errno) ? strerror(errno):
1095 gettext("Illegal character"));
1096 p = internal_property_create(SCF_PROPERTY_TIMEOUT,
1097 SCF_TYPE_COUNT, 1, u_timeout);
1098 r = internal_attach_property(pg, p);
1099 xmlFree(timeout);
1100 }
1101 if (r != 0)
1102 return (-1);
1103
1104 /*
1105 * There is a possibility that a method context also exists, in which
1106 * case the following attributes are defined: project, resource_pool,
1107 * working_directory, profile, user, group, privileges,
1108 * limit_privileges, security_flags
1109 */
1110 for (cursor = emeth->xmlChildrenNode; cursor != NULL;
1111 cursor = cursor->next) {
1112 if (lxml_ignorable_block(cursor))
1113 continue;
1114
1115 switch (lxml_xlate_element(cursor->name)) {
1116 case SC_STABILITY:
1117 if (lxml_get_pgroup_stability(pg, cursor) != 0)
1118 return (-1);
1119 break;
1120
1121 case SC_METHOD_CONTEXT:
1122 (void) lxml_get_method_context(pg, cursor);
1123 break;
1124
1125 case SC_PROPVAL:
1126 (void) lxml_get_propval(pg, cursor);
1127 break;
1128
3341
3342 /*
3343 * Check to see if the service should allow the upgrade
3344 * process to handle adding of the manifestfiles linkage.
3345 *
3346 * If the service exists and does not have a manifestfiles
3347 * property group then the upgrade process should handle
3348 * the service.
3349 *
3350 * If the service doesn't exist or the service exists
3351 * and has a manifestfiles property group then the import
3352 * process can handle the manifestfiles property group
3353 * work.
3354 *
3355 * This prevents potential cleanup of unaccounted for instances
3356 * in early manifest import due to upgrade process needing
3357 * information that has not yet been supplied by manifests
3358 * that are still located in the /var/svc manifests directory.
3359 */
3360 static int
3361 lxml_check_upgrade(const char *service)
3362 {
3363 scf_handle_t *h = NULL;
3364 scf_scope_t *sc = NULL;
3365 scf_service_t *svc = NULL;
3366 scf_propertygroup_t *pg = NULL;
3367 int rc = SCF_FAILED;
3368
3369 if ((h = scf_handle_create(SCF_VERSION)) == NULL ||
3370 (sc = scf_scope_create(h)) == NULL ||
3371 (svc = scf_service_create(h)) == NULL ||
3372 (pg = scf_pg_create(h)) == NULL)
3373 goto out;
3374
3375 if (scf_handle_bind(h) != 0)
3376 goto out;
3377
3378 if (scf_handle_get_scope(h, SCF_FMRI_LOCAL_SCOPE, sc) == -1)
3379 goto out;
3380
3381 if (scf_scope_get_service(sc, service, svc) != SCF_SUCCESS) {
3382 if (scf_error() == SCF_ERROR_NOT_FOUND)
|