diff options
Diffstat (limited to 'usr/src/lib')
| -rw-r--r-- | usr/src/lib/brand/shared/zone/common.ksh | 90 | ||||
| -rw-r--r-- | usr/src/lib/brand/solaris10/s10_support/s10_support.c | 16 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/common/instzones_lib.h | 5 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/common/mapfile-vers | 5 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/common/zones.c | 68 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/common/zones_paths.c | 329 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/common/zones_strings.h | 14 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/common/zones_utils.c | 82 | ||||
| -rw-r--r-- | usr/src/lib/libinstzones/hdrs/instzones_api.h | 11 | ||||
| -rw-r--r-- | usr/src/lib/libzonecfg/common/libzonecfg.c | 178 | ||||
| -rw-r--r-- | usr/src/lib/libzonecfg/common/mapfile-vers | 9 | ||||
| -rw-r--r-- | usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 | 8 |
12 files changed, 43 insertions, 772 deletions
diff --git a/usr/src/lib/brand/shared/zone/common.ksh b/usr/src/lib/brand/shared/zone/common.ksh index 8ab05a395e..3b5a68cbd2 100644 --- a/usr/src/lib/brand/shared/zone/common.ksh +++ b/usr/src/lib/brand/shared/zone/common.ksh @@ -18,7 +18,7 @@ # # CDDL HEADER END # -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -234,11 +234,9 @@ safe_wrap() } # -# Read zonecfg ipd and fs entries and save the relevant data, one entry per +# Read zonecfg fs entries and save the relevant data, one entry per # line. # This assumes the properties from the zonecfg output, e.g.: -# inherit-pkg-dir: -# dir: /usr # fs: # dir: /opt # special: /opt @@ -246,37 +244,10 @@ safe_wrap() # type: lofs # options: [noexec,ro,noatime] # -# and it assumes the order of the fs properties as above. This also saves the -# inherit-pkg-dir patterns into the ipd.{cpio|pax} temporary files for -# filtering while extracting the image into the zonepath. We have to save the -# IPD patterns in the appropriate format for filtering with the different -# archivers and we don't know what format we'll get until after the flash -# archive is unpacked. +# and it assumes the order of the fs properties as above. # get_fs_info() { - zonecfg -z $zonename info inherit-pkg-dir | \ - nawk -v ipdcpiof=$ipdcpiofile -v ipdpaxf=$ipdpaxfile '{ - if ($1 == "dir:") { - dir=$2; - printf("%s lofs %s ro\n", dir, dir); - - if (substr(dir, 1, 1) == "/") { - printf("%s\n", substr(dir, 2)) >> ipdcpiof - printf("%s/*\n", substr(dir, 2)) >> ipdcpiof - } else { - printf("%s\n", dir) >> ipdcpiof - printf("%s/*\n", dir) >> ipdcpiof - } - - if (substr(dir, 1, 1) == "/") { - printf("%s ", substr(dir, 2)) >> ipdpaxf - } else { - printf("%s ", dir) >> ipdpaxf - } - } - }' >> $fstmpfile - zonecfg -z $zonename info fs | nawk '{ if ($1 == "options:") { # Remove brackets. @@ -501,16 +472,16 @@ install_flar() if [[ $archiver == "pax" ]]; then # pax archiver specified archiver_command="/usr/bin/pax" - if [[ -s $ipdpaxfile ]]; then + if [[ -s $fspaxfile ]]; then archiver_arguments="-r -p e -c \ - $(/usr/bin/cat $ipdpaxfile)" + $(/usr/bin/cat $fspaxfile)" else archiver_arguments="-r -p e" fi elif [[ $archiver == "cpio" || -z $archiver ]]; then # cpio archived specified OR no archiver specified - use default archiver_command="/usr/bin/cpio" - archiver_arguments="-icdumfE $ipdcpiofile" + archiver_arguments="-icdumfE $fscpiofile" else # unknown archiver specified log "$unknown_archiver" $archiver @@ -659,7 +630,7 @@ install_cpio() get_archive_base "$stage1" "$archive" "cpio -it" - cpioopts="-idmfE $ipdcpiofile" + cpioopts="-idmfE $fscpiofile" vlog "cd \"$ARCHIVE_BASE\" && $stage1 \"$archive\" | cpio $cpioopts" @@ -681,8 +652,8 @@ install_pax() get_archive_base "cat" "$archive" "pax" - if [[ -s $ipdpaxfile ]]; then - filtopt="-c $(/usr/bin/cat $ipdpaxfile)" + if [[ -s $fspaxfile ]]; then + filtopt="-c $(/usr/bin/cat $fspaxfile)" fi vlog "cd \"$ARCHIVE_BASE\" && pax -r -f \"$archive\" $filtopt" @@ -708,8 +679,6 @@ install_ufsdump() # # ufsrestore goes interactive if you ^C it. To prevent that, # we make sure its stdin is not a terminal. - # Note that there is no way to filter inherit-pkg-dirs for a full - # restore so there will be warnings in the log file. # ( cd "$ZONEROOT" && ufsrestore rf "$archive" < /dev/null ) result=$? @@ -729,7 +698,7 @@ install_dir() cpioopts="-pdm" first=1 - filt=$(for i in $(cat $ipdpaxfile) + filt=$(for i in $(cat $fspaxfile) do echo $i | egrep -s "/" && continue if [[ $first == 1 ]]; then @@ -906,33 +875,32 @@ install_image() # Make sure we always have the files holding the directories to filter # out when extracting from a CPIO or PAX archive. We'll add the fs - # entries to these files in get_fs_info() (there may be no IPDs for - # some brands but thats ok). - ipdcpiofile=$(/usr/bin/mktemp -t -p /var/tmp ipd.cpio.XXXXXX) - if [[ -z "$ipdcpiofile" ]]; then + # entries to these files in get_fs_info() + fscpiofile=$(/usr/bin/mktemp -t -p /var/tmp fs.cpio.XXXXXX) + if [[ -z "$fscpiofile" ]]; then rm -f $fstmpfile fatal "$e_tmpfile" fi - # In addition to the IPDs, also filter out these directories. - echo 'dev/*' >>$ipdcpiofile - echo 'devices/*' >>$ipdcpiofile - echo 'devices' >>$ipdcpiofile - echo 'proc/*' >>$ipdcpiofile - echo 'tmp/*' >>$ipdcpiofile - echo 'var/run/*' >>$ipdcpiofile - echo 'system/contract/*' >>$ipdcpiofile - echo 'system/object/*' >>$ipdcpiofile - - ipdpaxfile=$(/usr/bin/mktemp -t -p /var/tmp ipd.pax.XXXXXX) - if [[ -z "$ipdpaxfile" ]]; then - rm -f $fstmpfile $ipdcpiofile + # Filter out these directories. + echo 'dev/*' >>$fscpiofile + echo 'devices/*' >>$fscpiofile + echo 'devices' >>$fscpiofile + echo 'proc/*' >>$fscpiofile + echo 'tmp/*' >>$fscpiofile + echo 'var/run/*' >>$fscpiofile + echo 'system/contract/*' >>$fscpiofile + echo 'system/object/*' >>$fscpiofile + + fspaxfile=$(/usr/bin/mktemp -t -p /var/tmp fs.pax.XXXXXX) + if [[ -z "$fspaxfile" ]]; then + rm -f $fstmpfile $fscpiofile fatal "$e_tmpfile" fi printf "%s " \ "dev devices proc tmp var/run system/contract system/object" \ - >>$ipdpaxfile + >>$fspaxfile # Set up any fs mounts so the archive will install into the correct # locations. @@ -940,7 +908,7 @@ install_image() mnt_fs if (( $? != 0 )); then umnt_fs >/dev/null 2>&1 - rm -f $fstmpfile $ipdcpiofile $ipdpaxfile + rm -f $fstmpfile $fscpiofile $fspaxfile fatal "$mount_failed" fi @@ -1013,7 +981,7 @@ install_image() # Clean up any fs mounts used during unpacking. umnt_fs - rm -f $fstmpfile $ipdcpiofile $ipdpaxfile + rm -f $fstmpfile $fscpiofile $fspaxfile chmod 700 $zonepath diff --git a/usr/src/lib/brand/solaris10/s10_support/s10_support.c b/usr/src/lib/brand/solaris10/s10_support/s10_support.c index 80c572f59e..fa563de644 100644 --- a/usr/src/lib/brand/solaris10/s10_support/s10_support.c +++ b/usr/src/lib/brand/solaris10/s10_support/s10_support.c @@ -99,7 +99,6 @@ static int s10_verify(char *xmlfile) { zone_dochandle_t handle; - struct zone_fstab fstab; struct zone_devtab devtab; zone_iptype_t iptype; @@ -112,21 +111,6 @@ s10_verify(char *xmlfile) } /* - * Check to see whether the zone has any inherit-pkg-dirs - * configured. - */ - if (zonecfg_setipdent(handle) != Z_OK) { - zonecfg_fini_handle(handle); - s10_err(gettext("zonecfg provided an invalid XML file")); - } - if (zonecfg_getipdent(handle, &fstab) == Z_OK) { - zonecfg_fini_handle(handle); - s10_err(gettext("solaris10 zones do not support " - "inherit-pkg-dirs")); - } - (void) zonecfg_endipdent(handle); - - /* * Check to see whether the zone has any unsupported devices * configured. * diff --git a/usr/src/lib/libinstzones/common/instzones_lib.h b/usr/src/lib/libinstzones/common/instzones_lib.h index 969a025a7c..a7acdbcf47 100644 --- a/usr/src/lib/libinstzones/common/instzones_lib.h +++ b/usr/src/lib/libinstzones/common/instzones_lib.h @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -179,7 +178,6 @@ struct _zoneBrandList { typedef unsigned long _zone_status_t; struct _zoneListElement_t { - char **_zlInheritedDirs; char *_zlName; char *_zlPath; char *_zlScratchName; @@ -307,7 +305,6 @@ void _z_echo(char *fmt, ...); /*PRINTFLIKE1*/ void _z_echoDebug(char *a_fmt, ...); int _z_is_directory(char *path); -char **_z_get_inherited_dirs(char *a_zoneName); boolean_t _z_running_in_global_zone(void); boolean_t _z_zones_are_implemented(void); void _z_sig_trap(int a_signo); diff --git a/usr/src/lib/libinstzones/common/mapfile-vers b/usr/src/lib/libinstzones/common/mapfile-vers index c57f4c78eb..164dc673af 100644 --- a/usr/src/lib/libinstzones/common/mapfile-vers +++ b/usr/src/lib/libinstzones/common/mapfile-vers @@ -42,7 +42,6 @@ $mapfile_version 2 SYMBOL_VERSION SUNWprivate { global: UmountAllZones; - z_add_inherited_file_system; z_brands_are_implemented; z_canoninplace; z_createMountTable; @@ -51,9 +50,7 @@ SYMBOL_VERSION SUNWprivate { z_ExecCmdArray; z_ExecCmdList; z_free_brand_list; - z_free_inherited_file_systems; z_free_zone_list; - z_get_inherited_file_systems; z_get_nonglobal_zone_list; z_get_nonglobal_zone_list_by_brand; z_get_zonename; @@ -69,7 +66,6 @@ SYMBOL_VERSION SUNWprivate { z_non_global_zones_exist; z_on_zone_spec; z_path_canonize; - z_path_is_inherited; z_resolve_lofs; z_running_in_global_zone; z_set_output_functions; @@ -81,7 +77,6 @@ SYMBOL_VERSION SUNWprivate { z_verify_zone_spec; z_zlist_change_zone_state; z_zlist_get_current_state; - z_zlist_get_inherited_pkg_dirs; z_zlist_get_original_state; z_zlist_get_scratch; z_zlist_get_zonename; diff --git a/usr/src/lib/libinstzones/common/zones.c b/usr/src/lib/libinstzones/common/zones.c index 2e30c24281..dc3a2036b2 100644 --- a/usr/src/lib/libinstzones/common/zones.c +++ b/usr/src/lib/libinstzones/common/zones.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -62,8 +61,6 @@ * z_zlist_change_zone_state - Change the current state of the specified zone * z_zlist_get_current_state - Determine the current kernel state of the * specified zone - * z_zlist_get_inherited_pkg_dirs - Determine directories inherited by - * specified zone * z_zlist_get_original_state - Return the original kernal state of the * specified zone * z_zlist_get_scratch - Determine name of scratch zone @@ -328,18 +325,6 @@ z_free_zone_list(zoneList_t a_zlst) free(zelm->_zlPath); } - /* free list of inherited package directories */ - - if (zelm->_zlInheritedDirs != (char **)NULL) { - int n; - - for (n = 0; - (zelm->_zlInheritedDirs)[n] != (char *)NULL; - n++) { - (void) free((zelm->_zlInheritedDirs)[n]); - } - (void) free(zelm->_zlInheritedDirs); - } } /* free handle to the list */ @@ -565,9 +550,6 @@ z_get_nonglobal_zone_list_by_brand(zoneBrandList_t *brands) zlst[numzones]._zlOrigKernelStatus = st; zlst[numzones]._zlCurrKernelStatus = st; - zlst[numzones]._zlInheritedDirs = - _z_get_inherited_dirs(ze->zone_name); - numzones++; free(ze); } @@ -1786,54 +1768,6 @@ z_zlist_get_current_state(zoneList_t a_zlst, int a_zoneIndex) } /* - * Name: z_zlist_get_inherited_pkg_dirs - * Description: Determine directories inherited by specified zone - * Arguments: a_zlst - handle to zoneList_t object describing all zones - * a_zoneIndex - index into a_zlst of the zone to return the - * inherited directories list - * Returns: char ** - * == NULL - zone does not inherit any directories - * - zone index is invalid - * != NULL - array of inherited directories - * NOTE: Any directory list returned is located in static storage that - * must NEVER be free()ed by the caller. - */ - -extern char ** -z_zlist_get_inherited_pkg_dirs(zoneList_t a_zlst, int a_zoneIndex) -{ - int i; - - /* if zones are not implemented, return empty list */ - - if (z_zones_are_implemented() == B_FALSE) { - return (NULL); - } - - /* ignore empty list */ - - if (a_zlst == (zoneList_t)NULL) { - return (NULL); - } - - /* find the specified zone in the list */ - - for (i = 0; (i != a_zoneIndex) && - (a_zlst[i]._zlName != (char *)NULL); i++) - ; - - /* return error if the specified zone does not exist */ - - if (a_zlst[i]._zlName == (char *)NULL) { - return (NULL); - } - - /* return selected zone's inherited directories */ - - return (a_zlst[i]._zlInheritedDirs); -} - -/* * Name: z_zlist_get_original_state * Description: Return the original kernal state of the specified zone * Arguments: a_zlst - handle to zoneList_t object describing all zones diff --git a/usr/src/lib/libinstzones/common/zones_paths.c b/usr/src/lib/libinstzones/common/zones_paths.c index 23f667fcc4..baa730f808 100644 --- a/usr/src/lib/libinstzones/common/zones_paths.c +++ b/usr/src/lib/libinstzones/common/zones_paths.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -57,323 +56,12 @@ (!x[2] || (x[2] == '/'))) /* - * forward declarations - */ - -static char **inheritedFileSystems = (char **)NULL; -static size_t *inheritedFileSystemsLen = (size_t *)NULL; -static int numInheritedFileSystems = 0; - -/* * ***************************************************************************** * global external (public) functions * ***************************************************************************** */ /* - * Name: z_get_inherited_file_systems - * Description: Return list of file systems inherited from the global zone; - * These file systems are entered into the list when the function - * pkgAddInheritedFileSystem() is called. - * Arguments: void - * Returns: char ** - * - pointer to array of character pointers, each pointer - * being a pointer to a string representing a file - * system that is inherited from the global zone - * the last entry will be (char *)NULL - * - (char **)NULL - no file systems inherited - * - */ - -char ** -z_get_inherited_file_systems(void) -{ - return (inheritedFileSystems); -} - -/* - * Name: z_add_inherited_file_system - * Description: Add specified package to internal list of inherited file systems - * Arguments: a_inheritedFileSystem - absolute path to file systen "inherited" - * - * This function is called to register a directory (or - * file system) as being inherited from the global zone - * into the non-global zone being operated on. The - * inherited directory must be specified relative to the - * root file system ("/"). For example, if "/usr" is - * inherited, then the path specified would be "/usr". - * - * Any path subsequently checked for being present in a - * directory inherited read-only from the global zone: - * - * -- will NOT have $PKG_INSTALL_ROOT prepended to it - * -- if $PKG_INSTALL_ROOT is set and $BASEDIR is not set. - * -- WILL have $BASEDIR prepended to it (if set). - * -- $BASEDIR always has $PKG_INSTALL_ROOT included in it. - * -- For example, if $PKG_INSTALL_ROOT is set to /a, and - * -- the base install directory is set to "/opt", then the - * -- $BASEDIR variable will be set to "/a/opt". - * - * Any path that is checked for being present in an inherited - * directory will be specified relative to the root file system - * of the non-global zone in which the path is located. - * - * When a path to update is checked for being present in - * an inherited directory, $PKG_INSTALL_ROOT is stripped - * off the path before it is checked. - * - * If the non-global zone is not running, the scratch zone - * is used to access the non-global zone. In this case, - * $PKG_INSTALL_ROOT will be set to "/a" and both the - * non-global zone's root file system and all inherited - * directories will be mounted on "/a". When a path is checked - * for being inherited, it will have $PKG_INSTALL_ROOT stripped - * from the beginning, so any inherited directories must be - * specified relative to "/" and not $PKG_INSTALL_ROOT. - * - * If the non-global zone is running, the non-global zone - * is used directly. In this case, $PKG_INSTALL_ROOT will - * be set to "/" and both the non-global zone's root file - * system and all inherited directories will be mounted on - * "/". $PKG_INSTALL_ROOT is set to "/" so the path is unchanged - * before being checked against the list of inherited directories. - * - * Returns: boolean_t - * B_TRUE - file system successfully added to list - * B_FALSE - failed to add file system to list - */ - -boolean_t -z_add_inherited_file_system(char *a_inheritedFileSystem) -{ -#define IPSLOP 2 /* for trailing '/' and '\0' */ -#define IPMAX ((sizeof (rp))-IPSLOP) - - char rp[PATH_MAX+1+IPSLOP] = {'\0'}; - int n; - - /* file system cannot be empty */ - - if (a_inheritedFileSystem == NULL || *a_inheritedFileSystem == '\0') { - _z_program_error(ERR_INHERITED_PATH_NULL); - return (B_FALSE); - } - - /* file system must be absolute */ - - if (*a_inheritedFileSystem != '/') { - _z_program_error(ERR_INHERITED_PATH_NOT_ABSOLUTE, - a_inheritedFileSystem); - return (B_FALSE); - } - - /* make a local copy of the path and canonize it */ - - n = strlcpy(rp, a_inheritedFileSystem, IPMAX); - if (n > IPMAX) { - _z_program_error(ERR_INHERITED_PATH_TOO_LONG, - strlen(a_inheritedFileSystem), IPMAX, - a_inheritedFileSystem); - return (B_FALSE); - } - - assert(n > 0); /* path must have at least 1 byte in it */ - - z_path_canonize(rp); /* remove duplicate "/"s, ./, etc */ - - /* add trailing "/" if it's not already there */ - n = strlen(rp); - if (rp[n-1] != '/') { - rp[n++] = '/'; - } - - /* null terminate the string */ - - rp[n] = '\0'; - - /* add file system to internal list */ - - if (inheritedFileSystems == (char **)NULL) { - inheritedFileSystems = (char **)_z_calloc( - 2 * (sizeof (char **))); - inheritedFileSystemsLen = - (size_t *)_z_calloc(2 * (sizeof (size_t *))); - } else { - inheritedFileSystems = (char **)_z_realloc(inheritedFileSystems, - sizeof (char **)*(numInheritedFileSystems+2)); - inheritedFileSystemsLen = (size_t *)_z_realloc( - inheritedFileSystemsLen, - sizeof (size_t *)*(numInheritedFileSystems+2)); - } - - /* add this entry to the end of the list */ - - inheritedFileSystemsLen[numInheritedFileSystems] = strlen(rp); - inheritedFileSystems[numInheritedFileSystems] = _z_strdup(rp); - - numInheritedFileSystems++; - - /* make sure end of the list is properly terminated */ - - inheritedFileSystemsLen[numInheritedFileSystems] = 0; - inheritedFileSystems[numInheritedFileSystems] = (char *)NULL; - - /* exit debugging info */ - - _z_echoDebug(DBG_PATHS_ADD_FS, numInheritedFileSystems, - inheritedFileSystems[numInheritedFileSystems-1]); - - return (B_TRUE); -} - -/* - * Name: z_path_is_inherited - * Description: Determine if the specified path is in a file system that is - * in the internal list of inherited file systems - * Arguments: a_path - pointer to string representing path to verify - * a_ftype - file "type" if known otherwise '\0' - * Type can be "f" (file), or "d" (directory) - * a_rootDir - pointer to string representing root directory where - * a_path is relative to - typically this would either be - * "/" or the path specified as an alternative root to -R - * Returns: boolean_t - * B_TRUE - the path is in inherited file system space - * B_FALSE - the path is NOT in inherited file system space - */ - -boolean_t -z_path_is_inherited(char *a_path, char a_ftype, char *a_rootDir) -{ - int n; - char *cp, *path2use; - char real_path[PATH_MAX]; - char path_copy[PATH_MAX]; - boolean_t found = B_FALSE; - - /* entry assertions */ - - assert(a_path != (char *)NULL); - assert(*a_path != '\0'); - - /* if no inherited file systems, there can be no match */ - - if (numInheritedFileSystems == 0) { - _z_echoDebug(DBG_PATHS_NOT_INHERITED, a_path); - return (B_FALSE); - } - - /* normalize root directory */ - - if ((a_rootDir == (char *)NULL) || (*a_rootDir == '\0')) { - a_rootDir = "/"; - } - - /* - * The loop below represents our best effort to identify real path of - * a file, which doesn't need to exist. realpath() returns error for - * nonexistent path, therefore we need to cut off trailing components - * of path until we get path which exists and can be resolved by - * realpath(). Lookup of "/dir/symlink/nonexistent-file" would fail - * to resolve symlink without this. - */ - (void) strlcpy(path_copy, a_path, PATH_MAX); - for (cp = dirname(path_copy); strlen(cp) > 1; cp = dirname(cp)) { - if (realpath(cp, real_path) != NULL) { - found = B_TRUE; - break; - } else if (errno != ENOENT) - break; - } - if (found) { - /* - * In the loop above we always strip trailing path component, - * so the type of real_path is always 'd'. - */ - a_ftype = 'd'; - path2use = real_path; - } else { - path2use = a_path; - } - - /* - * if path resides on an inherited filesystem then - * it must be read-only. - */ - - if (z_isPathWritable(path2use) != 0) { - return (B_FALSE); - } - - /* - * remove the root path from the target path before comparing: - * Example 1: - * -- path is "/export/zone1/root/usr/test" - * -- root path is "/export/zone1/root" - * --- final path should be "/usr/test" - * Example 2: - * -- path is "/usr/test" - * -- root path is "/" - * --- final path should be "/usr/test" - */ - - /* advance past given root directory if path begins with it */ - - n = strlen(a_rootDir); - if (strncmp(a_rootDir, path2use, n) == 0) { - char *p; - - /* advance past the root path */ - - p = path2use + n; - - /* go back to the first occurance of the path separator */ - - while ((*p != '/') && (p > path2use)) { - p--; - } - - /* use this location in the path to compare */ - - path2use = p; - } - - /* - * see if this path is in any inherited file system path - * note that all paths in the inherited list are directories - * so they end in "/" to prevent a partial match, such as - * comparing "/usr/libx" with "/usr/lib" - by making the comparison - * "/usr/libx" with "/usr/lib/" the partial false positive will not - * occur. This complicates matters when the object to compare is a - * directory - in this case, comparing "/usr" with "/usr/" will fail, - * so if the object is a directory, compare one less byte from the - * inherited file system so that the trailing "/" is ignored. - */ - - for (n = 0; n < numInheritedFileSystems; n++) { - int fslen; - - /* get target fs len; adjust -1 if directory */ - - fslen = inheritedFileSystemsLen[n]; - if ((a_ftype == 'd') && (fslen > 1)) { - fslen--; - } - - if (strncmp(path2use, inheritedFileSystems[n], fslen) == 0) { - _z_echoDebug(DBG_PATHS_IS_INHERITED, a_path, - inheritedFileSystems[n]); - return (B_TRUE); - } - } - - /* path is not in inherited file system space */ - - _z_echoDebug(DBG_PATHS_IS_NOT_INHERITED, a_path, a_rootDir); - - return (B_FALSE); -} - -/* * Name: z_make_zone_root * Description: Given its zonepath, generate a string representing the * mountpoint of where the root path for a nonglobal zone is @@ -480,18 +168,3 @@ z_canoninplace(char *src) dst--; *dst = '\0'; } - -void -z_free_inherited_file_systems(void) -{ - int i; - - for (i = 0; i < numInheritedFileSystems; i++) { - free(inheritedFileSystems[i]); - } - free(inheritedFileSystems); - inheritedFileSystems = NULL; - free(inheritedFileSystemsLen); - inheritedFileSystemsLen = NULL; - numInheritedFileSystems = 0; -} diff --git a/usr/src/lib/libinstzones/common/zones_strings.h b/usr/src/lib/libinstzones/common/zones_strings.h index 8c22e1c370..61d928d75b 100644 --- a/usr/src/lib/libinstzones/common/zones_strings.h +++ b/usr/src/lib/libinstzones/common/zones_strings.h @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -71,10 +70,6 @@ extern "C" { #define DBG_ARG ILIBSTR("argument <%d> = <%s>") #define DBG_LIBRARY_NOT_FOUND ILIBSTR("unable to dlopen library <%s>: %s") #define DBG_MNTPT_NAMES ILIBSTR("mount point for global zone path <%s> in zone <%s> is global zone mount point <%s> non-global zone mount point <%s>") -#define DBG_PATHS_ADD_FS ILIBSTR("add inherited file system entry <%d> path <%s>") -#define DBG_PATHS_IS_INHERITED ILIBSTR("path <%s> is inherited from <%s>") -#define DBG_PATHS_IS_NOT_INHERITED ILIBSTR("path <%s> in root <%s> not inherited") -#define DBG_PATHS_NOT_INHERITED ILIBSTR("path <%s> not inherited: no inherited file systems") #define DBG_TO_ZONEHALT ILIBSTR("halting zone <%s>") #define DBG_TO_ZONEREADY ILIBSTR("readying zone <%s>") #define DBG_TO_ZONERUNNING ILIBSTR("running zone <%s>") @@ -143,9 +138,6 @@ extern "C" { #define ERR_GZPATH_NOT_ABSOLUTE ILIBSTR("unable to mount global zone path <%s>: path must be absolute") #define ERR_GZPATH_NOT_DIR ILIBSTR("unable to mount global zone path <%s>: %s") #define ERR_GZUMOUNT_FAILED ILIBSTR("unable to unmount <%s>: %s") -#define ERR_INHERITED_PATH_NOT_ABSOLUTE ILIBSTR("inherited file system must be absolute path: <%s>") -#define ERR_INHERITED_PATH_NOT_DIR ILIBSTR("inherited file system <%s> must be absolute path to directory: %s") -#define ERR_INHERITED_PATH_NULL ILIBSTR("empty path specified for inherited file system: must be absolute path") #define ERR_LZMNTPT_NOTDIR ILIBSTR("unable to unmount global zone mount point <%s>: %s") #define ERR_LZMNTPT_NOT_ABSOLUTE ILIBSTR("unable to unmount <%s>: path must be absolute") #define ERR_LZROOT_NOTDIR ILIBSTR("unable to use <%s> as zone root path: %s") @@ -154,9 +146,6 @@ extern "C" { #define ERR_MEMORY ILIBSTR("memory allocation failure, errno=%d") #define ERR_MNTPT_MKDIR ILIBSTR("unable to create temporary mount point <%s> in zone <%s>: %s") #define ERR_NO_ZONE_ROOTPATH ILIBSTR("unable to get root path of zone <%s>: %s") -#define ERR_PKGDIR_GETHANDLE ILIBSTR("unable to get inherited directories: zonecfg_get_handle: %s") -#define ERR_PKGDIR_NOHANDLE ILIBSTR("unable to get inherited directories: zonecfg_init_handle: %s") -#define ERR_PKGDIR_SETIPDENT ILIBSTR("unable to get inherited directories: zonecfg_setipdent: %s") #define ERR_ROOTPATH_EMPTY ILIBSTR("unable to get root path of zone <%s>: empty path returned") #define ERR_ZEXEC_ASSEMBLE ILIBSTR("unable to establish connection with zone <%s>: could not assemble new environment") #define ERR_ZEXEC_BADSTATE ILIBSTR("unable to establish connection with zone <%s>: zone is in state '%s'") @@ -196,7 +185,6 @@ extern "C" { #define ERR_ZONE_LIST_EMPTY ILIBSTR("empty zone list specified") #define ERR_ZONE_NAME_ILLEGAL ILIBSTR("illegal zone name %.*s") #define ERR_ZONE_NONEXISTENT ILIBSTR("zone %s does not exist") -#define ERR_INHERITED_PATH_TOO_LONG ILIBSTR("inherited path too long current length <%d> maximum length <%d> bytes: <%s>") #define ERR_OPEN_READ ILIBSTR("unable to open <%s> for reading: (%d) %s") #define ERR_ZONEUNMOUNT_CMD_SIGNAL ILIBSTR("unable to unmount zone: problem running <%s> on zone <%s>: terminated by signal") #define ERR_ZONEUNMOUNT_EXEC ILIBSTR("unable to unmount zone: could not execute zone administration command <%s>: %s") diff --git a/usr/src/lib/libinstzones/common/zones_utils.c b/usr/src/lib/libinstzones/common/zones_utils.c index cd0edec9c4..3b51d145d1 100644 --- a/usr/src/lib/libinstzones/common/zones_utils.c +++ b/usr/src/lib/libinstzones/common/zones_utils.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -36,8 +35,6 @@ * list "a_fds" * _z_echo - Output an interactive message if interaction is enabled * _z_echoDebug - Output a debugging message if debugging is enabled - * _z_get_inherited_dirs - return array of directories inherited by - * specified zone * _z_is_directory - determine if specified path exists and is a directory * _z_program_error - Output an error message to the appropriate destinations * _z_pluginCatchSigint - SIGINT/SIGHUP interrupt handler @@ -277,83 +274,6 @@ _z_echoDebug(char *a_format, ...) } /* - * Name: _z_get_inherited_dirs - * Description: return array of directories inherited by specified zone - * Arguments: a_zoneName - [RO, *RO] - (char *) - * Pointer to string representing the name of the zone - * to return the list of inherited directories for - * Returns: char ** - * != NULL - list of inherited directories, terminated - * by a NULL pointer - * == NULL - error - unable to retrieve list - */ - -char ** -_z_get_inherited_dirs(char *a_zoneName) -{ - char **dirs = NULL; - int err; - int numIpdents = 0; - struct zone_fstab lookup; - zone_dochandle_t handle = NULL; - - /* entry assertions */ - - assert(a_zoneName != NULL); - assert(*a_zoneName != '\0'); - - /* initialize the zone configuration interface handle */ - - handle = zonecfg_init_handle(); - if (handle == NULL) { - _z_program_error(ERR_PKGDIR_NOHANDLE, - zonecfg_strerror(Z_NOMEM)); - return (NULL); - } - - /* get handle to configuration information for the specified zone */ - - err = zonecfg_get_handle(a_zoneName, handle); - if (err != Z_OK) { - /* If there was no zone before, that's OK */ - if (err != Z_NO_ZONE) { - _z_program_error(ERR_PKGDIR_GETHANDLE, - zonecfg_strerror(err)); - zonecfg_fini_handle(handle); - return (NULL); - } - } - assert(handle != NULL); - - /* get handle to non-global zone ipd enumerator */ - - err = zonecfg_setipdent(handle); - if (err != Z_OK) { - _z_program_error(ERR_PKGDIR_SETIPDENT, zonecfg_strerror(err)); - zonecfg_fini_handle(handle); - return (NULL); - } - - /* enumerate the non-global zone ipd's */ - - while (zonecfg_getipdent(handle, &lookup) == Z_OK) { - dirs = _z_realloc(dirs, sizeof (char **)*(numIpdents+1)); - dirs[numIpdents++] = strdup(lookup.zone_fs_dir); - } - - if (dirs != NULL) { - dirs = _z_realloc(dirs, sizeof (char **)*(numIpdents+1)); - dirs[numIpdents] = NULL; - } - - /* toss non-global zone ipd enumerator handle */ - - (void) zonecfg_endipdent(handle); - - return (dirs); -} - -/* * Name: _z_is_directory * Description: determine if specified path exists and is a directory * Arguments: path - pointer to string representing the path to verify diff --git a/usr/src/lib/libinstzones/hdrs/instzones_api.h b/usr/src/lib/libinstzones/hdrs/instzones_api.h index 5fea8c0ce6..7ff3a649e4 100644 --- a/usr/src/lib/libinstzones/hdrs/instzones_api.h +++ b/usr/src/lib/libinstzones/hdrs/instzones_api.h @@ -20,8 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. */ #ifndef _INSTZONES_API_H @@ -102,8 +101,6 @@ extern boolean_t z_zlist_change_zone_state(zoneList_t a_zoneList, extern char *z_get_zonename(void); extern zone_state_t z_zlist_get_current_state(zoneList_t a_zoneList, int a_zoneIndex); -extern char **z_zlist_get_inherited_pkg_dirs(zoneList_t a_zoneList, - int a_zoneIndex); extern zone_state_t z_zlist_get_original_state(zoneList_t a_zoneList, int a_zoneIndex); extern int z_zoneExecCmdArray(int *r_status, char **r_results, @@ -157,15 +154,9 @@ extern int z_ExecCmdList(int *r_status, char **r_results, char *a_inputFile, char *a_cmd, ...); /* zones_paths.c */ -extern boolean_t z_add_inherited_file_system( - char *a_inheritedFileSystem); -extern boolean_t z_path_is_inherited(char *a_path, char a_ftype, - char *a_rootDir); -extern char ** z_get_inherited_file_systems(void); extern char *z_make_zone_root(char *); extern void z_path_canonize(char *file); extern void z_canoninplace(char *file); -extern void z_free_inherited_file_systems(void); /* zones_lofs.c */ extern void z_destroyMountTable(void); diff --git a/usr/src/lib/libzonecfg/common/libzonecfg.c b/usr/src/lib/libzonecfg/common/libzonecfg.c index 4e901c3f12..b927b6b954 100644 --- a/usr/src/lib/libzonecfg/common/libzonecfg.c +++ b/usr/src/lib/libzonecfg/common/libzonecfg.c @@ -83,7 +83,6 @@ #define DTD_ELEM_DEVICE (const xmlChar *) "device" #define DTD_ELEM_FS (const xmlChar *) "filesystem" #define DTD_ELEM_FSOPTION (const xmlChar *) "fsoption" -#define DTD_ELEM_IPD (const xmlChar *) "inherited-pkg-dir" #define DTD_ELEM_NET (const xmlChar *) "network" #define DTD_ELEM_RCTL (const xmlChar *) "rctl" #define DTD_ELEM_RCTLVALUE (const xmlChar *) "rctl-value" @@ -1695,35 +1694,6 @@ zonecfg_add_filesystem(zone_dochandle_t handle, struct zone_fstab *tabptr) return (Z_OK); } -static int -zonecfg_add_ipd_core(zone_dochandle_t handle, struct zone_fstab *tabptr) -{ - xmlNodePtr newnode, cur = handle->zone_dh_cur; - int err; - - newnode = xmlNewTextChild(cur, NULL, DTD_ELEM_IPD, NULL); - if ((err = newprop(newnode, DTD_ATTR_DIR, tabptr->zone_fs_dir)) != Z_OK) - return (err); - return (Z_OK); -} - -int -zonecfg_add_ipd(zone_dochandle_t handle, struct zone_fstab *tabptr) -{ - int err; - - if (tabptr == NULL) - return (Z_INVAL); - - if ((err = operation_prep(handle)) != Z_OK) - return (err); - - if ((err = zonecfg_add_ipd_core(handle, tabptr)) != Z_OK) - return (err); - - return (Z_OK); -} - int zonecfg_add_fs_option(struct zone_fstab *tabptr, char *option) { @@ -1866,61 +1836,6 @@ zonecfg_modify_filesystem( return (Z_OK); } -static int -zonecfg_delete_ipd_core(zone_dochandle_t handle, struct zone_fstab *tabptr) -{ - xmlNodePtr cur = handle->zone_dh_cur; - - for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) { - if (xmlStrcmp(cur->name, DTD_ELEM_IPD)) - continue; - if (match_prop(cur, DTD_ATTR_DIR, tabptr->zone_fs_dir)) { - xmlUnlinkNode(cur); - xmlFreeNode(cur); - return (Z_OK); - } - } - return (Z_NO_RESOURCE_ID); -} - -int -zonecfg_delete_ipd(zone_dochandle_t handle, struct zone_fstab *tabptr) -{ - int err; - - if (tabptr == NULL) - return (Z_INVAL); - - if ((err = operation_prep(handle)) != Z_OK) - return (err); - - if ((err = zonecfg_delete_ipd_core(handle, tabptr)) != Z_OK) - return (err); - - return (Z_OK); -} - -int -zonecfg_modify_ipd(zone_dochandle_t handle, struct zone_fstab *oldtabptr, - struct zone_fstab *newtabptr) -{ - int err; - - if (oldtabptr == NULL || newtabptr == NULL) - return (Z_INVAL); - - if ((err = operation_prep(handle)) != Z_OK) - return (err); - - if ((err = zonecfg_delete_ipd_core(handle, oldtabptr)) != Z_OK) - return (err); - - if ((err = zonecfg_add_ipd_core(handle, newtabptr)) != Z_OK) - return (err); - - return (Z_OK); -} - int zonecfg_lookup_filesystem( zone_dochandle_t handle, @@ -2050,55 +1965,6 @@ zonecfg_lookup_filesystem( return (Z_OK); } -int -zonecfg_lookup_ipd(zone_dochandle_t handle, struct zone_fstab *tabptr) -{ - xmlNodePtr cur, match; - int err; - char dirname[MAXPATHLEN]; - - if (tabptr == NULL) - return (Z_INVAL); - - if ((err = operation_prep(handle)) != Z_OK) - return (err); - - /* - * General algorithm: - * Walk the list of children looking for matches on any properties - * specified in the fstab parameter. If more than one resource - * matches, we return Z_INSUFFICIENT_SPEC; if none match, we return - * Z_NO_RESOURCE_ID. - */ - cur = handle->zone_dh_cur; - match = NULL; - for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) { - if (xmlStrcmp(cur->name, DTD_ELEM_IPD)) - continue; - if (strlen(tabptr->zone_fs_dir) > 0) { - if ((fetchprop(cur, DTD_ATTR_DIR, dirname, - sizeof (dirname)) == Z_OK) && - (strcmp(tabptr->zone_fs_dir, dirname) == 0)) { - if (match == NULL) - match = cur; - else - return (Z_INSUFFICIENT_SPEC); - } - } - } - - if (match == NULL) - return (Z_NO_RESOURCE_ID); - - cur = match; - - if ((err = fetchprop(cur, DTD_ATTR_DIR, tabptr->zone_fs_dir, - sizeof (tabptr->zone_fs_dir))) != Z_OK) - return (err); - - return (Z_OK); -} - /* * Compare two IP addresses in string form. Allow for the possibility that * one might have "/<prefix-length>" at the end: allow a match on just the @@ -3969,8 +3835,6 @@ nm_to_dtd(char *nm) return (DTD_ELEM_DEVICE); if (strcmp(nm, "fs") == 0) return (DTD_ELEM_FS); - if (strcmp(nm, "inherit-pkg-dir") == 0) - return (DTD_ELEM_IPD); if (strcmp(nm, "net") == 0) return (DTD_ELEM_NET); if (strcmp(nm, "attr") == 0) @@ -4839,48 +4703,6 @@ zonecfg_endfsent(zone_dochandle_t handle) } int -zonecfg_setipdent(zone_dochandle_t handle) -{ - return (zonecfg_setent(handle)); -} - -int -zonecfg_getipdent(zone_dochandle_t handle, struct zone_fstab *tabptr) -{ - xmlNodePtr cur; - int err; - - if (handle == NULL) - return (Z_INVAL); - - if ((cur = handle->zone_dh_cur) == NULL) - return (Z_NO_ENTRY); - - for (; cur != NULL; cur = cur->next) - if (!xmlStrcmp(cur->name, DTD_ELEM_IPD)) - break; - if (cur == NULL) { - handle->zone_dh_cur = handle->zone_dh_top; - return (Z_NO_ENTRY); - } - - if ((err = fetchprop(cur, DTD_ATTR_DIR, tabptr->zone_fs_dir, - sizeof (tabptr->zone_fs_dir))) != Z_OK) { - handle->zone_dh_cur = handle->zone_dh_top; - return (err); - } - - handle->zone_dh_cur = cur->next; - return (Z_OK); -} - -int -zonecfg_endipdent(zone_dochandle_t handle) -{ - return (zonecfg_endent(handle)); -} - -int zonecfg_setnwifent(zone_dochandle_t handle) { return (zonecfg_setent(handle)); diff --git a/usr/src/lib/libzonecfg/common/mapfile-vers b/usr/src/lib/libzonecfg/common/mapfile-vers index 4a918197b5..98723f8e21 100644 --- a/usr/src/lib/libzonecfg/common/mapfile-vers +++ b/usr/src/lib/libzonecfg/common/mapfile-vers @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # @@ -52,7 +52,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_add_filesystem; zonecfg_add_fs_option; zonecfg_add_admin; - zonecfg_add_ipd; zonecfg_add_nwif; zonecfg_add_patch; zonecfg_add_patch_obs; @@ -82,7 +81,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_delete_dev; zonecfg_delete_ds; zonecfg_delete_filesystem; - zonecfg_delete_ipd; zonecfg_delete_mcap; zonecfg_delete_nwif; zonecfg_delete_pset; @@ -103,7 +101,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_enddevperment; zonecfg_enddsent; zonecfg_endfsent; - zonecfg_endipdent; zonecfg_endnwifent; zonecfg_endrctlent; zonecfg_find_mounts; @@ -130,7 +127,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_get_fs_allowed; zonecfg_get_handle; zonecfg_get_hostid; - zonecfg_getipdent; zonecfg_get_iptype; zonecfg_get_limitpriv; zonecfg_getmcapent; @@ -166,7 +162,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_lookup_dev; zonecfg_lookup_ds; zonecfg_lookup_filesystem; - zonecfg_lookup_ipd; zonecfg_lookup_mcap; zonecfg_lookup_nwif; zonecfg_lookup_pset; @@ -176,7 +171,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_modify_dev; zonecfg_modify_ds; zonecfg_modify_filesystem; - zonecfg_modify_ipd; zonecfg_modify_mcap; zonecfg_modify_nwif; zonecfg_modify_pset; @@ -210,7 +204,6 @@ SYMBOL_VERSION SUNWprivate_1.1 { zonecfg_setfsent; zonecfg_set_fs_allowed; zonecfg_set_hostid; - zonecfg_setipdent; zonecfg_set_iptype; zonecfg_set_limitpriv; zonecfg_set_name; diff --git a/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 b/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 index 89ffe59f2e..d1857cd7c5 100644 --- a/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 +++ b/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 @@ -20,7 +20,7 @@ CDDL HEADER END - Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. --> @@ -36,6 +36,12 @@ directory CDATA #REQUIRED type CDATA #REQUIRED> +<!-- + The "inherited-pkg-dir" element may no longer be specified in a + configuration, however we retain the definition to aid with migration + of existing configurations. +--> + <!ELEMENT inherited-pkg-dir EMPTY> <!ATTLIST inherited-pkg-dir directory CDATA #REQUIRED> |
