--- old/usr/src/cmd/zoneadmd/zoneadmd.c	Wed Oct  5 00:33:12 2016
+++ new/usr/src/cmd/zoneadmd/zoneadmd.c	Wed Oct  5 00:33:12 2016
@@ -120,11 +120,10 @@
 boolean_t zone_islabeled;
 boolean_t shutdown_in_progress;
 static zoneid_t zone_id;
-static zoneid_t zone_did = 0;
 dladm_handle_t dld_handle = NULL;
 
-char pre_statechg_hook[2 * MAXPATHLEN];
-char post_statechg_hook[2 * MAXPATHLEN];
+static char pre_statechg_hook[2 * MAXPATHLEN];
+static char post_statechg_hook[2 * MAXPATHLEN];
 char query_hook[2 * MAXPATHLEN];
 
 zlog_t logsys;
@@ -294,7 +293,7 @@
 {
 	int argc = 0, argc_save;
 	int i;
-	int err = Z_OK;
+	int err;
 	char *arg, *lasts, **argv = NULL, **argv_save;
 	char zonecfg_args[BOOTARGS_MAX];
 	char scratchargs[BOOTARGS_MAX], *sargs;
@@ -309,10 +308,25 @@
 	 * and use them if applicable.
 	 */
 	if (inargs == NULL || inargs[0] == '\0')  {
+		zone_dochandle_t handle;
+		if ((handle = zonecfg_init_handle()) == NULL) {
+			zerror(zlogp, B_TRUE,
+			    "getting zone configuration handle");
+			return (Z_BAD_HANDLE);
+		}
+		err = zonecfg_get_snapshot_handle(zone_name, handle);
+		if (err != Z_OK) {
+			zerror(zlogp, B_FALSE,
+			    "invalid configuration snapshot");
+			zonecfg_fini_handle(handle);
+			return (Z_BAD_HANDLE);
+		}
+
 		bzero(zonecfg_args, sizeof (zonecfg_args));
-		(void) zonecfg_get_bootargs(snap_hndl, zonecfg_args,
+		(void) zonecfg_get_bootargs(handle, zonecfg_args,
 		    sizeof (zonecfg_args));
 		inargs = zonecfg_args;
+		zonecfg_fini_handle(handle);
 	}
 
 	if (strlen(inargs) >= BOOTARGS_MAX) {
@@ -462,7 +476,7 @@
  * Run the brand's pre-state change callback, if it exists.
  */
 static int
-brand_prestatechg(zlog_t *zlogp, int state, int cmd, boolean_t debug)
+brand_prestatechg(zlog_t *zlogp, int state, int cmd)
 {
 	char cmdbuf[2 * MAXPATHLEN];
 	const char *altroot;
@@ -475,7 +489,7 @@
 	    state, cmd, altroot) > sizeof (cmdbuf))
 		return (-1);
 
-	if (do_subproc(zlogp, cmdbuf, NULL, debug) != 0)
+	if (do_subproc(zlogp, cmdbuf, NULL) != 0)
 		return (-1);
 
 	return (0);
@@ -485,7 +499,7 @@
  * Run the brand's post-state change callback, if it exists.
  */
 static int
-brand_poststatechg(zlog_t *zlogp, int state, int cmd, boolean_t debug)
+brand_poststatechg(zlog_t *zlogp, int state, int cmd)
 {
 	char cmdbuf[2 * MAXPATHLEN];
 	const char *altroot;
@@ -498,7 +512,7 @@
 	    state, cmd, altroot) > sizeof (cmdbuf))
 		return (-1);
 
-	if (do_subproc(zlogp, cmdbuf, NULL, debug) != 0)
+	if (do_subproc(zlogp, cmdbuf, NULL) != 0)
 		return (-1);
 
 	return (0);
@@ -535,51 +549,39 @@
  * Bring a zone up to the pre-boot "ready" stage.  The mount_cmd argument is
  * 'true' if this is being invoked as part of the processing for the "mount"
  * subcommand.
- *
- * If a scratch zone mount (ALT_MOUNT) is being performed then do not
- * call the state change hooks.
  */
 static int
-zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate, boolean_t debug)
+zone_ready(zlog_t *zlogp, zone_mnt_t mount_cmd, int zstate)
 {
 	int err;
-	boolean_t snapped = B_FALSE;
 
-	if ((snap_hndl = zonecfg_init_handle()) == NULL) {
-		zerror(zlogp, B_TRUE, "getting zone configuration handle");
-		goto bad;
-	}
+	if (!ALT_MOUNT(mount_cmd) &&
+	    brand_prestatechg(zlogp, zstate, Z_READY) != 0)
+		return (-1);
+
 	if ((err = zonecfg_create_snapshot(zone_name)) != Z_OK) {
 		zerror(zlogp, B_FALSE, "unable to create snapshot: %s",
 		    zonecfg_strerror(err));
 		goto bad;
 	}
-	snapped = B_TRUE;
 
-	if (zonecfg_get_snapshot_handle(zone_name, snap_hndl) != Z_OK) {
-		zerror(zlogp, B_FALSE, "invalid configuration snapshot");
+	if ((zone_id = vplat_create(zlogp, mount_cmd)) == -1) {
+		if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
+			zerror(zlogp, B_FALSE, "destroying snapshot: %s",
+			    zonecfg_strerror(err));
 		goto bad;
 	}
-
-	if (zone_did == 0)
-		zone_did = zone_get_did(zone_name);
-
-	if (!ALT_MOUNT(mount_cmd) &&
-	    brand_prestatechg(zlogp, zstate, Z_READY, debug) != 0)
-		goto bad;
-
-	if ((zone_id = vplat_create(zlogp, mount_cmd, zone_did)) == -1)
-		goto bad;
-
 	if (vplat_bringup(zlogp, mount_cmd, zone_id) != 0) {
 		bringup_failure_recovery = B_TRUE;
-		(void) vplat_teardown(NULL, (mount_cmd != Z_MNT_BOOT), B_FALSE,
-		    debug);
+		(void) vplat_teardown(NULL, (mount_cmd != Z_MNT_BOOT), B_FALSE);
+		if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
+			zerror(zlogp, B_FALSE, "destroying snapshot: %s",
+			    zonecfg_strerror(err));
 		goto bad;
 	}
 
 	if (!ALT_MOUNT(mount_cmd) &&
-	    brand_poststatechg(zlogp, zstate, Z_READY, debug) != 0)
+	    brand_poststatechg(zlogp, zstate, Z_READY) != 0)
 		goto bad;
 
 	return (0);
@@ -590,15 +592,7 @@
 	 * state, READY, and then invoke the hook as if we're halting.
 	 */
 	if (!ALT_MOUNT(mount_cmd))
-		(void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT,
-		    debug);
-
-	if (snapped)
-		if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
-			zerror(zlogp, B_FALSE, "destroying snapshot: %s",
-			    zonecfg_strerror(err));
-	zonecfg_fini_handle(snap_hndl);
-	snap_hndl = NULL;
+		(void) brand_poststatechg(zlogp, ZONE_STATE_READY, Z_HALT);
 	return (-1);
 }
 
