diff options
author | carlsonj <none@none> | 2006-06-29 12:12:49 -0700 |
---|---|---|
committer | carlsonj <none@none> | 2006-06-29 12:12:49 -0700 |
commit | 555afedfc38adf0cc5fbc1de696dc811973eaaca (patch) | |
tree | 5900355bf83e141f219bd32bf2fe74ef4e19b5a2 /usr/src/lib/libzonecfg | |
parent | 368eb9166ea32e85e3565e5902f9fa4bafe50220 (diff) | |
download | illumos-joyent-555afedfc38adf0cc5fbc1de696dc811973eaaca.tar.gz |
PSARC 2006/387 Zones Features For Zulu
6365741 RFE: add unique identifier to facilitate asset tracking (similar to hostid)
6384962 libzonecfg doesn't preserve owner/mode on changes
6394273 fix for CR 6305641 missed one of the hard-coded constants
6431731 zoneadm list -p (parseable) output isn't
6436841 Zonecfg needs to address alternate roots to adjust file paths
6436853 Zoneadm should allow zones to be marked as incomplete
Diffstat (limited to 'usr/src/lib/libzonecfg')
-rw-r--r-- | usr/src/lib/libzonecfg/common/getzoneent.c | 3 | ||||
-rw-r--r-- | usr/src/lib/libzonecfg/common/libzonecfg.c | 22 | ||||
-rw-r--r-- | usr/src/lib/libzonecfg/common/zonecfg_impl.h | 19 |
3 files changed, 28 insertions, 16 deletions
diff --git a/usr/src/lib/libzonecfg/common/getzoneent.c b/usr/src/lib/libzonecfg/common/getzoneent.c index c75ce2f096..c623152933 100644 --- a/usr/src/lib/libzonecfg/common/getzoneent.c +++ b/usr/src/lib/libzonecfg/common/getzoneent.c @@ -308,6 +308,8 @@ putzoneent(struct zoneent *ze, zoneent_op_t operation) (void) unlock_index_file(lock_fd); return (Z_TEMP_FILE); } + (void) fchmod(tmp_file_desc, ZONE_INDEX_MODE); + (void) fchown(tmp_file_desc, ZONE_INDEX_UID, ZONE_INDEX_GID); if ((tmp_file = fdopen(tmp_file_desc, "w")) == NULL) { (void) close(tmp_file_desc); err = Z_MISC_FS; @@ -454,7 +456,6 @@ putzoneent(struct zoneent *ze, zoneent_op_t operation) goto error; } tmp_file = NULL; - (void) chmod(tmp_file_name, 0644); if (rename(tmp_file_name, path) == -1) { err = errno == EACCES ? Z_ACCES : Z_MISC_FS; goto error; diff --git a/usr/src/lib/libzonecfg/common/libzonecfg.c b/usr/src/lib/libzonecfg/common/libzonecfg.c index 023a96888f..19ca573b0c 100644 --- a/usr/src/lib/libzonecfg/common/libzonecfg.c +++ b/usr/src/lib/libzonecfg/common/libzonecfg.c @@ -828,6 +828,17 @@ zonecfg_get_zonepath(zone_dochandle_t handle, char *path, size_t pathsize) int zonecfg_set_zonepath(zone_dochandle_t handle, char *zonepath) { + size_t len; + + /* + * The user deals in absolute paths in the running global zone, but the + * internal configuration files deal with boot environment relative + * paths. Strip out the alternate root when specified. + */ + len = strlen(zonecfg_root); + if (strncmp(zonepath, zonecfg_root, len) != 0 || zonepath[len] != '/') + return (Z_BAD_PROPERTY); + zonepath += len; return (setrootattr(handle, DTD_ATTR_ZONEPATH, zonepath)); } @@ -923,7 +934,8 @@ zonecfg_refresh_index_file(zone_dochandle_t handle) if ((err = zonecfg_get_zonepath(handle, zonepath, sizeof (zonepath))) != Z_OK) return (err); - (void) strlcpy(ze.zone_path, zonepath, sizeof (ze.zone_path)); + (void) strlcpy(ze.zone_path, zonepath + strlen(zonecfg_root), + sizeof (ze.zone_path)); if (is_renaming(handle)) { opcode = PZE_MODIFY; @@ -4012,22 +4024,24 @@ zone_state_str(zone_state_t state_num) * doesn't touch this buffer on failure. */ int -zonecfg_get_name_by_uuid(const uuid_t uuid, char *zonename, size_t namelen) +zonecfg_get_name_by_uuid(const uuid_t uuidin, char *zonename, size_t namelen) { FILE *fp; struct zoneent *ze; + uchar_t *uuid; /* * A small amount of subterfuge via casts is necessary here because * libuuid doesn't use const correctly, but we don't want to export * this brokenness to our clients. */ - if (uuid_is_null(*(uuid_t *)&uuid)) + uuid = (uchar_t *)uuidin; + if (uuid_is_null(uuid)) return (Z_NO_ZONE); if ((fp = setzoneent()) == NULL) return (Z_NO_ZONE); while ((ze = getzoneent_private(fp)) != NULL) { - if (uuid_compare(*(uuid_t *)&uuid, ze->zone_uuid) == 0) + if (uuid_compare(uuid, ze->zone_uuid) == 0) break; free(ze); } diff --git a/usr/src/lib/libzonecfg/common/zonecfg_impl.h b/usr/src/lib/libzonecfg/common/zonecfg_impl.h index b24f94ab1e..d6be1387e4 100644 --- a/usr/src/lib/libzonecfg/common/zonecfg_impl.h +++ b/usr/src/lib/libzonecfg/common/zonecfg_impl.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,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. */ @@ -34,6 +33,7 @@ extern "C" { #endif #include <zone.h> +#include <sys/uuid.h> #if !defined(TEXT_DOMAIN) /* should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ @@ -57,15 +57,12 @@ typedef enum { /* * ":::\n" => 4, no need to count '\0' as ZONENAME_MAX covers that. * - * Note that both ZONE_STATE_MAXSTRLEN and MAXPATHLEN include a NUL byte, and - * this extra count of 2 bytes covers the quotes that may be placed around the - * path. - * - * The swilly "36" constant here is to cover the fact that libuuid is broken; - * see CR 6305641. + * Note that ZONE_STATE_MAXSTRLEN, MAXPATHLEN, and UUID_PRINTABLE_STRING_LENGTH + * all include a NUL byte, and this extra count of 2 bytes covers the quotes + * that may be placed around the path plus one more. */ #define MAX_INDEX_LEN (ZONENAME_MAX + ZONE_STATE_MAXSTRLEN + MAXPATHLEN + \ - 36 + 4) + UUID_PRINTABLE_STRING_LENGTH + 3) #define ZONE_INDEX_LOCK_DIR ZONE_SNAPSHOT_ROOT #define ZONE_INDEX_LOCK_FILE "/index.lock" |