/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* 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
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Program: pkgadd / pkgask
*
* Function: public command and private utility functions that
* implement the package add and package ask operations.
*
*/
/*
* System includes
*/
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <pkgdev.h>
#include <pkginfo.h>
#include <pkglocs.h>
#include <locale.h>
#include <libintl.h>
#include <pkgtrans.h>
#include <boot_http.h>
#include <assert.h>
/*
* consolidation pkg command library includes
*/
#include <pkglib.h>
#include <pkgerr.h>
#include <pkgweb.h>
#include <instzones_api.h>
/*
* local pkg command library includes
*/
#include <install.h>
#include <libinst.h>
#include <libadm.h>
#include <messages.h>
/*
* pkgadd local includes
*/
#include "quit.h"
/*
*/
/* check.c */
char *a_zoneTempDir);
/*
* ckquit is a global that controls 'ckyorn' (defined in libadm)
* If ckquit is non-zero, then "quit" is allowed as an answer when
* ckyorn is called. If is it zero, then "quit" is not an allowed answer.
*/
extern int ckquit;
/*
* exported global variables
*/
/* these globals are set by ckreturn and used by quit.c */
/* imported by quit.c */
/* imported by various (many) */
/*
* internal global variables
*/
/* set by ckreturn() */
/* Set by -O nozones: do not process any zones */
/* Set by -O zonelist=<names...>: process only named zones */
/* Set by -O debug: debug output is enabled? */
/* Set by the -G option: install packages in global zone only */
/*
* Assume the package is ABI and POSIX compliant as regards user
* interactiion during procedure scripts.
*/
static int old_pkg = 0;
/* Assume pkg should be installed according to the ABI */
static int old_symlinks = 0;
/*
* Default name length will be 32 chars - if this is set,
* disable the 32 char name limit extension
*/
static int ABI_namelength = 0;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
/* printable string - if string is null results in ??? */
/*
* forward declarations
*/
char *a_idsName, char *a_altBinDir,
char *a_zoneAdminFile, char *a_zoneTempDir);
char *a_idsName, char *a_altBinDir,
char *a_zoneAdminFile, char *a_zoneTempDir);
static void pkginstall_check_in_one_zone(char *a_zoneName,
char *a_idsName, char *a_zoneAdminFile,
char *a_zoneTempDir, char *a_altBinDir,
static void create_zone_adminfile(char **r_zoneAdminFile,
char *a_zoneTempDir, char *a_admnfile);
static void create_zone_tempdir(char **r_zoneTempDir,
char *a_tmpdir);
char *a_zoneAdminFile, char *a_zoneTempDir,
char *a_idsName, char *a_altBinDir,
char *a_zoneAdminFile, char *a_zoneTempDir);
char *a_altBinDir, char *a_zoneAdminFile,
char *a_zoneTempDir);
char *a_altBinDir);
static int pkgZoneCheckInstall(char *a_zoneName,
char *a_idsName, char *a_altBinDir,
char *a_adminFile, char *a_stdoutPath,
static int pkgZoneInstall(char *a_zoneName,
char *a_idsName, char *a_altBinDir,
static void resetreturn();
static void usage(void);
char *a_altBinDir, char *a_device,
char *a_altBinDir, char *a_device);
char *a_altBinDir, char *a_device,
char *a_altBinDir, char *a_device);
char *a_pkgInst, char *a_rootPath,
char *a_categories, char **a_categoryList,
char *a_keystoreFile, char *a_idsName,
int *r_repeat);
static boolean_t continue_installation(void);
char *a_idsName, char *a_packageDir);
/*
* *****************************************************************************
* global external (public) functions
* *****************************************************************************
*/
/*
* Name: main
* Returns: int
* 0 Successful completion
* 1 Fatal error.
* 2 Warning.
* 3 Interruption.
* 4 Administration.
* 5 Administration. Interaction is required. Do not use pkgadd -n.
* In addition, one of the following values may be added to the previous value
* as appropriate:
* 10 Reboot after installation of all packages.
* 20 Reboot after installation of this package.
* For example, "14" would indicate both "administration" and "reboot after
* installation of all packages".
*/
int
{
char *abiPtr;
char *p;
char *q;
char *prog;
int c;
int ignore_sig = 0;
int n;
int repeat;
/* initialize locale environment */
(void) textdomain(TEXT_DOMAIN);
/* initialize program name */
prog_full_name = argv[0];
/* tell spmi zones interface how to access package output functions */
/* set sane umask */
(void) umask(0022);
/* tell quit which ckreturn function to call */
/* initially no source "device" */
/* reset npkgs (used as pkg remaining count in quit.c) */
npkgs = 0;
/* set default password prompt for encrypted packages */
/* initialize security operations structures and libraries */
sec_init();
if (z_running_in_global_zone() && !enable_local_fs()) {
}
/*
* ********************************************************************
* parse command line options
* ********************************************************************
*/
"?Aa:b:B:Cc:D:d:GhIik:MnO:P:R:r:Ss:tV:vx:Y:zZ")) != EOF) {
switch (c) {
/*
* Not a public interface: This disables attribute checking.
* It speeds up installation a little bit.
*/
case 'A':
break;
/*
* Public interface: Define an installation administration
* file, admin, to be used in place of the default
* administration file. The token none overrides the use
* of any admin file, and thus forces interaction with the
* user. Unless a full path name is given, pkgadd first
* looks in the current working directory for the
* administration file. If the specified administration
* file is not in the current working directory, pkgadd
* administration file.
*/
case 'a':
break;
/*
* Not a public interface: control block size given to
* pkginstall - block size used in read()/write() loop;
* default is st_blksize from stat() of source file.
*/
case 'B':
if (optarg[0] == '-') {
usage();
quit(1);
}
break;
/*
* Not a public interface: location where package executables
*/
case 'b':
if (optarg[0] == '-') {
usage();
quit(1);
}
if (!path_valid(optarg)) {
quit(1);
}
quit(1);
}
break;
/*
* Not a public interface: This disables checksum tests on
* the source files. It speeds up installation a little bit.
*/
case 'C':
break;
/*
* Not a public interface: This allows designation of a
* continuation file. It is the same format as a dryrun file
* but it is used to take up where the dryrun left off.
*/
case 'c':
break;
/*
* Not a public interface: This allows designation of a
* dryrun file. This pkgadd will create dryrun files
* in the directory provided.
*/
case 'D':
if (optarg[0] == '-') {
usage();
quit(1);
}
break;
/*
* Public interface: Install or copy a package from
* device. device can be a full path name to a directory
* or the identifiers for tape, floppy disk, or removable
* disk - for example, /var/tmp or /floppy/floppy_name.
* It can also be a device alias - for example,
*/
case 'd':
if (optarg[0] == '-') {
usage();
quit(1);
}
if (!path_valid(optarg)) {
quit(1);
/* NOTREACHED */
}
}
exit(1);
}
} else {
}
break;
/*
* Public interface: install package in global zone only.
*/
case 'G':
break;
/*
* Not a public interface: Enable hollow package support. When
* specified, for any package that has SUNW_PKG_HOLLOW=true:
* Do not calculate and verify package size against target.
* Do not run any package procedure or class action scripts.
* Do not create any target directories.
* Do not perform any script locking.
* Do not install any components of any package.
* Do not output any status or database update messages.
*/
case 'h':
break;
/*
* Not a public interface: Informs scripts that this is
* an initial install by setting the environment parameter
* PKG_INIT_INSTALL=TRUE for all scripts. They may use it as
* they see fit, safe in the knowledge that the target
* filesystem is tabula rasa.
*/
case 'I':
init_install++;
break;
/*
* Not a public interface: ignore signatures.
*/
case 'i':
ignore_sig++;
break;
/*
* Public interface: Use keystore as the location from which to
* get trusted certificate authority certificates when verifying
* digital signatures found in packages. If no keystore is
* specified, then the default keystore locations are searched
* for valid trusted certificates.
*/
case 'k':
if (!path_valid(optarg)) {
quit(1);
/* NOTREACHED */
}
break;
/*
* Public interface: Instruct pkgadd not to use the
* mount points. This option assumes the mount points are
* correct on the server and it behaves consistently with
* Solaris 2.5 and earlier releases.
*/
case 'M':
no_map_client = 1;
break;
/*
* Not a public interface: the -O option allows the behavior
* of the package tools to be modified. Recognized options:
* -> debug
* ---> enable debugging output
* -> addzonename
* ---> add zone name to appropriate messages
* -> nozones
* ---> act as though in global zone with no non-global zones
* -> enable-hollow-package-support
* ---> Enable hollow package support. When specified, for any
* ---> package that has SUNW_PKG_HOLLOW=true:
* ---> Do not calculate and verify package size against target
* ---> Do not run any package procedure or class action scripts
* ---> Do not create any target directories
* ---> Do not perform any script locking
* ---> Do not install any components of any package
* ---> Do not output any status or database update messages
* -> zonelist="<names...>"
*/
case 'O':
if (strcmp(p, "debug") == 0) {
(void) echoDebugSetFlag(debugFlag);
/* debug info on arguments to pkgadd */
}
continue;
}
if (strcmp(p,
"enable-hollow-package-support") == 0) {
continue;
}
if (strcmp(p, "addzonename") == 0) {
continue;
}
if (strcmp(p, "nozones") == 0) {
continue;
}
/*
* If colons used as separators,
* convert to spaces.
*/
q = p + 9;
while (*q != '\0') {
if (*q == ':') {
*q = ' ';
}
q++;
}
quit(1);
continue;
}
continue;
}
break;
/*
* Public interface: installation occurs in
* non-interactive mode. Suppress output of the list of
* installed files. The default mode is interactive.
*/
case 'n':
nointeract++;
(void) echoSetFlag(B_FALSE);
break;
/*
* Public interface: Password to use to decrypt keystore
* specified with -k, if required. See PASS PHRASE
* ARGUMENTS for more information about the format of this
* option's argument.
*/
case 'P':
if (optarg[0] == '-') {
usage();
quit(1);
}
/*
* passwords on the command line are highly
* insecure. complain.
*/
}
break;
/*
* Public interface: Define the full path name of a
* directory to use as the root_path. All files,
* including package system information files, are
* relocated to a directory tree starting in the specified
* root_path. The root_path may be specified when
* installing to a client from a server (for example,
*/
case 'R':
if (optarg[0] == '-') {
usage();
quit(1);
}
/* determine the real path specified */
/* use supplied path if not resolvable */
if (n == -1) {
} else {
/* null terminate string */
Rpath[n] = '\0';
}
/* set the alternative root path */
if (!set_inst_root(Rpath)) {
exit(1);
}
break;
/*
* Public interface: Identify a file or directory which
* contains output from a previous pkgask(1M)
* session. This file supplies the interaction responses
* that would be requested by the package in interactive
* mode. response must be a full pathname.
*/
case 'r':
if (optarg[0] == '-') {
usage();
quit(1);
}
break;
/*
* Not a public interface: suppress copyright notice being
* output during installation.
*/
case 'S':
break;
/*
* Public interface: Write the package into the directory
* spool instead of installing it. The default directory
*/
case 's':
break;
/*
* Not a public interface: disable save spool area creation;
* suppress the creation and population of the package save
*/
case 't':
break;
/*
* Public interface: Specify an alternative fs_file to map
* the client's file systems. For example, used in
* non-existent or unreliable. Informs the pkginstall
* portion to mount up a client filesystem based upon the
* supplied vfstab-like file of stable format.
*/
case 'V':
no_map_client = 0;
break;
/*
* Public interface: Trace all of the scripts that get
* directory. This option is used for debugging the
* procedural and non-procedural scripts
*/
case 'v':
pkgverbose++;
break;
/*
* Public interface: Specify a HTTP[S] proxy to use when
* downloading packages The format of proxy is host:port,
* where host is the hostname of the HTTP[S] proxy, and
* port is the port number associated with the proxy. This
* switch overrides all other methods of specifying a
* proxy. See ENVIRONMENT VARIABLES for more information
* on alternate methods of specifying a default proxy.
*/
case 'x':
if (!path_valid(optarg)) {
quit(1);
/* NOTREACHED */
}
break;
/*
* Public interface: Install packages based on the value
* of the CATEGORY parameter stored in the package's
* pkginfo(4) file. All packages on the source medium
* whose CATEGORY matches one of the specified categories
* will be selected for installation or spooling. Install
* packages that contain the same CATEGORY as the one
* provided on the command line.
*/
case 'Y':
if (optarg[0] == '-') {
usage();
quit(1);
}
exit(1);
} else if (is_not_valid_length(category)) {
exit(1);
}
break;
/*
* Not a public interface: perform fresh install from
* package save spool area. When set, the package contents
* are installed from the package spool save area instead
* of from the package root area, so that the original
* source packages are not required to install the
* package. If the -h option is also specified and the
* package is hollow, then this option is ignored. When -z
* is specified:
* - Editable files are installed from the package instance
* save area.
* - Volatile files are installed from the package instance
* save area.
* - Executable and data files are installed from the final
* installed location as specified in the pkgmap file.
* - Installation scripts are run from the package spool
* save area.
*/
case 'z':
break;
/*
* unrecognized option
*/
default:
usage();
return (1);
}
}
/*
* ********************************************************************
* validate command line options
* ********************************************************************
*/
/* set "debug echo" flag according to setting of "-O debug" option */
(void) echoDebugSetFlag(debugFlag);
/* output entry debugging information */
if (z_running_in_global_zone()) {
} else {
z_get_zonename());
}
/*
* Later, it may be decided to pursue this ability to continue to an
* actual installation based only on the dryrun data. At this time,
* it is too risky.
*/
if (pkgcontsrc && !pkgdrtarg) {
usage();
return (1);
}
/* ignore -G option if not used in the global zone */
if (!z_running_in_global_zone()) {
}
/* if zonelist used, must be in global zone */
if (usedZoneList && !z_running_in_global_zone()) {
return (1);
}
/* -G and zonelist cannot be used together */
if (globalZoneOnly && usedZoneList) {
usage();
return (1);
}
/* -s cannot be used with either -G or zonelist */
if (globalZoneOnly) {
usage();
return (1);
}
if (usedZoneList) {
usage();
return (1);
}
usage();
return (1);
}
}
/* pkgask does not support the same options as pkgadd */
usage();
return (1);
}
usage();
return (1);
}
if (askflag && keystore_file) {
usage();
return (1);
}
if (askflag && ignore_sig) {
usage();
return (1);
}
usage();
return (1);
}
if (askflag && nointeract) {
usage();
return (1);
}
/* cannot use response file and web address together */
usage();
return (1);
}
/* cannot use response file/not-interactive and spool-to directory */
if (spoolDir && nointeract) {
usage();
return (1);
}
usage();
return (1);
}
if (usedZoneList) {
/* Verify supplied zone list valid for the target */
if (z_verify_zone_spec() == -1)
return (1);
/* -z zonelist=global is logically the same as -G */
if (z_global_only() && z_running_in_global_zone())
}
/*
* hook SIGINT and SIGHUP interrupts into quit.c's trap handler
*/
/* connect quit.c:trap() to SIGINT */
/* connect quit.c:trap() to SIGHUP */
/* release hold on signals */
/*
* This function is in the libadm library; it sets:
* -> pkg_install_root = <install_root>
* This controls operations of libadm functions such as:
* -> pkginfofind, pkginfopen, fpkgparam, pkgparam, get_PKGLOC,
* -> get_PKGADM, get_install_root
*/
/*
* This function is in the libinst library; it reads the specified
* admin(4) file and, using fpkgparam(), sets the global "adm" structure
* values to match what is in the specified admin file.
*/
/*
* if running in the global zone, and non-global zones exist, then
* enable hollow package support so that any packages that are marked
* SUNW_PKG_HOLLOW=true will be correctly installed in non-global zones
* when added directly in the global zone by the global zone admin.
*/
if (is_depend_pkginfo_DB()) {
} else if ((z_running_in_global_zone() == B_TRUE) &&
(z_non_global_zones_exist() == B_TRUE)) {
}
/* if no device and no url, get and validate default device */
quit(1);
/* NOTREACHED */
}
}
/* must be root if not directing results to spool directory */
exit(1);
}
/*
* process response file argument
*/
if (respfile) {
if (respfile[0] != '/') {
quit(1);
/* NOTREACHED */
}
if (askflag) {
quit(1);
/* NOTREACHED */
}
quit(1);
/* NOTREACHED */
}
}
} else if (askflag) {
usage();
quit(1);
/* NOTREACHED */
}
/* establish temporary directory to use */
/* use default - no override specified */
}
/*
* setup and prepare secure package operations
*/
/* initialize error object used by security functions */
err = pkgerr_new();
/* validate keystore file */
if (!check_keystore_admin(&keystore_file)) {
quit(1);
/* NOTREACHED */
}
/* if uri provided, establish session */
boolean_t b;
int len;
quit(1);
/* NOTREACHED */
}
quit(1);
/* NOTREACHED */
}
}
if ((retries = web_ck_retries()) == 0) {
quit(1);
/* NOTREACHED */
}
if ((timeout = web_ck_timeout()) == 0) {
quit(1);
/* NOTREACHED */
}
/* create temporary directory */
if (b != B_TRUE) {
quit(1);
/* NOTREACHED */
}
/* register with quit() so directory is removed on exit */
/* open keystore if this is a secure download */
KEYSTORE_DFLT_FLAGS, &keystore) != 0) {
web_cleanup();
quit(1);
/* NOTREACHED */
}
}
web_cleanup();
quit(1);
/* NOTREACHED */
}
/*
* reset device to point to newly-downloaded file; note
* when (scheme == web_https || scheme == web_http) that
* device gets preloaded with a pointer to PATH_MAX bytes
* allocated via malloc().
*/
quit(1);
/* NOTREACHED */
}
}
/*
* See if user wants this to be handled as an old style pkg.
* NOTE : the ``exception_pkg()'' stuff is to be used only
* through on495. This function comes out for on1095. See
* PSARC 1993-546. -- JST
*/
old_pkg = 1;
}
/*
* See if the user wants to process symlinks consistent with
* the old behavior.
*/
old_symlinks = 1;
}
/*
* See if the user wants the package name length restricted.
*/
ABI_namelength = 1;
}
/*
* validate the package source device - return pkgdev info that
* describes the package source device.
*/
quit(1);
/* NOTREACHED */
}
/*
* If writing the packages into a spool directory instead of
* installing the packages, open the package datastream and
* invoke pkgtrans to perform the conversion and exit.
*/
boolean_t b;
int n;
if (b != B_TRUE) {
quit(1);
}
quit(n);
/* NOTREACHED */
}
/*
* error if there are packages on the command line and a category
* was specified
*/
usage();
quit(1);
/* NOTREACHED */
}
/*
* ********************************************************************
* main package processing "loop"
* ********************************************************************
*/
for (;;) {
boolean_t b;
/*
* open next package data stream
*/
if (b == B_FALSE) {
continue;
}
/*
* package source data stream open - get the package list
*/
if (b == B_FALSE) {
quit(1);
/* NOTREACHED */
}
/*
* count the number of packages to install
* NOTE: npkgs is a global variable that is referenced by quit.c
* when error messages are generated - it is referenced directly
* by the other functions called below...
*/
npkgs++;
}
/* output number of packages to be added */
/*
* if pkgask and response container is a file (not a directory),
* and there is more than one package to install, then it is an
* error - too many packages to install when response container
* is a file.
*/
(npkgs > 1)) {
quit(1);
/* NOTREACHED */
}
/*
* package list generated - add packages
*/
/*
* close open input data stream (source package) if left open.
*/
if (ids_name) {
(void) ds_close(1);
}
/*
* continue with next sequence of packages if continue set
*/
if (b == B_TRUE) {
continue;
}
/*
* not continuing - quit with 0 exit code
*/
quit(0);
/* NOTREACHED */
}
/* NOTREACHED */
}
/*
* *****************************************************************************
* static internal (private) functions
* *****************************************************************************
*/
/*
* Name: pkgZoneCheckInstall
* Description: Invoke pkginstall in a specified zone to perform a preinstall
* check of the a single package in the specified zone
* Arguments: a_zoneName - pointer to string representing the name of the
* zone to check install the package in.
* a_zoneState - current state of the zone; must be mounted or
* running.
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be check installed.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_adminFile - pointer to string representing the admin
* file to pass to pkginstall when installing the package.
* If this is == NULL no admin file is given to pkginstall.
* a_stdoutPath - pointer to string representing the local path
* into which all output written by pkginstall to stdout
* is stored.
* a_tmpzn - B_TRUE when this zone is booted by the package
* command or B_FALSE if it was running before.
* Returns: int (see ckreturn() function for details)
* 0 - success
* 1 - package operation failed (fatal error)
* 2 - non-fatal error (warning)
* 3 - user selected quit (operation interrupted)
* 4 - admin settings prevented operation
* 5 - interaction required and -n (non-interactive) specified
* "10" will be added to indicate "immediate reboot required"
* "20" will be added to indicate "reboot after install required"
*/
static int
{
char *p;
int maxfds;
int n;
int nargs;
/* entry assertions */
/* entry debugging info */
/* generate full path to 'phatinstall' to run in zone */
/* start at first file descriptor */
maxfds = 0;
/*
* generate argument list for call to pkginstall
*/
/* start at argument 0 */
nargs = 0;
/* first argument is always: full path to executable */
/*
* second argument is always: pass -O debug to pkginstall: debug mode
*/
}
/* pkgadd -G: pass -G to pkginstall */
if (globalZoneOnly == B_TRUE) {
}
/* pkgadd -b dir: pass -b to pkginstall */
if (a_altBinDir != (char *)NULL) {
}
/* pkgadd -C: pass -C to pkginstall: disable checksum */
if (disableChecksum) {
}
/* pkgadd -A: pass -A to pkginstall: disable attribute checking */
if (disableAttributes) {
}
/*
* NONABI_SCRIPTS defined: pass -o to pkginstall; refers to a
* pkg requiring operator interaction during a procedure script
* (common before on1093)
*/
if (old_pkg) {
}
/*
* PKG_NONABI_SYMLINKS defined: pass -y to pkginstall; process
* symlinks consistent with old behavior
*/
if (old_symlinks) {
}
/*
* PKG_ABI_NAMELENGTH defined: pass -e to pkginstall; causes
* package name length to be restricted
*/
if (ABI_namelength) {
}
/* pkgadd -S: pass -S to pkginstall: suppress copyright notices */
/* pkgadd -M: pass -M to pkginstall: dont mount client file systems */
/* pkgadd -v: pass -v to pkginstall: never trace scripts */
/* if running pkgask, pass -i to pkginstall: running pkgask */
if (askflag) {
return (0);
}
/* pass "-O enable-hollow-package-support" */
if (is_depend_pkginfo_DB()) {
}
/* check is always in non-interactive mode */
/* pkgadd -a admin: pass -a admin to pkginstall in zone: admin file */
if (a_adminFile) {
int fd;
if (fd < 0) {
return (1);
}
}
/* pkgadd -R root: pass -R /a to pkginstall when zone is mounted */
if (a_zoneState == ZONE_STATE_MOUNTED) {
}
/* pass -N to pkginstall: program name to report */
/* pass "-O preinstallcheck" */
/* add "-O addzonename" */
/*
*/
p = z_get_zonename();
if ((p != NULL) && (*p != '\0')) {
"parent-zone-name=%s", p);
}
/* current zone type */
if (z_running_in_global_zone() == B_TRUE) {
"parent-zone-type=%s",
} else {
"parent-zone-type=%s",
}
/* Add the pkgserv options */
/* add in the package stream file */
int fd;
if (fd < 0) {
quit(1);
}
} else {
quit(1);
}
/* add package instance name */
/* terminate the argument list */
/*
* run the appropriate pkginstall command in the specified zone
*/
for (n = 0; arg[n]; n++) {
}
}
/* terminate file descriptor list */
/* exec command in zone */
PSTR(a_stdoutPath));
/*
* close any files that were opened for use by the
* via the z_zone_exec() interface
*/
}
/* return results of pkginstall in zone execution */
return (n);
}
/*
* Name: pkgZoneInstall
* Description: Invoke pkginstall in a specified zone to perform an install
* of a single package in the specified zone
* Arguments: a_zoneName - pointer to string representing the name of the
* zone to install the package in.
* a_zoneState - current state of the zone; must be mounted or
* running.
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be installed.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_adminFile - pointer to string representing the admin
* file to pass to pkginstall when installing the package.
* If this is == NULL no admin file is given to pkginstall.
* a_stdoutPath - pointer to string representing the local path
* into which all output written by pkginstall to stdout
* is stored.
* a_tmpzn - B_TRUE when this zone is booted by the package
* command or B_FALSE if it was running before.
* Returns: int (see ckreturn() function for details)
* 0 - success
* 1 - package operation failed (fatal error)
* 2 - non-fatal error (warning)
* 3 - user selected quit (operation interrupted)
* 4 - admin settings prevented operation
* 5 - interaction required and -n (non-interactive) specified
* "10" will be added to indicate "immediate reboot required"
* "20" will be added to indicate "reboot after install required"
*/
static int
{
char *p;
int maxfds;
int n;
int nargs;
/* entry assertions */
/* entry debugging info */
/* generate path to pkginstall */
/* start at first file descriptor */
maxfds = 0;
/*
* generate argument list for call to pkginstall
*/
/* start at argument 0 */
nargs = 0;
/* first argument is path to executable */
/*
* second argument is always: pass -O debug to pkginstall: debug mode
*/
}
/* pkgadd -G: pass -G to pkginstall */
if (globalZoneOnly == B_TRUE) {
}
/* pkgadd -b dir: pass -b to pkginstall in zone */
if (a_altBinDir != (char *)NULL) {
}
/* pkgadd -B blocksize: pass -B to pkginstall in zone */
if (rw_block_size != NULL) {
}
/* pkgadd -C: pass -C to pkgadd in zone: disable checksum */
if (disableChecksum) {
}
/* pkgadd -A: pass -A to pkgadd in zone: disable attribute checking */
if (disableAttributes) {
}
/* pkgadd -S: pass -S to pkgadd in zone: suppress copyright notices */
/* pkgadd -I: pass -I to pkgadd in zone: initial install */
if (init_install) {
}
/* pkgadd -M: pass -M to pkgadd in zone: dont mount client file sys */
/* pkgadd -v: pass -v to pkgadd in zone: trace scripts */
if (pkgverbose) {
}
/* pkgadd -z: pass -z to pkgadd in zone fresh inst from pkg save area */
if (saveSpoolInstall) {
}
/* pass "-O enable-hollow-package-support" */
if (is_depend_pkginfo_DB()) {
}
/* pkgadd -t pass -t to pkgadd in zone disable save spool area create */
if (disableSaveSpool) {
}
/* if running pkgask, pass -i to pkgadd in zone: running pkgask */
if (askflag) {
return (0);
}
/*
* pkgadd -n (not pkgask): pass -n to pkginstall: noninteractive mode
*/
if (nointeract && !askflag) {
}
/* pkgadd -a admin: pass -a admin to pkginstall in zone: admin file */
if (a_adminFile) {
int fd;
if (fd < 0) {
return (1);
}
}
/* pkgadd -R root: pass -R /a to pkginstall when zone is mounted */
if (a_zoneState == ZONE_STATE_MOUNTED) {
}
/*
* pkgadd -D arg: pass -D dryrun to pkginstall in zone: dryrun
*/
if (pkgdrtarg) {
}
/*
* pkgadd -c cont: pass -c cont to pkginstall in zone: continuation
* file
*/
if (pkgcontsrc) {
}
/* pkgadd -r resp: pass -r resp to pkginstall in zone: response file */
if (respfile) {
int fd;
if (fd < 0) {
return (1);
}
(void) snprintf(respfilefd_path,
sizeof (respfilefd_path),
}
/* add "-O addzonename" */
/*
*/
p = z_get_zonename();
if ((p != NULL) && (*p != '\0')) {
"parent-zone-name=%s", p);
}
/* current zone type */
if (z_running_in_global_zone() == B_TRUE) {
"parent-zone-type=%s",
} else {
"parent-zone-type=%s",
}
/* Add the pkgserv options */
/* add in the package stream file */
int fd;
if (fd < 0) {
quit(1);
}
} else {
quit(1);
}
/* add package instance name */
/* terminate the argument list */
/*
* run the appropriate pkginstall command in the specified zone
*/
for (n = 0; arg[n]; n++) {
}
}
/* terminate file descriptor list */
/* exec command in zone */
/*
* close any files that were opened for use by the
* via the z_zone_exec() interface
*/
}
/* return results of pkginstall in zone execution */
return (n);
}
/*
* Name: pkgInstall
* Description: Invoke pkginstall in the current zone to perform an install
* of a single package to the current zone or standalone system
* Arguments: a_altRoot - pointer to string representing the alternative
* root to use for the install
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be installed.
* a_pkgDir - pointer to string representing the path to the
* directory containing the package
* a_altBinDir - pointer to string representing location of the
* pkginstall executable to run. If not NULL, then pass
* the path specified to the -b option to pkginstall.
* Returns: int (see ckreturn() function for details)
* 0 - success
* 1 - package operation failed (fatal error)
* 2 - non-fatal error (warning)
* 3 - user selected quit (operation interrupted)
* 4 - admin settings prevented operation
* 5 - interaction required and -n (non-interactive) specified
* "10" will be added to indicate "immediate reboot required"
* "20" will be added to indicate "reboot after install required"
* NOTE: Both a_idsName and a_pkgDir are used to determine where the
* package to be installed is located. If a_idsName is != NULL
* then it must be the path to a device containing a package
* stream that contains the package to be installed. If a_idsName
* is == NULL then a_pkgDir must contain a full path to a directory
* that contains the package to be installed.
*/
static int
{
char *p;
int n, nargs;
/* entry debugging info */
/* generate full path to 'pkginstall' to run in zone */
/*
* generate argument list for call to pkginstall
*/
/* start at argument 0 */
nargs = 0;
/* first argument is path to executable */
/*
* second argument is always: pass -O debug to pkginstall: debug mode
*/
}
/*
* pkgadd -G: pass -G to pkginstall if:
* - the -G option is specified on the pkgadd command line
* - this package is marked 'this zone only':
* -- package has SUNW_PKG_THISZONE=true, or
* -- package has a request script
* Setting -G for pkginstall causes pkginstall to install the package
* in the target zone. If running in the global zone, will install the
* package and mark the package as installed "in the global zone only".
* If running in a non-global zone, will just install the package.
*/
if (globalZoneOnly == B_TRUE) {
}
/* pkgadd -b dir: pass -b to pkginstall */
if (a_altBinDir != (char *)NULL) {
}
/* pkgadd -B blocksize: pass -B to pkginstall */
if (rw_block_size != NULL) {
}
/* pkgadd -C: pass -C to pkginstall: disable checksum */
if (disableChecksum) {
}
/* pkgadd -A: pass -A to pkginstall: disable attribute checking */
if (disableAttributes) {
}
/*
* NONABI_SCRIPTS defined: pass -o to pkginstall; refers to a
* pkg requiring operator interaction during a procedure script
* (common before on1093)
*/
if (old_pkg) {
}
/*
* PKG_NONABI_SYMLINKS defined: pass -y to pkginstall; process
* symlinks consistent with old behavior
*/
if (old_symlinks) {
}
/*
* PKG_ABI_NAMELENGTH defined: pass -e to pkginstall; causes
* package name length to be restricted
*/
if (ABI_namelength) {
}
/* pkgadd -S: pass -S to pkginstall: suppress copyright notices */
if (suppressCopyright) {
}
/* pkgadd -I: pass -I to pkginstall: initial install being performed */
if (init_install) {
}
/* pkgadd -M: pass -M to pkginstall: dont mount client file systems */
if (no_map_client) {
}
/* pkgadd -v: pass -v to pkginstall: trace scripts */
if (pkgverbose) {
}
/* pkgadd -z: pass -z to pkginstall: fresh install from pkg save area */
if (saveSpoolInstall) {
}
/*
* if running in a non-global zone and the 'hollow' attribute is
* passed in, then pass -h to pkginstall so that it knows how to
* handle hollow packages for this local zone.
*/
if (!z_running_in_global_zone() && is_depend_pkginfo_DB()) {
}
/* pkgadd -t: pass -t to pkginstall: disable save spool area creation */
if (disableSaveSpool) {
}
/* if running pkgask, pass -i to pkginstall: running pkgask */
if (askflag) {
}
/* pkgadd -n (not pkgask): pass -n to pkginstall: noninteractive mode */
if (nointeract && !askflag) {
}
/* pkgadd -a admin: pass -a admin to pkginstall: admin file */
if (admnfile) {
}
if (pkgdrtarg) {
}
/* pkgadd -c cont: pass -c cont to pkginstall: continuation file */
if (pkgcontsrc) {
}
/* pkgadd -V vfstab: pass -V vfstab to pkginstall: alternate vfstab */
if (vfstab_file) {
}
/* pkgadd -r resp: pass -r resp to pkginstall: response file */
if (respfile) {
}
/* pkgadd -R root: pass -R root to pkginstall: alternative root */
}
/*
* If input data stream is available,
* - add: -d ids_name -p number_of_parts
* else,
* - add: -d device -m mount [-f type]
*/
ds_close(1);
}
}
/*
*/
p = z_get_zonename();
if ((p != NULL) && (*p != '\0')) {
"parent-zone-name=%s", p);
}
/* current zone type */
if (z_running_in_global_zone() == B_TRUE) {
"parent-zone-type=%s",
} else {
"parent-zone-type=%s",
}
/* pass -N to pkginstall: program name to report */
/* add package directory name */
/* add package instance name */
/* terminate the argument list */
/*
* run the appropriate pkginstall command in the specified zone
*/
for (n = 0; arg[n]; n++) {
}
}
/* execute pkginstall command */
/* return results of pkginstall execution */
return (n);
}
/*
* function to clear out any exisiting error return conditions that may have
* been set by previous calls to ckreturn()
*/
static void
{
admnflag = 0; /* != 0 if any pkg op admin setting failure (4) */
doreboot = 0; /* != 0 if reboot required after installation (>= 10) */
failflag = 0; /* != 0 if fatal error has occurred (1) */
intrflag = 0; /* != 0 if user selected quit (3) */
ireboot = 0; /* != 0 if immediate reboot required (>= 20) */
nullflag = 0; /* != 0 if admin interaction required (5) */
warnflag = 0; /* != 0 if non-fatal error has occurred (2) */
interrupted = 0; /* last pkg op was quit (1,2,3,4,5) */
needconsult = 0; /* essential ask admin now (1,2,3,5) */
}
/*
* function which checks the indicated return value
* and indicates disposition of installation
*/
static void
{
/*
* entry debugging info
*/
/* reset needconsult so it only reflects this call to ckreturn */
needconsult = 0;
switch (retcode) {
case 0: /* successful */
case 10:
case 20:
break; /* empty case */
case 1: /* package operation failed (fatal error) */
case 11:
case 21:
failflag++;
interrupted++;
needconsult++;
break;
case 2: /* non-fatal error (warning) */
case 12:
case 22:
warnflag++;
interrupted++;
needconsult++;
break;
case 3: /* user selected quit; operation interrupted */
case 13:
case 23:
intrflag++;
interrupted++;
needconsult++;
break;
case 4: /* admin settings prevented operation */
case 14:
case 24:
admnflag++;
interrupted++;
break;
case 5: /* administration: interaction req (no -n) */
case 15:
case 25:
nullflag++;
interrupted++;
needconsult++;
break;
default:
failflag++;
interrupted++;
needconsult++;
return;
}
if (retcode >= 20) {
ireboot++;
} else if (retcode >= 10) {
doreboot++;
}
}
static void
usage(void)
{
if (askflag) {
} else if (z_running_in_global_zone() == B_FALSE) {
} else {
}
}
/*
* Name: check_applicability
* Description: determine if a package is installable in this zone; that is,
* does the scope of install conflict with existing installation
* or can the package be installed
* Arguments: a_packageDir - [RO, *RO] - (char *)
* Pointer to string representing the directory where the
* package is located
* a_pkgInst - [RO, *RO] - (char *)
* Pointer to string representing the name of the package
* to check
* a_rootPath - [RO, *RO] - (char *)
* Pointer to string representing path to the root of the
* file system where the package is to be installed - this
* is usually the same as the "-R" argument to pkgadd
* a_flags - [RO, *RO] - (CAF_T)
* Flags set by the caller to indicate the conditions
* under which the package is to be installed:
* CAF_IN_GLOBAL_ZONE - in global zone
* CAF_SCOPE_GLOBAL - -G specified
* CAF_SCOPE_NONGLOBAL - -Z specified
* Returns: boolean_t
* B_TRUE - the package can be installed
* B_FALSE - the package can not be installed
*/
static boolean_t
{
int len;
/* entry assertions */
/* normalize root path */
if (a_rootPath == (char *)NULL) {
a_rootPath = "";
}
/* entry debugging info */
/*
* calculate paths to various objects
*/
/* path to package to be installed top level (main) directory */
return (B_FALSE);
}
/* error if package top level directory does not exist */
return (B_FALSE);
}
/* path to pkginfo file within the package to be installed */
pkgpath);
if (len > sizeof (pkginfoPath)) {
return (B_FALSE);
}
/* path to highest instance of package currently installed */
/*
* gather information from this package's pkginfo file
*/
return (B_FALSE);
}
/* determine "HOLLOW" setting for this package */
"true", B_FALSE);
/* determine "ALLZONES" setting for this package */
"true", B_FALSE);
/* determine "THISZONE" setting for this package */
"true", B_FALSE);
/* close pkginfo file */
/*
* If request file is not found, it may be in the datastream which
* is not yet unpacked. Check in the pkgmap file.
*/
/* path to pkgmap file within the package to be installed */
pkgpath);
return (B_FALSE);
}
break;
}
}
} else {
}
/*
* If this package is not marked for installation in this zone only,
* check to see if this package has a request script. If this package
* does have a request script, then mark the package for installation
* in this zone only. Any package with a request script cannot be
* installed outside of the zone the pkgadd command is being run in,
* nor can such a package be installed as part of a new zone install.
* A new zone install must be non-interactive, which is required
* by all packages integrated into the Solaris WOS.
*/
if ((!this_zone) && (reqfile_found)) {
if (a_flags & CAF_IN_GLOBAL_ZONE) {
}
}
/*
* If this package is already installed, see if the current installation
* of the package has a request file - if it does, then act as though
* the current package to be added has a request file - install the
* package in the current zone only.
*/
if (a_flags & CAF_IN_GLOBAL_ZONE) {
}
}
/* gather information from the global zone only file */
if (a_flags & CAF_IN_GLOBAL_ZONE) {
}
/* determine if this package is currently installed */
/*
* verify package applicability based on information gathered,
* and validate the three SUNW_PKG_ options:
*
* -----------|--------------|-------------|-------------|-----------
* - - - - - -| GLOBAL ZONE -| GLOBAL ZONE | LOCAL ZONE | LOCAL ZONE
* - - - - - -| - - pkgadd - | pkgadd -G | pkgadd | pkgadd -G
* ----1------|--------------|-------------|-------------|------------
* ALLZONES f | add to gz | add to gz | add to ls | add to ls
* HOLLOW f | current lz | not to curr | only - - - -| only - - -
* THISZONE f | futr lz - - -| or futr lz | - - - - - - | - - - - - -
* ----2------|--------------|-------------|-------------|------------
* ALLZONES T | add to gz | operation | operation | operation
* HOLLOW f | current lz | not allowed | not allowed | not allowed
* THISZONE f | future lz | - - - - - - | - - - - - - | - - - - - -
* ----3------|--------------|-------------|-------------|------------
* ALLZONES T | add to gz | operation | operation | operation
* HOLLOW T | pkg db only | not allowed | not allowed | not allowed
* ----4------|--------------|-------------|-------------|------------
* ALLZONES T | bad option | bad option | bad option | bad option
* HOLLOW * | combo - - - -| combo - - - | combo - - - | combo - -
* THISZONE T | - - - - - - -|- - - - - - -|- - - - - - -|- - - - - -
* ----5------|--------------|-------------|-------------|------------
* ALLZONES f | bad option | bad option | bad option | bad option
* HOLLOW T | combo - - - -| combo - - - | combo - - - | combo - - -
* THISZONE * | - - - - - - -| - - - - - - | - - - - - - | - - - - - -
* ----6------|--------------|-------------|-------------|------------
* ALLZONES f | add to gz | add to gz | add to lz | add to lz
* HOLLOW f | not current | not current | only - - - | only - - -
* THISZONE T | or future lz | or futr lz | - - - - - - | - - - - - -
* -----------|--------------|-------------|-------------|-----------
*/
/* pkg "all zones" && "this zone" (#4) */
return (B_FALSE);
}
/* pkg "!all zones" && "hollow" (#5) */
return (B_FALSE);
}
/* pkg ALLZONES=true && -Z specified */
return (B_FALSE);
}
/* pkg ALLZONES=true & not running in global zone (#2/#3) */
return (B_FALSE);
}
/* pkg "in gz only" & pkg "NOT installed" */
if (in_gz_only && (!pkg_installed)) {
/* MAKE A WARNING */
pkgGetGzOnlyPath());
}
/* pkg ALLZONES=true & pkg "in gz only" & pkg "is installed" */
return (B_FALSE);
}
/* pkg ALLZONES=true && -G specified (#2/#3) */
return (B_FALSE);
}
/* pkg "!this zone" && "in gz only" & -G not specified */
return (B_FALSE);
}
/* pkg "NOT in gz only" & -Z specified */
return (B_FALSE);
}
/* pkg "this zone" && -Z specified */
return (B_FALSE);
}
/*
* If this package is marked 'this zone only', then mark the package
* as "add to this zone only". This is referenced by the various
* add_package_... functions to determine if the package should be
* added to the current zone, or to all zones, depending on the
* zone in which the command is being run.
*/
if (this_zone) {
}
return (B_TRUE);
}
/*
* Name: create_zone_adminfile
* Description: Given a zone temporary directory and optionally an existing
* administration file, generate an administration file that
* can be used to perform "non-interactive" operations in a
* non-global zone.
* Arguments: r_zoneAdminFile - pointer to handle that will contain a
* string representing the path to the temporary
* administration file created - this must be NULL
* before the first call to this function - on
* subsequent calls if the pointer is NOT null then
* the existing string will NOT be overwritten.
* a_zoneTempDir - pointer to string representing the path
* to the zone temporary directory to create the
* temporary administration file in
* a_admnfile - pointer to string representing the path to
* an existing "user" administration file - the
* administration file created will contain the
* settings contained in this file, modified as
* appropriate to supress any interaction;
* If this is == NULL then the administration file
* created will not contain any extra settings
* Returns: void
* NOTE: Any string returned is placed in new storage for the
* calling method. The caller must use 'free' to dispose
* of the storage once the string is no longer needed.
* NOTE: On any error this function will call 'quit(1)'
*/
static void
char *a_admnfile)
{
boolean_t b;
/* entry assertions */
/* entry debugging info */
/* if temporary name already exists, do not overwrite */
if (*r_zoneAdminFile != (char *)NULL) {
return;
}
/* create temporary name */
if (b == B_FALSE) {
quit(1);
/* NOTREACHED */
}
}
/*
* Name: create_zone_tempdir
* Description: Given a system temporary directory, create a "zone" specific
* temporary directory and return the path to the directory
* created.
* Arguments: r_zoneTempDir - pointer to handle that will contain a
* string representing the path to the temporary
* directory created - this must be NULL before the
* first call to this function - on subsequent calls
* if the pointer is NOT null then the existing string
* will NOT be overwritten.
* a_zoneTempDir - pointer to string representing the path
* to the system temporary directory to create the
* temporary zone directory in
* Returns: void
* NOTE: Any string returned is placed in new storage for the
* calling method. The caller must use 'free' to dispose
* of the storage once the string is no longer needed.
* NOTE: On any error this function will call 'quit(1)'
* NOTE: This function calls "quitSetZoneTmpdir" on success to
* register the directory created with quit() so that the
* directory will be automatically deleted on exit.
*/
static void
{
boolean_t b;
/* entry assertions */
/* entry debugging info */
/* if temporary directory already exists, do not overwrite */
if (*r_zoneTempDir != (char *)NULL) {
return;
}
/* create temporary directory */
if (b == B_FALSE) {
quit(1);
/* NOTREACHED */
}
/* register with quit() so directory is removed on exit */
/* exit debugging info */
}
/*
* Name: continue_installation
* Description: Called from within a loop that is installing packages,
* this function examines various global variables and decides
* whether or not to ask an appropriate question, and wait for
* and appropriate reply.
* Arguments: <<global variables>>
* Returns: B_TRUE - continue processing with next package
* B_FALSE - do not continue processing with next package
*/
static boolean_t
continue_installation(void)
{
int n;
/* return TRUE if not interrupted */
if (!interrupted) {
return (B_TRUE);
}
/*
* process interrupted - determine whether or not to continue
*/
/* output appropriate interrupted message */
if (askflag) {
} else {
}
/* if running with no interaction (-n) do not ask question */
if (nointeract) {
/* if admin required return 'dont continue' */
if (needconsult) {
return (B_FALSE);
}
ckquit = 1;
return (B_TRUE);
}
/* interaction possible: ask question */
ckquit = 0;
if (n != 0) {
quit(n);
/* NOTREACHED */
}
ckquit = 1;
return (B_FALSE);
}
return (B_TRUE);
}
/*
* package can be in a number of formats:
* - file containing package stream (pkgadd -d file [pkgs])
* - directory containing packages (pkgadd -d /dir [pkgs])
* - device containing packages (pkgadd -d diskette1 [pkgs])
* non-global zones can be passed open files and strings as arguments
* - for file containing package stream
* -- the stream can be passed directly to the non-global zone
* - for directory
* -- convert packages to datastream to pass to the non-global zone
* - for device
* -- ?
*/
static boolean_t
{
int i;
/* entry assertions */
/* entry debugging info */
/*
* set flags for applicability check
*/
/* determine if running in the global zone */
if (z_running_in_global_zone() == B_TRUE) {
}
/* set -G flag */
if (globalZoneOnly == B_TRUE) {
}
/*
* for each package to install:
* - if packages from datastream, unpack package into package dir
*/
/* create stream out of package if not already one */
a_packageDir) == B_FALSE) {
PSTR(a_packageDir));
return (B_FALSE);
}
} else {
}
/* check package applicability */
return (B_FALSE);
}
npkgs--;
}
return (B_TRUE);
}
/*
* returns:
* B_TRUE - package list generated
* B_FALSE - failed to generate package list
* Will call quit(n) on fatal error.
*/
static boolean_t
{
int n;
/* entry assertions */
/* entry debugging info */
*r_repeat);
/*
* get the list of the packages to add
*/
a_categoryList, &pkgdev);
switch (n) {
case -1: /* no packages found */
return (B_FALSE);
case 0: /* packages found */
break;
default: /* "quit" error */
quit(n);
/* NOTREACHED */
}
/*
* If we are not ignoring signatures, check the package's
* signature if one exists. pkgask doesn't care about
* signatures though.
*/
(web_ck_authentication() == AUTH_QUIT)) {
/* Retrieve signature */
web_cleanup();
quit(1);
/* NOTREACHED */
}
/* Found signature. Verify. */
if (a_httpProxyName != NULL) {
/* Proxy will be needed for OCSP */
!= URL_PARSE_SUCCESS) {
quit(99);
/* NOTREACHED */
}
}
/* Start with fresh error stack */
if (a_keystore == NULL) {
/* keystore not opened - open it */
&a_keystore) != 0) {
web_cleanup();
quit(1);
/* NOTREACHED */
}
}
/* get trusted CA certs */
web_cleanup();
quit(1);
/* NOTREACHED */
}
/* Verify signature */
quit(99);
/* NOTREACHED */
}
/* cleanup */
web_cleanup();
}
}
/* order package list if input data stream specified */
if (a_idsName) {
}
return (B_TRUE);
}
/*
* Name: install_in_one_zone
* Description: Install a single package in a single zone
* Arguments: a_zoneName - pointer to string representing the name of the
* zone to install the package into.
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be installed.
* If this is == NULL the package is assumed to be
* spooled in the zone temporary directory.
* a_zoneAdminFile - pointer to string representing the admin
* file to pass to pkginstall when installing the package.
* If this is == NULL no admin file is given to pkginstall.
* a_zoneTempDir - pointer to string representing the temporary
* directory in which spooled packages can be found if
* a_idsName is == NULL.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_scratchName - pointer to string representing the name of the
* scratch zone to use for installation.
* a_zoneState - state of the zone; must be mounted or running.
* a_tmpzn - B_TRUE when this zone is booted by the package
* command or B_FALSE if it was running before.
* Returns: void
* NOTE: As a side effect, "ckreturn" is called on the result returned
* from running 'pkginstall' in the zone; this sets several global
* variables which allows the caller to determine the result of
* the installation operation.
*/
static void
char *a_zoneAdminFile, char *a_zoneTempDir,
{
int n;
/* entry assertions */
/* entry debugging info */
PSTR(a_altBinDir));
/* echo operation to perform to stdout */
/* determine path to the package stream */
/* locate temp stream created earlier */
} else {
/* use stream passed in on command line */
"%s", a_idsName);
}
ckreturn(n);
/* exit debugging info */
}
/*
* Name: install_in_zones
* Description: Install a single package in the zones that are running from
* a list of zones
* Arguments: a_zlst - list of zones to install the package into
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be installed.
* If this is == NULL the package is assumed to be
* spooled in the zone temporary directory.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_zoneAdminFile - pointer to string representing the admin
* file to pass to pkginstall when installing the package.
* If this is == NULL no admin file is given to pkginstall.
* a_zoneTempDir - pointer to string representing the temporary
* directory in which spooled packages can be found if
* a_idsName is == NULL.
*/
static int
char *a_zoneAdminFile, char *a_zoneTempDir)
{
char *zoneName;
int zoneIndex;
int zonesSkipped = 0;
/* entry assertions */
/* entry debugging info */
/* process each zone in the list */
for (zoneIndex = 0;
zoneIndex++) {
/* skip the zone if it is NOT running */
zonesSkipped++;
continue;
}
/* install the package in this zone */
}
return (zonesSkipped);
}
/*
* Name: boot_and_install_in_zones
* Description: Install a single package in the zones that are NOT running from
* a list of zones - each zone is booted, the package installed,
* and the zone is halted
* Arguments: a_zlst - list of zones to install the package into
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be installed.
* If this is == NULL the package is assumed to be
* spooled in the zone temporary directory.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_zoneAdminFile - pointer to string representing the admin
* file to pass to pkginstall when installing the package.
* If this is == NULL no admin file is given to pkginstall.
* a_zoneTempDir - pointer to string representing the temporary
* directory in which spooled packages can be found if
* a_idsName is == NULL.
*/
static int
char *a_zoneAdminFile, char *a_zoneTempDir)
{
boolean_t b;
char *zoneName;
int zoneIndex;
int zonesSkipped = 0;
/* entry assertions */
/* entry debugging info */
/* process each zone in the list */
for (zoneIndex = 0;
zoneIndex++) {
/* skip the zone if it IS running */
continue;
}
/* skip the zone if it is NOT bootable */
continue;
}
/* mount up the zone */
if (b == B_FALSE) {
/* set fatal error return condition */
ckreturn(1);
zonesSkipped++;
continue;
}
/* install the package in this zone */
/* restore original state of zone */
}
return (zonesSkipped);
}
/*
* Name: pkginstall_check_in_one_zone
* Description: Do a pre install check of a single package in a single zone
* Arguments: a_zoneName - pointer to string representing the name of the
* zone to check install the package in.
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be check installed.
* If this is == NULL the package is assumed to be
* spooled in the zone temporary directory.
* a_zoneAdminFile - pointer to string representing the admin
* file to pass to pkginstall when installing the package.
* If this is == NULL no admin file is given to pkginstall.
* a_zoneTempDir - pointer to string representing the temporary
* directory in which spooled packages can be found if
* a_idsName is == NULL.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_scratchName - pointer to string representing the name of the
* scratch zone to use for installation.
* a_zoneState - state of the zone; must be mounted or running.
* a_tmpzn - B_TRUE when this zone is booted by the package
* command or B_FALSE if it was running before.
* Returns: void
* NOTE: As a side effect, "ckreturn" is called on the result returned
* from running 'pkginstall' in the zone; this sets several global
* variables which allows the caller to determine the result of
* the pre installation check operation.
*/
static void
{
int n;
/* locate temporary stream created earlier */
} else {
"%s", a_idsName);
}
ckreturn(n);
}
/*
* Name: pkginstall_check_in_zones
* Description: Check installation of a single package in the zones that
* are running from a list of zones
* Arguments: a_zlst - list of zones to check install the package
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be check installed.
* If this is == NULL the package is assumed to be
* spooled in the zone temporary directory.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_zoneAdminFile - pointer to string representing the admin
* file to pass to pkginstall when checking the installing
* of the package.
* If this is == NULL no admin file is given to pkginstall.
* a_zoneTempDir - pointer to string representing the temporary
* directory in which spooled packages can be found if
* a_idsName is == NULL.
*/
static int
char *a_zoneAdminFile, char *a_zoneTempDir)
{
char *zoneName;
int zoneIndex;
int zonesSkipped = 0;
for (zoneIndex = 0;
zoneIndex++) {
zonesSkipped++;
continue;
}
}
return (zonesSkipped);
}
/*
* Name: boot_and_pkginstall_check_in_zones
* Description: Check installation of a single package in the zones that
* are NOT running from a list of zones - each zone is booted,
* the package installation is checked, and the zone is halted.
* Arguments: a_zlst - list of zones to install the package into
* a_idsName - pointer to string representing the data stream
* device (input data stream) containing the package to
* be check installed.
* If this is == NULL the package is assumed to be
* spooled in the zone temporary directory.
* a_altBinDir - pointer to string representing an alternative
* binary location directory to pass to pkginstall.
* If this is == NULL no alternative binary location is
* passed to pkginstall.
* a_zoneAdminFile - pointer to string representing the admin
* file to pass to pkginstall when check installing the
* package.
* If this is == NULL no admin file is given to pkginstall.
* a_zoneTempDir - pointer to string representing the temporary
* directory in which spooled packages can be found if
* a_idsName is == NULL.
*/
static int
{
int zoneIndex;
int zonesSkipped = 0;
char *zoneName;
boolean_t b;
/* entry assertions */
/* entry debugging info */
/* process each zone in the list */
for (zoneIndex = 0;
zoneIndex++) {
/* skip the zone if it IS running */
continue;
}
/* skip the zone if it is NOT bootable */
continue;
}
/* mount up the zone */
if (b == B_FALSE) {
/* set fatal error return condition */
ckreturn(1);
zonesSkipped++;
continue;
}
/* pre-installation check of the package in this zone */
/* restore original state of zone */
}
return (zonesSkipped);
}
/*
* Function: add_packages_in_global_with_zones
* Description: call this function to add a list of packages in the global zone
* when one or more non-global zones exist
* returns:
* B_TRUE to process next data stream
* B_FALSE to exit
*/
static boolean_t
{
boolean_t b;
char *packageDir;
int i;
int n;
int zonesSkipped;
/* entry assertions */
/* create temporary directory for use by zone operations */
/* create hands off settings admin file for use in a non-global zone */
/* determine directory where packages can be found */
/* no stream - directory containing packages provided */
} else {
}
/* unpack and check all packages */
if (b != B_TRUE) {
quit(1);
}
/*
* if the packages are contained in a directory, convert the
* packages into individual streams because pkgZoneInstall is only able
* to pass a stream to the non-global zone's pkginstall command.
* After this code is executed:
* if the original input was a datastream:
* -> that datastream has been unpacked into "instdir"
* if the original input was a directory with packages in it:
* -> those packages have been placed into a single datastream
*/
/* package is not a stream - create one */
/* set up list of packages to be this package only */
if (n != 0) {
quit(1);
}
npkgs--;
}
}
/*
* Phase I - run collect dependency information for all packages for all
* zones - this involves running pkginstall with the "preinstallcheck"
* option which causes all dependency checks to be performed without
* actually doing the installation of the packages. This information is
* gathered in the zone temporary directory and is used later to present
* the dependency check results to the system administrator depending
* on the administration settings.
*/
/* reset interrupted flag before calling pkginstall */
interrupted = 0; /* last action was NOT quit */
/*
* if this package is marked "install in this zone only", then
* do not check dependencies in any other zone
*/
npkgs--;
continue;
}
/*
* if operation failed in global zone do not propagate
* to any non-global zones
*/
if (interrupted != 0) {
break;
}
/*
* call pkginstall to verify this package for all non-global
* zones that are currently booted
*/
/*
* if any zones were skipped (becuase they are not currently
* booted), boot each zone one at a time and call pkginstall
* to verify this package for each such non-global zone
*/
if (zonesSkipped > 0) {
if (zonesSkipped > 0) {
}
}
npkgs--;
}
/*
* At this point, all of the dependency information has been gathered
* and is ready to be analyzed. This function processes all of that
* dependency information and presents the results to the system
* administrator, depending on the current administration settings.
*/
if (i != 0) {
/* dependency checks failed - exit */
quit(i);
}
/*
* reset all error return condition variables that may have been
* set during package installation dependency checking so that they
* installation operations
*/
resetreturn();
/*
* At this point, all of the dependency checking is completed, and
* the installation of the packages can proceed. Install each package
* one at a time, starting with the global zone, and the for each
* non-global zone that is booted, and then for each non-global zone
* that is not currently booted.
*/
/*
* if immediate reboot required from last package and this is
* not 'pkgask' then suspend installation of remaining packages
*/
continue;
}
/*
* handle interrupt if the previous pkginstall was interrupted
*/
if (continue_installation() == B_FALSE) {
return (B_FALSE);
}
/*
* if pkgask, handle response file creation:
* - if the response file is a directory, then create a path to
* -- a package instance within the response file directory.
* - If the response file is NOT a directory, if more than one
* -- package is to be installed.
*/
}
/*
* If we're installing another package in the same
* session, the second through nth pkginstall, must
* continue from where the prior one left off. For this
* reason, the continuation feature (implied by the
* nature of the command) is used for the remaining
* packages.
*/
}
if (globalPresent) {
/*
* call pkginstall for this package for the global zone
*/
/* reset interrupted flag before calling pkginstall */
interrupted = 0; /* last action was NOT quit */
ckreturn(n);
/*
* if operation failed in global zone do not propagate
* to any non-global zones
*/
if (interrupted != 0) {
pkginst);
break;
}
}
/*
* if this package is marked "install in this zone only",
* then only need to install the package in the global zone;
* skip installation in any non-global zones.
*/
npkgs--;
continue;
}
/* install package in currently booted zones */
/* install package in zones that are not currently booted */
if (zonesSkipped > 0) {
if (zonesSkipped > 0) {
}
}
/*
* package completely installed - remove any temporary stream
* of the package that might have been created
*/
/* locate temporary stream created earlier */
/* remove stream - no longer needed */
pkginst);
(void) remove(zoneStreamName);
} else {
/* remove package - no longer needed */
quit(1);
}
}
/* decrement number of packages left to install */
npkgs--;
/*
* if no packages left to install, unmount package source
* device if appropriate
*/
(void) chdir("/");
if (!a_idsName) {
}
}
}
/*
* all packages in the package list have been installed.
* Continue with installation if:
* -- immediate reboot is NOT required
* -- there are more packages to install
* -- the package source is a path to a file
* else return do NOT continue.
*/
return (B_TRUE);
}
/* return 'dont continue' */
return (B_FALSE);
}
/*
* Function: add_packages_in_nonglobal_zone
* Description: call this function to add a list of packages in a non-global
* zone
* returns:
* B_TRUE to process next data stream
* B_FALSE to exit
*/
static boolean_t
{
char *packageDir;
int i;
int n;
boolean_t b;
/* entry assertions */
/* entry debugging info */
/* create temporary directory for use by zone operations */
/*
* package can be in a number of formats:
* - file containing package stream (pkgadd -d file [pkgs])
* - directory containing packages (pkgadd -d /dir [pkgs])
* - device containing packages (pkgadd -d diskette1 [pkgs])
* non-global zones can be passed open file drescriptors and
* strings as arguments
* - for file containing package stream
* -- the stream can be passed directly to the non-global zone
* - for directory
* -- convert packages to datastream to pass to the non-global zone
* - for device
*/
/* determine directory where packages can be found */
/* no stream - directory containing packages provided */
} else {
}
if (b != B_TRUE) {
quit(1);
}
/*
* this is the main loop where all of the packages (as listed in the
* package list) are added one at a time.
*/
npkgs--;
}
/*
* this is the main loop where all of the packages (as listed in the
* package list) are added one at a time.
*/
/*
* if immediate reboot required from last package and this is
* not 'pkgask' then suspend installation of remaining packages
*/
continue;
}
/*
* handle interrupt if the previous pkginstall was interrupted
*/
if (continue_installation() == B_FALSE) {
return (B_FALSE);
}
/*
* if pkgask, handle response file creation:
* - if the response file is a directory, then create a path to
* -- a package instance within the response file directory.
* - If the response file is NOT a directory, if more than one
* -- package is to be installed.
*/
}
/*
* If we're installing another package in the same
* session, the second through nth pkginstall, must
* continue from where the prior one left off. For this
* reason, the continuation feature (implied by the
* nature of the command) is used for the remaining
* packages.
*/
}
/* reset interrupted flag before calling pkginstall */
interrupted = 0; /* last action was NOT quit */
/* call pkginstall for this package */
ckreturn(n);
/* decrement number of packages left to install */
npkgs--;
/*
* if no packages left to install, unmount package source
* device if appropriate
*/
(void) chdir("/");
if (!a_idsName) {
}
}
}
/*
* all packages in the package list have been installed.
* Continue with installation if:
* -- immediate reboot is NOT required
* -- there are more packages to install
* -- the package source is a path to a file
* else return do NOT continue.
*/
return (B_TRUE);
}
/* return 'dont continue' */
return (B_FALSE);
}
/*
* Function: add_packages_in_global_no_zones
* Description: call this function to add a list of packages in the global zone
* when no non-global zones exist
* returns:
* B_TRUE to process next data stream
* B_FALSE to exit
*/
static boolean_t
{
int n;
int i;
/* entry assertions */
/*
* set flags for applicability check
*/
/* in the global zone */
/* set -G flag */
if (globalZoneOnly == B_TRUE) {
}
/*
* this is the main loop where all of the packages (as listed in the
* package list) are added one at a time.
*/
/*
* if immediate reboot required from last package and this is
* not 'pkgask' then suspend installation of remaining packages
*/
continue;
}
/*
* handle interrupt if the previous pkginstall was interrupted
*/
if (continue_installation() == B_FALSE) {
return (B_FALSE);
}
/*
* check package applicability to install in this context
*/
quit(1);
}
/*
* if pkgask, handle response file creation:
* - if the response file is a directory, then create a path to
* -- a package instance within the response file directory.
* - If the response file is NOT a directory, if more than one
* -- package is to be installed.
*/
}
/*
* If we're installing another package in the same
* session, the second through nth pkginstall, must
* continue from where the prior one left off. For this
* reason, the continuation feature (implied by the
* nature of the command) is used for the remaining
* packages.
*/
}
/* reset interrupted flag before calling pkginstall */
interrupted = 0; /* last action was NOT quit */
/* call pkginstall for this package */
ckreturn(n);
/* decrement number of packages left to install */
npkgs--;
/*
* if no packages left to install, unmount package source
* device if appropriate
*/
(void) chdir("/");
if (!a_idsName) {
}
}
}
/*
* all packages in the package list have been installed.
* Continue with installation if:
* -- immediate reboot is NOT required
* -- there are more packages to install
* -- the package source is a path to a file
* else return do NOT continue.
*/
return (B_TRUE);
}
/* return 'dont continue' */
return (B_FALSE);
}
/*
* returns:
* B_TRUE to process next data stream
* B_FALSE to exit
*/
static boolean_t
{
boolean_t b;
/* entry assertions */
/*
* if running in the global zone AND one or more non-global
* zones exist, add packages in a 'zones aware' manner, else
* add packages in the standard 'non-zones aware' manner.
*/
/* in non-global zone */
if (b != B_TRUE) {
/* set fatal error return condition */
ckreturn(1);
return (B_FALSE);
}
(void) z_unlock_this_zone(ZLOCKS_ALL);
return (B_FALSE);
}
/* running in the global zone */
b = z_non_global_zones_exist();
(globalZoneOnly == B_FALSE)) {
/* error if -V specified - what to use in non-global zone? */
if (vfstab_file) {
quit(1);
}
/* get a list of all non-global zones */
quit(1);
}
/* need to lock all of the zones */
if (b == B_FALSE) {
/* set fatal error return condition */
ckreturn(1);
return (B_FALSE);
}
/* add packages to all zones */
/* unlock all zones */
/* free list of all non-global zones */
return (B_FALSE);
}
/* in global zone no non-global zones */
if (b != B_TRUE) {
/* set fatal error return condition */
ckreturn(1);
return (B_FALSE);
}
(void) z_unlock_this_zone(ZLOCKS_ALL);
return (B_FALSE);
}