@@ -779,8 +773,7 @@
 
 /*
  * env variable name format
- *	_ZONECFG_{resource name}_{identifying attr. name}_{property name}
- * Any dashes (-) in the property names are replaced with underscore (_).
+ *	_ZONECFG;{resource name};{identifying attr. name};{property name}
  */
 static void
 set_zonecfg_env(char *rsrc, char *attr, char *name, char *val)
@@ -811,24 +804,25 @@
  * We could export more of the config in the future, as necessary.
  */
 static int
-setup_subproc_env(boolean_t debug)
+setup_subproc_env()
 {
 	int res;
+	zone_dochandle_t handle;
 	struct zone_nwiftab ntab;
 	struct zone_devtab dtab;
-	struct zone_attrtab atab;
 	char net_resources[MAXNAMELEN * 2];
 	char dev_resources[MAXNAMELEN * 2];
 
-	/* snap_hndl is null when called through the set_brand_env code path */
-	if (snap_hndl == NULL)
-		return (Z_OK);
+	if ((handle = zonecfg_init_handle()) == NULL)
+		exit(Z_NOMEM);
 
-	net_resources[0] = '\0';
-	if ((res = zonecfg_setnwifent(snap_hndl)) != Z_OK)
+	if ((res = zonecfg_get_handle(zone_name, handle)) != Z_OK)
 		goto done;
 
-	while (zonecfg_getnwifent(snap_hndl, &ntab) == Z_OK) {
+	if ((res = zonecfg_setnwifent(handle)) != Z_OK)
+		goto done;
+
+	while (zonecfg_getnwifent(handle, &ntab) == Z_OK) {
 		struct zone_res_attrtab *rap;
 		char *phys;
 
@@ -855,17 +849,14 @@
 		    rap = rap->zone_res_attr_next)
 			set_zonecfg_env(RSRC_NET, phys, rap->zone_res_attr_name,
 			    rap->zone_res_attr_value);
-		nwifent_free_attrs(&ntab);
 	}
 
-	(void) setenv("_ZONECFG_net_resources", net_resources, 1);
+	(void) zonecfg_endnwifent(handle);
 
-	(void) zonecfg_endnwifent(snap_hndl);
-
-	if ((res = zonecfg_setdevent(snap_hndl)) != Z_OK)
+	if ((res = zonecfg_setdevent(handle)) != Z_OK)
 		goto done;
 
-	while (zonecfg_getdevent(snap_hndl, &dtab) == Z_OK) {
+	while (zonecfg_getdevent(handle, &dtab) == Z_OK) {
 		struct zone_res_attrtab *rap;
 		char *match;
 
@@ -880,42 +871,15 @@
 			    rap->zone_res_attr_name, rap->zone_res_attr_value);
 	}
 
-	(void) zonecfg_enddevent(snap_hndl);
+	(void) zonecfg_enddevent(handle);
 
-	if ((res = zonecfg_setattrent(snap_hndl)) != Z_OK)
-		goto done;
-
-	while (zonecfg_getattrent(snap_hndl, &atab) == Z_OK) {
-		set_zonecfg_env("attr", NULL, atab.zone_attr_name,
-		    atab.zone_attr_value);
-	}
-
-	(void) zonecfg_endattrent(snap_hndl);
-
-	if (debug)
-		(void) setenv("_ZONEADMD_brand_debug", "1", 1);
-	else
-		(void) setenv("_ZONEADMD_brand_debug", "", 1);
-
 	res = Z_OK;
 
 done:
+	zonecfg_fini_handle(handle);
 	return (res);
 }
 
