diff options
author | Philippe Jung <Philippe.Jung@Sun.COM> | 2008-09-03 00:00:40 -0700 |
---|---|---|
committer | Philippe Jung <Philippe.Jung@Sun.COM> | 2008-09-03 00:00:40 -0700 |
commit | 70cbfe41f2338b77c15f79c6625eca6e70c412f3 (patch) | |
tree | 7dd8cf514b3381d51819a68779f3a64e48cebc97 /usr/src/cmd/svc/common/manifest_hash.c | |
parent | 28a27262607274108141b82c5960bbaa1b3a9aae (diff) | |
download | illumos-joyent-70cbfe41f2338b77c15f79c6625eca6e70c412f3.tar.gz |
6438829 SMF svcs are not removed when performing a pkgrm in an alternate root
Diffstat (limited to 'usr/src/cmd/svc/common/manifest_hash.c')
-rw-r--r-- | usr/src/cmd/svc/common/manifest_hash.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/usr/src/cmd/svc/common/manifest_hash.c b/usr/src/cmd/svc/common/manifest_hash.c index 7c27c5f491..547f791df9 100644 --- a/usr/src/cmd/svc/common/manifest_hash.c +++ b/usr/src/cmd/svc/common/manifest_hash.c @@ -19,11 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <sys/stat.h> #include <sys/types.h> @@ -48,18 +47,27 @@ /* * Translate a file name to property name. Return an allocated string or NULL - * if realpath() fails. + * if realpath() fails. If deathrow is true, realpath() is skipped. This + * allows to return the property name even if the file doesn't exist. */ char * -mhash_filename_to_propname(const char *in) +mhash_filename_to_propname(const char *in, boolean_t deathrow) { char *out, *cp, *base; size_t len, piece_len; out = uu_zalloc(PATH_MAX + 1); - if (realpath(in, out) == NULL) { - uu_free(out); - return (NULL); + if (deathrow) { + /* used only for service deathrow handling */ + if (strlcpy(out, in, PATH_MAX + 1) >= (PATH_MAX + 1)) { + uu_free(out); + return (NULL); + } + } else { + if (realpath(in, out) == NULL) { + uu_free(out); + return (NULL); + } } base = getenv("PKG_INSTALL_ROOT"); @@ -517,7 +525,7 @@ mhash_test_file(scf_handle_t *hndl, const char *file, uint_t is_profile, return (MHASH_NEWFILE); } - pname = mhash_filename_to_propname(file); + pname = mhash_filename_to_propname(file, B_FALSE); if (pname == NULL) return (MHASH_FAILURE); @@ -538,9 +546,9 @@ mhash_test_file(scf_handle_t *hndl, const char *file, uint_t is_profile, return (MHASH_NEWFILE); } - do + do { ret = stat64(file, &st); - while (ret < 0 && errno == EINTR); + } while (ret < 0 && errno == EINTR); if (ret < 0) { uu_free(pname); return (MHASH_FAILURE); |