summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authormh138676 <none@none>2006-01-18 17:52:01 -0800
committermh138676 <none@none>2006-01-18 17:52:01 -0800
commitba1637f8b78b432c41b36839c92aecf1f5f9fafb (patch)
tree34c46f9ed9fcf4ada7a9923dba30a1530df88b86 /usr/src
parentdd2b4cced17a52cdf7734ecd0bbc4582dee18b26 (diff)
downloadillumos-joyent-ba1637f8b78b432c41b36839c92aecf1f5f9fafb.tar.gz
6272094 inetconv fails to observe alignment, improperly validates rpc versions
6365545 snoop.c needs some old code removed
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/inetd/config.c88
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c115
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c48
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c29
-rw-r--r--usr/src/lib/libinetsvc/common/inetsvc.c345
-rw-r--r--usr/src/lib/libinetsvc/common/inetsvc.h41
-rw-r--r--usr/src/lib/libinetsvc/spec/inetsvc.spec71
7 files changed, 443 insertions, 294 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c b/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c
index 68fb319c30..5bcaebcbf5 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c
+++ b/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -51,17 +51,17 @@
/* supported method properties and their attributes */
static inetd_prop_t method_props[] = {
-{PR_EXEC_NAME, "", SCF_TYPE_ASTRING, B_FALSE, IVE_UNSET, NULL},
-{PR_ARG0_NAME, "", SCF_TYPE_ASTRING, B_TRUE, IVE_UNSET, NULL},
-{NULL, "", SCF_TYPE_COUNT, B_TRUE, IVE_UNSET, NULL}
+{PR_EXEC_NAME, "", INET_TYPE_STRING, B_FALSE, IVE_UNSET, NULL, B_FALSE},
+{PR_ARG0_NAME, "", INET_TYPE_STRING, B_TRUE, IVE_UNSET, NULL, B_FALSE},
+{SCF_PROPERTY_TIMEOUT, "", INET_TYPE_COUNT, B_TRUE, IVE_UNSET, NULL, B_FALSE},
+{NULL},
};
/* enumeration of method properties; used to index into method_props[] */
typedef enum {
MP_EXEC,
MP_ARG0,
- MP_TIMEOUT,
- NUM_METHOD_PROPS
+ MP_TIMEOUT
} method_prop_t;
@@ -87,17 +87,6 @@ config_init(void)
return (-1);
}
- /*
- * Work around the (const *) nature of SCF property #defines in
- * libscf.h that prevent us from directly initializing the name
- * element of members of the method properties table.
- */
- if ((method_props[MP_TIMEOUT].ip_name = strdup(SCF_PROPERTY_TIMEOUT))
- == NULL) {
- error_msg(strerror(errno));
- return (-1);
- }
-
if ((proto_info_pool = uu_list_pool_create("proto_info_pool",
sizeof (proto_info_t), offsetof(proto_info_t, link),
proto_info_compare, UU_LIST_POOL_DEBUG)) == NULL) {
@@ -167,7 +156,7 @@ create_method_info(const inetd_prop_t *mprops, boolean_t *exec_invalid)
goto alloc_fail;
/* Expand the exec string. */
- if ((i = wordexp(get_prop_value(mprops, PR_EXEC_NAME),
+ if ((i = wordexp(get_prop_value_string(mprops, PR_EXEC_NAME),
&ret->exec_args_we, WRDE_NOCMD|WRDE_UNDEF)) != 0) {
if (i == WRDE_NOSPACE)
goto alloc_fail;
@@ -188,13 +177,14 @@ create_method_info(const inetd_prop_t *mprops, boolean_t *exec_invalid)
*/
ret->wordexp_arg0_backup = ret->exec_args_we.we_wordv[0];
if ((ret->exec_args_we.we_wordv[0] =
- strdup(get_prop_value(mprops, PR_ARG0_NAME))) == NULL)
+ strdup(get_prop_value_string(mprops, PR_ARG0_NAME)))
+ == NULL)
goto alloc_fail;
}
if (mprops[MP_TIMEOUT].ip_error == IVE_VALID) {
- ret->timeout = *(int64_t *)get_prop_value(mprops,
- (char *)SCF_PROPERTY_TIMEOUT);
+ ret->timeout = get_prop_value_count(mprops,
+ SCF_PROPERTY_TIMEOUT);
} else {
ret->timeout = DEFAULT_METHOD_TIMEOUT;
}
@@ -332,33 +322,24 @@ populate_defaults(inetd_prop_t *bprops, basic_cfg_t *cfg)
{
debug_msg("Entering populate_defaults");
- /*
- * All time related values below are stored as 32 bits values because
- * the consumers of the data rely on this, and so we cast them all
- * to int's here.
- */
- cfg->do_tcp_wrappers =
- *(boolean_t *)get_prop_value(bprops, PR_DO_TCP_WRAPPERS_NAME);
- cfg->do_tcp_trace =
- *(boolean_t *)get_prop_value(bprops, PR_DO_TCP_TRACE_NAME);
- cfg->inherit_env =
- *(boolean_t *)get_prop_value(bprops, PR_INHERIT_ENV_NAME);
- cfg->wait_fail_cnt =
- *(int64_t *)get_prop_value(bprops, PR_MAX_FAIL_RATE_CNT_NAME);
- cfg->wait_fail_interval = (int)*(int64_t *)get_prop_value(bprops,
+ cfg->do_tcp_wrappers = get_prop_value_boolean(bprops,
+ PR_DO_TCP_WRAPPERS_NAME);
+ cfg->do_tcp_trace = get_prop_value_boolean(bprops,
+ PR_DO_TCP_TRACE_NAME);
+ cfg->inherit_env = get_prop_value_boolean(bprops, PR_INHERIT_ENV_NAME);
+ cfg->wait_fail_cnt = get_prop_value_int(bprops,
+ PR_MAX_FAIL_RATE_CNT_NAME);
+ cfg->wait_fail_interval = get_prop_value_int(bprops,
PR_MAX_FAIL_RATE_INTVL_NAME);
- cfg->max_copies =
- *(int64_t *)get_prop_value(bprops, PR_MAX_COPIES_NAME);
- cfg->conn_rate_offline =
- (int)*(int64_t *)get_prop_value(bprops, PR_CON_RATE_OFFLINE_NAME);
- cfg->conn_rate_max =
- *(int64_t *)get_prop_value(bprops, PR_CON_RATE_MAX_NAME);
- cfg->bind_fail_interval =
- (int)*(int64_t *)get_prop_value(bprops, PR_BIND_FAIL_INTVL_NAME);
- cfg->bind_fail_max =
- *(int64_t *)get_prop_value(bprops, PR_BIND_FAIL_MAX_NAME);
+ cfg->max_copies = get_prop_value_int(bprops, PR_MAX_COPIES_NAME);
+ cfg->conn_rate_offline = get_prop_value_int(bprops,
+ PR_CON_RATE_OFFLINE_NAME);
+ cfg->conn_rate_max = get_prop_value_int(bprops, PR_CON_RATE_MAX_NAME);
+ cfg->bind_fail_interval = get_prop_value_int(bprops,
+ PR_BIND_FAIL_INTVL_NAME);
+ cfg->bind_fail_max = get_prop_value_int(bprops, PR_BIND_FAIL_MAX_NAME);
if ((cfg->bind_addr =
- strdup(get_prop_value(bprops, PR_BIND_ADDR_NAME))) == NULL) {
+ strdup(get_prop_value_string(bprops, PR_BIND_ADDR_NAME))) == NULL) {
error_msg(strerror(errno));
return (-1);
}
@@ -436,7 +417,7 @@ read_method_props(const char *inst, instance_method_t method, scf_error_t *err)
}
(void) memcpy(ret, method_props, sizeof (method_props));
- for (i = 0; i < NUM_METHOD_PROPS; i++) {
+ for (i = 0; ret[i].ip_name != NULL; i++) {
*err = read_prop(rep_handle, &ret[i], i, inst,
methods[method].name);
if ((*err != 0) && (*err != SCF_ERROR_NOT_FOUND)) {
@@ -456,9 +437,10 @@ destroy_method_props(inetd_prop_t *mprop)
if (mprop == NULL)
return;
- for (i = 0; i < NUM_METHOD_PROPS; i++) {
- if (mprop[i].ip_type == SCF_TYPE_ASTRING)
- free(mprop[i].ip_value.iv_astring);
+ for (i = 0; mprop[i].ip_name != NULL; i++) {
+ if (mprop[i].ip_type == INET_TYPE_STRING &&
+ mprop[i].ip_error == IVE_VALID)
+ free(mprop[i].ip_value.iv_string);
}
free(mprop);
@@ -540,7 +522,7 @@ valid_inst_props(const char *fmri, inetd_prop_t *bprops, inetd_prop_t **mprops,
* for each invalid/ missing property.
*/
(void) get_prop_table(&num_bprops);
- for (i = 0; i < num_bprops; i++) {
+ for (i = 0; bprops[i].ip_name != NULL; i++) {
switch (bprops[i].ip_error) {
case IVE_UNSET:
if (!bprops[i].ip_default)
@@ -560,12 +542,12 @@ valid_inst_props(const char *fmri, inetd_prop_t *bprops, inetd_prop_t **mprops,
int j;
/* check if any properties are set */
- for (j = 0; j < NUM_METHOD_PROPS; j++) {
+ for (j = 0; mprops[i][j].ip_name != NULL; j++) {
if (mprops[i][j].ip_error != IVE_UNSET)
break;
}
- if (j == NUM_METHOD_PROPS) {
+ if (mprops[i][j].ip_name == NULL) {
/* an unspecified method */
if ((instance_method_t)i == IM_START) {
error_msg(gettext(
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c b/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c
index 47d45ecb95..d0e96f81b7 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/inetadm/inetadm.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -387,11 +387,8 @@ commit_props(const scf_instance_t *inst, inetd_prop_t *mod, boolean_t defaults)
{
int i;
uint8_t new_bool;
- size_t numprops;
-
- (void) get_prop_table(&numprops);
- for (i = 0; i < numprops; i++) {
+ for (i = 0; mod[i].ip_name != NULL; i++) {
switch (mod[i].ip_error) {
case IVE_UNSET:
break;
@@ -400,22 +397,27 @@ commit_props(const scf_instance_t *inst, inetd_prop_t *mod, boolean_t defaults)
break;
case IVE_VALID:
switch (mod[i].ip_type) {
- case SCF_TYPE_ASTRING:
+ case INET_TYPE_STRING:
+ modify_prop(inst,
+ defaults ? PG_NAME_SERVICE_DEFAULTS :
+ mod[i].ip_pg, mod[i].ip_name,
+ SCF_TYPE_ASTRING,
+ mod[i].ip_value.iv_string);
+ break;
+ case INET_TYPE_STRING_LIST:
modify_prop(inst,
defaults ? PG_NAME_SERVICE_DEFAULTS :
mod[i].ip_pg, mod[i].ip_name,
SCF_TYPE_ASTRING,
- (i == PT_PROTO_INDEX) ?
- (void *)mod[i].ip_value.iv_proto_list :
- (void *)mod[i].ip_value.iv_astring);
+ mod[i].ip_value.iv_string_list);
break;
- case SCF_TYPE_INTEGER:
+ case INET_TYPE_INTEGER:
modify_prop(inst,
defaults ? PG_NAME_SERVICE_DEFAULTS :
mod[i].ip_pg, mod[i].ip_name,
SCF_TYPE_INTEGER, &mod[i].ip_value.iv_int);
break;
- case SCF_TYPE_BOOLEAN:
+ case INET_TYPE_BOOLEAN:
new_bool = (mod[i].ip_value.iv_boolean) ? 1 : 0;
modify_prop(inst,
@@ -522,31 +524,31 @@ list_services()
}
static void
-print_prop_val(int index, inetd_prop_t *prop)
+print_prop_val(inetd_prop_t *prop)
{
switch (prop->ip_type) {
- case SCF_TYPE_ASTRING:
- if (index == PT_PROTO_INDEX) {
+ case INET_TYPE_STRING:
+ (void) printf("\"%s\"\n", prop->ip_value.iv_string);
+ break;
+ case INET_TYPE_STRING_LIST:
+ {
int j = 0;
- char **cpp = prop->ip_value.iv_proto_list;
+ char **cpp = prop->ip_value.iv_string_list;
/*
- * Print proto string array as comma separated list.
+ * Print string list as comma separated list.
*/
(void) printf("\"%s", cpp[j]);
while (cpp[++j] != NULL)
(void) printf(",%s", cpp[j]);
(void) printf("\"\n");
- } else {
- (void) printf("\"%s\"\n",
- prop->ip_value.iv_astring);
}
break;
- case SCF_TYPE_INTEGER:
+ case INET_TYPE_INTEGER:
(void) printf("%lld\n", prop->ip_value.iv_int);
break;
- case SCF_TYPE_BOOLEAN:
+ case INET_TYPE_BOOLEAN:
if (prop->ip_value.iv_boolean)
(void) printf("%s\n", INETADM_TRUE_STR);
else
@@ -636,7 +638,7 @@ list_props_cb(void *data, scf_walkinfo_t *wip)
(void) printf("%-9s%s=",
proplist[i].from_inetd ? INETADM_DEFAULT_STR : "",
proplist[i].ip_name);
- print_prop_val(i, &proplist[i]);
+ print_prop_val(&proplist[i]);
continue;
}
@@ -732,7 +734,7 @@ list_defaults()
}
(void) printf("%s=", proptable[i].ip_name);
- print_prop_val(i, &proptable[i]);
+ print_prop_val(&proptable[i]);
}
free_instance_props(proptable);
@@ -783,12 +785,12 @@ modify_inst_props_cb(void *data, scf_walkinfo_t *wip)
value++;
/* Find property name in array of properties */
- for (j = 0; j < numprops; j++) {
+ for (j = 0; mod[j].ip_name != NULL; j++) {
if (strcmp(mod[j].ip_name, argv[i]) == 0)
break;
}
- if (j >= numprops)
+ if (mod[j].ip_name == NULL)
uu_die(gettext("Error: \"%s\" is not a valid "
"property.\n"), argv[i]);
@@ -809,7 +811,7 @@ modify_inst_props_cb(void *data, scf_walkinfo_t *wip)
}
switch (mod[j].ip_type) {
- case SCF_TYPE_INTEGER:
+ case INET_TYPE_INTEGER:
if (uu_strtoint(value, &new_int, sizeof (new_int), NULL,
NULL, NULL) == -1)
uu_die(gettext("Error: \"%s\" is not a valid "
@@ -817,36 +819,37 @@ modify_inst_props_cb(void *data, scf_walkinfo_t *wip)
mod[j].ip_value.iv_int = new_int;
break;
- case SCF_TYPE_ASTRING:
- if (j == PT_PROTO_INDEX) {
- if ((mod[j].ip_value.iv_proto_list =
- get_protos(value)) == NULL) {
- if (errno == ENOMEM) {
- uu_die(gettext(
- "Error: Out of memory.\n"));
- } else if (errno == E2BIG) {
- uu_die(gettext(
- "Error: String value in "
- "%s property longer than "
- "%l characters.\n"),
- PR_PROTO_NAME, max_val);
- } else {
- uu_die(gettext(
- "Error: No values "
- "specified for %s "
- "property.\n"),
- PR_PROTO_NAME);
- }
- }
- } else if (strlen(value) >= max_val) {
+ case INET_TYPE_STRING:
+ if (strlen(value) >= max_val) {
uu_die(gettext("Error: String value is longer "
"than %l characters.\n"), max_val);
- } else if ((mod[j].ip_value.iv_astring = strdup(value))
+ } else if ((mod[j].ip_value.iv_string = strdup(value))
== NULL) {
uu_die(gettext("Error: Out of memory.\n"));
}
break;
- case SCF_TYPE_BOOLEAN:
+ case INET_TYPE_STRING_LIST:
+ if ((mod[j].ip_value.iv_string_list =
+ get_protos(value)) == NULL) {
+ if (errno == ENOMEM) {
+ uu_die(gettext(
+ "Error: Out of memory.\n"));
+ } else if (errno == E2BIG) {
+ uu_die(gettext(
+ "Error: String value in "
+ "%s property longer than "
+ "%l characters.\n"),
+ PR_PROTO_NAME, max_val);
+ } else {
+ uu_die(gettext(
+ "Error: No values "
+ "specified for %s "
+ "property.\n"),
+ PR_PROTO_NAME);
+ }
+ }
+ break;
+ case INET_TYPE_BOOLEAN:
if (strcasecmp(value, INETADM_TRUE_STR) == 0)
mod[j].ip_value.iv_boolean = B_TRUE;
else if (strcasecmp(value, INETADM_FALSE_STR) == 0)
@@ -920,14 +923,14 @@ modify_defaults(int argc, char *argv[])
value++;
/* Find property name in array of defaults */
- for (j = 0; j < numprops; j++) {
+ for (j = 0; mod[j].ip_name != NULL; j++) {
if (!mod[j].ip_default)
continue;
if (strcmp(mod[j].ip_name, argv[i]) == 0)
break;
}
- if (j >= numprops)
+ if (mod[j].ip_name == NULL)
uu_die(gettext("Error: \"%s\" is not a default inetd "
"property.\n"), argv[i]);
@@ -936,7 +939,7 @@ modify_defaults(int argc, char *argv[])
"properties.\n"));
switch (mod[j].ip_type) {
- case SCF_TYPE_INTEGER:
+ case INET_TYPE_INTEGER:
if (uu_strtoint(value, &new_int, sizeof (new_int), NULL,
NULL, NULL) == -1)
uu_die(gettext("Error: \"%s\" is not a valid "
@@ -944,15 +947,15 @@ modify_defaults(int argc, char *argv[])
mod[j].ip_value.iv_int = new_int;
break;
- case SCF_TYPE_ASTRING:
+ case INET_TYPE_STRING:
if (strlen(value) >= max_val)
uu_die(gettext("Error: String value is longer "
"than %l characters.\n"), max_val);
- if ((mod[j].ip_value.iv_astring = strdup(value))
+ if ((mod[j].ip_value.iv_string = strdup(value))
== NULL)
uu_die(gettext("Error: Out of memory.\n"));
break;
- case SCF_TYPE_BOOLEAN:
+ case INET_TYPE_BOOLEAN:
if (strcasecmp(value, INETADM_TRUE_STR) == 0)
mod[j].ip_value.iv_boolean = B_TRUE;
else if (strcasecmp(value, INETADM_FALSE_STR) == 0)
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c b/usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c
index 13b4af67d1..eb09ad71f0 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/inetconv/inetconv.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -370,24 +370,6 @@ invalid_props(inetd_prop_t *p)
return (buf);
}
-/*
- * wrapper around put_prop_value() that errors and exits on malloc failures,
- * returns -1 on other failures, else returns 0.
- */
-static int
-my_put_prop_value(inetd_prop_t *props, char *pname, void *value)
-{
- if (put_prop_value(props, pname, value) == 0)
- return (0);
-
- if (errno == ENOMEM) {
- (void) fprintf(stderr, gettext("%s: malloc failed: %s\n"),
- progname, strerror(errno));
- exit(EXIT_ERROR_SYS);
- }
- return (-1);
-}
-
static boolean_t
valid_basic_properties(struct inetconfent *iconf, struct fileinfo *finfo)
{
@@ -402,23 +384,31 @@ valid_basic_properties(struct inetconfent *iconf, struct fileinfo *finfo)
(void) memcpy(prop, inetd_properties,
prop_size * sizeof (inetd_prop_t));
- (void) put_prop_value(prop, PR_ISRPC_NAME, &iconf->isrpc);
- (void) put_prop_value(prop, PR_ISWAIT_NAME, &iconf->wait);
+ put_prop_value_boolean(prop, PR_ISRPC_NAME, iconf->isrpc);
+ put_prop_value_boolean(prop, PR_ISWAIT_NAME, iconf->wait);
if (iconf->isrpc) {
- (void) put_prop_value(prop, PR_RPC_LW_VER_NAME,
- &iconf->rpc_low_version);
- (void) put_prop_value(prop, PR_RPC_HI_VER_NAME,
- &iconf->rpc_high_version);
+ put_prop_value_int(prop, PR_RPC_LW_VER_NAME,
+ iconf->rpc_low_version);
+ put_prop_value_int(prop, PR_RPC_HI_VER_NAME,
+ iconf->rpc_high_version);
svc_name = iconf->rpc_prog;
proto += 4; /* skip 'rpc/' */
}
- if ((my_put_prop_value(prop, PR_SOCK_TYPE_NAME, iconf->endpoint)
- != 0) ||
- (my_put_prop_value(prop, PR_SVC_NAME_NAME, svc_name) != 0) ||
- (my_put_prop_value(prop, PR_PROTO_NAME, proto) != 0))
+ if (!put_prop_value_string(prop, PR_SOCK_TYPE_NAME, iconf->endpoint) ||
+ !put_prop_value_string(prop, PR_SVC_NAME_NAME, svc_name)) {
valid = B_FALSE;
+ if (errno == ENOMEM) {
+ (void) fprintf(stderr,
+ gettext("%s: failed to allocate memory: %s\n"),
+ progname, strerror(errno));
+ exit(EXIT_ERROR_SYS);
+ }
+ }
+
+ put_prop_value_string_list(prop, PR_PROTO_NAME, get_protos(proto));
+
if (!valid_props(prop, NULL, NULL, NULL, NULL) || !valid) {
valid = B_FALSE;
(void) fprintf(stderr, gettext("%s: Error %s line %d "
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c
index ee9b73c5a8..3b5e49bb39 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -501,25 +501,20 @@ main(int argc, char **argv)
}
int tone[] = {
-0x034057, 0x026074, 0x136710, 0x126660, 0x147551, 0x034460,
-0x026775, 0x141727, 0x127670, 0x156532, 0x036064, 0x030721,
-0x134703, 0x126705, 0x046071, 0x030073, 0x036667, 0x140666,
-0x126137, 0x064463, 0x031064, 0x072677, 0x135652, 0x141734,
-0x036463, 0x027472, 0x137333, 0x127257, 0x152534, 0x033065,
-0x027723, 0x136313, 0x127735, 0x053473, 0x035470, 0x052666,
-0x167260, 0x140535, 0x045471, 0x034474, 0x132711, 0x132266,
-0x047127, 0x027077, 0x043705, 0x141676, 0x134110, 0x063400,
+0x076113, 0x153333, 0x147317, 0x144311, 0x147315, 0x050353, 0x037103, 0x051106,
+0x157155, 0x142723, 0x133273, 0x134664, 0x051712, 0x024465, 0x026447, 0x072473,
+0x136715, 0x126257, 0x135256, 0x047344, 0x034476, 0x027464, 0x036062, 0x133334,
+0x127256, 0x130660, 0x136262, 0x040724, 0x016446, 0x025437, 0x137171, 0x127672,
+0x124655, 0x134654, 0x032741, 0x021447, 0x037450, 0x125675, 0x127650, 0x077277,
+0x046514, 0x036077, 0x035471, 0x147131, 0x136272, 0x162720, 0x166151, 0x037527,
};
/*
- * Make a sound on /dev/audio according
- * to the length of the packet. The tone
- * data above is a piece of waveform from
- * a Pink Floyd track. The amount of waveform
- * used is a function of packet length e.g.
- * a series of small packets is heard as
- * clicks, whereas a series of NFS packets
- * in an 8k read sounds like a "WHAAAARP".
+ * Make a sound on /dev/audio according to the length of the packet. The
+ * tone data was ripped from /usr/share/audio/samples/au/bark.au. The
+ * amount of waveform used is a function of packet length e.g. a series
+ * of small packets is heard as clicks, whereas a series of NFS packets in
+ * an 8k read sounds like a "WHAAAARP".
*/
void
click(len)
diff --git a/usr/src/lib/libinetsvc/common/inetsvc.c b/usr/src/lib/libinetsvc/common/inetsvc.c
index 60c9a0623e..1f2020100f 100644
--- a/usr/src/lib/libinetsvc/common/inetsvc.c
+++ b/usr/src/lib/libinetsvc/common/inetsvc.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -61,52 +61,51 @@
#include <libuutil.h>
static inetd_prop_t inetd_properties[] = {
- {PR_SVC_NAME_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_ASTRING,
+ {PR_SVC_NAME_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_SOCK_TYPE_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_ASTRING,
+ {PR_SOCK_TYPE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_PROTO_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_ASTRING,
+ {PR_PROTO_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING_LIST,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_ISRPC_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_BOOLEAN,
+ {PR_ISRPC_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_RPC_LW_VER_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_RPC_LW_VER_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_RPC_HI_VER_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_RPC_HI_VER_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_ISWAIT_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_BOOLEAN,
+ {PR_ISWAIT_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_EXEC_NAME, START_METHOD_NAME, SCF_TYPE_ASTRING,
+ {PR_EXEC_NAME, START_METHOD_NAME, INET_TYPE_STRING,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_ARG0_NAME, START_METHOD_NAME, SCF_TYPE_ASTRING,
+ {PR_ARG0_NAME, START_METHOD_NAME, INET_TYPE_STRING,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_USER_NAME, START_METHOD_NAME, SCF_TYPE_ASTRING,
+ {PR_USER_NAME, START_METHOD_NAME, INET_TYPE_STRING,
B_FALSE, IVE_UNSET, NULL, B_FALSE},
- {PR_BIND_ADDR_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_ASTRING,
+ {PR_BIND_ADDR_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_STRING,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_BIND_FAIL_MAX_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_BIND_FAIL_MAX_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_BIND_FAIL_INTVL_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_BIND_FAIL_INTVL_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_CON_RATE_MAX_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_CON_RATE_MAX_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_MAX_COPIES_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_MAX_COPIES_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_CON_RATE_OFFLINE_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_CON_RATE_OFFLINE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_MAX_FAIL_RATE_CNT_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_MAX_FAIL_RATE_CNT_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_MAX_FAIL_RATE_INTVL_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_INTEGER,
+ {PR_MAX_FAIL_RATE_INTVL_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_INHERIT_ENV_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_BOOLEAN,
+ {PR_INHERIT_ENV_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_DO_TCP_TRACE_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_BOOLEAN,
+ {PR_DO_TCP_TRACE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN,
B_TRUE, IVE_UNSET, NULL, B_FALSE},
- {PR_DO_TCP_WRAPPERS_NAME, PG_NAME_SERVICE_CONFIG, SCF_TYPE_BOOLEAN,
- B_TRUE, IVE_UNSET, NULL, B_FALSE}
+ {PR_DO_TCP_WRAPPERS_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN,
+ B_TRUE, IVE_UNSET, NULL, B_FALSE},
+ {NULL},
};
-#define INETD_NUMPROPS (sizeof (inetd_properties) / sizeof (inetd_prop_t))
-
#define INETSVC_SVC_BUF_MAX (NSS_BUFLEN_RPC + sizeof (struct rpcent))
#define DIGEST_LEN 16
@@ -126,9 +125,9 @@ boolean_t
is_tlx_service(inetd_prop_t *props)
{
return ((strcmp(SOCKTYPE_TLI_STR,
- props[PT_SOCK_TYPE_INDEX].ip_value.iv_astring) == 0) ||
+ props[PT_SOCK_TYPE_INDEX].ip_value.iv_string) == 0) ||
(strcmp(SOCKTYPE_XTI_STR,
- props[PT_SOCK_TYPE_INDEX].ip_value.iv_astring) == 0));
+ props[PT_SOCK_TYPE_INDEX].ip_value.iv_string) == 0));
}
/*
@@ -138,83 +137,182 @@ is_tlx_service(inetd_prop_t *props)
inetd_prop_t *
get_prop_table(size_t *num_elements)
{
- *num_elements = INETD_NUMPROPS;
+ *num_elements = sizeof (inetd_properties) / sizeof (inetd_prop_t);
return (&inetd_properties[0]);
}
/*
- * get_prop_value takes an array of inetd_prop_t's and a name of an inetd
- * property, and returns a pointer to the value of the requested property.
+ * find_prop takes an array of inetd_prop_t's, the name of an inetd
+ * property, the type expected, and returns a pointer to the matching member,
+ * or NULL.
*/
+inetd_prop_t *
+find_prop(const inetd_prop_t *prop, const char *name, inet_type_t type)
+{
+ int i = 0;
+
+ while (prop[i].ip_name != NULL && strcmp(name, prop[i].ip_name) != 0)
+ i++;
+
+ if (prop[i].ip_name == NULL)
+ return (NULL);
+
+ if (prop[i].ip_type != type)
+ return (NULL);
-void *
-get_prop_value(const inetd_prop_t *prop, char *name)
+ return ((inetd_prop_t *)prop + i);
+}
+
+/*
+ * get_prop_value_int takes an array of inetd_prop_t's together with the name of
+ * an inetd property and returns the value of the property. It's expected that
+ * the property exists in the searched array.
+ */
+int64_t
+get_prop_value_int(const inetd_prop_t *prop, const char *name)
{
- int i;
+ inetd_prop_t *p;
- for (i = 0; i < INETD_NUMPROPS; i++) {
- if (strcmp(name, prop[i].ip_name) != 0)
- continue;
- if (prop[i].ip_type == SCF_TYPE_ASTRING) {
- if (i == PT_PROTO_INDEX) {
- return ((void *)
- prop[i].ip_value.iv_proto_list);
- } else {
- return ((void *) prop[i].ip_value.iv_astring);
- }
- } else {
- return ((void *) &prop[i].ip_value);
- }
- }
+ p = find_prop(prop, name, INET_TYPE_INTEGER);
+ return (p->ip_value.iv_int);
+}
- return (NULL);
+/*
+ * get_prop_value_count takes an array of inetd_prop_t's together with the name
+ * of an inetd property and returns the value of the property. It's expected
+ * that the property exists in the searched array.
+ */
+uint64_t
+get_prop_value_count(const inetd_prop_t *prop, const char *name)
+{
+ inetd_prop_t *p;
+
+ p = find_prop(prop, name, INET_TYPE_COUNT);
+ return (p->ip_value.iv_cnt);
}
/*
- * put_prop_value takes an array of inetd_prop_t's, a name of an inetd
- * property, and a pointer to a value. It copies the value into the property
- * in the array, and returns 0 for success and -1 for failure.
+ * get_prop_value_boolean takes an array of inetd_prop_t's together with the
+ * name of an inetd property and returns the value of the property. It's
+ * expected that the property exists in the searched array.
*/
+boolean_t
+get_prop_value_boolean(const inetd_prop_t *prop, const char *name)
+{
+ inetd_prop_t *p;
-int
-put_prop_value(inetd_prop_t *prop, char *name, void *value)
+ p = find_prop(prop, name, INET_TYPE_BOOLEAN);
+ return (p->ip_value.iv_boolean);
+}
+
+/*
+ * get_prop_value_string takes an array of inetd_prop_t's together with
+ * the name of an inetd property and returns the value of the property.
+ * It's expected that the property exists in the searched array.
+ */
+const char *
+get_prop_value_string(const inetd_prop_t *prop, const char *name)
{
- int i;
+ inetd_prop_t *p;
- for (i = 0; i < INETD_NUMPROPS; i++) {
- if (strcmp(name, prop[i].ip_name) != 0)
- continue;
- switch (prop[i].ip_type) {
- case SCF_TYPE_INTEGER:
- prop[i].ip_value.iv_int = *((int64_t *)value);
- prop[i].ip_error = IVE_VALID;
- return (0);
- case SCF_TYPE_BOOLEAN:
- prop[i].ip_value.iv_boolean =
- *((boolean_t *)value);
- prop[i].ip_error = IVE_VALID;
- return (0);
- case SCF_TYPE_ASTRING:
- if (i == PT_PROTO_INDEX) {
- if ((prop[i].ip_value.iv_proto_list =
- get_protos((char *)value)) == NULL)
- return (-1);
- } else {
- if (strlen((char *)value) >=
- scf_limit(SCF_LIMIT_MAX_VALUE_LENGTH)) {
- errno = E2BIG;
- return (-1);
- }
- if ((prop[i].ip_value.iv_astring =
- strdup((char *)value)) == NULL)
- return (-1);
- }
- prop[i].ip_error = IVE_VALID;
- return (0);
- }
+ p = find_prop(prop, name, INET_TYPE_STRING);
+ return (p->ip_value.iv_string);
+}
+
+/*
+ * get_prop_value_string_list takes an array of inetd_prop_t's together
+ * with the name of an inetd property and returns the value of the property.
+ * It's expected that the property exists in the searched array.
+ */
+const char **
+get_prop_value_string_list(const inetd_prop_t *prop, const char *name)
+{
+ inetd_prop_t *p;
+
+ p = find_prop(prop, name, INET_TYPE_STRING_LIST);
+ return ((const char **)p->ip_value.iv_string_list);
+}
+
+/*
+ * put_prop_value_int takes an array of inetd_prop_t's, a name of an inetd
+ * property, and a value. It copies the value into the property
+ * in the array. It's expected that the property exists in the searched array.
+ */
+void
+put_prop_value_int(inetd_prop_t *prop, const char *name, int64_t value)
+{
+ inetd_prop_t *p;
+
+ p = find_prop(prop, name, INET_TYPE_INTEGER);
+ p->ip_value.iv_int = value;
+ p->ip_error = IVE_VALID;
+}
+
+/*
+ * put_prop_value_count takes an array of inetd_prop_t's, a name of an inetd
+ * property, and a value. It copies the value into the property
+ * in the array. It's expected that the property exists in the searched array.
+ */
+void
+put_prop_value_count(inetd_prop_t *prop, const char *name, uint64_t value)
+{
+ inetd_prop_t *p;
+
+ p = find_prop(prop, name, INET_TYPE_COUNT);
+ p->ip_value.iv_cnt = value;
+ p->ip_error = IVE_VALID;
+}
+
+/*
+ * put_prop_value_boolean takes an array of inetd_prop_t's, a name of an inetd
+ * property, and a value. It copies the value into the property
+ * in the array. It's expected that the property exists in the searched array.
+ */
+void
+put_prop_value_boolean(inetd_prop_t *prop, const char *name, boolean_t value)
+{
+ inetd_prop_t *p;
+
+ p = find_prop(prop, name, INET_TYPE_BOOLEAN);
+ p->ip_value.iv_boolean = value;
+ p->ip_error = IVE_VALID;
+}
+
+/*
+ * put_prop_value_string takes an array of inetd_prop_t's, a name of an inetd
+ * property, and a value. It duplicates the value into the property
+ * in the array, and returns B_TRUE for success and B_FALSE for failure. It's
+ * expected that the property exists in the searched array.
+ */
+boolean_t
+put_prop_value_string(inetd_prop_t *prop, const char *name, const char *value)
+{
+ inetd_prop_t *p;
+
+ if (strlen(value) >= scf_limit(SCF_LIMIT_MAX_VALUE_LENGTH)) {
+ errno = E2BIG;
+ return (B_FALSE);
}
+ p = find_prop(prop, name, INET_TYPE_STRING);
+ if ((p->ip_value.iv_string = strdup(value)) == NULL)
+ return (B_FALSE);
+ p->ip_error = IVE_VALID;
+ return (B_TRUE);
+}
- return (-1);
+/*
+ * put_prop_value_string_list takes an array of inetd_prop_t's, a name of an
+ * inetd property, and a value. It copies the value into the property
+ * in the array. It's expected that the property exists in the searched array.
+ */
+void
+put_prop_value_string_list(inetd_prop_t *prop, const char *name, char **value)
+{
+ inetd_prop_t *p;
+
+ p = find_prop(prop, name, INET_TYPE_STRING_LIST);
+ p->ip_value.iv_string_list = value;
+ p->ip_error = IVE_VALID;
}
static void
@@ -466,7 +564,7 @@ valid_props(inetd_prop_t *prop, const char *fmri, basic_cfg_t **cfgpp,
* Set all checkable properties to valid as a baseline. We'll be
* marking all invalid properties.
*/
- for (i = 0; i < INETD_NUMPROPS; i++) {
+ for (i = 0; prop[i].ip_name != NULL; i++) {
if (prop[i].ip_error != IVE_UNSET)
prop[i].ip_error = IVE_VALID;
}
@@ -482,7 +580,7 @@ valid_props(inetd_prop_t *prop, const char *fmri, basic_cfg_t **cfgpp,
/* Check a service name was supplied */
if ((prop[PT_SVC_NAME_INDEX].ip_error == IVE_UNSET) ||
((cfg->svc_name =
- strdup(prop[PT_SVC_NAME_INDEX].ip_value.iv_astring)) == NULL))
+ strdup(prop[PT_SVC_NAME_INDEX].ip_value.iv_string)) == NULL))
prop[PT_SVC_NAME_INDEX].ip_error = IVE_INVALID;
/* Check that iswait and isrpc have valid boolean values */
@@ -531,7 +629,7 @@ valid_props(inetd_prop_t *prop, const char *fmri, basic_cfg_t **cfgpp,
cfg->istlx = B_FALSE;
if ((prop[PT_SOCK_TYPE_INDEX].ip_error == IVE_UNSET) ||
((sock_type_id = get_sock_type_id(
- prop[PT_SOCK_TYPE_INDEX].ip_value.iv_astring)) == -1) &&
+ prop[PT_SOCK_TYPE_INDEX].ip_value.iv_string)) == -1) &&
!(cfg->istlx = is_tlx_service(prop)))
prop[PT_SOCK_TYPE_INDEX].ip_error = IVE_INVALID;
@@ -568,7 +666,7 @@ valid_props(inetd_prop_t *prop, const char *fmri, basic_cfg_t **cfgpp,
invalid_proto = B_TRUE;
goto past_proto_processing;
}
- protos = prop[PT_PROTO_INDEX].ip_value.iv_proto_list;
+ protos = prop[PT_PROTO_INDEX].ip_value.iv_string_list;
/*
* Get the next netid/proto.
@@ -801,7 +899,7 @@ past_proto_processing:
if (prop[PT_EXEC_INDEX].ip_error != IVE_UNSET) {
/* Don't pass any arguments to access() */
if ((bufp = strdup(
- prop[PT_EXEC_INDEX].ip_value.iv_astring)) == NULL) {
+ prop[PT_EXEC_INDEX].ip_value.iv_string)) == NULL) {
prop[PT_EXEC_INDEX].ip_error = IVE_INVALID;
} else {
if ((cp = strpbrk(bufp, " \t")) != NULL)
@@ -817,10 +915,10 @@ past_proto_processing:
char pw_buf[NSS_BUFLEN_PASSWD];
struct passwd pw;
- if (getpwnam_r(prop[PT_USER_INDEX].ip_value.iv_astring, &pw,
+ if (getpwnam_r(prop[PT_USER_INDEX].ip_value.iv_string, &pw,
pw_buf, NSS_BUFLEN_PASSWD) == NULL) {
errno = 0;
- uidl = strtol(prop[PT_USER_INDEX].ip_value.iv_astring,
+ uidl = strtol(prop[PT_USER_INDEX].ip_value.iv_string,
&bufp, 10);
if ((errno != 0) || (*bufp != '\0') ||
(getpwuid_r(uidl, &pw, pw_buf,
@@ -835,7 +933,7 @@ past_proto_processing:
* according to whether any properties were marked invalid.
*/
- for (i = 0; i < INETD_NUMPROPS; i++) {
+ for (i = 0; prop[i].ip_name != NULL; i++) {
if (prop[i].ip_error == IVE_UNSET)
continue;
@@ -864,29 +962,31 @@ past_proto_processing:
*/
boolean_t
-valid_default_prop(char *name, void *value)
+valid_default_prop(const char *name, const void *value)
{
int i;
- for (i = 0; i < INETD_NUMPROPS; i++) {
+ for (i = 0; inetd_properties[i].ip_name != NULL; i++) {
if (strcmp(name, inetd_properties[i].ip_name) != 0)
continue;
if (!inetd_properties[i].ip_default)
return (B_FALSE);
switch (inetd_properties[i].ip_type) {
- case SCF_TYPE_INTEGER:
+ case INET_TYPE_INTEGER:
if (*((int64_t *)value) >= -1)
return (B_TRUE);
else
return (B_FALSE);
- case SCF_TYPE_BOOLEAN:
+ case INET_TYPE_BOOLEAN:
if ((*((boolean_t *)value) == B_FALSE) ||
(*((boolean_t *)value) == B_TRUE))
return (B_TRUE);
else
return (B_FALSE);
- case SCF_TYPE_ASTRING:
+ case INET_TYPE_COUNT:
+ case INET_TYPE_STRING_LIST:
+ case INET_TYPE_STRING:
return (B_TRUE);
}
}
@@ -909,8 +1009,16 @@ read_prop(scf_handle_t *h, inetd_prop_t *iprop, int index, const char *inst,
return (scf_error());
switch (iprop->ip_type) {
- case SCF_TYPE_ASTRING:
- if (index == PT_PROTO_INDEX) {
+ case INET_TYPE_STRING:
+ if ((tmp_char = scf_simple_prop_next_astring(sprop)) == NULL)
+ goto scf_error;
+ if ((iprop->ip_value.iv_string = strdup(tmp_char)) == NULL) {
+ scf_simple_prop_free(sprop);
+ return (SCF_ERROR_NO_MEMORY);
+ }
+ break;
+ case INET_TYPE_STRING_LIST:
+ {
int j = 0;
while ((tmp_char =
@@ -918,12 +1026,12 @@ read_prop(scf_handle_t *h, inetd_prop_t *iprop, int index, const char *inst,
char **cpp;
if ((cpp = realloc(
- iprop->ip_value.iv_proto_list,
+ iprop->ip_value.iv_string_list,
(j + 2) * sizeof (char *))) == NULL) {
scf_simple_prop_free(sprop);
return (SCF_ERROR_NO_MEMORY);
}
- iprop->ip_value.iv_proto_list = cpp;
+ iprop->ip_value.iv_string_list = cpp;
if ((cpp[j] = strdup(tmp_char)) == NULL) {
scf_simple_prop_free(sprop);
return (SCF_ERROR_NO_MEMORY);
@@ -932,29 +1040,20 @@ read_prop(scf_handle_t *h, inetd_prop_t *iprop, int index, const char *inst,
}
if ((j == 0) || (scf_error() != SCF_ERROR_NONE))
goto scf_error;
- } else {
- if ((tmp_char = scf_simple_prop_next_astring(sprop)) ==
- NULL)
- goto scf_error;
- if ((iprop->ip_value.iv_astring = strdup(tmp_char)) ==
- NULL) {
- scf_simple_prop_free(sprop);
- return (SCF_ERROR_NO_MEMORY);
- }
}
break;
- case SCF_TYPE_BOOLEAN:
+ case INET_TYPE_BOOLEAN:
if ((tmp_bool = scf_simple_prop_next_boolean(sprop)) == NULL)
goto scf_error;
iprop->ip_value.iv_boolean =
(*tmp_bool == 0) ? B_FALSE : B_TRUE;
break;
- case SCF_TYPE_COUNT:
+ case INET_TYPE_COUNT:
if ((tmp_cnt = scf_simple_prop_next_count(sprop)) == NULL)
goto scf_error;
iprop->ip_value.iv_cnt = *tmp_cnt;
break;
- case SCF_TYPE_INTEGER:
+ case INET_TYPE_INTEGER:
if ((tmp_int = scf_simple_prop_next_integer(sprop)) == NULL)
goto scf_error;
iprop->ip_value.iv_int = *tmp_int;
@@ -999,7 +1098,7 @@ read_props(scf_handle_t *h, const char *instance, size_t *num_elements,
if (defaults_only)
instance = INETD_INSTANCE_FMRI;
- for (i = 0; i < INETD_NUMPROPS; i++) {
+ for (i = 0; ret[i].ip_name != NULL; i++) {
if (defaults_only && !ret[i].ip_default)
continue;
@@ -1033,7 +1132,7 @@ read_props(scf_handle_t *h, const char *instance, size_t *num_elements,
}
}
- *num_elements = INETD_NUMPROPS;
+ *num_elements = i;
return (ret);
failure_cleanup:
@@ -1068,13 +1167,11 @@ free_instance_props(inetd_prop_t *prop)
if (prop == NULL)
return;
- for (i = 0; i < INETD_NUMPROPS; i++) {
- if (prop[i].ip_type == SCF_TYPE_ASTRING) {
- if (i == PT_PROTO_INDEX) {
- destroy_strings(prop[i].ip_value.iv_proto_list);
- } else {
- free(prop[i].ip_value.iv_astring);
- }
+ for (i = 0; prop[i].ip_name != NULL; i++) {
+ if (prop[i].ip_type == INET_TYPE_STRING) {
+ free(prop[i].ip_value.iv_string);
+ } else if (prop[i].ip_type == INET_TYPE_STRING_LIST) {
+ destroy_strings(prop[i].ip_value.iv_string_list);
}
}
free(prop);
diff --git a/usr/src/lib/libinetsvc/common/inetsvc.h b/usr/src/lib/libinetsvc/common/inetsvc.h
index f0d5f90988..b1a4644640 100644
--- a/usr/src/lib/libinetsvc/common/inetsvc.h
+++ b/usr/src/lib/libinetsvc/common/inetsvc.h
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -285,8 +285,8 @@ typedef union {
int64_t iv_int;
uint64_t iv_cnt;
boolean_t iv_boolean;
- char *iv_astring;
- char **iv_proto_list;
+ char *iv_string;
+ char **iv_string_list;
} inetd_value_t;
typedef enum {
@@ -295,10 +295,24 @@ typedef enum {
IVE_INVALID
} iv_error_t;
+/*
+ * Operations on these types (like valid_default_prop()) need to be modified
+ * when this list is changed.
+ */
+typedef enum {
+ INET_TYPE_INVALID = 0,
+
+ INET_TYPE_BOOLEAN,
+ INET_TYPE_COUNT,
+ INET_TYPE_INTEGER,
+ INET_TYPE_STRING,
+ INET_TYPE_STRING_LIST
+} inet_type_t;
+
typedef struct {
- char *ip_name;
- char *ip_pg;
- scf_type_t ip_type;
+ const char *ip_name;
+ const char *ip_pg;
+ inet_type_t ip_type;
boolean_t ip_default;
iv_error_t ip_error;
inetd_value_t ip_value;
@@ -306,13 +320,22 @@ typedef struct {
} inetd_prop_t;
inetd_prop_t *get_prop_table(size_t *);
-void *get_prop_value(const inetd_prop_t *, char *);
-int put_prop_value(inetd_prop_t *, char *, void *);
+inetd_prop_t *find_prop(const inetd_prop_t *, const char *, inet_type_t);
+int64_t get_prop_value_int(const inetd_prop_t *, const char *);
+uint64_t get_prop_value_count(const inetd_prop_t *, const char *);
+boolean_t get_prop_value_boolean(const inetd_prop_t *, const char *);
+const char *get_prop_value_string(const inetd_prop_t *, const char *);
+const char **get_prop_value_string_list(const inetd_prop_t *, const char *);
+void put_prop_value_int(inetd_prop_t *, const char *, int64_t);
+void put_prop_value_count(inetd_prop_t *, const char *, uint64_t);
+void put_prop_value_boolean(inetd_prop_t *, const char *, boolean_t);
+boolean_t put_prop_value_string(inetd_prop_t *, const char *, const char *);
+void put_prop_value_string_list(inetd_prop_t *, const char *, char **);
boolean_t valid_props(inetd_prop_t *, const char *fmri, basic_cfg_t **,
uu_list_pool_t *, uu_list_pool_t *);
void destroy_basic_cfg(basic_cfg_t *);
void destroy_proto_list(basic_cfg_t *);
-boolean_t valid_default_prop(char *, void *);
+boolean_t valid_default_prop(const char *, const void *);
scf_error_t read_prop(scf_handle_t *, inetd_prop_t *, int, const char *,
const char *);
inetd_prop_t *read_instance_props(scf_handle_t *, const char *, size_t *,
diff --git a/usr/src/lib/libinetsvc/spec/inetsvc.spec b/usr/src/lib/libinetsvc/spec/inetsvc.spec
index 66b3547376..49aa24aa1e 100644
--- a/usr/src/lib/libinetsvc/spec/inetsvc.spec
+++ b/usr/src/lib/libinetsvc/spec/inetsvc.spec
@@ -1,5 +1,5 @@
#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# CDDL HEADER START
@@ -31,15 +31,73 @@ declaration inetd_prop_t *get_prop_table(size_t *num_elements)
version SUNWprivate_1.1
end
-function get_prop_value
+function find_prop
include <inetsvc.h>
-declaration void *get_prop_value(const inetd_prop_t *prop, char *name)
+declaration inetd_prop_t *find_prop(const inetd_prop_t *prop,
+ const char *name, inet_type_t type)
version SUNWprivate_1.1
end
-function put_prop_value
+function get_prop_value_int
include <inetsvc.h>
-declaration int put_prop_value(inetd_prop_t *prop, char *name, void *value)
+declaration int64_t get_prop_value_int(const inetd_prop_t *prop,
+ const char *name)
+version SUNWprivate_1.1
+end
+
+function get_prop_value_count
+include <inetsvc.h>
+declaration uint64_t get_prop_value_count(const inetd_prop_t *prop,
+ const char *name)
+version SUNWprivate_1.1
+end
+
+function get_prop_value_boolean
+include <inetsvc.h>
+declaration boolean_t get_prop_value_boolean(const inetd_prop_t *prop,
+ const char *name)
+version SUNWprivate_1.1
+end
+
+function get_prop_value_string
+include <inetsvc.h>
+declaration char *get_prop_value_string(const inetd_prop_t *prop,
+ const char *name)
+version SUNWprivate_1.1
+end
+
+function put_prop_value_int
+include <inetsvc.h>
+declaration void put_prop_value_int(inetd_prop_t *prop,
+ const char *name, int64_t value)
+version SUNWprivate_1.1
+end
+
+function put_prop_value_count
+include <inetsvc.h>
+declaration void put_prop_value_count(inetd_prop_t *prop,
+ const char *name, uint64_t value)
+version SUNWprivate_1.1
+end
+
+function put_prop_value_boolean
+include <inetsvc.h>
+declaration void put_prop_value_boolean(inetd_prop_t *prop,
+ const char *name, boolean_t value)
+version SUNWprivate_1.1
+end
+
+function put_prop_value_string
+include <inetsvc.h>
+declaration boolean_t put_prop_value_string(inetd_prop_t *prop,
+ const char *name, const char *value)
+version SUNWprivate_1.1
+end
+
+function put_prop_value_string_list
+include <inetsvc.h>
+declaration void put_prop_value_string_list(inetd_prop_t *prop,
+ const char *name, char **value)
version SUNWprivate_1.1
end
@@ -51,7 +109,8 @@ end
function valid_default_prop
include <inetsvc.h>
-declaration boolean_t valid_default_prop(char *name, void *value)
+declaration boolean_t valid_default_prop(const char *name,
+ const void *value)
version SUNWprivate_1.1
end