10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*1293Smh138676 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * Routines used by inetd to read inetd's configuration from the repository, 310Sstevel@tonic-gate * to validate it and setup inetd's data structures appropriately based on 320Sstevel@tonic-gate * in. 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <stdlib.h> 360Sstevel@tonic-gate #include <string.h> 370Sstevel@tonic-gate #include <errno.h> 380Sstevel@tonic-gate #include <unistd.h> 390Sstevel@tonic-gate #include <netdb.h> 400Sstevel@tonic-gate #include <netinet/in.h> 410Sstevel@tonic-gate #include <libintl.h> 420Sstevel@tonic-gate #include <nss_dbdefs.h> 430Sstevel@tonic-gate #include <signal.h> 440Sstevel@tonic-gate #include <wait.h> 450Sstevel@tonic-gate #include "inetd_impl.h" 460Sstevel@tonic-gate 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* method timeout used if one isn't explicitly specified */ 490Sstevel@tonic-gate #define DEFAULT_METHOD_TIMEOUT 10 500Sstevel@tonic-gate 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* supported method properties and their attributes */ 530Sstevel@tonic-gate static inetd_prop_t method_props[] = { 54*1293Smh138676 {PR_EXEC_NAME, "", INET_TYPE_STRING, B_FALSE, IVE_UNSET, NULL, B_FALSE}, 55*1293Smh138676 {PR_ARG0_NAME, "", INET_TYPE_STRING, B_TRUE, IVE_UNSET, NULL, B_FALSE}, 56*1293Smh138676 {SCF_PROPERTY_TIMEOUT, "", INET_TYPE_COUNT, B_TRUE, IVE_UNSET, NULL, B_FALSE}, 57*1293Smh138676 {NULL}, 580Sstevel@tonic-gate }; 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* enumeration of method properties; used to index into method_props[] */ 610Sstevel@tonic-gate typedef enum { 620Sstevel@tonic-gate MP_EXEC, 630Sstevel@tonic-gate MP_ARG0, 64*1293Smh138676 MP_TIMEOUT 650Sstevel@tonic-gate } method_prop_t; 660Sstevel@tonic-gate 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* handle used for repository access in read_prop() */ 690Sstevel@tonic-gate static scf_handle_t *rep_handle = NULL; 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* pool used to create proto_info_t lists (generic proto info structure) */ 720Sstevel@tonic-gate static uu_list_pool_t *proto_info_pool = NULL; 730Sstevel@tonic-gate 740Sstevel@tonic-gate static void destroy_method_props(inetd_prop_t *); 750Sstevel@tonic-gate static int proto_info_compare(const void *, const void *, void *); 760Sstevel@tonic-gate 770Sstevel@tonic-gate int 780Sstevel@tonic-gate config_init(void) 790Sstevel@tonic-gate { 800Sstevel@tonic-gate if ((rep_handle = scf_handle_create(SCF_VERSION)) == NULL) { 810Sstevel@tonic-gate error_msg("%s: %s", 820Sstevel@tonic-gate gettext("Failed to create repository handle"), 830Sstevel@tonic-gate scf_strerror(scf_error())); 840Sstevel@tonic-gate return (-1); 850Sstevel@tonic-gate } else if (make_handle_bound(rep_handle) == -1) { 860Sstevel@tonic-gate /* let config_fini clean-up */ 870Sstevel@tonic-gate return (-1); 880Sstevel@tonic-gate } 890Sstevel@tonic-gate 900Sstevel@tonic-gate if ((proto_info_pool = uu_list_pool_create("proto_info_pool", 910Sstevel@tonic-gate sizeof (proto_info_t), offsetof(proto_info_t, link), 920Sstevel@tonic-gate proto_info_compare, UU_LIST_POOL_DEBUG)) == NULL) { 930Sstevel@tonic-gate error_msg(gettext("Failed to create uu list pool: %s"), 940Sstevel@tonic-gate uu_strerror(uu_error())); 950Sstevel@tonic-gate return (-1); 960Sstevel@tonic-gate } 970Sstevel@tonic-gate 980Sstevel@tonic-gate return (0); 990Sstevel@tonic-gate } 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate void 1020Sstevel@tonic-gate config_fini(void) 1030Sstevel@tonic-gate { 1040Sstevel@tonic-gate if (rep_handle == NULL) 1050Sstevel@tonic-gate return; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate if (proto_info_pool != NULL) { 1080Sstevel@tonic-gate uu_list_pool_destroy(proto_info_pool); 1090Sstevel@tonic-gate proto_info_pool = NULL; 1100Sstevel@tonic-gate } 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate (void) scf_handle_unbind(rep_handle); 1130Sstevel@tonic-gate scf_handle_destroy(rep_handle); 1140Sstevel@tonic-gate rep_handle = NULL; 1150Sstevel@tonic-gate } 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate static void 1180Sstevel@tonic-gate destroy_method_info(method_info_t *mi) 1190Sstevel@tonic-gate { 1200Sstevel@tonic-gate if (mi == NULL) 1210Sstevel@tonic-gate return; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate if (mi->wordexp_arg0_backup != NULL) { 1240Sstevel@tonic-gate /* 1250Sstevel@tonic-gate * Return the wordexp structure back to its original 1260Sstevel@tonic-gate * state so it can be consumed by wordfree. 1270Sstevel@tonic-gate */ 1280Sstevel@tonic-gate free(mi->exec_args_we.we_wordv[0]); 1290Sstevel@tonic-gate mi->exec_args_we.we_wordv[0] = 1300Sstevel@tonic-gate (char *)mi->wordexp_arg0_backup; 1310Sstevel@tonic-gate } 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate free(mi->exec_path); 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate wordfree(&mi->exec_args_we); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate free(mi); 1380Sstevel@tonic-gate } 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* 1410Sstevel@tonic-gate * Transforms the properties read from the repository for a method into a 1420Sstevel@tonic-gate * method_info_t and returns a pointer to it. If expansion of the exec 1430Sstevel@tonic-gate * property fails, due to an invalid string or memory allocation failure, 1440Sstevel@tonic-gate * NULL is returned and exec_invalid is set appropriately to indicate whether 1450Sstevel@tonic-gate * it was a memory allocation failure or an invalid exec string. 1460Sstevel@tonic-gate */ 1470Sstevel@tonic-gate static method_info_t * 1480Sstevel@tonic-gate create_method_info(const inetd_prop_t *mprops, boolean_t *exec_invalid) 1490Sstevel@tonic-gate { 1500Sstevel@tonic-gate method_info_t *ret; 1510Sstevel@tonic-gate int i; 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate debug_msg("Entering create_method_info"); 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate if ((ret = calloc(1, sizeof (method_info_t))) == NULL) 1560Sstevel@tonic-gate goto alloc_fail; 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* Expand the exec string. */ 159*1293Smh138676 if ((i = wordexp(get_prop_value_string(mprops, PR_EXEC_NAME), 1600Sstevel@tonic-gate &ret->exec_args_we, WRDE_NOCMD|WRDE_UNDEF)) != 0) { 1610Sstevel@tonic-gate if (i == WRDE_NOSPACE) 1620Sstevel@tonic-gate goto alloc_fail; 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate *exec_invalid = B_TRUE; 1650Sstevel@tonic-gate free(ret); 1660Sstevel@tonic-gate return (NULL); 1670Sstevel@tonic-gate } 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate if ((ret->exec_path = strdup(ret->exec_args_we.we_wordv[0])) == NULL) 1700Sstevel@tonic-gate goto alloc_fail; 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate if (mprops[MP_ARG0].ip_error == IVE_VALID) { /* arg0 is set */ 1730Sstevel@tonic-gate /* 1740Sstevel@tonic-gate * Keep a copy of arg0 of the wordexp structure so that 1750Sstevel@tonic-gate * wordfree() gets passed what wordexp() originally returned, 1760Sstevel@tonic-gate * as documented as required in the man page. 1770Sstevel@tonic-gate */ 1780Sstevel@tonic-gate ret->wordexp_arg0_backup = ret->exec_args_we.we_wordv[0]; 1790Sstevel@tonic-gate if ((ret->exec_args_we.we_wordv[0] = 180*1293Smh138676 strdup(get_prop_value_string(mprops, PR_ARG0_NAME))) 181*1293Smh138676 == NULL) 1820Sstevel@tonic-gate goto alloc_fail; 1830Sstevel@tonic-gate } 1840Sstevel@tonic-gate 1850Sstevel@tonic-gate if (mprops[MP_TIMEOUT].ip_error == IVE_VALID) { 186*1293Smh138676 ret->timeout = get_prop_value_count(mprops, 187*1293Smh138676 SCF_PROPERTY_TIMEOUT); 1880Sstevel@tonic-gate } else { 1890Sstevel@tonic-gate ret->timeout = DEFAULT_METHOD_TIMEOUT; 1900Sstevel@tonic-gate } 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate /* exec_invalid not set on success */ 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate return (ret); 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate alloc_fail: 1970Sstevel@tonic-gate error_msg(strerror(errno)); 1980Sstevel@tonic-gate destroy_method_info(ret); 1990Sstevel@tonic-gate *exec_invalid = B_FALSE; 2000Sstevel@tonic-gate return (NULL); 2010Sstevel@tonic-gate } 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate /* 2040Sstevel@tonic-gate * Returns B_TRUE if the contents of the 2 method_info_t structures are 2050Sstevel@tonic-gate * equivalent, else B_FALSE. 2060Sstevel@tonic-gate */ 2070Sstevel@tonic-gate boolean_t 2080Sstevel@tonic-gate method_info_equal(const method_info_t *mi, const method_info_t *mi2) 2090Sstevel@tonic-gate { 2100Sstevel@tonic-gate int i; 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate debug_msg("Entering method_info_equal"); 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate if ((mi == NULL) && (mi2 == NULL)) { 2150Sstevel@tonic-gate return (B_TRUE); 2160Sstevel@tonic-gate } else if (((mi == NULL) || (mi2 == NULL)) || 2170Sstevel@tonic-gate (mi->exec_args_we.we_wordc != mi2->exec_args_we.we_wordc) || 2180Sstevel@tonic-gate (strcmp(mi->exec_path, mi2->exec_path) != 0)) { 2190Sstevel@tonic-gate return (B_FALSE); 2200Sstevel@tonic-gate } 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate for (i = 0; i < mi->exec_args_we.we_wordc; i++) { 2230Sstevel@tonic-gate if (strcmp(mi->exec_args_we.we_wordv[i], 2240Sstevel@tonic-gate mi2->exec_args_we.we_wordv[i]) != 0) { 2250Sstevel@tonic-gate return (B_FALSE); 2260Sstevel@tonic-gate } 2270Sstevel@tonic-gate } 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate return (B_TRUE); 2300Sstevel@tonic-gate } 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate /* 2330Sstevel@tonic-gate * Checks if the contents of the 2 socket_info_t structures are equivalent. 2340Sstevel@tonic-gate * If 'isrpc' is false, the address components of the two structures are 2350Sstevel@tonic-gate * compared for equality as part of this. If the two structures are 2360Sstevel@tonic-gate * equivalent B_TRUE is returned, else B_FALSE. 2370Sstevel@tonic-gate */ 2380Sstevel@tonic-gate boolean_t 2390Sstevel@tonic-gate socket_info_equal(const socket_info_t *si, const socket_info_t *si2, 2400Sstevel@tonic-gate boolean_t isrpc) 2410Sstevel@tonic-gate { 2420Sstevel@tonic-gate return ((isrpc || (memcmp(&si->local_addr, &si2->local_addr, 2430Sstevel@tonic-gate sizeof (si->local_addr)) == 0)) && 2440Sstevel@tonic-gate (si->type == si2->type)); 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate } 2470Sstevel@tonic-gate 2480Sstevel@tonic-gate /* 2490Sstevel@tonic-gate * proto_info_t comparison function. Returns 0 on match, else -1, as required 2500Sstevel@tonic-gate * by uu_list_find(). 2510Sstevel@tonic-gate */ 2520Sstevel@tonic-gate static int 2530Sstevel@tonic-gate proto_info_compare(const void *lv, const void *rv, void *istlx) 2540Sstevel@tonic-gate { 2550Sstevel@tonic-gate proto_info_t *pi = (proto_info_t *)lv; 2560Sstevel@tonic-gate proto_info_t *pi2 = (proto_info_t *)rv; 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate /* check their RPC configuration matches */ 2590Sstevel@tonic-gate if (pi->ri != NULL) { 2600Sstevel@tonic-gate if ((pi2->ri == NULL) || !rpc_info_equal(pi->ri, pi2->ri)) 2610Sstevel@tonic-gate return (-1); 2620Sstevel@tonic-gate } else if (pi2->ri != NULL) { 2630Sstevel@tonic-gate return (-1); 2640Sstevel@tonic-gate } 2650Sstevel@tonic-gate 2660Sstevel@tonic-gate if (pi->v6only != pi2->v6only) 2670Sstevel@tonic-gate return (-1); 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate if (*(boolean_t *)istlx) { 2700Sstevel@tonic-gate if (tlx_info_equal((tlx_info_t *)lv, (tlx_info_t *)rv, 2710Sstevel@tonic-gate pi->ri != NULL)) 2720Sstevel@tonic-gate return (0); 2730Sstevel@tonic-gate } else { 2740Sstevel@tonic-gate if (socket_info_equal((socket_info_t *)lv, 2750Sstevel@tonic-gate (socket_info_t *)rv, pi->ri != NULL)) 2760Sstevel@tonic-gate return (0); 2770Sstevel@tonic-gate } 2780Sstevel@tonic-gate return (-1); 2790Sstevel@tonic-gate } 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate /* 2820Sstevel@tonic-gate * Returns B_TRUE if the bind configuration of the two instance_cfg_t 2830Sstevel@tonic-gate * structures are equivalent, else B_FALSE. 2840Sstevel@tonic-gate */ 2850Sstevel@tonic-gate boolean_t 2860Sstevel@tonic-gate bind_config_equal(const basic_cfg_t *c1, const basic_cfg_t *c2) 2870Sstevel@tonic-gate { 2880Sstevel@tonic-gate proto_info_t *pi; 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate debug_msg("Entering bind_config_equal"); 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate if ((c1->iswait != c2->iswait) || 2930Sstevel@tonic-gate (c1->istlx != c2->istlx)) 2940Sstevel@tonic-gate return (B_FALSE); 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate if (uu_list_numnodes(c1->proto_list) != 2970Sstevel@tonic-gate uu_list_numnodes(c2->proto_list)) 2980Sstevel@tonic-gate return (B_FALSE); 2990Sstevel@tonic-gate /* 3000Sstevel@tonic-gate * For each element in the first configuration's socket/tlx list, 3010Sstevel@tonic-gate * check there's a matching one in the other list. 3020Sstevel@tonic-gate */ 3030Sstevel@tonic-gate for (pi = uu_list_first(c1->proto_list); pi != NULL; 3040Sstevel@tonic-gate pi = uu_list_next(c1->proto_list, pi)) { 3050Sstevel@tonic-gate uu_list_index_t idx; 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate if (uu_list_find(c2->proto_list, pi, (void *)&c1->istlx, 3080Sstevel@tonic-gate &idx) == NULL) 3090Sstevel@tonic-gate return (B_FALSE); 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate return (B_TRUE); 3130Sstevel@tonic-gate } 3140Sstevel@tonic-gate 3150Sstevel@tonic-gate /* 3160Sstevel@tonic-gate * Write the default values contained in 'bprops', read by 3170Sstevel@tonic-gate * read_instance_props(), into 'cfg'. 3180Sstevel@tonic-gate * Returns -1 if memory allocation fails, else 0. 3190Sstevel@tonic-gate */ 3200Sstevel@tonic-gate static int 3210Sstevel@tonic-gate populate_defaults(inetd_prop_t *bprops, basic_cfg_t *cfg) 3220Sstevel@tonic-gate { 3230Sstevel@tonic-gate debug_msg("Entering populate_defaults"); 3240Sstevel@tonic-gate 325*1293Smh138676 cfg->do_tcp_wrappers = get_prop_value_boolean(bprops, 326*1293Smh138676 PR_DO_TCP_WRAPPERS_NAME); 327*1293Smh138676 cfg->do_tcp_trace = get_prop_value_boolean(bprops, 328*1293Smh138676 PR_DO_TCP_TRACE_NAME); 329*1293Smh138676 cfg->inherit_env = get_prop_value_boolean(bprops, PR_INHERIT_ENV_NAME); 330*1293Smh138676 cfg->wait_fail_cnt = get_prop_value_int(bprops, 331*1293Smh138676 PR_MAX_FAIL_RATE_CNT_NAME); 332*1293Smh138676 cfg->wait_fail_interval = get_prop_value_int(bprops, 3330Sstevel@tonic-gate PR_MAX_FAIL_RATE_INTVL_NAME); 334*1293Smh138676 cfg->max_copies = get_prop_value_int(bprops, PR_MAX_COPIES_NAME); 335*1293Smh138676 cfg->conn_rate_offline = get_prop_value_int(bprops, 336*1293Smh138676 PR_CON_RATE_OFFLINE_NAME); 337*1293Smh138676 cfg->conn_rate_max = get_prop_value_int(bprops, PR_CON_RATE_MAX_NAME); 338*1293Smh138676 cfg->bind_fail_interval = get_prop_value_int(bprops, 339*1293Smh138676 PR_BIND_FAIL_INTVL_NAME); 340*1293Smh138676 cfg->bind_fail_max = get_prop_value_int(bprops, PR_BIND_FAIL_MAX_NAME); 3410Sstevel@tonic-gate if ((cfg->bind_addr = 342*1293Smh138676 strdup(get_prop_value_string(bprops, PR_BIND_ADDR_NAME))) == NULL) { 3430Sstevel@tonic-gate error_msg(strerror(errno)); 3440Sstevel@tonic-gate return (-1); 3450Sstevel@tonic-gate } 3460Sstevel@tonic-gate return (0); 3470Sstevel@tonic-gate } 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate void 3500Sstevel@tonic-gate destroy_method_infos(method_info_t **mis) 3510Sstevel@tonic-gate { 3520Sstevel@tonic-gate int i; 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate for (i = 0; i < NUM_METHODS; i++) { 3550Sstevel@tonic-gate destroy_method_info(mis[i]); 3560Sstevel@tonic-gate mis[i] = NULL; 3570Sstevel@tonic-gate } 3580Sstevel@tonic-gate } 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* 3610Sstevel@tonic-gate * For each method, if it was specifed convert its entry in 'mprops', 3620Sstevel@tonic-gate * into an entry in 'mis'. Returns -1 if memory allocation fails or one of the 3630Sstevel@tonic-gate * exec strings was invalid, else 0. 3640Sstevel@tonic-gate */ 3650Sstevel@tonic-gate static int 3660Sstevel@tonic-gate create_method_infos(const char *fmri, inetd_prop_t **mprops, 3670Sstevel@tonic-gate method_info_t **mis) 3680Sstevel@tonic-gate { 3690Sstevel@tonic-gate int i; 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate debug_msg("Entering create_method_infos, inst: %s", fmri); 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate for (i = 0; i < NUM_METHODS; i++) { 3740Sstevel@tonic-gate /* 3750Sstevel@tonic-gate * Only create a method info structure if the method properties 3760Sstevel@tonic-gate * contain an exec string, which we take to mean the method 3770Sstevel@tonic-gate * is specified. 3780Sstevel@tonic-gate */ 3790Sstevel@tonic-gate if (mprops[i][MP_EXEC].ip_error == IVE_VALID) { 3800Sstevel@tonic-gate boolean_t exec_invalid; 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate if ((mis[i] = create_method_info(mprops[i], 3830Sstevel@tonic-gate &exec_invalid)) == NULL) { 3840Sstevel@tonic-gate if (exec_invalid) { 3850Sstevel@tonic-gate error_msg(gettext("Property %s for " 3860Sstevel@tonic-gate "method %s of instance %s is " 3870Sstevel@tonic-gate "invalid"), PR_EXEC_NAME, 3880Sstevel@tonic-gate methods[i].name, fmri); 3890Sstevel@tonic-gate } 3900Sstevel@tonic-gate return (-1); 3910Sstevel@tonic-gate } 3920Sstevel@tonic-gate } 3930Sstevel@tonic-gate } 3940Sstevel@tonic-gate return (0); 3950Sstevel@tonic-gate } 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate /* 3980Sstevel@tonic-gate * Try and read each of the method properties for the method 'method' of 3990Sstevel@tonic-gate * instance 'inst', and return a table containing all method properties. If an 4000Sstevel@tonic-gate * error occurs, NULL is returned, with 'err' set to indicate the cause. 4010Sstevel@tonic-gate * Otherwise, a pointer to an inetd_prop_t table is returned containing all 4020Sstevel@tonic-gate * the method properties, and each of the properties is flagged according to 4030Sstevel@tonic-gate * whether it was present or not, and if it was present its value is set in 4040Sstevel@tonic-gate * the property's entry in the table. 4050Sstevel@tonic-gate */ 4060Sstevel@tonic-gate static inetd_prop_t * 4070Sstevel@tonic-gate read_method_props(const char *inst, instance_method_t method, scf_error_t *err) 4080Sstevel@tonic-gate { 4090Sstevel@tonic-gate inetd_prop_t *ret; 4100Sstevel@tonic-gate int i; 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate debug_msg("Entering read_method_props"); 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate if ((ret = calloc(1, sizeof (method_props))) == NULL) { 4150Sstevel@tonic-gate *err = SCF_ERROR_NO_MEMORY; 4160Sstevel@tonic-gate return (NULL); 4170Sstevel@tonic-gate } 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate (void) memcpy(ret, method_props, sizeof (method_props)); 420*1293Smh138676 for (i = 0; ret[i].ip_name != NULL; i++) { 4210Sstevel@tonic-gate *err = read_prop(rep_handle, &ret[i], i, inst, 4220Sstevel@tonic-gate methods[method].name); 4230Sstevel@tonic-gate if ((*err != 0) && (*err != SCF_ERROR_NOT_FOUND)) { 4240Sstevel@tonic-gate destroy_method_props(ret); 4250Sstevel@tonic-gate return (NULL); 4260Sstevel@tonic-gate } 4270Sstevel@tonic-gate } 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate return (ret); 4300Sstevel@tonic-gate } 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate static void 4330Sstevel@tonic-gate destroy_method_props(inetd_prop_t *mprop) 4340Sstevel@tonic-gate { 4350Sstevel@tonic-gate int i; 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate if (mprop == NULL) 4380Sstevel@tonic-gate return; 4390Sstevel@tonic-gate 440*1293Smh138676 for (i = 0; mprop[i].ip_name != NULL; i++) { 441*1293Smh138676 if (mprop[i].ip_type == INET_TYPE_STRING && 442*1293Smh138676 mprop[i].ip_error == IVE_VALID) 443*1293Smh138676 free(mprop[i].ip_value.iv_string); 4440Sstevel@tonic-gate } 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate free(mprop); 4470Sstevel@tonic-gate } 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate /* 4500Sstevel@tonic-gate * Destroy the basic and method properties returned by read_inst_props(). 4510Sstevel@tonic-gate */ 4520Sstevel@tonic-gate static void 4530Sstevel@tonic-gate destroy_inst_props(inetd_prop_t *bprops, inetd_prop_t **mprops) 4540Sstevel@tonic-gate { 4550Sstevel@tonic-gate int i; 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate free_instance_props(bprops); 4580Sstevel@tonic-gate for (i = 0; i < NUM_METHODS; i++) 4590Sstevel@tonic-gate destroy_method_props(mprops[i]); 4600Sstevel@tonic-gate } 4610Sstevel@tonic-gate 4620Sstevel@tonic-gate /* 4630Sstevel@tonic-gate * Read all the basic and method properties for instance 'inst', as inetd_prop_t 4640Sstevel@tonic-gate * tables, into the spaces referenced by 'bprops' and 'mprops' respectively. 4650Sstevel@tonic-gate * Each of the properties in the tables are flagged to indicate if the 4660Sstevel@tonic-gate * property was present or not, and if it was the value is stored within it. 4670Sstevel@tonic-gate * If an error occurs at any time -1 is returned and 'err' is set to 4680Sstevel@tonic-gate * indicate the reason, else 0 is returned. 4690Sstevel@tonic-gate */ 4700Sstevel@tonic-gate static int 4710Sstevel@tonic-gate read_inst_props(const char *fmri, inetd_prop_t **bprops, 4720Sstevel@tonic-gate inetd_prop_t **mprops, scf_error_t *err) 4730Sstevel@tonic-gate { 4740Sstevel@tonic-gate size_t nprops; 4750Sstevel@tonic-gate int i; 4760Sstevel@tonic-gate 4770Sstevel@tonic-gate debug_msg("Entering read_inst_props"); 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate if ((*bprops = read_instance_props(rep_handle, (char *)fmri, &nprops, 4800Sstevel@tonic-gate err)) == NULL) 4810Sstevel@tonic-gate return (-1); 4820Sstevel@tonic-gate 4830Sstevel@tonic-gate for (i = 0; i < NUM_METHODS; i++) { 4840Sstevel@tonic-gate if ((mprops[i] = 4850Sstevel@tonic-gate read_method_props(fmri, (instance_method_t)i, err)) == 4860Sstevel@tonic-gate NULL) { 4870Sstevel@tonic-gate for (i--; i >= 0; i--) 4880Sstevel@tonic-gate destroy_method_props(mprops[i]); 4890Sstevel@tonic-gate free_instance_props(*bprops); 4900Sstevel@tonic-gate return (-1); 4910Sstevel@tonic-gate } 4920Sstevel@tonic-gate } 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate return (0); 4950Sstevel@tonic-gate } 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate /* 4980Sstevel@tonic-gate * Returns B_TRUE if all required properties were read from the repository 4990Sstevel@tonic-gate * (whether taken from the defaults or directly from the instance), they 5000Sstevel@tonic-gate * all had valid values, all the required methods were present, and they 5010Sstevel@tonic-gate * each had the required properties with valid values. Else, returns B_FALSE. 5020Sstevel@tonic-gate * If the function returns B_TRUE, the storage referenced by 'cfg' is set 5030Sstevel@tonic-gate * to point at an allocated instance_cfg_t initialized based on the basic 5040Sstevel@tonic-gate * properties (not method or defaults). 5050Sstevel@tonic-gate */ 5060Sstevel@tonic-gate static boolean_t 5070Sstevel@tonic-gate valid_inst_props(const char *fmri, inetd_prop_t *bprops, inetd_prop_t **mprops, 5080Sstevel@tonic-gate basic_cfg_t **cfg) 5090Sstevel@tonic-gate { 5100Sstevel@tonic-gate boolean_t valid; 5110Sstevel@tonic-gate size_t num_bprops; 5120Sstevel@tonic-gate int i; 5130Sstevel@tonic-gate 5140Sstevel@tonic-gate debug_msg("Entering valid_inst_props: inst: %s, bprops: %x, mprops: %x", 5150Sstevel@tonic-gate fmri, bprops, *mprops); 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate valid = valid_props(bprops, fmri, cfg, proto_info_pool, conn_ind_pool); 5180Sstevel@tonic-gate 5190Sstevel@tonic-gate /* 5200Sstevel@tonic-gate * Double check we've got all necessary properties (valid_props() 5210Sstevel@tonic-gate * doesn't enforce the presence of defaults), and output error messages 5220Sstevel@tonic-gate * for each invalid/ missing property. 5230Sstevel@tonic-gate */ 5240Sstevel@tonic-gate (void) get_prop_table(&num_bprops); 525*1293Smh138676 for (i = 0; bprops[i].ip_name != NULL; i++) { 5260Sstevel@tonic-gate switch (bprops[i].ip_error) { 5270Sstevel@tonic-gate case IVE_UNSET: 5280Sstevel@tonic-gate if (!bprops[i].ip_default) 5290Sstevel@tonic-gate continue; 5300Sstevel@tonic-gate if ((i == PT_ARG0_INDEX) || (i == PT_EXEC_INDEX)) 5310Sstevel@tonic-gate continue; 5320Sstevel@tonic-gate /* FALLTHROUGH */ 5330Sstevel@tonic-gate case IVE_INVALID: 5340Sstevel@tonic-gate error_msg(gettext("Property '%s' of instance " 5350Sstevel@tonic-gate "%s is missing, inconsistent or invalid"), 5360Sstevel@tonic-gate bprops[i].ip_name, fmri); 5370Sstevel@tonic-gate valid = B_FALSE; 5380Sstevel@tonic-gate } 5390Sstevel@tonic-gate } 5400Sstevel@tonic-gate 5410Sstevel@tonic-gate for (i = 0; i < NUM_METHODS; i++) { 5420Sstevel@tonic-gate int j; 5430Sstevel@tonic-gate 5440Sstevel@tonic-gate /* check if any properties are set */ 545*1293Smh138676 for (j = 0; mprops[i][j].ip_name != NULL; j++) { 5460Sstevel@tonic-gate if (mprops[i][j].ip_error != IVE_UNSET) 5470Sstevel@tonic-gate break; 5480Sstevel@tonic-gate } 5490Sstevel@tonic-gate 550*1293Smh138676 if (mprops[i][j].ip_name == NULL) { 5510Sstevel@tonic-gate /* an unspecified method */ 5520Sstevel@tonic-gate if ((instance_method_t)i == IM_START) { 5530Sstevel@tonic-gate error_msg(gettext( 5540Sstevel@tonic-gate "Unspecified %s method for instance %s"), 5550Sstevel@tonic-gate START_METHOD_NAME, fmri); 5560Sstevel@tonic-gate valid = B_FALSE; 5570Sstevel@tonic-gate } 5580Sstevel@tonic-gate } else if (mprops[i][MP_EXEC].ip_error == IVE_UNSET) { 5590Sstevel@tonic-gate error_msg(gettext("Missing %s property from method %s " 5600Sstevel@tonic-gate "of instance %s"), PR_EXEC_NAME, 5610Sstevel@tonic-gate methods[(instance_method_t)i].name, fmri); 5620Sstevel@tonic-gate valid = B_FALSE; 5630Sstevel@tonic-gate } 5640Sstevel@tonic-gate } 5650Sstevel@tonic-gate 5660Sstevel@tonic-gate if (!valid) 5670Sstevel@tonic-gate destroy_basic_cfg(*cfg); 5680Sstevel@tonic-gate 5690Sstevel@tonic-gate return (valid); 5700Sstevel@tonic-gate } 5710Sstevel@tonic-gate 5720Sstevel@tonic-gate void 5730Sstevel@tonic-gate destroy_instance_cfg(instance_cfg_t *cfg) 5740Sstevel@tonic-gate { 5750Sstevel@tonic-gate if (cfg != NULL) { 5760Sstevel@tonic-gate destroy_basic_cfg(cfg->basic); 5770Sstevel@tonic-gate destroy_method_infos(cfg->methods); 5780Sstevel@tonic-gate free(cfg); 5790Sstevel@tonic-gate } 5800Sstevel@tonic-gate } 5810Sstevel@tonic-gate 5820Sstevel@tonic-gate /* 5830Sstevel@tonic-gate * Returns an allocated instance_cfg_t representation of an instance's 5840Sstevel@tonic-gate * configuration read from the repository. If the configuration is invalid, a 5850Sstevel@tonic-gate * repository error occurred, or a memory allocation occurred returns NULL, 5860Sstevel@tonic-gate * else returns a pointer to the allocated instance_cfg_t. 5870Sstevel@tonic-gate */ 5880Sstevel@tonic-gate instance_cfg_t * 5890Sstevel@tonic-gate read_instance_cfg(const char *fmri) 5900Sstevel@tonic-gate { 5910Sstevel@tonic-gate uint_t retries; 5920Sstevel@tonic-gate inetd_prop_t *bprops; 5930Sstevel@tonic-gate inetd_prop_t *mprops[NUM_METHODS]; 5940Sstevel@tonic-gate instance_cfg_t *ret = NULL; 5950Sstevel@tonic-gate scf_error_t err; 5960Sstevel@tonic-gate 5970Sstevel@tonic-gate debug_msg("Entering read_instance_cfg"); 5980Sstevel@tonic-gate 5990Sstevel@tonic-gate if ((ret = calloc(1, sizeof (instance_cfg_t))) == NULL) 6000Sstevel@tonic-gate return (NULL); 6010Sstevel@tonic-gate 6020Sstevel@tonic-gate for (retries = 0; retries <= REP_OP_RETRIES; retries++) { 6030Sstevel@tonic-gate if (make_handle_bound(rep_handle) == -1) { 6040Sstevel@tonic-gate err = scf_error(); 6050Sstevel@tonic-gate goto read_error; 6060Sstevel@tonic-gate } 6070Sstevel@tonic-gate 6080Sstevel@tonic-gate if (read_inst_props(fmri, &bprops, mprops, &err) == 0) 6090Sstevel@tonic-gate break; 6100Sstevel@tonic-gate if (err != SCF_ERROR_CONNECTION_BROKEN) 6110Sstevel@tonic-gate goto read_error; 6120Sstevel@tonic-gate (void) scf_handle_unbind(rep_handle); 6130Sstevel@tonic-gate } 6140Sstevel@tonic-gate if (retries > REP_OP_RETRIES) 6150Sstevel@tonic-gate goto read_error; 6160Sstevel@tonic-gate 6170Sstevel@tonic-gate /* 6180Sstevel@tonic-gate * Switch off validation of the start method's exec string, since 6190Sstevel@tonic-gate * during boot the filesystem it resides on may not have been 6200Sstevel@tonic-gate * mounted yet, which would result in a false validation failure. 6210Sstevel@tonic-gate * We'll catch any real errors when the start method is first run 6220Sstevel@tonic-gate * in passes_basic_exec_checks(). 6230Sstevel@tonic-gate */ 6240Sstevel@tonic-gate bprops[PT_EXEC_INDEX].ip_error = IVE_UNSET; 6250Sstevel@tonic-gate 6260Sstevel@tonic-gate if ((!valid_inst_props(fmri, bprops, mprops, &ret->basic)) || 6270Sstevel@tonic-gate (populate_defaults(bprops, ret->basic) != 0) || 6280Sstevel@tonic-gate (create_method_infos(fmri, mprops, ret->methods) != 0)) { 6290Sstevel@tonic-gate destroy_instance_cfg(ret); 6300Sstevel@tonic-gate ret = NULL; 6310Sstevel@tonic-gate } 6320Sstevel@tonic-gate 6330Sstevel@tonic-gate destroy_inst_props(bprops, mprops); 6340Sstevel@tonic-gate return (ret); 6350Sstevel@tonic-gate 6360Sstevel@tonic-gate read_error: 6370Sstevel@tonic-gate error_msg(gettext( 6380Sstevel@tonic-gate "Failed to read the configuration of instance %s: %s"), fmri, 6390Sstevel@tonic-gate scf_strerror(err)); 6400Sstevel@tonic-gate free(ret); 6410Sstevel@tonic-gate return (NULL); 6420Sstevel@tonic-gate } 6430Sstevel@tonic-gate 6440Sstevel@tonic-gate /* 6450Sstevel@tonic-gate * Returns a pointer to an allocated method context for the specified method 6460Sstevel@tonic-gate * of the specified instance if it could retrieve it. Else, if there were 6470Sstevel@tonic-gate * errors retrieving it, NULL is returned and the pointer referenced by 6480Sstevel@tonic-gate * 'errstr' is set to point at an appropriate error string. 6490Sstevel@tonic-gate */ 6500Sstevel@tonic-gate struct method_context * 6510Sstevel@tonic-gate read_method_context(const char *inst_fmri, const char *method, const char *path, 6520Sstevel@tonic-gate const char **errstr) 6530Sstevel@tonic-gate { 6540Sstevel@tonic-gate scf_instance_t *scf_inst = NULL; 6550Sstevel@tonic-gate struct method_context *ret; 6560Sstevel@tonic-gate uint_t retries; 6570Sstevel@tonic-gate const char *tmpstr; 6580Sstevel@tonic-gate 6590Sstevel@tonic-gate debug_msg("Entering read_method_context: inst: %s, method: %s, " 6600Sstevel@tonic-gate "path: %s", inst_fmri, method, path); 6610Sstevel@tonic-gate 6620Sstevel@tonic-gate for (retries = 0; retries <= REP_OP_RETRIES; retries++) { 6630Sstevel@tonic-gate if (make_handle_bound(rep_handle) == -1) 6640Sstevel@tonic-gate goto inst_failure; 6650Sstevel@tonic-gate 6660Sstevel@tonic-gate if (((scf_inst = scf_instance_create(rep_handle)) != NULL) && 6670Sstevel@tonic-gate (scf_handle_decode_fmri(rep_handle, inst_fmri, NULL, NULL, 6680Sstevel@tonic-gate scf_inst, NULL, NULL, SCF_DECODE_FMRI_EXACT) == 0)) 6690Sstevel@tonic-gate break; 6700Sstevel@tonic-gate if (scf_error() != SCF_ERROR_CONNECTION_BROKEN) { 6710Sstevel@tonic-gate scf_instance_destroy(scf_inst); 6720Sstevel@tonic-gate goto inst_failure; 6730Sstevel@tonic-gate } 6740Sstevel@tonic-gate 6750Sstevel@tonic-gate (void) scf_instance_destroy(scf_inst); 6760Sstevel@tonic-gate scf_inst = NULL; 6770Sstevel@tonic-gate 6780Sstevel@tonic-gate (void) scf_handle_unbind(rep_handle); 6790Sstevel@tonic-gate } 6800Sstevel@tonic-gate if (retries > REP_OP_RETRIES) 6810Sstevel@tonic-gate goto inst_failure; 6820Sstevel@tonic-gate 6830Sstevel@tonic-gate if ((tmpstr = restarter_get_method_context( 6840Sstevel@tonic-gate RESTARTER_METHOD_CONTEXT_VERSION, scf_inst, NULL, method, path, 6850Sstevel@tonic-gate &ret)) != NULL) { 6860Sstevel@tonic-gate ret = NULL; 6870Sstevel@tonic-gate *errstr = tmpstr; 6880Sstevel@tonic-gate } 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate scf_instance_destroy(scf_inst); 6910Sstevel@tonic-gate return (ret); 6920Sstevel@tonic-gate 6930Sstevel@tonic-gate inst_failure: 6940Sstevel@tonic-gate /* 6950Sstevel@tonic-gate * We can rely on this string not becoming invalid 6960Sstevel@tonic-gate * since we don't call bind_textdomain_codeset() or 6970Sstevel@tonic-gate * setlocale(3C) after initialization. 6980Sstevel@tonic-gate */ 6990Sstevel@tonic-gate *errstr = gettext("failed to get instance from repository"); 7000Sstevel@tonic-gate return (NULL); 7010Sstevel@tonic-gate } 7020Sstevel@tonic-gate 7030Sstevel@tonic-gate /* 7040Sstevel@tonic-gate * Reads the value of the enabled property from the named property group 7050Sstevel@tonic-gate * of the given instance. 7060Sstevel@tonic-gate * If an error occurs, the SCF error code is returned. The possible errors are: 7070Sstevel@tonic-gate * - SCF_ERROR_INVALID_ARGUMENT: The enabled property is not a boolean. 7080Sstevel@tonic-gate * - SCF_ERROR_NONE: No value exists for the enabled property. 7090Sstevel@tonic-gate * - SCF_ERROR_CONNECTION_BROKEN: Repository connection broken. 7100Sstevel@tonic-gate * - SCF_ERROR_NOT_FOUND: The property wasn't found. 7110Sstevel@tonic-gate * - SCF_ERROR_NO_MEMORY: allocation failure. 7120Sstevel@tonic-gate * Else 0 is returned and 'enabled' set appropriately. 7130Sstevel@tonic-gate */ 7140Sstevel@tonic-gate static scf_error_t 7150Sstevel@tonic-gate read_enable_prop(const char *fmri, boolean_t *enabled, const char *pg) 7160Sstevel@tonic-gate { 7170Sstevel@tonic-gate scf_simple_prop_t *sp; 7180Sstevel@tonic-gate uint8_t *u8p; 7190Sstevel@tonic-gate 7200Sstevel@tonic-gate if ((sp = scf_simple_prop_get(rep_handle, fmri, pg, 7210Sstevel@tonic-gate SCF_PROPERTY_ENABLED)) == NULL) 7220Sstevel@tonic-gate return (scf_error()); 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate if ((u8p = scf_simple_prop_next_boolean(sp)) == NULL) { 7250Sstevel@tonic-gate scf_simple_prop_free(sp); 7260Sstevel@tonic-gate return (scf_error()); 7270Sstevel@tonic-gate } 7280Sstevel@tonic-gate 7290Sstevel@tonic-gate *enabled = (*u8p != 0); 7300Sstevel@tonic-gate scf_simple_prop_free(sp); 7310Sstevel@tonic-gate return (0); 7320Sstevel@tonic-gate } 7330Sstevel@tonic-gate 7340Sstevel@tonic-gate /* 7350Sstevel@tonic-gate * Reads the enabled value for the given instance FMRI. The read value 7360Sstevel@tonic-gate * is based on a merge of the 'standard' enabled property, and the temporary 7370Sstevel@tonic-gate * override one; the merge involves using the latter properties value if 7380Sstevel@tonic-gate * present, else resporting to the formers. If an error occurs -1 is returned, 7390Sstevel@tonic-gate * else 0 is returned and 'enabled' set approriately. 7400Sstevel@tonic-gate */ 7410Sstevel@tonic-gate int 7420Sstevel@tonic-gate read_enable_merged(const char *fmri, boolean_t *enabled) 7430Sstevel@tonic-gate { 7440Sstevel@tonic-gate uint_t retries; 7450Sstevel@tonic-gate 7460Sstevel@tonic-gate debug_msg("Entering read_enabled_prop: inst: %s", fmri); 7470Sstevel@tonic-gate 7480Sstevel@tonic-gate for (retries = 0; retries <= REP_OP_RETRIES; retries++) { 7490Sstevel@tonic-gate if (make_handle_bound(rep_handle) == -1) 7500Sstevel@tonic-gate goto gen_fail; 7510Sstevel@tonic-gate 7520Sstevel@tonic-gate switch (read_enable_prop(fmri, enabled, SCF_PG_GENERAL_OVR)) { 7530Sstevel@tonic-gate case 0: 7540Sstevel@tonic-gate debug_msg("read %d from override", *enabled); 7550Sstevel@tonic-gate return (0); 7560Sstevel@tonic-gate case SCF_ERROR_CONNECTION_BROKEN: 7570Sstevel@tonic-gate break; 7580Sstevel@tonic-gate case SCF_ERROR_NOT_FOUND: 7590Sstevel@tonic-gate case SCF_ERROR_NONE: 7600Sstevel@tonic-gate case SCF_ERROR_INVALID_ARGUMENT: 7610Sstevel@tonic-gate switch (read_enable_prop(fmri, enabled, 7620Sstevel@tonic-gate SCF_PG_GENERAL)) { 7630Sstevel@tonic-gate case 0: 7640Sstevel@tonic-gate debug_msg("read %d from non_override", 7650Sstevel@tonic-gate *enabled); 7660Sstevel@tonic-gate return (0); 7670Sstevel@tonic-gate case SCF_ERROR_CONNECTION_BROKEN: 7680Sstevel@tonic-gate break; 7690Sstevel@tonic-gate case SCF_ERROR_NOT_FOUND: 7700Sstevel@tonic-gate case SCF_ERROR_NONE: 7710Sstevel@tonic-gate case SCF_ERROR_INVALID_ARGUMENT: 7720Sstevel@tonic-gate error_msg(gettext("Missing %s property/value " 7730Sstevel@tonic-gate "for instance %s"), SCF_PROPERTY_ENABLED, 7740Sstevel@tonic-gate fmri); 7750Sstevel@tonic-gate return (-1); 7760Sstevel@tonic-gate default: 7770Sstevel@tonic-gate goto gen_fail; 7780Sstevel@tonic-gate } 7790Sstevel@tonic-gate break; 7800Sstevel@tonic-gate default: 7810Sstevel@tonic-gate goto gen_fail; 7820Sstevel@tonic-gate } 7830Sstevel@tonic-gate 7840Sstevel@tonic-gate (void) scf_handle_unbind(rep_handle); 7850Sstevel@tonic-gate continue; 7860Sstevel@tonic-gate } 7870Sstevel@tonic-gate 7880Sstevel@tonic-gate gen_fail: 7890Sstevel@tonic-gate error_msg(gettext("Failed to read the %s property of instance %s: %s"), 7900Sstevel@tonic-gate SCF_PROPERTY_ENABLED, fmri, scf_strerror(scf_error())); 7910Sstevel@tonic-gate return (-1); 7920Sstevel@tonic-gate } 793