zoneadm.c revision 7e362f586af53d30ffc869a0ddc7d0f284ef8f82
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* zoneadm is a command interpreter for zone administration. It is all in
* main() calls parse_and_run() which calls cmd_match(), then invokes the
* appropriate command's handler function. The rest of the program is the
* handler functions and their helper functions.
*
* Some of the helper functions are used largely to simplify I18N: reducing
* the need for translation notes. This is particularly true of many of
* the zerror() calls: doing e.g. zerror(gettext("%s failed"), "foo") rather
* than zerror(gettext("foo failed")) with a translation note indicating
* that "foo" need not be translated.
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <wait.h>
#include <zone.h>
#include <priv.h>
#include <locale.h>
#include <libintl.h>
#include <libzonecfg.h>
#include <assert.h>
#include <limits.h>
#include <fcntl.h>
#include <door.h>
#include <macros.h>
#include <libgen.h>
#include <pool.h>
#define MAXARGS 8
/* Reflects kernel zone entries */
typedef struct zone_entry {
char zname[ZONENAME_MAX];
char *zstate_str;
char zroot[MAXPATHLEN];
} zone_entry_t;
static zone_entry_t *zents;
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
#endif
#define Z_ERR 1
#define Z_USAGE 2
/* 0755 is the default directory mode. */
#define DEFAULT_DIR_MODE \
#define CMD_HELP 0
#define CMD_BOOT 1
#define CMD_HALT 2
#define CMD_READY 3
#define CMD_REBOOT 4
#define CMD_LIST 5
#define CMD_VERIFY 6
#define CMD_INSTALL 7
#define CMD_UNINSTALL 8
#define CMD_MAX CMD_UNINSTALL
struct cmd {
char *cmd_name; /* command name */
char *short_usage; /* short form help */
};
#define SHELP_HELP "help"
#define SHELP_BOOT "boot [-s]"
#define SHELP_HALT "halt"
#define SHELP_READY "ready"
#define SHELP_REBOOT "reboot"
#define SHELP_LIST "list [-cipv]"
#define SHELP_VERIFY "verify"
#define SHELP_INSTALL "install"
#define SHELP_UNINSTALL "uninstall [-F]"
static int verify_details(int);
};
/* global variables */
/* set early in main(), never modified thereafter, used all over the place */
static char *execname;
static char *target_zone;
static char *locale;
/* used in do_subproc() and signal handler */
static volatile boolean_t child_killed;
static char *
cmd_to_str(int cmd_num)
{
}
/* This is a separate function because of gettext() wrapping. */
static char *
{
switch (cmd_num) {
case CMD_HELP:
return (gettext("Print usage message."));
case CMD_BOOT:
return (gettext("Activates (boots) specified zone. "
"The -s flag can be used\n\tto boot the zone in "
"the single-user state."));
case CMD_HALT:
return (gettext("Halts specified zone, bypassing "
"shutdown scripts and removing runtime\n\t"
"resources of the zone."));
case CMD_READY:
return (gettext("Prepares a zone for running "
"applications but does not start any user\n\t"
"processes in the zone."));
case CMD_REBOOT:
return (gettext("Restarts the zone (equivalent to a "
"halt / boot sequence).\n\tFails if the zone is "
"not active."));
case CMD_LIST:
return (gettext("Lists the current zones, or a "
"specific zone if indicated. By default,\n\tall "
"running zones are listed, though this can be "
"expanded to all\n\tinstalled zones with the -i "
"option or all configured zones with the\n\t-c "
"option. When used with the general -z <zone> "
"option, lists only the\n\tspecified zone, but "
"lists it regardless of its state, and the -i "
"and -c\n\toptions are disallowed. The -v option "
"can be used to display verbose\n\tinformation: "
"zone name, id, current state, root directory and "
"options.\n\tThe -p option can be used to request "
"machine-parsable output. The -v\n\tand -p "
"options are mutually exclusive. If neither -v "
"nor -p is used,\n\tjust the zone name is "
"listed."));
case CMD_VERIFY:
return (gettext("Check to make sure the configuration "
"can safely be instantiated\n\ton the machine: "
"physical network interfaces exist, etc."));
case CMD_INSTALL:
return (gettext("Install the configuration on to the "
"system."));
case CMD_UNINSTALL:
return (gettext("Uninstall the configuration from the "
"system. The -F flag can be used\n\tto force the "
"action."));
}
/* NOTREACHED */
return (NULL);
}
/*
* Called with explicit B_TRUE when help is explicitly requested, B_FALSE for
* unexpected errors.
*/
static int
{
int i;
gettext("subcommand"));
if (explicit)
}
if (!explicit)
return (Z_USAGE);
}
static void
{
}
/*
* zperror() is like perror(3c) except that this also prints the executable
* name at the start of the message, and takes a boolean indicating whether
* to call libc'c strerror() or that from libzonecfg.
*/
static void
{
}
/*
* zperror2() is very similar to zperror() above, except it also prints a
* supplied zone name after the executable.
*
* All current consumers of this function want libzonecfg's strerror() rather
* than libc's; if this ever changes, this function can be made more generic
* like zperror() above.
*/
static void
{
}
/* PRINTFLIKE1 */
static void
{
if (target_zone != NULL)
}
static void *
{
if (r == NULL) {
}
return (r);
}
static void
{
"NAME", "STATUS", "PATH");
}
if (!verbose) {
if (!parsable) {
return;
}
(void) printf("-");
else
return;
}
else
}
}
static int
{
char root[MAXPATHLEN];
int err;
Z_OK) {
return (Z_ERR);
}
return (Z_ERR);
}
return (Z_OK);
}
/*
* fetch_zents() calls zone_list(2) to find out how many zones are running
* (which is stored in the global nzents), then calls zone_list(2) again
* to fetch the list of running zones (stored in the global zents). This
* function may be called multiple times, so if zents is already set, we
* return immediately to save work.
*/
static int
{
int i;
if (nzents > 0)
return (Z_OK);
return (Z_ERR);
}
if (nzents == 0)
return (Z_OK);
return (Z_ERR);
}
if (nzents != nzents_saved) {
/* list changed, try again */
goto again;
}
for (i = 0; i < nzents; i++) {
char name[ZONENAME_MAX];
}
return (Z_OK);
}
static void
{
int i;
char *name;
/*
* First get the list of running zones from the kernel and print them.
* If that is all we need, then return.
*/
if (fetch_zents() != Z_OK) {
/*
* No need for error messages; fetch_zents() has already taken
* care of this.
*/
return;
}
for (i = 0; i < nzents; i++) {
continue;
}
}
if (min_state >= ZONE_STATE_RUNNING)
return;
/*
* Next, get the full list of zones from the configuration, skipping
* any we have already printed.
*/
cookie = setzoneent();
for (i = 0; i < nzents; i++) {
break;
}
if (i < nzents) {
continue;
}
continue;
}
}
}
static zone_entry_t *
lookup_running_zone(char *str)
{
char *cp;
int i;
if (fetch_zents() != Z_OK)
return (NULL);
for (i = 0; i < nzents; i++) {
return (&zents[i]);
}
errno = 0;
return (NULL);
for (i = 0; i < nzents; i++) {
return (&zents[i]);
}
return (NULL);
}
/*
* Check a bit in a mode_t: if on is B_TRUE, that bit should be on; if
* B_FALSE, it should be off. Return B_TRUE if the mode is bad (incorrect).
*/
static boolean_t
{
char *str;
/*
* TRANSLATION_NOTE
* The strings below will be used as part of a larger message,
* either:
* (file name) must be (owner|group|world) (read|writ|execut)able
* or
* (file name) must not be (owner|group|world) (read|writ|execut)able
*/
switch (bit) {
case S_IRUSR:
break;
case S_IWUSR:
break;
case S_IXUSR:
break;
case S_IRGRP:
break;
case S_IWGRP:
break;
case S_IXGRP:
break;
case S_IROTH:
break;
case S_IWOTH:
break;
case S_IXOTH:
break;
}
/*
* TRANSLATION_NOTE
* The first parameter below is a file name; the second
* is one of the "(owner|group|world) (read|writ|execut)able"
* strings from above.
*/
/*
* The code below could be simplified but not in a way
* that would easily translate to non-English locales.
*/
if (on) {
} else {
}
return (B_TRUE);
}
return (B_FALSE);
}
/*
* We want to make sure that no zone has its zone path as a child node
* (in the directory sense) of any other. We do that by comparing this
* zone's path to the path of all other (non-global) zones. The comparison
* in each case is simple: add '/' to the end of the path, then do a
* strncmp() of the two paths, using the length of the shorter one.
*/
static int
crosscheck_zonepaths(char *path)
{
cookie = setzoneent();
/* Skip zones which are not installed. */
continue;
}
/* Skip the global zone and the current target zone. */
continue;
}
/* old index file without path, fall back */
gettext("could not get zone path"));
continue;
}
}
if (res == -1) {
return (Z_ERR);
}
continue;
}
"%s zonepath (%s) overlap.\n"),
return (Z_ERR);
}
}
return (Z_OK);
}
static int
{
if (path[0] != '/') {
return (Z_ERR);
}
return (Z_ERR);
}
if (cmd_num == CMD_VERIFY) {
"exist, so it cannot be verified.\nWhen 'zoneadm "
"%s' is run, '%s' will try to create\n%s, and '%s' "
"will be tried again,\nbut the '%s' may fail if:\n"
"the parent directory of %s is group- or other-"
"writable\nor\n%s overlaps with any other "
"installed zones.\n"), path,
return (Z_OK);
}
/*
* The zonepath is supposed to be mode 700 but its
* parent(s) 755. So use 755 on the mkdirp() then
* chmod() the zonepath itself to 700.
*/
return (Z_ERR);
}
/*
* If the chmod() fails, report the error, but might
* as well continue the verify procedure.
*/
/*
* Since the mkdir() succeeded, we should not have to
* worry about a subsequent ENOENT, thus this should
* only recurse once.
*/
}
return (Z_ERR);
}
return (Z_ERR);
}
rpath);
return (Z_ERR);
}
"file-system.\n"), rpath);
}
return (Z_ERR);
/*
* Try to collect and report as many minor errors as possible
* before returning, so the user can learn everything that needs
* to be fixed up front.
*/
rpath);
}
return (Z_ERR);
}
return (Z_ERR);
}
/* theoretically impossible */
rppath);
return (Z_ERR);
}
rppath);
}
rppath);
}
return (Z_ERR);
}
"which is not currently supported.\n"), rpath);
return (Z_ERR);
}
return (Z_ERR);
}
/*
* The existence of the root path is only bad in the configured state,
* as it is *supposed* to be there at the installed and later states.
*/
if (state == ZONE_STATE_CONFIGURED) {
sizeof (rootpath)) {
return (Z_ERR);
}
"remove or move aside prior to %s.\n"), rootpath,
return (Z_ERR);
}
}
}
static void
release_lock_file(int lockfd)
{
}
static int
{
return (Z_ERR);
}
/*
* One of these lock files is created for each zone (when needed).
* The lock files are not cleaned up (except on system reboot),
* but since there is only one per zone, there is no resource
* starvation issue.
*/
return (Z_ERR);
}
/*
* Lock the file to synchronize with other zoneadmds
*/
return (Z_ERR);
}
return (Z_OK);
}
static void
{
}
/*
* system daemons are not audited. For the global zone, this occurs
* "naturally" since init is started with the default audit
* characteristics. Since zoneadmd is a system daemon and it starts
* init for a zone, it is necessary to clear out the audit
* characteristics inherited from whomever started zoneadmd. This is
* indicated by the audit id, which is set from the ruid parameter of
* adt_set_user(), below.
*/
static void
{
return;
}
(void) adt_end_session(ah);
return;
}
if (adt_set_proc(ah))
(void) adt_end_session(ah);
}
static int
start_zoneadmd(const char *zone_name)
{
return (Z_ERR);
/*
* Now that we have the lock, re-confirm that the daemon is
* *not* up and working fine. If it is still down, we have a green
* light to start it.
*/
goto out;
}
} else {
goto out;
}
}
goto out;
} else if (child_pid == 0) {
/* child process */
} else {
/* parent process */
int pstatus = 0;
do {
WEXITSTATUS(pstatus) != 0)) {
goto out;
}
}
out:
return (error);
}
static int
ping_zoneadmd(const char *zone_name)
{
int doorfd;
return (Z_ERR);
}
return (Z_OK);
}
return (Z_ERR);
}
static int
{
rlen = getpagesize();
return (-1);
}
sizeof (uniqid));
}
/*
* Loop trying to start zoneadmd; if something goes seriously
* wrong we break out and fail.
*/
for (;;) {
break;
break;
}
/*
* We'll get EBADF if the door has been revoked.
*/
break;
}
continue; /* take another lap */
}
/* Door server is going away; kick it again. */
continue;
}
while (*errbuf != '\0') {
/*
* Remove any newlines since zerror()
* will append one automatically.
*/
*cp = '\0';
break;
}
return (result);
}
return (-1);
}
static int
{
int arg;
optind = 0;
switch (arg) {
case '?':
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
return (Z_ERR);
return (Z_ERR);
return (Z_ERR);
}
return (Z_OK);
}
static int
{
int arg;
/*
* At the current time, the only supported subargument to the
* "boot" subcommand is "-s" which specifies a single-user boot.
* In the future, other boot arguments should be supported
* including "-m" for specifying alternate smf(5) milestones.
*/
optind = 0;
switch (arg) {
case '?':
case 's':
break;
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
return (Z_ERR);
return (Z_ERR);
return (Z_ERR);
}
return (Z_OK);
}
static void
{
/*
* Since we're looking up our own (non-global) zone name,
* we can be assured that it will succeed.
*/
}
static int
{
int arg;
if (target_zone == NULL) {
/* all zones: default view to running but allow override */
optind = 0;
switch (arg) {
case '?':
case 'c':
break;
case 'i':
break;
case 'p':
break;
case 'v':
break;
default:
return (Z_USAGE);
}
}
return (Z_ERR);
}
if (zone_id == GLOBAL_ZONEID) {
} else {
}
return (Z_OK);
}
/*
* Specific target zone: disallow -i/-c suboptions.
*/
optind = 0;
switch (arg) {
case '?':
case 'p':
break;
case 'v':
break;
default:
return (Z_USAGE);
}
}
return (Z_ERR);
}
return (Z_USAGE);
}
if (zone_id != GLOBAL_ZONEID) {
/*
* main() will issue a Z_NO_ZONE error if it cannot get an
* id for target_zone, which in a non-global zone should
* happen for any zone name except `zonename`. Thus we
* assert() that here but don't otherwise check.
*/
}
}
static void
{
/*
* Ignore SIG{INT,TERM}, so we don't end up in an infinite loop,
* then propagate the signal to our process group.
*/
}
static int
do_subproc(char *cmdbuf)
{
/*
* We use popen(3c) to launch child processes for [un]install;
* this library call does not return a PID, so we have to kill
* the whole process group. To avoid killing our parent, we
* become a process group leader here. But doing so can wreak
* havoc with reading from stdin when launched by a non-job-control
*/
(void) close(STDIN_FILENO);
(void) setpgid(0, 0);
for (;;) {
break;
}
}
static int
{
if (exit_code == 0)
return (Z_OK);
} else if (WIFSIGNALED(status)) {
char sigstr[SIG2STR_MAX];
sigstr);
} else {
cmd);
}
} else {
}
return (Z_ERR);
}
/*
* Various sanity checks; make sure:
* 1. We're in the global zone.
* 2. The calling user has sufficient privilege.
* 3. The target zone is neither the global zone nor anything starting with
* "SUNW".
* 4a. If we're looking for a 'not running' (i.e., configured or installed)
* zone, the name service knows about it.
* 4b. For some operations which expect a zone not to be running, that it is
* not already running (or ready).
*/
static int
{
if (getzoneid() != GLOBAL_ZONEID) {
return (Z_ERR);
}
return (Z_ERR);
}
return (Z_ERR);
}
return (Z_ERR);
}
return (Z_ERR);
}
return (Z_ERR);
}
return (Z_ERR);
}
/*
* Look up from the kernel for 'running' zones.
*/
if (running) {
return (Z_ERR);
}
} else {
int err;
/* check whether the zone is ready or running */
gettext("could not get state"));
/* can't tell, so hedge */
} else {
zent->zstate_str =
}
return (Z_ERR);
}
return (Z_ERR);
}
switch (cmd_num) {
case CMD_UNINSTALL:
if (state == ZONE_STATE_CONFIGURED) {
return (Z_ERR);
}
break;
case CMD_INSTALL:
if (state == ZONE_STATE_INSTALLED) {
return (Z_ERR);
} else if (state == ZONE_STATE_INCOMPLETE) {
return (Z_ERR);
}
break;
case CMD_READY:
case CMD_BOOT:
if (state < ZONE_STATE_INSTALLED) {
return (Z_ERR);
}
break;
case CMD_VERIFY:
if (state == ZONE_STATE_INCOMPLETE) {
return (Z_ERR);
}
break;
}
}
return (Z_OK);
}
static int
{
int arg;
optind = 0;
switch (arg) {
case '?':
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
/*
* zoneadmd should be the one to decide whether or not to proceed,
* so even though it seems that the fourth parameter below should
* perhaps be B_TRUE, it really shouldn't be.
*/
return (Z_ERR);
}
static int
{
int arg;
optind = 0;
switch (arg) {
case '?':
default:
return (Z_USAGE);
}
}
if (argc > 0) {
return (Z_USAGE);
}
/*
* zoneadmd should be the one to decide whether or not to proceed,
* so even though it seems that the fourth parameter below should
* perhaps be B_TRUE, it really shouldn't be.
*/
return (Z_ERR);
}
static int
{
struct zone_rctltab rctltab;
return (Z_NOMEM);
}
return (error);
}
struct zone_rctlvaltab *rctlval;
if (!zonecfg_is_rctl(name)) {
"'%s'."), name);
continue;
}
!= Z_OK) {
"(priv=%s,limit=%s,action%s)"),
goto out;
}
"is not a valid value for rctl '%s'"),
name);
goto out;
}
}
}
out:
(void) zonecfg_endrctlent(handle);
return (error);
}
static int
{
char poolname[MAXPATHLEN];
int status;
int error;
/*
* This ends up being very similar to the check done in zoneadmd.
*/
/*
* No pool specified.
*/
return (0);
}
"configuration"), B_TRUE);
return (error);
}
/*
* Don't do anything if pools aren't enabled.
*/
"zone will not be bound to pool '%s'."), poolname);
return (Z_OK);
}
/*
* Try to provide a sane error message if the requested pool doesn't
* exist. It isn't clear that pools-related failures should
* necessarily translate to a failure to verify the zone configuration,
* hence they are not considered errors.
*/
"using default pool"));
return (Z_OK);
}
PO_SUCCESS) {
"using default pool"));
return (Z_OK);
}
(void) pool_conf_close(poolconf);
"using default pool"), poolname);
}
return (Z_OK);
}
static int
{
int return_code = Z_OK;
struct zone_fstab fstab;
char cmdbuf[MAXPATHLEN];
/*
* No need to verify inherit-pkg-dir fs types, as their type is
* implicitly lofs, which is known. Therefore, the types are only
* verified for regular filesystems below.
*
* Since the actual mount point is not known until the dependent mounts
* are performed, we don't attempt any path validation here: that will
* happen later when zoneadmd actually does the mounts.
*/
"unable to enumerate mounts\n"));
return (Z_ERR);
}
return_code = Z_ERR;
goto next_fs;
}
/*
*/
return_code = Z_ERR;
goto next_fs;
}
return_code = Z_ERR;
goto next_fs;
}
cmdbuf);
return_code = Z_ERR;
goto next_fs;
}
/*
* set.
*/
return_code = Z_ERR;
goto next_fs;
}
"must specify 'raw' device for %s file-systems\n"),
return_code = Z_ERR;
goto next_fs;
}
"'raw' device specified but "
"no fsck executable exists for %s\n"),
return_code = Z_ERR;
goto next_fs;
}
}
(void) zonecfg_endfsent(handle);
return (return_code);
}
static int
verify_details(int cmd_num)
{
struct zone_nwiftab nwiftab;
int return_code = Z_OK;
int err;
return (Z_ERR);
}
return (Z_ERR);
}
Z_OK) {
return (Z_ERR);
}
/*
* zonecfg_get_zonepath() gets its data from the XML repository.
* Verify this against the index file, which is checked first by
* zone_get_zonepath(). If they don't match, bail out.
*/
return (Z_ERR);
}
"zonepath '%s',\nbut the index file has zonepath '%s'.\n"
"These must match, so fix the incorrect entry.\n"),
return (Z_ERR);
}
"because of the above errors.\n"), zonepath);
return_code = Z_ERR;
}
return (Z_ERR);
}
/* skip any loopback interfaces */
continue;
"%s=%s %s=%s: %s\n"), "net", "address",
return_code = Z_ERR;
continue;
}
"%s=%s %s=%s: could not get socket: %s\n"), "net",
return_code = Z_ERR;
continue;
}
gettext("could not verify %s %s=%s %s=%s: %s\n"),
return_code = Z_ERR;
}
}
(void) zonecfg_endnwifent(handle);
return_code = Z_ERR;
return_code = Z_ERR;
return_code = Z_ERR;
if (return_code == Z_ERR)
gettext("%s: zone %s failed to verify\n"),
return (return_code);
}
static int
{
int arg;
optind = 0;
switch (arg) {
case '?':
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
return (Z_ERR);
return (verify_details(CMD_VERIFY));
}
#define LUCREATEZONE "/usr/lib/lu/lucreatezone"
static int
{
/* 9: "exec " and " -z " */
int lockfd;
char zonepath[MAXPATHLEN];
int status;
optind = 0;
switch (arg) {
case '?':
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
return (Z_ERR);
return (Z_ERR);
"zoneadmd");
return (Z_ERR);
}
goto done;
}
/*
* According to the Application Packaging Developer's Guide, a
* "checkinstall" script when included in a package is executed as
* the user "install", if such a user exists, or by the user
* "nobody". In order to support this dubious behavior, the path
* to the zone being constructed is opened up during the life of
* the command laying down the zone's root file system. Once this
* has completed, regardless of whether it was successful, the
* path to the zone is again restricted.
*/
goto done;
}
goto done;
}
/*
* "exec" the command so that the returned status is that of
* LUCREATEZONE and not the shell.
*/
goto done;
}
goto done;
goto done;
}
done:
}
/*
* On input, TRUE => yes, FALSE => no.
* On return, TRUE => 1, FALSE => 0, could not ask => -1.
*/
static int
{
if (!isatty(STDIN_FILENO))
return (-1);
for (;;) {
line[0] == '\n')
return (default_answer ? 1 : 0);
return (1);
return (0);
}
}
/* ARGSUSED */
int
zfm_print(const char *p, void *r) {
zerror(" %s\n", p);
return (0);
}
static int
{
/* 6: "exec " and " " */
int status;
optind = 0;
switch (arg) {
case '?':
case 'F':
break;
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
return (Z_ERR);
if (!force) {
gettext("Are you sure you want to %s zone %s"),
return (Z_OK);
} else if (answer == -1) {
"not specified: %s not done."),
return (Z_ERR);
}
}
return (Z_ERR);
}
return (Z_ERR);
}
/*
* If there seems to be a zoneadmd running for this zone, call it
* to tell it that an uninstall is happening; if all goes well it
* will then shut itself down.
*/
/* we don't care too much if this fails... just plow on */
}
"zoneadmd");
return (Z_ERR);
}
/* Don't uninstall the zone if anything is mounted there */
if (err) {
"subdirectories of %s.\n"), rootpath);
return (Z_ERR);
}
goto bad;
}
/*
* "exec" the command so that the returned status is that of
* RMCOMMAND and not the shell.
*/
devpath);
goto bad;
rootpath);
goto bad;
}
bad:
return (err);
}
static int
{
if (argc == 0) {
return (Z_OK);
}
optind = 0;
switch (arg) {
case '?':
default:
return (Z_USAGE);
}
}
return (Z_USAGE);
}
optind++;
}
return (Z_OK);
}
/*
* Returns: CMD_MIN thru CMD_MAX on success, -1 on error
*/
static int
{
int i;
/* return only if there is an exact match */
}
return (-1);
}
static int
{
if (i < 0)
}
static char *
get_execbasename(char *execfullname)
{
char *last_slash, *execbasename;
/* guard against '/' at end of command invocation */
for (;;) {
if (last_slash == NULL) {
break;
} else {
if (*execbasename == '\0') {
*last_slash = '\0';
continue;
}
break;
}
}
return (execbasename);
}
int
{
int arg;
locale = "C";
(void) textdomain(TEXT_DOMAIN);
target_zone = NULL;
if (chdir("/") != 0) {
}
switch (arg) {
case '?':
case 'z':
break;
default:
}
}
}
}