-void
-nwifent_free_attrs(struct zone_nwiftab *np)
-{
-	struct zone_res_attrtab *rap;
-
-	for (rap = np->zone_nwif_attrp; rap != NULL; ) {
-		struct zone_res_attrtab *tp = rap;
-
-		rap = rap->zone_res_attr_next;
-		free(tp);
-	}
-}
-
 /*
  * If retstr is not NULL, the output of the subproc is returned in the str,
  * otherwise it is output using zerror().  Any memory allocated for retstr
@@ -922,7 +886,7 @@
  * should be freed by the caller.
  */
 int
-do_subproc(zlog_t *zlogp, char *cmdbuf, char **retstr, boolean_t debug)
+do_subproc(zlog_t *zlogp, char *cmdbuf, char **retstr)
 {
 	char buf[1024];		/* arbitrary large amount */
 	char *inbuf;
@@ -941,7 +905,7 @@
 		inbuf = buf;
 	}
 
-	if (setup_subproc_env(debug) != Z_OK) {
+	if (setup_subproc_env() != Z_OK) {
 		zerror(zlogp, B_FALSE, "failed to setup environment");
 		return (-1);
 	}
@@ -954,13 +918,8 @@
 
 	while (fgets(inbuf, 1024, file) != NULL) {
 		if (retstr == NULL) {
-			if (zlogp != &logsys) {
-				int last = strlen(inbuf) - 1;
-
-				if (inbuf[last] == '\n')
-					inbuf[last] = '\0';
+			if (zlogp != &logsys)
 				zerror(zlogp, B_FALSE, "%s", inbuf);
-			}
 		} else {
 			char *p;
 
@@ -991,57 +950,16 @@
 }
 
 /*
- * Get the path for this zone's init(1M) (or equivalent) process. First look
- * for a zone-specific init-name attr, then get it from the brand.
- */
-static int
-get_initname(brand_handle_t bh, char *initname, int len)
-{
-	struct zone_attrtab a;
-
-	bzero(&a, sizeof (a));
-	(void) strlcpy(a.zone_attr_name, "init-name",
-	    sizeof (a.zone_attr_name));
-
-	if (zonecfg_lookup_attr(snap_hndl, &a) == Z_OK) {
-		(void) strlcpy(initname, a.zone_attr_value, len);
-		return (0);
-	}
-
-	return (brand_get_initname(bh, initname, len));
-}
-
-/*
- * Get the restart-init flag for this zone's init(1M) (or equivalent) process.
- * First look for a zone-specific restart-init attr, then get it from the brand.
- */
-static boolean_t
-restartinit(brand_handle_t bh)
-{
-	struct zone_attrtab a;
-
-	bzero(&a, sizeof (a));
-	(void) strlcpy(a.zone_attr_name, "restart-init",
-	    sizeof (a.zone_attr_name));
-
-	if (zonecfg_lookup_attr(snap_hndl, &a) == Z_OK) {
-		if (strcmp(a.zone_attr_value, "false") == 0)
-			return (B_FALSE);
-		return (B_TRUE);
-	}
-
-	return (brand_restartinit(bh));
-}
-
-/*
  * Get the app-svc-dependent flag for this zone's init process. This is a
  * zone-specific attr which controls the type of contract we create for the
  * zone's init. When true, the contract will include CT_PR_EV_EXIT in the fatal
  * set, so that when any service which is in the same contract exits, the init
  * application will be terminated.
+ *
+ * We use the global "snap_hndl", so no parameters get passed here.
  */
 static boolean_t
-is_app_svc_dep(brand_handle_t bh)
+is_app_svc_dep(void)
 {
 	struct zone_attrtab a;
 
@@ -1058,7 +976,7 @@
 }
 
 static int
-zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate, boolean_t debug)
+zone_bootup(zlog_t *zlogp, const char *bootargs, int zstate)
 {
 	zoneid_t zoneid;
 	struct stat st;
@@ -1074,7 +992,7 @@
 	boolean_t restart_init;
 	boolean_t app_svc_dep;
 
-	if (brand_prestatechg(zlogp, zstate, Z_BOOT, debug) != 0)
+	if (brand_prestatechg(zlogp, zstate, Z_BOOT) != 0)
 		return (-1);
 
 	if ((zoneid = getzoneidbyname(zone_name)) == -1) {
@@ -1117,7 +1035,7 @@
 	}
 
 	/* Get the path for this zone's init(1M) (or equivalent) process.  */
-	if (get_initname(bh, init_file, MAXPATHLEN) != 0) {
+	if (brand_get_initname(bh, init_file, MAXPATHLEN) != 0) {
 		zerror(zlogp, B_FALSE,
 		    "unable to determine zone's init(1M) location");
 		brand_close(bh);
@@ -1124,14 +1042,14 @@
 		goto bad;
 	}
 
-	/* See if we should restart init if it dies. */
-	restart_init = restartinit(bh);
+	/* See if this zone's brand should restart init if it dies. */
+	restart_init = brand_restartinit(bh);
 
 	/*
 	 * See if we need to setup contract dependencies between the zone's
 	 * primary application and any of its services.
 	 */
-	app_svc_dep = is_app_svc_dep(bh);
+	app_svc_dep = is_app_svc_dep();
 
 	brand_close(bh);
 
@@ -1157,9 +1075,11 @@
 		goto bad;
 	}
 
-	if ((st.st_mode & S_IFMT) == S_IFLNK) {
-		/* symlink, we'll have to wait and resolve when we boot */
-	} else if ((st.st_mode & S_IXUSR) == 0) {
+	/*
+	 * If a symlink, we'll have to wait and resolve when we boot,
+	 * otherwise check the executable bits now.
+	 */
+	if ((st.st_mode & S_IFMT) != S_IFLNK && (st.st_mode & S_IXUSR) == 0) {
 		zerror(zlogp, B_FALSE, "%s is not executable", initpath);
 		goto bad;
 	}
@@ -1185,7 +1105,7 @@
 	 * is booted.
 	 */
 	if ((strlen(cmdbuf) > EXEC_LEN) &&
-	    (do_subproc(zlogp, cmdbuf, NULL, debug) != Z_OK)) {
+	    (do_subproc(zlogp, cmdbuf, NULL) != Z_OK)) {
 		zerror(zlogp, B_FALSE, "%s failed", cmdbuf);
 		goto bad;
 	}
@@ -1223,7 +1143,7 @@
 		goto bad;
 	}
 
-	if (brand_poststatechg(zlogp, zstate, Z_BOOT, debug) != 0)
+	if (brand_poststatechg(zlogp, zstate, Z_BOOT) != 0)
 		goto bad;
 
 	/* Startup a thread to perform zfd logging/tty svc for the zone. */
@@ -1239,29 +1159,24 @@
 	 * If something goes wrong, we up the zones's state to the target
 	 * state, RUNNING, and then invoke the hook as if we're halting.
 	 */
-	(void) brand_poststatechg(zlogp, ZONE_STATE_RUNNING, Z_HALT, debug);
+	(void) brand_poststatechg(zlogp, ZONE_STATE_RUNNING, Z_HALT);
 
 	return (-1);
 }
 
 static int
-zone_halt(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting, int zstate,
-    boolean_t debug)
+zone_halt(zlog_t *zlogp, boolean_t unmount_cmd, boolean_t rebooting, int zstate)
 {
 	int err;
 
-	/*
-	 * If performing a scratch zone unmount then do not call the
-	 * state change hooks.
-	 */
 	if (unmount_cmd == B_FALSE &&
-	    brand_prestatechg(zlogp, zstate, Z_HALT, debug) != 0)
+	    brand_prestatechg(zlogp, zstate, Z_HALT) != 0)
 		return (-1);
 
 	/* Shutting down, stop the memcap thread */
 	destroy_mcap_thread();
 
-	if (vplat_teardown(zlogp, unmount_cmd, rebooting, debug) != 0) {
+	if (vplat_teardown(zlogp, unmount_cmd, rebooting) != 0) {
 		if (!bringup_failure_recovery)
 			zerror(zlogp, B_FALSE, "unable to destroy zone");
 		destroy_log_thread();
@@ -1272,7 +1187,7 @@
 	destroy_log_thread();
 
 	if (unmount_cmd == B_FALSE &&
-	    brand_poststatechg(zlogp, zstate, Z_HALT, debug) != 0)
+	    brand_poststatechg(zlogp, zstate, Z_HALT) != 0)
 		return (-1);
 
 	if ((err = zonecfg_destroy_snapshot(zone_name)) != Z_OK)
@@ -1279,9 +1194,6 @@
 		zerror(zlogp, B_FALSE, "destroying snapshot: %s",
 		    zonecfg_strerror(err));
 
-	zonecfg_fini_handle(snap_hndl);
-	snap_hndl = NULL;
-
 	return (0);
 }
 
@@ -1497,11 +1409,10 @@
 
 	zone_state_t zstate;
 	zone_cmd_t cmd;
-	boolean_t debug;
 	int init_status;
 	zone_cmd_arg_t *zargp;
 
-	boolean_t kernelcall = B_TRUE;
+	boolean_t kernelcall;
 
 	int rval = -1;
 	uint64_t uniqid;
@@ -1551,7 +1462,6 @@
 		goto out;
 	}
 	cmd = zargp->cmd;
