2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * This file implements the bulk of the libscf templates interfaces. 2N/A * Templates describe metadata about a service or instance in general, 2N/A * and individual configuration properties on those services and instances. 2N/A * Human-consumable descriptions can be provided, along with definitions 2N/A * of valid configuration. See service_bundle.dtd.1 for XML definitions 2N/A * of templates, and the svccfg code for information on how those definitions 2N/A * are translated into the repository. 2N/A * The main data structures are scf_pg_tmpl and scf_prop_tmpl. These 2N/A * are allocated by the callers through scf_tmpl_[pg|prop]_create(), and 2N/A * destroyed with scf_tmpl_[pg|prop]_destroy(). They are populated by 2N/A * scf_tmpl_get_by_pg_name(), scf_tmpl_get_by_pg(), and 2N/A * scf_tmpl_get_by_prop(). They also store the iterator state for 2N/A * scf_tmpl_iter_pgs() and scf_tmpl_iter_props(). 2N/A * These data structures are then consumed by other functions to 2N/A * gather information about the template (e.g. name, description, 2N/A * choices, constraints, etc.). 2N/A * scf_tmpl_validate_fmri() does instance validation against template 2N/A * data, and populates a set of template errors which can be explored using 2N/A * the scf_tmpl_next_error() and the scf_tmpl_error*() suite of functions. 2N/A * The main data structures for template errors are scf_tmpl_errors, 2N/A * scf_tmpl_error is shared with svccfg to offer common printing 2N/A * of error messages between libscf and svccfg. 2N/A * General convenience functions are towards the top of this file, 2N/A * followed by pg and prop template discovery functions, followed 2N/A * by functions which gather information about the discovered 2N/A * template. Validation and error functions are at the end of this file. 2N/A * Common server errors are usually passed back to the caller. This 2N/A * array defines them centrally so that they don't need to be enumerated 2N/A * in every libscf call. 2N/A * Returns 1 if the supplied error is a member of the error array, 0 2N/A * char *_scf_tmpl_get_fmri() 2N/A * Given a pg_tmpl, returns the FMRI of the service or instance that 2N/A * template describes. The allocated string must be freed with free(). 2N/A * On failure, returns NULL and sets scf_error() to _CONNECTION_BROKEN, 2N/A * _DELETED, or _NO_MEMORY. 2N/A * char *_scf_get_pg_type() 2N/A * Given a propertygroup, returns an allocated string containing the 2N/A * type. The string must be freed with free(). 2N/A * On failure, returns NULL and sets scf_error() to: _CONNECTION_BROKEN, 2N/A * _DELETED, or _NO_MEMORY. 2N/A * char *_scf_get_prop_name() 2N/A * Given a property, returns the name in an allocated string. The string must 2N/A * be freed with free(). 2N/A * On error, returns NULL and sets scf_error() to _CONNECTION_BROKEN, 2N/A * _DELETED, or _NO_MEMORY. 2N/A * char *_scf_get_prop_type() 2N/A * Given a property, returns the type in an allocated string. The string must 2N/A * be freed with free(). 2N/A * On error, returns NULL and sets scf_error() to _CONNECTION_BROKEN, 2N/A * _DELETED, or _NO_MEMORY. 2N/A * int _read_single_value_from_pg() 2N/A * Reads a single value from the pg and property name specified. On success, 2N/A * returns an allocated value that must be freed. 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * Property has more than one value associated with it. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * prop_name not a valid property name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * Property group specified by pg is not set. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * char *_scf_read_single_astring_from_pg() 2N/A * Reads an astring from the pg and property name specified. On success, 2N/A * returns an allocated string. The string must be freed with free(). 2N/A * Returns NULL on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * Property has more than one value associated with it. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * prop_name not a valid property name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * The property group specified by pg is not set. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TYPE_MISMATCH 2N/A * char *_scf_read_tmpl_prop_type_as_string() 2N/A * Reads the property type and returns it as an allocated string. The string 2N/A * must be freed with free(). 2N/A * Returns NULL on failure, sets scf_error() to _BACKEND_ACCESS, 2N/A * _CONNECTION_BROKEN, _DELETED, _HANDLE_DESTROYED, _INTERNAL, _NO_MEMORY, 2N/A * _NO_RESOURCES, _NOT_BOUND, _PERMISSION_DENIED, or _TEMPLATE_INVALID. 2N/A * int _read_single_boolean_from_pg() 2N/A * Reads a boolean from the pg and property name specified. 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * Property has more than one value associated with it. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * prop_name is not a valid property name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * The property group specified by pg is not set. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TYPE_MISMATCH 2N/A * static char ** _append_astrings_values() 2N/A * This function reads the values from the property prop_name in pg and 2N/A * appends to an existing scf_values_t *vals. vals may be empty, but 2N/A * must exist. The function skips over zero-length and duplicate values. 2N/A * Returns NULL on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * prop_name is not a valid property name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TYPE_MISMATCH 2N/A * The array may be bigger, but it is irrelevant since 2N/A * we will always re-allocate a new one. 2N/A /* discard zero length strings */ 2N/A /* find and discard duplicates */ 2N/A * Returns NULL on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * prop_name is not a valid property name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TYPE_MISMATCH 2N/A * The returned string needs to be freed by the caller 2N/A * Returns NULL on failure. Sets scf_error() to: 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * Name isn't short enough to add the locale to. 2N/A * char *_tmpl_pg_name(pg, type, use_type) 2N/A * pg and type can both be NULL. Returns the name of the most specific 2N/A * template property group name based on the inputs. 2N/A * If use_type is set and pg is not NULL, a property group name for a 2N/A * property group template that has type defined is returned, even if no 2N/A * Returns NULL on failure and sets scf_error() to: 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * can't combine the arguments and get a reasonable length name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * _scf_get_pg_name() 2N/A * Gets the name of the supplied property group. On success, returns an 2N/A * allocated string. The string must be freed by free(). 2N/A * Returns NULL on failure and sets scf_error() to _CONNECTION_BROKEN, 2N/A * _DELETED, or _NO_MEMORY. 2N/A * char *_tmpl_prop_name() 2N/A * Returns the name of the property template prop (which is the name of 2N/A * the property template property group) in the property group 2N/A * template t. Returns NULL on failure and sets scf_error() to: 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * can't combine the arguments and get a reasonable length name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * int _get_snapshot() 2N/A * Gets the specified snapshot. If "snapshot" isn't defined, use the 2N/A * running snapshot. If the snapshot isn't found, that may or may 2N/A * not be an error depending on the caller. Return 0 in that case, 2N/A * but leave scf_error() set to SCF_ERROR_NOT_FOUND. On all other 2N/A * errors, set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * The handle argument is NULL, or snaphot is not a valid snapshot name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A /* Use running snapshot by default. */ 2N/A * Explicitly set SCF_ERROR_NONE so that the SCF_ERROR_NOT_FOUND 2N/A * return above is explicitly guaranteed to be from 2N/A * scf_instance_get_snapshot(). 2N/A * Returns NULL on error, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * The restarter's FMRI does not match an existing instance. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * The restarter's FMRI is not a valid FMRI. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * restarter property is not SCF_TYPE_ASTRING or has more than one value 2N/A /* Assume default restarter. */ 2N/A * If the arguments to the above functions 2N/A * aren't derived from the same handle, there's 2N/A * something wrong with the internal implementation, 2N/A * not the public caller further up the chain. 2N/A /* zero length string is NOT a valid restarter */ 2N/A /* Use default restarter */ 2N/A * Returns NULL on error, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * Restarter property has more than one value associated with it, 2N/A * or FMRI does not meet restrictions in scf_handle_decode_fmri() flags. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * The fmri argument in scf_handle_decode_fmri() is not a valid FMRI. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * Call the supplied function for each of the service or instance, the 2N/A * service's restarter, and the globally defined template instance. 2N/A * If the function returns SCF_WALK_ERROR, the walk is ended. If 2N/A * the function returns SCF_WALK_NEXT, the next entity is tried. 2N/A * The function is only expected to return SCF_WALK_DONE if it has 2N/A * found a property group match in the current entity, and has 2N/A * populated p->pw_pg with the matching property group. 2N/A * The caller of _walk_template_instances() MUST check if the passed parameters 2N/A * inst and svc match the fields pw_inst and pw_svc in the resulting 2N/A * pg_tmpl_walk_t and call the destructor for the unmatching objects. The walker 2N/A * may silently drop them if the template definition is in the restarter or in 2N/A * the global instance. 2N/A /* First, use supplied service or instance */ 2N/A * Check that the template scoping matches and if not, 2N/A /* Next the restarter. */ 2N/A * Check that the template scoping matches and if not, 2N/A * Check that the template scoping matches and if not, 2N/A * _get_pg() returns 0 on success and -1 on failure. Sets scf_error() 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_MISMATCH 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * name is not a valid property group. 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Returns SCF_WALK_NEXT for not found, SCF_WALK_ERROR for error, 2N/A * and SCF_WALK_DONE for found. 2N/A * On error, destroy pg and set it to NULL. 2N/A * Sets scf_error() if SCF_WALK_ERROR is returned to _BACKEND_ACCESS, 2N/A * _CONNECTION_BROKEN, _INTERNAL, _INVALID_ARGUMENT (name is not a 2N/A * valid property group), _NO_RESOURCES, or _NOT_BOUND. 2N/A * If match, return 0. If no match, return 1. If error, return -1. 2N/A * On error set scf_error() to _BACKEND_ACCESS, _CONNECTION_BROKEN, 2N/A * _HANDLE_DESTROYED, _INTERNAL, _NO_MEMORY, _NO_RESOURCES, _NOT_BOUND, 2N/A * _NOT_SET (property group specified by pg is not set), _PERMISSION_DENIED, 2N/A * or _TEMPLATE_INVALID (target property is not SCF_TYPE_ASTRING or has 2N/A * more than one value). 2N/A /* For a desired target of 'this', check for 'this' and 'instance'. */ 2N/A * Check if a matching template property group exists for each of: 2N/A * name and type, name only, type only, and completely wildcarded 2N/A * Both pg_name and pg_type are optional. 2N/A * Returns NULL on failure, sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * can't combine the _tmpl_pg_name arguments and get a reasonable 2N/A * length name, or pg_name is not a valid property group. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * target property is not SCF_TYPE_ASTRING or has more than one value. 2N/A * We're going to walk through the possible pg templates that 2N/A * could match the supplied name and type. We do this 2N/A * by explicit name lookups when possible to avoid having to 2N/A * keep track of a most-explicit-match during iteration. 2N/A /* First look for a template with name and type set and matching. */ 2N/A * Need to search on a name-only match before searching on 2N/A /* Next, see if there's an "nt" template where the type matches. */ 2N/A /* Make sure this is a name and type specified pg. */ 2N/A * Finds the pg match in either the supplied service or instance. 2N/A * Returns SCF_WALK_ERROR, SCF_WALK_NEXT, or SCF_WALK_DONE. 2N/A * If returning SCF_WALK_ERROR, sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * The snaphot is not a valid snapshot name, 2N/A * or can't create a reasonable property group template name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * target property is not SCF_TYPE_ASTRING or has more than one value. 2N/A * return 0 on success and -1 on failure. 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_HANDLE_MISMATCH 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * FMRI argument, snapshot name, pg_name, or pg is invalid. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A /* Parent type doesn't match. Keep looking. */ 2N/A /* Pass these back to the caller. */ 2N/A * No snapshot. We'll use 'editing' by default since 2N/A * snap and snapbuf are NULL. 2N/A /* Grab snapshot name while we're here. */ 2N/A /* No snapshot parent. Go looking for instance parent. */ 2N/A /* First look for instance parent. */ 2N/A /* OK, check for service parent */ 2N/A /* we may get a different instance back */ 2N/A /* we may get a different service back */ 2N/A * int scf_tmpl_get_by_pg_name() 2N/A * Get a template by a combination of the name and type. Either name 2N/A * or type can be null, which indicates a wildcard. flags may be 2N/A * SCF_PG_TMPL_FLAG_CURRENT (use current properties rather than 2N/A * the defined or running snapshot), and SCF_PG_TMPL_FLAG_EXACT (match 2N/A * only templates defined by the FMRI in question, not by its restarter 2N/A * or globally). Returns 0 on success and -1 on error, and sets 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * The connection to the repository was lost. 2N/A * The instance has been deleted. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * FMRI isn't valid, pg_name is too long to look for a template, or 2N/A * snapshot specified isn't a valid name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * The server does not have adequate resources to complete the request. 2N/A * SCF_ERROR_NOT_BOUND 2N/A * The handle is not currently bound. 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Object matching FMRI doesn't exist in the repository, or snapshot 2N/A /* If we have a service fmri, snapshot is ignored. */ 2N/A * For each of instance, restarter, global 2N/A * - check for a tm_pg_pattern_nt_<name> matching type 2N/A * - check for a tm_pg_pattern_t_<type> matching type 2N/A * - check for any tm_pg_pattern_ 2N/A * Currently plan to return the most specific match only. 2N/A /* we may get a different instance back */ 2N/A /* we may get a different service back */ 2N/A * Returns NULL on failure, sets scf_error() to _CONNECTION_BROKEN, 2N/A * _DELETED, _NO_RESOURCES, or _NOT_BOUND. 2N/A /* Iterate on property groups of type template_pg_pattern */ 2N/A * Returns NULL on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * Handle argument is NULL, or snaphot is not a valid snapshot name. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Check what level we last iterated on: none, service, 2N/A * restarter, or global. Make sure that if one in the middle 2N/A * doesn't exist, we move on to the next entity. 2N/A * Before we drop any references to pt_inst or pt_svc we must 2N/A * destroy them so we don't leak them. 2N/A * Don't go any further than the specified instance 2N/A /* Set pt_snap to the snapshot for this instance */ 2N/A * scf_pg_tmpl_t *scf_tmpl_pg_create(scf_handle_t *) 2N/A * Returns NULL on failure, sets scf_error() to _INVALID_ARGUMENT 2N/A * Retrieves name or type of a template pg. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * pname property is not SCF_TYPE_ASTRING or has more than one value. 2N/A * int scf_tmpl_iter_pgs() 2N/A * Iterates through the property group templates for the fmri given. 2N/A * When t is uninitialized or reset, sets t to the first property group 2N/A * template in fmri. On subsequent calls, sets t to the next property group 2N/A * Returns 1 on success, 0 when no property group templates are left to 2N/A * iterate, -1 on error. 2N/A * The flags argument may include SCF_PG_TMPL_FLAG_REQUIRED, 2N/A * SCF_PG_TMPL_FLAG_CURRENT, and/or SCF_PG_TMPL_FLAG_EXACT. 2N/A * Returns -1 on error and sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * The handle argument is NULL, fmri is invalid, or snapshot is invalid. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A /* This iteration is done. Get the next one */ 2N/A * Discard pgs which don't exist at the right scoping. This 2N/A * check also makes sure that if we're looking at, for 2N/A * don't hand back the same property groups twice. 2N/A * If walking only required property groups, check if 2N/A * the retrieved group is required. 2N/A * If type != NULL, check if type property matches. If no 2N/A * type property exists, consider it a match. 2N/A /* Do not reset t->pt_h. */ 2N/A * int scf_tmpl_get_by_prop() 2N/A * Get the property template given a property group template and property 2N/A * name. No flags are currently defined for this function. 2N/A * Returns NULL on failure, and sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Template object matching property doesn't exist in the repository. 2N/A * SCF_ERROR_TYPE_MISMATCH 2N/A * Matching template object is the wrong type in the repository. 2N/A * We've only found a template property group if the type 2N/A * scf_prop_tmpl_t *scf_tmpl_prop_create(scf_handle_t *); 2N/A * Returns NULL on failure, sets scf_error() to _INVALID_ARGUMENT, or 2N/A * int scf_tmpl_iter_props() 2N/A * Iterates over all property templates defined in the specified property 2N/A * group template. The iterator state is stored on the property template 2N/A * data structure, and the data structure should be allocated with 2N/A * scf_tmpl_prop_create(). To continue the iteration, the previously 2N/A * returned structure should be passed in as an argument to this function. 2N/A * flags can include SCF_PROP_TMPL_FLAG_REQUIRED. The function returns 2N/A * 1 when a result was found, and 0 when the iteration is complete. 2N/A * Returns -1 on failure, and sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Template data is invalid. One of the property templates in this 2N/A * pg_tmpl is malformed. 2N/A * Check if the name matches the appropriate property 2N/A * group template name. 2N/A * If walking only required properties, check if 2N/A * the retrieved property is required. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * The name of the template property group (the pname property) has 2N/A * an improper repository format and is not type astring or has 2N/A * more than one value. 2N/A * returns an allocated string that must be freed 2N/A * Returns NULL on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * name not a valid property name 2N/A * name and locale are too long to make a property name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Valid locales are always in the for of xx_YY.CODESET@ATTRIBUTE 2N/A * Only xx, the language part is required. The country code, YY as well 2N/A * as the CODESET and ATTRIBUTE are all optional but they MUST appear 2N/A * If we use the locale from setlocale, we'll look first for it as 2N/A * provided by the setlocale(3C). If the the lookup fails, we'll trim 2N/A * from right to left in this order: '@', '.' and '_'. We'll pick the 2N/A * first match. If all of them fail, we'll try the "C" locale. 2N/A * For locales provided by the caller, we'll not do the trimming 2N/A * described above, but will fall back to "C" locale. 2N/A for (t =
"@._"; *t !=
'\0'; t++) {
2N/A goto out;
/* lname_prop == NULL */ 2N/A while (*t !=
'\0') {
2N/A * The trimming char is not on the locale, 2N/A * let's try the one next without a trip to the 2N/A * if the inner while loop reached the end of t, bail. 2N/A goto out;
/* lname_prop == NULL */ 2N/A goto out;
/* lname_prop == NULL */ 2N/A * returns an allocated string that must be freed 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * locale is too long to make a valid property name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * returns an allocated string that must be freed 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * locale is too long to make a valid property name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * 'type' property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * 'type' property is not SCF_TYPE_ASTRING or has more than one value. 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * required property is not SCF_TYPE_BOOLEAN or has more than one value. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * target property is not SCF_TYPE_ASTRING or has more than one value. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * 'type' property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * 'type' property is not SCF_TYPE_ASTRING, has more than one value, 2N/A * is SCF_TYPE_INVALID, or is the empty string. 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * Property group which represents t was deleted. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * required property is not SCF_TYPE_ASTRING has more than one value. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * locale is too long to make a property name 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * common_name property is not SCF_TYPE_ASTRING has more than one value. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * locale is too long to make a property name 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * description property is not SCF_TYPE_ASTRING has more than one value. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * locale is too long to make a property name 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * units property is not SCF_TYPE_ASTRING has more than one value. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * visibility property is not SCF_TYPE_ASTRING has more than one value. 2N/A /* prop doesn't exist we take the default value */ 2N/A * Return an allocated string containing the value that must be freed 2N/A * On error set scf_error() _NO_MEMORY, or _NOT_SET (val has not been set 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* property has no value */ 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* property has no value */ 2N/A * Returns NULL on failure. Sets scf_error(): 2N/A * Caller is responsible for freeing returned pointer after use. 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * More tokens than the array size supplied. 2N/A * SCF_ERROR_NO_MEMORY 2N/A * check if name is among values of CHOICES_INCLUDE_VALUES 2N/A * return 0 if name is present, 1 name is not present, -1 on failure 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* range values are empty */ 2N/A /* min and max should be separated by a "," */ 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* range values are empty */ 2N/A /* min and max should be separated by a "," */ 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_CONSTRAINT_VIOLATED 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A int c_flag = 0;
/* have not read any value yet */ 2N/A /* First, look for explicitly declared choices. */ 2N/A /* Next, check for choices included by 'values'. */ 2N/A /* read values_name */ 2N/A }
else if (r == -
1) {
2N/A /* Finally check for choices included by 'constraints'. */ 2N/A /* read constraint_name */ 2N/A }
else if (r == -
1) {
2N/A * char *_make_value_name() 2N/A * Construct the prefix for a value common name or value description property. 2N/A * It takes the form: 2N/A * value_<BASE32 name>_<common_name|description>_ 2N/A * This is then combined with a localized suffix by the caller to look 2N/A * up the property in the repository: 2N/A * value_<BASE32 name>_<common_name|description>_<lang> 2N/A * Returns NULL on failure. Sets scf_error(): 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * Name isn't short enough make a value name with. 2N/A * SCF_ERROR_NO_MEMORY 2N/A /* Shouldn't happen. */ 2N/A * ssize_t scf_tmpl_value_common_name() 2N/A * Populates "out" with an allocated string containing the value's 2N/A * common name. Returns the size of the string on successful return. 2N/A * out must be freed with free() on successful return. 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * Property group was deleted. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * name not a valid property name 2N/A * name and locale are too long to make a property name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * property is not SCF_TYPE_ASTRING has more than one value. 2N/A * ssize_t scf_tmpl_value_description() 2N/A * Populates "out" with an allocated string containing the value's 2N/A * description. Returns the size of the string on successful return. 2N/A * out must be freed with free() on successful return. 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * Property group was deleted. 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * name not a valid property name 2N/A * name and locale are too long to make a property name 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * Property doesn't exist or exists and has no value. 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * property is not SCF_TYPE_ASTRING has more than one value. 2N/A * Templates error messages format, in human readable form. 2N/A * Each line is one error item: 2N/A * prefix error message 2N/A * FMRI="err->te_errs->tes_fmri" 2N/A * Property group="err->te_pg_name" 2N/A * Property name="err->te_prop_name" 2N/A * expected value 1="err->te_ev1" 2N/A * expected value 2="err->te_ev2" 2N/A * actual value="err->te_actual" 2N/A * Tempalte source="err->te_tmpl_fmri" 2N/A * pg_pattern name="err->tmpl_pg_name" 2N/A * pg_pattern type="err->tmpl_pg_type" 2N/A * prop_pattern name="err->tmpl_prop_name" 2N/A * prop_pattern type="err->tmpl_prop_type" 2N/A * To add a new error type, include scf_tmpl_error_type_t in libscf.h 2N/A * add one entry in em_desc[], and update the functions pointed by the 2N/A * _tmpl_error_access array with the new error code. Also, update the 2N/A * scf_tmpl_error_* functions to provide access to desired 2N/A * scf_tmpl_error_t fields. 2N/A * To add a new error item, add a new field to scf_tmpl_error_t, a new field 2N/A * in _scf_tmpl_error_desc or a new non-error-dependent string, add a new entry 2N/A * in _tmpl_error_access array and create the appropriate get_val, get_desc 2N/A * Changes to both the validation logic and the error types and items must 2N/A * be coordinated with the code in svccfg to ensure both libscf and svccfg's 2N/A * manifest validation validate the same things. 2N/A * Container for all template errors on a validated object. 2N/A /* will free strings in tes_errs */ 2N/A * Templates error-dependent labels 2N/A * This array MUST be kept in synch with the template error definition of 2N/A /* SCF_TERR_MISSING_PG */ 2N/A {
"Required property group missing",
"Name of missing property group",
2N/A "Type of missing property group",
NULL },
2N/A /* SCF_TERR_WRONG_PG_TYPE */ 2N/A {
"Property group has bad type",
"Specified type",
NULL,
2N/A /* SCF_TERR_MISSING_PROP */ 2N/A {
"Required property missing",
"Name of missing property",
NULL,
NULL },
2N/A /* SCF_TERR_WRONG_PROP_TYPE */ 2N/A {
"Property has bad type",
"Specified property type",
NULL,
2N/A "Actual property type" },
2N/A /* SCF_TERR_CARDINALITY_VIOLATION */ 2N/A {
"Number of property values violates cardinality restriction",
2N/A "Cardinality minimum",
"Cardinality maximum",
2N/A "Actual number of values" },
2N/A /* SCF_TERR_VALUE_CONSTRAINT_VIOLATED */ 2N/A {
"Property has illegal value",
NULL,
NULL,
"Illegal value" },
2N/A /* SCF_TERR_RANGE_VIOLATION */ 2N/A {
"Property value is out of range",
NULL,
NULL,
"Actual value" },
2N/A /* SCF_TERR_PG_REDEFINE */ 2N/A {
"Instance redefines pg_pattern",
"Instance pg_pattern name",
2N/A "Instance pg_pattern type",
NULL },
2N/A /* SCF_TERR_PROP_TYPE_MISMATCH */ 2N/A {
"Property type and value type mismatch",
NULL,
NULL,
"Value type" },
2N/A /* SCF_TERR_VALUE_OUT_OF_RANGE */ 2N/A /* SCF_TERR_INVALID_VALUE */ 2N/A /* SCF_TERR_PG_PATTERN_CONFLICT */ 2N/A {
"Conflicting pg_pattern specifications",
"Template source",
2N/A "pg_pattern name",
"pg_pattern type" },
2N/A /* SCF_TERR_PROP_PATTERN_CONFLICT */ 2N/A {
"Conflicting prop_pattern specifications",
"Template source",
2N/A "prop_pattern name",
"prop_pattern type" },
2N/A /* SCF_TERR_GENERAL_REDEFINE */ 2N/A {
"Service or instance pg_pattern redefines a global or restarter " 2N/A "pg_pattern",
"Template source",
"pg_pattern name",
2N/A "pg_pattern type" },
2N/A /* SCF_TERR_INCLUDE_VALUES */ 2N/A {
"Missing constraints or values for include_values element",
2N/A /* SCF_TERR_PG_PATTERN_INCOMPLETE */ 2N/A {
"Required pg_pattern is missing a name or type attribute",
2N/A /* SCF_TERR_PROP_PATTERN_INCOMPLETE */ 2N/A {
"Required prop_pattern is missing a type attribute",
2N/A * Templates non error-dependent labels 2N/A * Templates error item retrival functions 2N/A * if new items (lines) are added to the templates error messages, 2N/A * new entries in this array (and new fuctions) will be required. 2N/A * Allocate a new scf_tmpl_error_t and add it to the errs list provided. 2N/A * Returns NULL on failure. Sets scf_error(): 2N/A * SCF_ERROR_NO_MEMORY 2N/A /* Time to grow the pointer array. */ 2N/A * If destroy_strings is set, scf_tmpl_errors_destroy will free the 2N/A * strings in scf_tmpl_error_t entries. 2N/A * Returns NULL on failure. Sets scf_error(): 2N/A * SCF_ERROR_NO_MEMORY 2N/A /* Make space for a few errors. */ 2N/A * return 0 on success, if fails set scf_error() to: 2N/A * SCF_ERROR_NO_MEMORY 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_NO_MEMORY 2N/A * returns an allocated string that must be freed with free() 2N/A * string contains converted 64-bit integer value 2N/A * flag set for signed values 2N/A * if fails return NULL and set scf_error() to: 2N/A * SCF_ERROR_NO_MEMORY 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* keep pg_name = NULL and prop_name = NULL */ 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* keep pg_name = NULL and prop_name = NULL */ 2N/A /* keep pg_name = NULL and prop_name = NULL */ 2N/A /* use value for value type */ 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* keep pg_name = NULL and prop_name = NULL */ 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * return 0 if value is within count ranges constraint. 2N/A * return -1 otherwise 2N/A /* value is within ranges constraint */ 2N/A * return 0 if value is within count ranges constraint. 2N/A * return -1 otherwise 2N/A /* value is within integer ranges constraint */ 2N/A * int _value_in_constraint() 2N/A * Checks whether the supplied value violates any of the constraints 2N/A * specified in the supplied property template. If it does, an appropriate 2N/A * error is appended to "errs". pg and prop, if supplied, are used to 2N/A * augment the information in the error. Returns 0 on success. 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* Check if template type matches value type. */ 2N/A /* type is not wildcarded */ 2N/A /* Numeric values should be checked against any range constraints. */ 2N/A /* value is within ranges constraint */ 2N/A * If we get here, we have a possible constraint 2N/A /* value is within ranges constraint */ 2N/A * If we get here, we have a possible constraint 2N/A * If a set of names is provided, confirm value has one of 2N/A * All errors (INVALID_ARGUMENT, NOT_SET, TYPE_MISMATCH) 2N/A * should be impossible or already caught above. 2N/A /* value is within constraint */ 2N/A /* if we get here, we have a constraint violation */ 2N/A /* register the errors found */ 2N/A * Help make the error more human-friendly. If 2N/A * pg and prop are provided, we know we're 2N/A * validating repository data. If they're not, 2N/A * we're validating a potentially hypothetical 2N/A * Returns -1 on failure. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A int nsz = 0;
/* err msg length */ 2N/A int sz = n;
/* available buffer size */ 2N/A char *
buf = s;
/* where to append in buffer */ 2N/A /* no item to print */ 2N/A * return 0 on success, -1 on failure. 2N/A * set scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* Any number of values permitted. Just return success. */ 2N/A * Returns -1 on error. Sets scf_error(): 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* If required, type must be specified. */ 2N/A * tmpl_prop_type shouldn't have handed back 2N/A * an invalid property type. 2N/A /* Value constraints */ 2N/A * Iterate through each value, and confirm it is defined as 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* Type must be specified for required pgs. */ 2N/A /* Iterate through properties in the repository and check them. */ 2N/A /* No template. Continue. */ 2N/A * Confirm required properties are present. 2N/A /* required properties cannot have type wildcarded */ 2N/A * Checks if instance fmri redefines any pgs defined in restarter or global 2N/A * Return -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A /* found a pg_pattern redefinition */ 2N/A * Returns -1 on failure, sets scf_error() to: 2N/A * SCF_ERROR_BACKEND_ACCESS 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_HANDLE_DESTROYED 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * SCF_ERROR_NOT_FOUND 2N/A * SCF_ERROR_PERMISSION_DENIED 2N/A * SCF_ERROR_TEMPLATE_INVALID 2N/A * Sets SCF_ERROR_INVALID_ARGUMENT, SCF_ERROR_NO_MEMORY, 2N/A * SCF_ERROR_NO_RESOURCES, SCF_ERROR_INTERNAL or 2N/A * SCF_ERROR_HANDLE_DESTROYED. 2N/A * Check that property groups on this instance conform to the template. 2N/A * Confirm required property groups are present. 2N/A * required property group templates should not have 2N/A * wildcarded name or type 2N/A /* there are no errors to report */ 2N/A * The conflict printing code is located here so we can keep the 2N/A * number files which require processing for the message build to 2N/A * conflicting property="foo/bar"; Value="X" from 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A * Prints all service and instance conflicts for an instance. 2N/A * SCF_ERROR_CONNECTION_BROKEN 2N/A * SCF_ERROR_INTERNAL 2N/A * SCF_ERROR_INVALID_ARGUMENT 2N/A * SCF_ERROR_NO_MEMORY 2N/A * SCF_ERROR_NO_RESOURCES 2N/A * SCF_ERROR_NOT_BOUND 2N/A /* First look at instance's parent for conflicts. */ 2N/A /* Reset the iterator, and then look at the instance. */