summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Wilcox <Sean.Wilcox@Sun.COM>2010-04-16 14:50:50 -0700
committerSean Wilcox <Sean.Wilcox@Sun.COM>2010-04-16 14:50:50 -0700
commit85bcc4e57d6d451b2647973b01b8ab11c489351a (patch)
tree2c9943bd299eae021aaadd898755dc1f13db2f72
parentf1ebe3a2bf61bc66e875e9906aa69d023c8e10fe (diff)
downloadillumos-joyent-85bcc4e57d6d451b2647973b01b8ab11c489351a.tar.gz
6942563 manifestfiles property and value should be consistent with each other
-rw-r--r--usr/src/cmd/svc/common/manifest_hash.c9
-rw-r--r--usr/src/cmd/svc/svccfg/svccfg_xml.c35
2 files changed, 30 insertions, 14 deletions
diff --git a/usr/src/cmd/svc/common/manifest_hash.c b/usr/src/cmd/svc/common/manifest_hash.c
index 705117a7f4..20f49b11ca 100644
--- a/usr/src/cmd/svc/common/manifest_hash.c
+++ b/usr/src/cmd/svc/common/manifest_hash.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
*/
@@ -55,6 +54,7 @@ mhash_filename_to_propname(const char *in, boolean_t deathrow)
{
char *out, *cp, *base;
size_t len, piece_len;
+ size_t base_sz = 0;
out = uu_zalloc(PATH_MAX + 1);
if (deathrow) {
@@ -77,7 +77,10 @@ mhash_filename_to_propname(const char *in, boolean_t deathrow)
* not relevant to when we boot with this repository.
*/
- cp = out + ((base != NULL)? strlen(base) : 0);
+ if (base != NULL && strncmp(out, base, strlen(base)) == 0)
+ base_sz = strlen(base);
+
+ cp = out + base_sz;
if (*cp == '/')
cp++;
(void) memmove(out, cp, strlen(cp) + 1);
diff --git a/usr/src/cmd/svc/svccfg/svccfg_xml.c b/usr/src/cmd/svc/svccfg/svccfg_xml.c
index d2d19c47cd..aa162fc5f0 100644
--- a/usr/src/cmd/svc/svccfg/svccfg_xml.c
+++ b/usr/src/cmd/svc/svccfg/svccfg_xml.c
@@ -19,8 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -45,6 +44,7 @@
#include <sasl/saslutil.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -3038,7 +3038,28 @@ lxml_get_service(bundle_t *bundle, xmlNodePtr svc, svccfg_op_t op)
if (lxml_check_upgrade(s->sc_name) == SCF_SUCCESS &&
svc->doc->name != NULL &&
bundle->sc_bundle_type == SVCCFG_MANIFEST) {
- char *buf, *base, *fname;
+ char *buf, *base, *fname, *bname;
+ size_t base_sz = 0;
+
+ /*
+ * Must remove the PKG_INSTALL_ROOT, point to the correct
+ * directory after install
+ */
+ bname = uu_zalloc(PATH_MAX + 1);
+ if (realpath(svc->doc->name, bname) == NULL) {
+ uu_die(gettext("Unable to create the real path of the "
+ "manifest file \"%s\" : %d\n"), svc->doc->name,
+ errno);
+ }
+
+ base = getenv("PKG_INSTALL_ROOT");
+ if (base != NULL && strncmp(bname, base, strlen(base)) == 0) {
+ base_sz = strlen(base);
+ }
+ fname = safe_strdup(bname + base_sz);
+
+ uu_free(bname);
+ buf = mhash_filename_to_propname(svc->doc->name, B_FALSE);
pg = internal_pgroup_create_strict(s, SCF_PG_MANIFESTFILES,
SCF_GROUP_FRAMEWORK);
@@ -3048,14 +3069,6 @@ lxml_get_service(bundle_t *bundle, xmlNodePtr svc, svccfg_op_t op)
"\"%s\", already exists in %s\n"),
SCF_PG_MANIFESTFILES, s->sc_name);
}
- buf = mhash_filename_to_propname(svc->doc->name, B_FALSE);
- /*
- * Must remove the PKG_INSTALL_ROOT, point to the correct
- * directory after install
- */
- base = getenv("PKG_INSTALL_ROOT");
- fname = safe_strdup(svc->doc->name +
- ((base != NULL) ? strlen(base) : 0));
p = internal_property_create(buf, SCF_TYPE_ASTRING, 1, fname);