-	debug = zargp->debug;
 	init_status = zargp->status;
 
 	if (door_ucred(&uc) != 0) {
@@ -1659,7 +1569,7 @@
 	case ZONE_STATE_INSTALLED:
 		switch (cmd) {
 		case Z_READY:
-			rval = zone_ready(zlogp, Z_MNT_BOOT, zstate, debug);
+			rval = zone_ready(zlogp, Z_MNT_BOOT, zstate);
 			if (rval == 0)
 				eventstream_write(Z_EVT_ZONE_READIED);
 			zcons_statechanged();
@@ -1667,10 +1577,10 @@
 		case Z_BOOT:
 		case Z_FORCEBOOT:
 			eventstream_write(Z_EVT_ZONE_BOOTING);
-			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
-			    debug)) == 0) {
+			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate))
+			    == 0) {
 				rval = zone_bootup(zlogp, zargp->bootbuf,
-				    zstate, debug);
+				    zstate);
 			}
 			audit_put_record(zlogp, uc, rval, "boot");
 			zcons_statechanged();
@@ -1677,7 +1587,7 @@
 			if (rval != 0) {
 				bringup_failure_recovery = B_TRUE;
 				(void) zone_halt(zlogp, B_FALSE, B_FALSE,
-				    zstate, debug);
+				    zstate);
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 			}
 			break;
