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