Print this page
335 service manifest does not support multiple manpage references for the same keyword
*** 19,28 ****
--- 19,32 ----
* CDDL HEADER END
*/
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+ /*
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ */
+
/*
* XML document manipulation routines
*
* These routines provide translation to and from the internal representation to
*** 578,590 ****
case SC_TIME:
case SC_ASTRING:
case SC_USTRING:
scf_type = lxml_element_to_type(type);
! if ((v->sc_u.sc_string = strdup((char *)value)) == NULL)
! uu_die(gettext("string duplication failed (%s)\n"),
! strerror(errno));
if (lxml_validate_string_value(scf_type,
v->sc_u.sc_string) != 0)
uu_die(gettext("illegal value \"%s\" for "
"%s (%s)\n"), (char *)value,
lxml_prop_types[type],
--- 582,592 ----
case SC_TIME:
case SC_ASTRING:
case SC_USTRING:
scf_type = lxml_element_to_type(type);
! v->sc_u.sc_string = safe_strdup((const char *)value);
if (lxml_validate_string_value(scf_type,
v->sc_u.sc_string) != 0)
uu_die(gettext("illegal value \"%s\" for "
"%s (%s)\n"), (char *)value,
lxml_prop_types[type],
*** 1368,1378 ****
xmlChar *stabval;
if (((stabval = xmlGetProp(rstr, (xmlChar *)value_attr)) == NULL) ||
(*stabval == 0)) {
uu_warn(gettext("no stability value found\n"));
! stabval = (xmlChar *)strdup("External");
}
pg = internal_pgroup_find_or_create(entity, (char *)scf_pg_general,
(char *)scf_group_framework);
--- 1370,1380 ----
xmlChar *stabval;
if (((stabval = xmlGetProp(rstr, (xmlChar *)value_attr)) == NULL) ||
(*stabval == 0)) {
uu_warn(gettext("no stability value found\n"));
! stabval = (xmlChar *)safe_strdup("External");
}
pg = internal_pgroup_find_or_create(entity, (char *)scf_pg_general,
(char *)scf_group_framework);
*** 1436,1447 ****
{
property_t *p;
char *value;
char *prop;
! if ((prop = strdup(propname)) == NULL)
! uu_die(gettext("Out of memory.\n"));
value = (char *)xmlGetProp(pval, (xmlChar *)value_attr);
if (value == NULL || *value == '\0')
uu_die(gettext("property value missing for property '%s/%s'\n"),
pgrp->sc_pgroup_name, propname);
--- 1438,1448 ----
{
property_t *p;
char *value;
char *prop;
! prop = safe_strdup(propname);
value = (char *)xmlGetProp(pval, (xmlChar *)value_attr);
if (value == NULL || *value == '\0')
uu_die(gettext("property value missing for property '%s/%s'\n"),
pgrp->sc_pgroup_name, propname);
*** 1453,1464 ****
static void
lxml_get_parameter(pgroup_t *pgrp, const char *propname, xmlNodePtr param)
{
property_t *p = internal_property_new();
! if ((p->sc_property_name = strdup(propname)) == NULL)
! uu_die(gettext("Out of memory.\n"));
p->sc_value_type = SCF_TYPE_ASTRING;
(void) lxml_get_value(p, SC_ASTRING, param);
(void) internal_attach_property(pgrp, p);
--- 1454,1464 ----
static void
lxml_get_parameter(pgroup_t *pgrp, const char *propname, xmlNodePtr param)
{
property_t *p = internal_property_new();
! p->sc_property_name = safe_strdup(propname);
p->sc_value_type = SCF_TYPE_ASTRING;
(void) lxml_get_value(p, SC_ASTRING, param);
(void) internal_attach_property(pgrp, p);
*** 1705,1716 ****
}
/*
* Remove leading and trailing whitespace.
*/
! if ((stripped = strdup((const char *)cursor->content)) == NULL)
! uu_die(gettext("Out of memory\n"));
for (; isspace(*stripped); stripped++)
;
for (cp = stripped + strlen(stripped) - 1; isspace(*cp); cp--)
;
--- 1705,1715 ----
}
/*
* Remove leading and trailing whitespace.
*/
! stripped = safe_strdup((const char *)cursor->content);
for (; isspace(*stripped); stripped++)
;
for (cp = stripped + strlen(stripped) - 1; isspace(*cp); cp--)
;
*** 1942,1980 ****
lxml_label_to_groupname(const char *prefix, const char *in)
{
char *out, *cp;
size_t len, piece_len;
! out = uu_zalloc(2 * scf_limit(SCF_LIMIT_MAX_NAME_LENGTH) + 1);
if (out == NULL)
return (NULL);
! (void) strcpy(out, prefix);
! (void) strcat(out, in);
! len = strlen(out);
if (len > max_scf_name_len) {
/* Use the first half and the second half. */
piece_len = (max_scf_name_len - 2) / 2;
(void) strncpy(out + piece_len, "..", 2);
(void) strcpy(out + piece_len + 2, out + (len - piece_len));
-
- len = strlen(out);
}
/*
* Translate non-property characters to '_'.
*/
for (cp = out; *cp != '\0'; ++cp) {
if (!(isalnum(*cp) || *cp == '_' || *cp == '-'))
*cp = '_';
}
- *cp = '\0';
-
return (out);
}
/*
* If *p is NULL, astring_prop_value() first creates a property with the
--- 1941,1974 ----
lxml_label_to_groupname(const char *prefix, const char *in)
{
char *out, *cp;
size_t len, piece_len;
! out = uu_zalloc(2 * max_scf_name_len + 1);
if (out == NULL)
return (NULL);
! (void) strlcpy(out, prefix, 2 * max_scf_name_len + 1);
! len = strlcat(out, in, 2 * max_scf_name_len + 1);
if (len > max_scf_name_len) {
/* Use the first half and the second half. */
piece_len = (max_scf_name_len - 2) / 2;
(void) strncpy(out + piece_len, "..", 2);
(void) strcpy(out + piece_len + 2, out + (len - piece_len));
}
/*
* Translate non-property characters to '_'.
*/
for (cp = out; *cp != '\0'; ++cp) {
if (!(isalnum(*cp) || *cp == '_' || *cp == '-'))
*cp = '_';
}
return (out);
}
/*
* If *p is NULL, astring_prop_value() first creates a property with the
*** 2034,2046 ****
for (; *seps != 0; seps++) {
v = internal_value_new();
v->sc_type = (*p)->sc_value_type;
v->sc_free = lxml_free_str;
val_str[0] = *seps;
! v->sc_u.sc_string = strdup(val_str);
! if (v->sc_u.sc_string == NULL)
! uu_die(gettext("Out of memory\n"));
internal_attach_value(*p, v);
}
}
/*
--- 2028,2038 ----
for (; *seps != 0; seps++) {
v = internal_value_new();
v->sc_type = (*p)->sc_value_type;
v->sc_free = lxml_free_str;
val_str[0] = *seps;
! v->sc_u.sc_string = safe_strdup(val_str);
internal_attach_value(*p, v);
}
}
/*
*** 2081,2103 ****
static int
lxml_get_tm_manpage(entity_t *service, xmlNodePtr manpage)
{
pgroup_t *pg;
char *pgname;
xmlChar *title;
/*
! * Fetch title attribute, convert to something sanitized, and create
! * property group.
*/
title = xmlGetProp(manpage, (xmlChar *)title_attr);
! pgname = (char *)lxml_label_to_groupname(SCF_PG_TM_MAN_PREFIX,
! (const char *)title);
xmlFree(title);
pg = internal_pgroup_find_or_create(service, pgname,
! (char *)SCF_GROUP_TEMPLATE);
/*
* Each attribute is an astring property within the group.
*/
if (new_str_prop_from_attr(pg, SCF_PROPERTY_TM_TITLE,
--- 2073,2124 ----
static int
lxml_get_tm_manpage(entity_t *service, xmlNodePtr manpage)
{
pgroup_t *pg;
char *pgname;
+ char *name;
xmlChar *title;
+ xmlChar *section;
/*
! * Fetch title and section attributes, convert to something sanitized,
! * and create property group.
*/
title = xmlGetProp(manpage, (xmlChar *)title_attr);
! if (title == NULL)
! return (-1);
! section = xmlGetProp(manpage, (xmlChar *)section_attr);
! if (section == NULL) {
xmlFree(title);
+ return (-1);
+ }
+ name = safe_malloc(max_scf_name_len + 1);
+
+ /* Find existing property group with underscore separators */
+ (void) snprintf(name, max_scf_name_len + 1, "%s_%s", title, section);
+ pgname = lxml_label_to_groupname(SCF_PG_TM_MAN_PREFIX, name);
+ pg = internal_pgroup_find(service, pgname, SCF_GROUP_TEMPLATE);
+
+ uu_free(pgname);
+ (void) snprintf(name, max_scf_name_len + 1, "%s%s", title, section);
+ pgname = lxml_label_to_groupname(SCF_PG_TM_MAN_PREFIX, name);
+
+ if (pg == NULL) {
pg = internal_pgroup_find_or_create(service, pgname,
! SCF_GROUP_TEMPLATE);
! } else {
! /* Rename property group */
! free((char *)pg->sc_pgroup_name);
! pg->sc_pgroup_name = safe_strdup(pgname);
! }
!
! uu_free(pgname);
! free(name);
! xmlFree(section);
! xmlFree(title);
!
/*
* Each attribute is an astring property within the group.
*/
if (new_str_prop_from_attr(pg, SCF_PROPERTY_TM_TITLE,
*** 2121,2136 ****
--- 2142,2161 ----
/*
* Fetch name attribute, convert name to something sanitized, and create
* property group.
*/
name = xmlGetProp(doc_link, (xmlChar *)name_attr);
+ if (name == NULL)
+ return (-1);
pgname = (char *)lxml_label_to_groupname(SCF_PG_TM_DOC_PREFIX,
(const char *)name);
pg = internal_pgroup_find_or_create(service, pgname,
(char *)SCF_GROUP_TEMPLATE);
+
+ uu_free(pgname);
xmlFree(name);
/*
* Each attribute is an astring property within the group.
*/
*** 3666,3676 ****
if ((document = xmlReadFile(filename, NULL, 0)) == NULL) {
semerr(gettext("couldn't parse document\n"));
return (-1);
}
! document->name = strdup(filename);
/*
* Verify that this is a document type we understand.
*/
if ((dtd = xmlGetIntSubset(document)) == NULL) {
--- 3691,3701 ----
if ((document = xmlReadFile(filename, NULL, 0)) == NULL) {
semerr(gettext("couldn't parse document\n"));
return (-1);
}
! document->name = safe_strdup(filename);
/*
* Verify that this is a document type we understand.
*/
if ((dtd = xmlGetIntSubset(document)) == NULL) {