@@ -1729,7 +1639,7 @@
 
 			rval = zone_ready(zlogp,
 			    strcmp(zargp->bootbuf, "-U") == 0 ?
-			    Z_MNT_UPDATE : Z_MNT_SCRATCH, zstate, debug);
+			    Z_MNT_UPDATE : Z_MNT_SCRATCH, zstate);
 			if (rval != 0)
 				break;
 
@@ -1791,18 +1701,16 @@
 			rval = 0;
 			break;
 		case Z_BOOT:
-		case Z_FORCEBOOT:
 			(void) strlcpy(boot_args, zargp->bootbuf,
 			    sizeof (boot_args));
 			eventstream_write(Z_EVT_ZONE_BOOTING);
-			rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
-			    debug);
+			rval = zone_bootup(zlogp, zargp->bootbuf, zstate);
 			audit_put_record(zlogp, uc, rval, "boot");
 			zcons_statechanged();
 			if (rval != 0) {
 				bringup_failure_recovery = B_TRUE;
 				(void) zone_halt(zlogp, B_FALSE, B_TRUE,
-				    zstate, debug);
+				    zstate);
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 			}
 			boot_args[0] = '\0';
@@ -1810,8 +1718,8 @@
 		case Z_HALT:
 			if (kernelcall)	/* Invalid; can't happen */
 				abort();
