17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53eae19d9Swesolows * Common Development and Distribution License (the "License"). 63eae19d9Swesolows * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 213eae19d9Swesolows 227c478bd9Sstevel@tonic-gate /* 23f329b923SSean Wilcox * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _CMD_SVCCFG_H 277c478bd9Sstevel@tonic-gate #define _CMD_SVCCFG_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <libxml/tree.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <libscf.h> 359444c26fSTom Whitten #include <libscf_priv.h> 367c478bd9Sstevel@tonic-gate #include <libtecla.h> 377c478bd9Sstevel@tonic-gate #include <libuutil.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* Command scope bits for command tab completion */ 447c478bd9Sstevel@tonic-gate #define CS_SCOPE 0x01 457c478bd9Sstevel@tonic-gate #define CS_SVC 0x02 467c478bd9Sstevel@tonic-gate #define CS_INST 0x04 477c478bd9Sstevel@tonic-gate #define CS_SNAP 0x08 487c478bd9Sstevel@tonic-gate #define CS_GLOBAL 0x0f 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* Flags for lscf_bundle_import() & co. */ 517c478bd9Sstevel@tonic-gate #define SCI_NOREFRESH 0x01 /* Don't refresh instances */ 527c478bd9Sstevel@tonic-gate #define SCI_GENERALLAST 0x04 /* Add general property group last */ 537c478bd9Sstevel@tonic-gate #define SCI_NOENABLED 0x08 /* Don't import general/enabled. */ 547c478bd9Sstevel@tonic-gate #define SCI_FRESH 0x10 /* Freshly imported service */ 557c478bd9Sstevel@tonic-gate #define SCI_FORCE 0x20 /* Override-import. */ 567c478bd9Sstevel@tonic-gate #define SCI_KEEP 0x40 /* Don't delete when SCI_FORCEing */ 573eae19d9Swesolows #define SCI_NOSNAP 0x80 /* Don't take last-import snapshot */ 583534c681SSean Wilcox #define SCI_DELAYENABLE 0x100 /* Delay the general/enable property */ 593eae19d9Swesolows 60f329b923SSean Wilcox #define SCI_OP_IMPORT 0x1000 61f329b923SSean Wilcox #define SCI_OP_APPLY 0x2000 62f329b923SSean Wilcox #define SCI_OP_RESTORE 0x4000 63f329b923SSean Wilcox 649444c26fSTom Whitten #define HASH_SVC "smf/manifest" 659444c26fSTom Whitten 669444c26fSTom Whitten /* 679444c26fSTom Whitten * If the filesystem/minimal service is not online, do not consider 689444c26fSTom Whitten * manifests in the /var file system. 699444c26fSTom Whitten */ 709444c26fSTom Whitten #define IGNORE_VAR (!est->sc_fs_minimal) 719444c26fSTom Whitten 723eae19d9Swesolows /* Flags for lscf_service_export() */ 733eae19d9Swesolows #define SCE_ALL_VALUES 0x01 /* Include all property values */ 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #ifdef lint 767c478bd9Sstevel@tonic-gate extern int yyerror(const char *); 777c478bd9Sstevel@tonic-gate extern int yyparse(void); 787c478bd9Sstevel@tonic-gate #endif /* lint */ 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate extern int lex_lineno; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #define MANIFEST_DTD_PATH "/usr/share/lib/xml/dtd/service_bundle.dtd.1" 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * The following list must be kept in the same order as that of 857c478bd9Sstevel@tonic-gate * lxml_prop_types[] 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate typedef enum element { 88f6f041a2SAntonello Cruz SC_ASTRING = 0, 89f6f041a2SAntonello Cruz SC_BOOLEAN, 90f6f041a2SAntonello Cruz SC_CARDINALITY, 91f6f041a2SAntonello Cruz SC_CHOICES, 92f6f041a2SAntonello Cruz SC_COMMON_NAME, 93f6f041a2SAntonello Cruz SC_CONSTRAINTS, 94f6f041a2SAntonello Cruz SC_COUNT, 95f6f041a2SAntonello Cruz SC_INSTANCE_CREATE_DEFAULT, 96f6f041a2SAntonello Cruz SC_DEPENDENCY, 97f6f041a2SAntonello Cruz SC_DEPENDENT, 98f6f041a2SAntonello Cruz SC_DESCRIPTION, 99f6f041a2SAntonello Cruz SC_DOC_LINK, 100f6f041a2SAntonello Cruz SC_DOCUMENTATION, 101f6f041a2SAntonello Cruz SC_ENABLED, 102*f6e214c7SGavin Maltby SC_EVENT, 103f6f041a2SAntonello Cruz SC_EXEC_METHOD, 104f6f041a2SAntonello Cruz SC_FMRI, 105f6f041a2SAntonello Cruz SC_HOST, 106f6f041a2SAntonello Cruz SC_HOSTNAME, 107f6f041a2SAntonello Cruz SC_INCLUDE_VALUES, 108f6f041a2SAntonello Cruz SC_INSTANCE, 109f6f041a2SAntonello Cruz SC_INTEGER, 110f6f041a2SAntonello Cruz SC_INTERNAL_SEPARATORS, 111f6f041a2SAntonello Cruz SC_LOCTEXT, 112f6f041a2SAntonello Cruz SC_MANPAGE, 113f6f041a2SAntonello Cruz SC_METHOD_CONTEXT, 114f6f041a2SAntonello Cruz SC_METHOD_CREDENTIAL, 115f6f041a2SAntonello Cruz SC_METHOD_PROFILE, 116f6f041a2SAntonello Cruz SC_METHOD_ENVIRONMENT, 117f6f041a2SAntonello Cruz SC_METHOD_ENVVAR, 118f6f041a2SAntonello Cruz SC_NET_ADDR, 119f6f041a2SAntonello Cruz SC_NET_ADDR_V4, 120f6f041a2SAntonello Cruz SC_NET_ADDR_V6, 121*f6e214c7SGavin Maltby SC_NOTIFICATION_PARAMETERS, 122f6f041a2SAntonello Cruz SC_OPAQUE, 123*f6e214c7SGavin Maltby SC_PARAMETER, 124*f6e214c7SGavin Maltby SC_PARAMVAL, 125f6f041a2SAntonello Cruz SC_PG_PATTERN, 126f6f041a2SAntonello Cruz SC_PROP_PATTERN, 127f6f041a2SAntonello Cruz SC_PROPERTY, 128f6f041a2SAntonello Cruz SC_PROPERTY_GROUP, 129f6f041a2SAntonello Cruz SC_PROPVAL, 130f6f041a2SAntonello Cruz SC_RANGE, 131f6f041a2SAntonello Cruz SC_RESTARTER, 132f6f041a2SAntonello Cruz SC_SERVICE, 133f6f041a2SAntonello Cruz SC_SERVICE_BUNDLE, 134f6f041a2SAntonello Cruz SC_SERVICE_FMRI, 135f6f041a2SAntonello Cruz SC_INSTANCE_SINGLE, 136f6f041a2SAntonello Cruz SC_STABILITY, 137f6f041a2SAntonello Cruz SC_TEMPLATE, 138f6f041a2SAntonello Cruz SC_TIME, 139*f6e214c7SGavin Maltby SC_TYPE, 140f6f041a2SAntonello Cruz SC_UNITS, 141f6f041a2SAntonello Cruz SC_URI, 142f6f041a2SAntonello Cruz SC_USTRING, 143f6f041a2SAntonello Cruz SC_VALUE, 144f6f041a2SAntonello Cruz SC_VALUE_NODE, 145f6f041a2SAntonello Cruz SC_VALUES, 146f6f041a2SAntonello Cruz SC_VISIBILITY, 147f6f041a2SAntonello Cruz SC_XI_FALLBACK, 148f6f041a2SAntonello Cruz SC_XI_INCLUDE 1497c478bd9Sstevel@tonic-gate } element_t; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate typedef enum bundle_type { 1527c478bd9Sstevel@tonic-gate SVCCFG_UNKNOWN_BUNDLE, SVCCFG_MANIFEST, SVCCFG_PROFILE, SVCCFG_ARCHIVE 1537c478bd9Sstevel@tonic-gate } bundle_type_t; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate typedef struct bundle { 1567c478bd9Sstevel@tonic-gate uu_list_t *sc_bundle_services; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate xmlChar *sc_bundle_name; 1597c478bd9Sstevel@tonic-gate bundle_type_t sc_bundle_type; 1607c478bd9Sstevel@tonic-gate } bundle_t; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate typedef enum service_type { 1637c478bd9Sstevel@tonic-gate SVCCFG_UNKNOWN_SERVICE = 0x0, SVCCFG_SERVICE, SVCCFG_RESTARTER, 1647c478bd9Sstevel@tonic-gate SVCCFG_MILESTONE 1657c478bd9Sstevel@tonic-gate } service_type_t; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate typedef enum entity_type { 1681f6eb021SLiane Praza SVCCFG_SERVICE_OBJECT = 0x0, SVCCFG_INSTANCE_OBJECT 1697c478bd9Sstevel@tonic-gate } entity_type_t; 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate enum import_state { 1727c478bd9Sstevel@tonic-gate IMPORT_NONE = 0, 1737c478bd9Sstevel@tonic-gate IMPORT_PREVIOUS, 1747c478bd9Sstevel@tonic-gate IMPORT_PROP_BEGUN, 1757c478bd9Sstevel@tonic-gate IMPORT_PROP_DONE, 1767c478bd9Sstevel@tonic-gate IMPORT_COMPLETE, 1777c478bd9Sstevel@tonic-gate IMPORT_REFRESHED 1787c478bd9Sstevel@tonic-gate }; 1797c478bd9Sstevel@tonic-gate 1803eae19d9Swesolows typedef enum svccfg_op { 181f329b923SSean Wilcox SVCCFG_OP_NONE = -1, 1823eae19d9Swesolows SVCCFG_OP_IMPORT = 0, 1833eae19d9Swesolows SVCCFG_OP_APPLY, 1843eae19d9Swesolows SVCCFG_OP_RESTORE 1853eae19d9Swesolows } svccfg_op_t; 1863eae19d9Swesolows 1871f6eb021SLiane Praza /* 1881f6eb021SLiane Praza * Return values for functions that validate an entity against the templates. 1891f6eb021SLiane Praza */ 1901f6eb021SLiane Praza typedef enum tmpl_validate_status { 1911f6eb021SLiane Praza TVS_SUCCESS = 0, 1921f6eb021SLiane Praza /* 1931f6eb021SLiane Praza * Either conversion of ASTRING property value to a number failed, 1941f6eb021SLiane Praza * or base 32 decoding of a property value failed. 1951f6eb021SLiane Praza */ 1961f6eb021SLiane Praza TVS_BAD_CONVERSION, 1971f6eb021SLiane Praza /* Template is defective. */ 1981f6eb021SLiane Praza TVS_BAD_TEMPLATE, 1991f6eb021SLiane Praza /* Template type spec is invalid. */ 2001f6eb021SLiane Praza TVS_INVALID_TYPE_SPECIFICATION, 2011f6eb021SLiane Praza /* Property group is missing a type specification. */ 2021f6eb021SLiane Praza TVS_MISSING_PG_TYPE, 2031f6eb021SLiane Praza /* Template with required == true is missing type specification. */ 2041f6eb021SLiane Praza TVS_MISSING_TYPE_SPECIFICATION, 2051f6eb021SLiane Praza /* No match was found for specified item. */ 2061f6eb021SLiane Praza TVS_NOMATCH, 2071f6eb021SLiane Praza /* Validation error occurred */ 2081f6eb021SLiane Praza TVS_VALIDATION, 2091f6eb021SLiane Praza /* Validation error that should not inhibit import. */ 2101f6eb021SLiane Praza TVS_WARN, 2111f6eb021SLiane Praza /* Could not validate because of fatal errors. */ 2121f6eb021SLiane Praza TVS_FATAL = -1 2131f6eb021SLiane Praza } tmpl_validate_status_t; 2141f6eb021SLiane Praza 2151f6eb021SLiane Praza /* 2161f6eb021SLiane Praza * The composed_pg structure is used for templates validation. It is 2171f6eb021SLiane Praza * defined in svccfg_tmpl.c 2181f6eb021SLiane Praza */ 2191f6eb021SLiane Praza typedef struct composed_pg composed_pg_t; 2201f6eb021SLiane Praza 2217c478bd9Sstevel@tonic-gate typedef struct entity { 2227c478bd9Sstevel@tonic-gate uu_list_node_t sc_node; 2237c478bd9Sstevel@tonic-gate entity_type_t sc_etype; 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate /* Common fields to all entities. */ 2267c478bd9Sstevel@tonic-gate const char *sc_name; 2277c478bd9Sstevel@tonic-gate const char *sc_fmri; 2287c478bd9Sstevel@tonic-gate uu_list_t *sc_pgroups; 2297c478bd9Sstevel@tonic-gate uu_list_t *sc_dependents; 2307c478bd9Sstevel@tonic-gate struct entity *sc_parent; 2317c478bd9Sstevel@tonic-gate enum import_state sc_import_state; 232f329b923SSean Wilcox boolean_t sc_miss_type; 2337c478bd9Sstevel@tonic-gate int sc_seen; 234f329b923SSean Wilcox svccfg_op_t sc_op; 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate union { 2377c478bd9Sstevel@tonic-gate struct { 2387c478bd9Sstevel@tonic-gate uu_list_t *sc_service_instances; 2397c478bd9Sstevel@tonic-gate service_type_t sc_service_type; 2407c478bd9Sstevel@tonic-gate uint_t sc_service_version; 2411f6eb021SLiane Praza /* Following used by template validation */ 2421f6eb021SLiane Praza struct entity *sc_restarter; 2431f6eb021SLiane Praza struct entity *sc_global; 2447c478bd9Sstevel@tonic-gate } sc_service; 2457c478bd9Sstevel@tonic-gate struct { 2461f6eb021SLiane Praza uu_avl_t *sc_composed; 2471f6eb021SLiane Praza /* Following used by template validation */ 2481f6eb021SLiane Praza struct entity *sc_instance_restarter; 2497c478bd9Sstevel@tonic-gate } sc_instance; 2507c478bd9Sstevel@tonic-gate } sc_u; 2517c478bd9Sstevel@tonic-gate } entity_t; 2527c478bd9Sstevel@tonic-gate 2531f6eb021SLiane Praza /* 2541f6eb021SLiane Praza * sc_pgroup_composed is only used for templates validation of properties. 2551f6eb021SLiane Praza * It is created in build_composed_property_groups() and destroyed in 2561f6eb021SLiane Praza * composed_pg_destroy(). It will only be set for property groups that are 2571f6eb021SLiane Praza * part of an instance -- not for service property groups. 2581f6eb021SLiane Praza */ 2597c478bd9Sstevel@tonic-gate typedef struct pgroup { 2607c478bd9Sstevel@tonic-gate uu_list_node_t sc_node; 2617c478bd9Sstevel@tonic-gate uu_list_t *sc_pgroup_props; 2621f6eb021SLiane Praza composed_pg_t *sc_pgroup_composed; /* Composed properties */ 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate const char *sc_pgroup_name; 2657c478bd9Sstevel@tonic-gate const char *sc_pgroup_type; 2667c478bd9Sstevel@tonic-gate uint_t sc_pgroup_flags; 2677c478bd9Sstevel@tonic-gate struct entity *sc_parent; 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate int sc_pgroup_delete; 2707c478bd9Sstevel@tonic-gate int sc_pgroup_override; 2717c478bd9Sstevel@tonic-gate const char *sc_pgroup_fmri; /* Used for dependents */ 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate int sc_pgroup_seen; 2747c478bd9Sstevel@tonic-gate } pgroup_t; 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate typedef struct property { 2777c478bd9Sstevel@tonic-gate uu_list_node_t sc_node; 2781f6eb021SLiane Praza uu_avl_node_t sc_composed_node; /* Composed props linkage */ 2797c478bd9Sstevel@tonic-gate uu_list_t *sc_property_values; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate char *sc_property_name; 2827c478bd9Sstevel@tonic-gate scf_type_t sc_value_type; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate int sc_property_override; 2857c478bd9Sstevel@tonic-gate int sc_seen; 2867c478bd9Sstevel@tonic-gate } property_t; 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate typedef struct value { 2897c478bd9Sstevel@tonic-gate uu_list_node_t sc_node; 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate scf_type_t sc_type; 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate void (*sc_free)(struct value *); 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate union { 2967c478bd9Sstevel@tonic-gate uint64_t sc_count; 2977c478bd9Sstevel@tonic-gate int64_t sc_integer; 2987c478bd9Sstevel@tonic-gate char *sc_string; 2997c478bd9Sstevel@tonic-gate } sc_u; 3007c478bd9Sstevel@tonic-gate } value_t; 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate typedef struct scf_callback { 3037c478bd9Sstevel@tonic-gate scf_handle_t *sc_handle; 3047c478bd9Sstevel@tonic-gate void *sc_parent; /* immediate parent: scope, service, */ 3057c478bd9Sstevel@tonic-gate /* instance, property group, property */ 3067c478bd9Sstevel@tonic-gate scf_transaction_t *sc_trans; 3077c478bd9Sstevel@tonic-gate int sc_service; /* True if sc_parent is a service. */ 3087c478bd9Sstevel@tonic-gate uint_t sc_flags; 3097c478bd9Sstevel@tonic-gate pgroup_t *sc_general; /* pointer to general property group */ 3103534c681SSean Wilcox property_t *sc_enable; /* pointer to enable property */ 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate const char *sc_source_fmri; 3137c478bd9Sstevel@tonic-gate const char *sc_target_fmri; 3147c478bd9Sstevel@tonic-gate int sc_err; 3157c478bd9Sstevel@tonic-gate } scf_callback_t; 3167c478bd9Sstevel@tonic-gate 3171f6eb021SLiane Praza /* 3181f6eb021SLiane Praza * Collection of template validation errors. 3191f6eb021SLiane Praza */ 3201f6eb021SLiane Praza typedef struct tmpl_errors tmpl_errors_t; 3211f6eb021SLiane Praza 3227c478bd9Sstevel@tonic-gate #ifndef NDEBUG 3237c478bd9Sstevel@tonic-gate #define bad_error(func, err) { \ 3247c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s:%d: %s() failed with unexpected " \ 3257c478bd9Sstevel@tonic-gate "error %d. Aborting.\n", __FILE__, __LINE__, (func), (err)); \ 3267c478bd9Sstevel@tonic-gate abort(); \ 3277c478bd9Sstevel@tonic-gate } 3287c478bd9Sstevel@tonic-gate #else 3297c478bd9Sstevel@tonic-gate #define bad_error(func, err) abort() 3307c478bd9Sstevel@tonic-gate #endif 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate #define SC_CMD_LINE 0x0 3337c478bd9Sstevel@tonic-gate #define SC_CMD_FILE 0x1 3347c478bd9Sstevel@tonic-gate #define SC_CMD_EOF 0x2 3357c478bd9Sstevel@tonic-gate #define SC_CMD_IACTIVE 0x4 3367c478bd9Sstevel@tonic-gate #define SC_CMD_DONT_EXIT 0x8 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate typedef struct engine_state { 3397c478bd9Sstevel@tonic-gate uint_t sc_cmd_flags; 3407c478bd9Sstevel@tonic-gate FILE *sc_cmd_file; 3417c478bd9Sstevel@tonic-gate uint_t sc_cmd_lineno; 3427c478bd9Sstevel@tonic-gate const char *sc_cmd_filename; 3437c478bd9Sstevel@tonic-gate char *sc_cmd_buf; 3447c478bd9Sstevel@tonic-gate size_t sc_cmd_bufsz; 3457c478bd9Sstevel@tonic-gate off_t sc_cmd_bufoff; 3467c478bd9Sstevel@tonic-gate GetLine *sc_gl; 3479444c26fSTom Whitten boolean_t sc_fs_minimal; /* SCF_INSTANCE_FS_MINIMAL is online. */ 3489444c26fSTom Whitten boolean_t sc_in_emi; /* During early import */ 349f329b923SSean Wilcox boolean_t sc_miss_type; /* Apply profile found missing types */ 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate pid_t sc_repo_pid; 3527c478bd9Sstevel@tonic-gate const char *sc_repo_filename; 3537c478bd9Sstevel@tonic-gate const char *sc_repo_doordir; 3547c478bd9Sstevel@tonic-gate const char *sc_repo_doorname; 3557c478bd9Sstevel@tonic-gate const char *sc_repo_server; 3567c478bd9Sstevel@tonic-gate } engine_state_t; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate extern engine_state_t *est; 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate typedef struct string_list { 3617c478bd9Sstevel@tonic-gate uu_list_node_t node; 3627c478bd9Sstevel@tonic-gate char *str; 3637c478bd9Sstevel@tonic-gate } string_list_t; 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate extern uu_list_pool_t *string_pool; 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate struct help_message { 3687c478bd9Sstevel@tonic-gate int token; 3697c478bd9Sstevel@tonic-gate const char *message; 3707c478bd9Sstevel@tonic-gate }; 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate extern struct help_message help_messages[]; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate extern scf_handle_t *g_hndl; /* global repcached connection handle */ 3757c478bd9Sstevel@tonic-gate extern int g_exitcode; 3767c478bd9Sstevel@tonic-gate extern int g_verbose; 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate extern ssize_t max_scf_fmri_len; 3797c478bd9Sstevel@tonic-gate extern ssize_t max_scf_name_len; 3807c478bd9Sstevel@tonic-gate extern ssize_t max_scf_value_len; 3817c478bd9Sstevel@tonic-gate extern ssize_t max_scf_pg_type_len; 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* Common strings */ 3847c478bd9Sstevel@tonic-gate extern const char * const name_attr; 3857c478bd9Sstevel@tonic-gate extern const char * const type_attr; 3867c478bd9Sstevel@tonic-gate extern const char * const value_attr; 3877c478bd9Sstevel@tonic-gate extern const char * const enabled_attr; 388*f6e214c7SGavin Maltby extern const char * const active_attr; 3897c478bd9Sstevel@tonic-gate extern const char * const scf_pg_general; 3907c478bd9Sstevel@tonic-gate extern const char * const scf_group_framework; 3917c478bd9Sstevel@tonic-gate extern const char * const true; 3927c478bd9Sstevel@tonic-gate extern const char * const false; 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate #define uu_list_append(list, elem) uu_list_insert_before(list, NULL, elem) 3957c478bd9Sstevel@tonic-gate #define uu_list_prepend(list, elem) uu_list_insert_after(list, NULL, elem) 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate void *safe_malloc(size_t); 3987c478bd9Sstevel@tonic-gate char *safe_strdup(const char *); 3997c478bd9Sstevel@tonic-gate void warn(const char *, ...); 4007c478bd9Sstevel@tonic-gate void synerr(int); 4017c478bd9Sstevel@tonic-gate void semerr(const char *, ...); 4027c478bd9Sstevel@tonic-gate 4037c478bd9Sstevel@tonic-gate void internal_init(void); 4047c478bd9Sstevel@tonic-gate void internal_dump(bundle_t *); 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate int value_cmp(const void *, const void *, void *); 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate bundle_t *internal_bundle_new(void); 4097c478bd9Sstevel@tonic-gate void internal_bundle_free(bundle_t *); 4107c478bd9Sstevel@tonic-gate entity_t *internal_service_new(const char *); 4117c478bd9Sstevel@tonic-gate void internal_service_free(entity_t *); 4127c478bd9Sstevel@tonic-gate entity_t *internal_instance_new(const char *); 4137c478bd9Sstevel@tonic-gate void internal_instance_free(entity_t *); 4147c478bd9Sstevel@tonic-gate entity_t *internal_template_new(void); 4157c478bd9Sstevel@tonic-gate pgroup_t *internal_pgroup_new(void); 4167c478bd9Sstevel@tonic-gate void internal_pgroup_free(pgroup_t *); 4177c478bd9Sstevel@tonic-gate pgroup_t *internal_pgroup_find(entity_t *, const char *, const char *); 4187c478bd9Sstevel@tonic-gate pgroup_t *internal_dependent_find(entity_t *, const char *); 4197c478bd9Sstevel@tonic-gate pgroup_t *internal_pgroup_find_or_create(entity_t *, const char *, 4207c478bd9Sstevel@tonic-gate const char *); 4211f6eb021SLiane Praza pgroup_t *internal_pgroup_create_strict(entity_t *, const char *, 4221f6eb021SLiane Praza const char *); 4237c478bd9Sstevel@tonic-gate property_t *internal_property_new(void); 4247c478bd9Sstevel@tonic-gate void internal_property_free(property_t *); 4257c478bd9Sstevel@tonic-gate property_t *internal_property_find(pgroup_t *, const char *); 4267c478bd9Sstevel@tonic-gate property_t *internal_property_create(const char *, scf_type_t, uint_t, ...); 4277c478bd9Sstevel@tonic-gate value_t *internal_value_new(void); 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate int internal_attach_service(bundle_t *, entity_t *); 4307c478bd9Sstevel@tonic-gate int internal_attach_entity(entity_t *, entity_t *); 4317c478bd9Sstevel@tonic-gate int internal_attach_pgroup(entity_t *, pgroup_t *); 4321f6eb021SLiane Praza void internal_detach_pgroup(entity_t *, pgroup_t *); 4337c478bd9Sstevel@tonic-gate int internal_attach_dependent(entity_t *, pgroup_t *); 4347c478bd9Sstevel@tonic-gate int internal_attach_property(pgroup_t *, property_t *); 4351f6eb021SLiane Praza void internal_detach_property(pgroup_t *, property_t *); 4367c478bd9Sstevel@tonic-gate void internal_attach_value(property_t *, value_t *); 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate int load_init(void); 4397c478bd9Sstevel@tonic-gate void load_fini(void); 4401f6eb021SLiane Praza int load_instance(const char *, const char *, entity_t **); 4417c478bd9Sstevel@tonic-gate int load_pg_attrs(const scf_propertygroup_t *, pgroup_t **); 4427c478bd9Sstevel@tonic-gate int load_pg(const scf_propertygroup_t *, pgroup_t **, const char *, 4437c478bd9Sstevel@tonic-gate const char *); 4447c478bd9Sstevel@tonic-gate int prop_equal(property_t *, property_t *, const char *, const char *, int); 4459e9ae1fcSbustos int pg_attrs_equal(const pgroup_t *, const pgroup_t *, const char *, int); 4467c478bd9Sstevel@tonic-gate int pg_equal(pgroup_t *, pgroup_t *); 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate void lscf_cleanup(void); 4497c478bd9Sstevel@tonic-gate void lscf_prep_hndl(void); 4507c478bd9Sstevel@tonic-gate void lscf_init(void); 4517c478bd9Sstevel@tonic-gate int lscf_bundle_import(bundle_t *, const char *, uint_t); 4525b7f77adStw21770 int lscf_bundle_apply(bundle_t *, const char *); 4537c478bd9Sstevel@tonic-gate void lscf_delete(const char *, int); 4547c478bd9Sstevel@tonic-gate void lscf_list(const char *); 4557c478bd9Sstevel@tonic-gate void lscf_select(const char *); 4567c478bd9Sstevel@tonic-gate void lscf_unselect(); 4577c478bd9Sstevel@tonic-gate void lscf_get_selection_str(char *, size_t); 4587c478bd9Sstevel@tonic-gate void lscf_add(const char *); 4597c478bd9Sstevel@tonic-gate void lscf_listpg(const char *); 4607c478bd9Sstevel@tonic-gate void lscf_addpg(const char *, const char *, const char *); 4617c478bd9Sstevel@tonic-gate void lscf_delpg(char *); 46270cbfe41SPhilippe Jung void lscf_delhash(char *, int); 4637c478bd9Sstevel@tonic-gate void lscf_listprop(const char *); 4647c478bd9Sstevel@tonic-gate void lscf_addprop(char *, const char *, const uu_list_t *); 4657c478bd9Sstevel@tonic-gate void lscf_delprop(char *); 4661f6eb021SLiane Praza int lscf_describe(uu_list_t *, int); 4677c478bd9Sstevel@tonic-gate void lscf_listsnap(); 4687c478bd9Sstevel@tonic-gate void lscf_selectsnap(const char *); 4697c478bd9Sstevel@tonic-gate void lscf_revert(const char *); 470347a77f2Samaguire void lscf_refresh(); 4717c478bd9Sstevel@tonic-gate char *filename_to_propname(const char *); 4727c478bd9Sstevel@tonic-gate int lscf_retrieve_hash(const char *, unsigned char *); 4737c478bd9Sstevel@tonic-gate int lscf_store_hash(const char *, unsigned char *); 4749444c26fSTom Whitten int lscf_service_cleanup(void *, scf_walkinfo_t *); 4759444c26fSTom Whitten int lscf_hash_cleanup(); 476*f6e214c7SGavin Maltby void lscf_delnotify(const char *, int); 477*f6e214c7SGavin Maltby void lscf_listnotify(const char *, int); 478*f6e214c7SGavin Maltby int lscf_setnotify(uu_list_t *); 479*f6e214c7SGavin Maltby 4807c478bd9Sstevel@tonic-gate CPL_MATCH_FN(complete_select); 4817c478bd9Sstevel@tonic-gate CPL_MATCH_FN(complete_command); 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate int lxml_init(void); 4843eae19d9Swesolows int lxml_get_bundle_file(bundle_t *, const char *, svccfg_op_t); 485f329b923SSean Wilcox void lxml_store_value(value_t *, element_t, const xmlChar *); 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate void engine_init(void); 4887c478bd9Sstevel@tonic-gate int engine_exec_cmd(void); 4897c478bd9Sstevel@tonic-gate int engine_exec(char *); 4907c478bd9Sstevel@tonic-gate int add_cmd_matches(WordCompletion *, const char *, int, uint32_t); 4917c478bd9Sstevel@tonic-gate int engine_interp(void); 4927c478bd9Sstevel@tonic-gate int engine_source(const char *, boolean_t); 4937c478bd9Sstevel@tonic-gate int engine_import(uu_list_t *); 4949444c26fSTom Whitten int engine_cleanup(int); 4957c478bd9Sstevel@tonic-gate void help(int); 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate int engine_cmd_getc(engine_state_t *); 4987c478bd9Sstevel@tonic-gate int engine_cmd_ungetc(engine_state_t *, char); 4997c478bd9Sstevel@tonic-gate void engine_cmd_nputs(engine_state_t *, char *, size_t); 5007c478bd9Sstevel@tonic-gate 5011f6eb021SLiane Praza void tmpl_errors_destroy(tmpl_errors_t *); 5021f6eb021SLiane Praza void tmpl_errors_print(FILE *, tmpl_errors_t *, const char *); 5031f6eb021SLiane Praza void tmpl_init(void); 5041f6eb021SLiane Praza void tmpl_property_fini(property_t *); 5051f6eb021SLiane Praza void tmpl_property_init(property_t *); 5061f6eb021SLiane Praza tmpl_validate_status_t tmpl_validate_bundle(bundle_t *, tmpl_errors_t **); 5071f6eb021SLiane Praza 508*f6e214c7SGavin Maltby #define FMA_TOKENS 0 509*f6e214c7SGavin Maltby #define MIXED_TOKENS -1 510*f6e214c7SGavin Maltby #define INVALID_TOKENS -2 511*f6e214c7SGavin Maltby 512*f6e214c7SGavin Maltby char **tokenize(char *, const char *); 513*f6e214c7SGavin Maltby int32_t check_tokens(char **); 514*f6e214c7SGavin Maltby const char *de_tag(const char *); 515*f6e214c7SGavin Maltby const char *tset_to_string(int32_t); 516*f6e214c7SGavin Maltby 5177c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5187c478bd9Sstevel@tonic-gate } 5197c478bd9Sstevel@tonic-gate #endif 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate #endif /* _CMD_SVCCFG_H */ 522