-			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
-			    debug)) != 0)
+			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate))
+			    != 0)
 				break;
 			zcons_statechanged();
 			eventstream_write(Z_EVT_ZONE_HALTED);
@@ -1820,7 +1728,6 @@
 		case Z_REBOOT:
 		case Z_NOTE_UNINSTALLING:
 		case Z_MOUNT:
-		case Z_FORCEMOUNT:
 		case Z_UNMOUNT:
 			if (kernelcall)	/* Invalid; can't happen */
 				abort();
@@ -1837,7 +1744,7 @@
 		case Z_UNMOUNT:
 			if (kernelcall)	/* Invalid; can't happen */
 				abort();
-			rval = zone_halt(zlogp, B_TRUE, B_FALSE, zstate, debug);
+			rval = zone_halt(zlogp, B_TRUE, B_FALSE, zstate);
 			if (rval == 0) {
 				eventstream_write(Z_EVT_ZONE_HALTED);
 				(void) sema_post(&scratch_sem);
@@ -1859,18 +1766,16 @@
 	case ZONE_STATE_DOWN:
 		switch (cmd) {
 		case Z_READY:
-			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
-			    debug)) != 0)
+			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate))
+			    != 0)
 				break;
 			zcons_statechanged();
-			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
-			    debug)) == 0)
+			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate)) == 0)
 				eventstream_write(Z_EVT_ZONE_READIED);
 			else
 				eventstream_write(Z_EVT_ZONE_HALTED);
 			break;
 		case Z_BOOT:
-		case Z_FORCEBOOT:
 			/*
 			 * We could have two clients racing to boot this
 			 * zone; the second client loses, but his request
@@ -1886,8 +1791,8 @@
 			} else {
 				log_init_exit(-1);
 			}
-			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
-			    debug)) != 0)
+			if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate))
+			    != 0)
 				break;
 			eventstream_write(Z_EVT_ZONE_HALTED);
 			zcons_statechanged();
@@ -1896,25 +1801,24 @@
 			(void) strlcpy(boot_args, zargp->bootbuf,
 			    sizeof (boot_args));
 			eventstream_write(Z_EVT_ZONE_REBOOTING);
-			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
-			    debug)) != 0) {
+			if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate))
+			    != 0) {
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 				boot_args[0] = '\0';
 				break;
 			}
 			zcons_statechanged();
-			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
-			    debug)) != 0) {
+			if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate)) !=
+			    0) {
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 				boot_args[0] = '\0';
 				break;
 			}
-			rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
-			    debug);
+			rval = zone_bootup(zlogp, zargp->bootbuf, zstate);
 			audit_put_record(zlogp, uc, rval, "reboot");
 			if (rval != 0) {
 				(void) zone_halt(zlogp, B_FALSE, B_TRUE,
-				    zstate, debug);
+				    zstate);
 				eventstream_write(Z_EVT_ZONE_BOOTFAILED);
 			}
 			boot_args[0] = '\0';
@@ -1926,7 +1830,6 @@
 			break;
 		case Z_NOTE_UNINSTALLING:
 		case Z_MOUNT:
-		case Z_FORCEMOUNT:
 		case Z_UNMOUNT:
 			zerror(zlogp, B_FALSE, "%s operation is invalid "
 			    "for zones in state '%s'", z_cmd_name(cmd),
@@ -2135,52 +2038,6 @@
 }
 
 /*
- * Run the query hook with the 'env' parameter.  It should return a
- * string of tab-delimited key-value pairs, each of which should be set
- * in the environment.
- *
- * Because the env_vars string values become part of the environment, the
- * string is static and we don't free it.
- *
- * This function is always called before zoneadmd forks and makes itself
- * exclusive, so it is possible there could more than one instance of zoneadmd
- * running in parallel at this point. Thus, we have no zonecfg snapshot and
- * shouldn't take one yet (i.e. snap_hndl is NULL). Thats ok, since we don't
- * need any zonecfg info to query for a brand-specific env value.
- */
-static int
-set_brand_env(zlog_t *zlogp)
-{
-	int ret = 0;
-	static char *env_vars = NULL;
-	char buf[2 * MAXPATHLEN];
-
-	if (query_hook[0] == '\0' || env_vars != NULL)
-		return (0);
-
-	if (snprintf(buf, sizeof (buf), "%s env", query_hook) > sizeof (buf))
-		return (-1);
-
-	if (do_subproc(zlogp, buf, &env_vars, B_FALSE) != 0)
-		return (-1);
-
-	if (env_vars != NULL) {
-		char *sp;
-
-		sp = strtok(env_vars, "\t");
-		while (sp != NULL) {
-			if (putenv(sp) != 0) {
-				ret = -1;
-				break;
-			}
-			sp = strtok(NULL, "\t");
-		}
-	}
-
-	return (ret);
-}
-
-/*
  * Setup the brand's pre and post state change callbacks, as well as the
  * query callback, if any of these exist.
  */
@@ -2416,11 +2273,6 @@
 	}
 	priv_freeset(privset);
 
-	if (set_brand_env(zlogp) != 0) {
-		zerror(zlogp, B_FALSE, "Unable to setup brand's environment");
-		return (1);
-	}
-
 	if (mkzonedir(zlogp) != 0)
 		return (1);
 
