Print this page
@@ -78,11 +78,10 @@
#include <sys/systeminfo.h>
#include <libdladm.h>
#include <libinetutil.h>
#include <pwd.h>
#include <inet/ip.h>
-#include <uuid/uuid.h>
#include <libzonecfg.h>
#include "zonecfg.h"
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
@@ -126,11 +125,11 @@
#define SHELP_HELP "help [commands] [syntax] [usage] [<command-name>]"
#define SHELP_INFO "info [<resource-type> [property-name=property-value]*]"
#define SHELP_REMOVE "remove [-F] <resource-type> " \
"[ <property-name>=<property-value> ]*\n" \
"\t(global scope)\n" \
- "remove [-F] <property-name> <property-value>\n" \
+ "remove <property-name> <property-value>\n" \
"\t(resource scope)"
#define SHELP_REVERT "revert [-F]"
#define SHELP_SELECT "select <resource-type> { <property-name>=" \
"<property-value> }"
#define SHELP_SET "set <property-name>=<property-value>"
@@ -187,12 +186,10 @@
"capped-cpu",
"hostid",
"admin",
"fs-allowed",
ALIAS_MAXPROCS,
- ALIAS_ZFSPRI,
- "uuid",
NULL
};
/* These *must* match the order of the PT_ define's from zonecfg.h */
char *prop_types[] = {
@@ -241,11 +238,10 @@
ALIAS_ZFSPRI,
"mac-addr",
"vlan-id",
"global-nic",
"property",
- "uuid",
NULL
};
/* These *must* match the order of the PROP_VAL_ define's from zonecfg.h */
static char *prop_val_types[] = {
@@ -307,11 +303,10 @@
"clear " ALIAS_MAXSHMIDS,
"clear " ALIAS_MAXMSGIDS,
"clear " ALIAS_MAXSEMIDS,
"clear " ALIAS_SHARES,
"clear " ALIAS_MAXPROCS,
- "clear " ALIAS_ZFSPRI,
NULL
};
static const char *remove_cmds[] = {
"remove fs ",
@@ -358,12 +353,10 @@
"set " ALIAS_MAXSEMIDS "=",
"set " ALIAS_SHARES "=",
"set hostid=",
"set fs-allowed=",
"set " ALIAS_MAXPROCS "=",
- "set " ALIAS_ZFSPRI "=",
- "set uuid=",
NULL
};
static const char *info_cmds[] = {
"info fs ",
@@ -392,11 +385,10 @@
"info cpu-shares",
"info hostid",
"info admin",
"info fs-allowed",
"info max-processes",
- "info uuid",
NULL
};
static const char *fs_res_scope_cmds[] = {
"add options ",
@@ -549,18 +541,16 @@
static zone_dochandle_t handle;
/* used all over the place */
static char zone[ZONENAME_MAX];
static char revert_zone[ZONENAME_MAX];
-static char new_uuid[UUID_PRINTABLE_STRING_LENGTH];
/* global brand operations */
static brand_handle_t brand;
/* set in modifying functions, checked in read_input() */
static boolean_t need_to_commit = B_FALSE;
-static boolean_t is_create = B_FALSE;
boolean_t saw_error;
/* set in yacc parser, checked in read_input() */
boolean_t newline_terminated;
@@ -998,12 +988,11 @@
return (-1);
}
static FILE *
-pager_open(void)
-{
+pager_open(void) {
FILE *newfp;
char *pager, *space;
pager = getenv("PAGER");
if (pager == NULL || *pager == '\0')
@@ -1025,12 +1014,11 @@
}
return (NULL);
}
static void
-pager_close(FILE *fp)
-{
+pager_close(FILE *fp) {
int status;
status = pclose(fp);
if (status == -1)
zerr(gettext("PAGER close failed (%s)."),
@@ -1281,17 +1269,15 @@
gettext("(to exit the zonecfg utility)"));
}
if (flags & HELP_USAGE) {
(void) fprintf(fp, "%s:\t%s %s\n", gettext("usage"),
execname, cmd_to_str(CMD_HELP));
- (void) fprintf(fp, "\t%s {-z <zone>|-u <uuid>}\t\t\t(%s)\n",
+ (void) fprintf(fp, "\t%s -z <zone>\t\t\t(%s)\n",
execname, gettext("interactive"));
- (void) fprintf(fp, "\t%s {-z <zone>|-u <uuid>} <command>\n",
+ (void) fprintf(fp, "\t%s -z <zone> <command>\n", execname);
+ (void) fprintf(fp, "\t%s -z <zone> -f <command-file>\n",
execname);
- (void) fprintf(fp,
- "\t%s {-z <zone>|-u <uuid>} -f <command-file>\n",
- execname);
}
if (flags & HELP_SUBCMDS) {
(void) fprintf(fp, "%s:\n\n", gettext("Commands"));
for (i = 0; i <= CMD_MAX; i++) {
(void) fprintf(fp, "%s\n", helptab[i].short_usage);
@@ -1375,14 +1361,10 @@
pt_to_str(PT_MAXMSGIDS));
(void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
pt_to_str(PT_MAXSEMIDS));
(void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
pt_to_str(PT_SHARES));
- (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
- pt_to_str(PT_UUID));
- (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
- pt_to_str(PT_ZFSPRI));
(void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s\n",
rt_to_str(RT_FS), pt_to_str(PT_DIR),
pt_to_str(PT_SPECIAL), pt_to_str(PT_RAW),
pt_to_str(PT_TYPE), pt_to_str(PT_OPTIONS));
(void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s, %s, %s %s\n",
@@ -1715,19 +1697,18 @@
char attach_path[MAXPATHLEN];
zone_dochandle_t tmphandle;
boolean_t force = B_FALSE;
boolean_t attach = B_FALSE;
boolean_t arg_err = B_FALSE;
- uuid_t uuid;
assert(cmd != NULL);
/* This is the default if no arguments are given. */
(void) strlcpy(zone_template, "SUNWdefault", sizeof (zone_template));
optind = 0;
- while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?a:bFt:X"))
+ while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?a:bFt:"))
!= EOF) {
switch (arg) {
case '?':
if (optopt == '?')
longer_usage(CMD_CREATE);
@@ -1813,18 +1794,13 @@
zone_perror(zone_template, err, B_TRUE);
return;
}
need_to_commit = B_TRUE;
- is_create = B_TRUE;
zonecfg_fini_handle(handle);
handle = tmphandle;
got_handle = B_TRUE;
-
- /* Allocate a new uuid for this new zone */
- uuid_generate(uuid);
- uuid_unparse(uuid, new_uuid);
}
/*
* This malloc()'s memory, which must be freed by the caller.
*/
@@ -1881,11 +1857,10 @@
char fsallowedp[ZONE_FS_ALLOWED_MAX];
char *limitpriv;
FILE *of;
boolean_t autoboot;
zone_iptype_t iptype;
- uuid_t uuid;
boolean_t need_to_close = B_FALSE;
boolean_t arg_err = B_FALSE;
assert(cmd != NULL);
@@ -1992,18 +1967,10 @@
sizeof (fsallowedp)) == Z_OK) {
(void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
pt_to_str(PT_FS_ALLOWED), fsallowedp);
}
- if (zonecfg_get_uuid(zone, uuid) == Z_OK && !uuid_is_null(uuid)) {
- char suuid[UUID_PRINTABLE_STRING_LENGTH];
-
- uuid_unparse(uuid, suuid);
- (void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
- pt_to_str(PT_UUID), suuid);
- }
-
if ((err = zonecfg_setfsent(handle)) != Z_OK) {
zone_perror(zone, err, B_FALSE);
goto done;
}
while (zonecfg_getfsent(handle, &fstab) == Z_OK) {
@@ -2467,33 +2434,22 @@
if (seen_name) {
zerr(gettext("%s already specified"),
pt_to_str(PT_NAME));
goto bad;
}
- if (strlcpy(np->zone_res_attr_name, cp->cp_value,
- sizeof (np->zone_res_attr_name)) >=
- sizeof (np->zone_res_attr_name)) {
- zerr(gettext("Input for %s is too long"),
- pt_to_str(PT_NAME));
- goto bad;
- }
+ (void) strlcpy(np->zone_res_attr_name, cp->cp_value,
+ sizeof (np->zone_res_attr_name));
seen_name = B_TRUE;
break;
case PT_VALUE:
if (seen_value) {
zerr(gettext("%s already specified"),
pt_to_str(PT_VALUE));
goto bad;
}
- if (strlcpy(np->zone_res_attr_value, cp->cp_value,
- sizeof (np->zone_res_attr_value)) >=
- sizeof (np->zone_res_attr_value)) {
- zerr(gettext("Input for %s is too long"),
- pt_to_str(PT_VALUE));
- goto bad;
- }
-
+ (void) strlcpy(np->zone_res_attr_value, cp->cp_value,
+ sizeof (np->zone_res_attr_value));
seen_value = B_TRUE;
break;
default:
zone_perror(pt_to_str(PT_NPROP), Z_NO_PROPERTY_TYPE,
B_TRUE);
@@ -2665,20 +2621,20 @@
static boolean_t
gz_invalid_rt_property(int type)
{
return (global_zone && (type == RT_ZONENAME || type == RT_ZONEPATH ||
- type == RT_AUTOBOOT || type == RT_LIMITPRIV || type == RT_UUID ||
+ type == RT_AUTOBOOT || type == RT_LIMITPRIV ||
type == RT_BOOTARGS || type == RT_BRAND || type == RT_SCHED ||
type == RT_IPTYPE || type == RT_HOSTID || type == RT_FS_ALLOWED));
}
static boolean_t
gz_invalid_property(int type)
{
return (global_zone && (type == PT_ZONENAME || type == PT_ZONEPATH ||
- type == PT_AUTOBOOT || type == PT_LIMITPRIV || type == PT_UUID ||
+ type == PT_AUTOBOOT || type == PT_LIMITPRIV ||
type == PT_BOOTARGS || type == PT_BRAND || type == PT_SCHED ||
type == PT_IPTYPE || type == PT_HOSTID || type == PT_FS_ALLOWED));
}
void
@@ -2892,36 +2848,10 @@
if (fill_in_only)
return (Z_OK);
return (zonecfg_lookup_filesystem(handle, fstab));
}
-/*
- * Turn an addr that looks like f:2:0:44:5:6C into 0f:02:00:44:05:6c
- * We're expecting a dst of at least MAXMACADDRLEN size here.
- */
-static void
-normalize_mac_addr(char *dst, const char *src, int len)
-{
- char *p, *e, *sep = "";
- long n;
- char buf[MAXMACADDRLEN], tmp[4];
-
- *dst = '\0';
- (void) strlcpy(buf, src, sizeof (buf));
- p = strtok(buf, ":");
- while (p != NULL) {
- n = strtol(p, &e, 16);
- if (*e != NULL || n > 0xff)
- return;
- (void) snprintf(tmp, sizeof (tmp), "%s%02x", sep, n);
- (void) strlcat(dst, tmp, len);
-
- sep = ":";
- p = strtok(NULL, ":");
- }
-}
-
static int
fill_in_nwiftab(cmd_t *cmd, struct zone_nwiftab *nwiftab,
boolean_t fill_in_only)
{
int err, i;
@@ -2952,11 +2882,11 @@
(void) strlcpy(nwiftab->zone_nwif_physical,
pp->pv_simple,
sizeof (nwiftab->zone_nwif_physical));
break;
case PT_MAC:
- normalize_mac_addr(nwiftab->zone_nwif_mac,
+ (void) strlcpy(nwiftab->zone_nwif_mac,
pp->pv_simple,
sizeof (nwiftab->zone_nwif_mac));
break;
case PT_VLANID:
(void) strlcpy(nwiftab->zone_nwif_vlan_id,
@@ -3216,12 +3146,10 @@
num = zonecfg_num_resources(handle, rsrc);
if (num == 0) {
- if (force)
- return (B_TRUE);
z_cmd_rt_perror(CMD_REMOVE, cmd->cmd_res_type, Z_NO_ENTRY,
B_TRUE);
return (B_FALSE);
}
if (num > 1 && !force) {
@@ -3246,29 +3174,26 @@
}
return (B_TRUE);
}
static void
-remove_fs(cmd_t *cmd, boolean_t force)
+remove_fs(cmd_t *cmd)
{
int err;
/* traditional, qualified fs removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_fstab fstab;
if ((err = fill_in_fstab(cmd, &fstab, B_FALSE)) != Z_OK) {
- if (!force)
z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_filesystem(handle, &fstab)) != Z_OK) {
- if (!force)
+ if ((err = zonecfg_delete_filesystem(handle, &fstab)) != Z_OK)
z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
- } else {
+ else
need_to_commit = B_TRUE;
- }
zonecfg_free_fs_option_list(fstab.zone_fs_options);
return;
}
/*
@@ -3283,31 +3208,26 @@
else
need_to_commit = B_TRUE;
}
static void
-remove_net(cmd_t *cmd, boolean_t force)
+remove_net(cmd_t *cmd)
{
int err;
/* traditional, qualified net removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_nwiftab nwiftab;
if ((err = fill_in_nwiftab(cmd, &nwiftab, B_FALSE)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_NET, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_nwif(handle, &nwiftab)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_NET, err,
- B_TRUE);
- } else {
+ if ((err = zonecfg_delete_nwif(handle, &nwiftab)) != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
+ else
need_to_commit = B_TRUE;
- }
return;
}
/*
* unqualified net removal. remove all nets but prompt if more
@@ -3321,31 +3241,26 @@
else
need_to_commit = B_TRUE;
}
static void
-remove_device(cmd_t *cmd, boolean_t force)
+remove_device(cmd_t *cmd)
{
int err;
/* traditional, qualified device removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_devtab devtab;
if ((err = fill_in_devtab(cmd, &devtab, B_FALSE)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_dev(handle, &devtab)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err,
- B_TRUE);
- } else {
+ if ((err = zonecfg_delete_dev(handle, &devtab)) != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
+ else
need_to_commit = B_TRUE;
- }
return;
}
/*
* unqualified device removal. remove all devices but prompt if more
@@ -3359,31 +3274,26 @@
else
need_to_commit = B_TRUE;
}
static void
-remove_attr(cmd_t *cmd, boolean_t force)
+remove_attr(cmd_t *cmd)
{
int err;
/* traditional, qualified attr removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_attrtab attrtab;
if ((err = fill_in_attrtab(cmd, &attrtab, B_FALSE)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_attr(handle, &attrtab)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err,
- B_TRUE);
- } else {
+ if ((err = zonecfg_delete_attr(handle, &attrtab)) != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
+ else
need_to_commit = B_TRUE;
- }
return;
}
/*
* unqualified attr removal. remove all attrs but prompt if more
@@ -3397,31 +3307,26 @@
else
need_to_commit = B_TRUE;
}
static void
-remove_dataset(cmd_t *cmd, boolean_t force)
+remove_dataset(cmd_t *cmd)
{
int err;
/* traditional, qualified dataset removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_dstab dstab;
if ((err = fill_in_dstab(cmd, &dstab, B_FALSE)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_ds(handle, &dstab)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err,
- B_TRUE);
- } else {
+ if ((err = zonecfg_delete_ds(handle, &dstab)) != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
+ else
need_to_commit = B_TRUE;
- }
return;
}
/*
* unqualified dataset removal. remove all datasets but prompt if more
@@ -3435,31 +3340,26 @@
else
need_to_commit = B_TRUE;
}
static void
-remove_rctl(cmd_t *cmd, boolean_t force)
+remove_rctl(cmd_t *cmd)
{
int err;
/* traditional, qualified rctl removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_rctltab rctltab;
if ((err = fill_in_rctltab(cmd, &rctltab, B_FALSE)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_rctl(handle, &rctltab)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err,
- B_TRUE);
- } else {
+ if ((err = zonecfg_delete_rctl(handle, &rctltab)) != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
+ else
need_to_commit = B_TRUE;
- }
zonecfg_free_rctl_value_list(rctltab.zone_rctl_valptr);
return;
}
/*
@@ -3474,54 +3374,46 @@
else
need_to_commit = B_TRUE;
}
static void
-remove_pset(boolean_t force)
+remove_pset()
{
int err;
struct zone_psettab psettab;
if ((err = zonecfg_lookup_pset(handle, &psettab)) != Z_OK) {
- if (!force)
z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
return;
}
- if ((err = zonecfg_delete_pset(handle)) != Z_OK) {
- if (!force)
+ if ((err = zonecfg_delete_pset(handle)) != Z_OK)
z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
- } else {
+ else
need_to_commit = B_TRUE;
- }
}
static void
-remove_pcap(boolean_t force)
+remove_pcap()
{
int err;
uint64_t tmp;
if (zonecfg_get_aliased_rctl(handle, ALIAS_CPUCAP, &tmp) != Z_OK) {
- if (!force) {
- zerr("%s %s: %s", cmd_to_str(CMD_REMOVE),
- rt_to_str(RT_PCAP),
+ zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_PCAP),
zonecfg_strerror(Z_NO_RESOURCE_TYPE));
saw_error = B_TRUE;
- }
return;
}
- if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_CPUCAP)) != Z_OK) {
- if (!force)
+ if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_CPUCAP)) != Z_OK)
z_cmd_rt_perror(CMD_REMOVE, RT_PCAP, err, B_TRUE);
- } else {
+ else
need_to_commit = B_TRUE;
- }
}
static void
-remove_mcap(boolean_t force)
+remove_mcap()
{
int err, res1, res2, res3;
uint64_t tmp;
boolean_t revert = B_FALSE;
@@ -3529,51 +3421,39 @@
res2 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP, &tmp);
res3 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM, &tmp);
/* if none of these exist, there is no resource to remove */
if (res1 != Z_OK && res2 != Z_OK && res3 != Z_OK) {
- if (!force) {
- zerr("%s %s: %s", cmd_to_str(CMD_REMOVE),
- rt_to_str(RT_MCAP),
+ zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_MCAP),
zonecfg_strerror(Z_NO_RESOURCE_TYPE));
saw_error = B_TRUE;
- }
return;
}
if (res1 == Z_OK) {
if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXPHYSMEM))
!= Z_OK) {
- if (!force) {
- z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
revert = B_TRUE;
- }
} else {
need_to_commit = B_TRUE;
}
}
if (res2 == Z_OK) {
if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXSWAP))
!= Z_OK) {
- if (!force) {
- z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
revert = B_TRUE;
- }
} else {
need_to_commit = B_TRUE;
}
}
if (res3 == Z_OK) {
if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM))
!= Z_OK) {
- if (!force) {
- z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
revert = B_TRUE;
- }
} else {
need_to_commit = B_TRUE;
}
}
@@ -3580,55 +3460,55 @@
if (revert)
need_to_commit = B_FALSE;
}
static void
-remove_admin(cmd_t *cmd, boolean_t force)
+remove_admin(cmd_t *cmd)
{
int err;
/* traditional, qualified attr removal */
if (cmd->cmd_prop_nv_pairs > 0) {
struct zone_admintab admintab;
if ((err = fill_in_admintab(cmd, &admintab, B_FALSE)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err,
- B_TRUE);
+ z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
+ err, B_TRUE);
return;
}
if ((err = zonecfg_delete_admin(handle, &admintab,
- zone)) != Z_OK) {
- if (!force)
- z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err,
- B_TRUE);
- } else {
+ zone))
+ != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
+ err, B_TRUE);
+ else
need_to_commit = B_TRUE;
- }
return;
- }
-
+ } else {
/*
* unqualified admin removal.
- * remove all admins but prompt if more than one.
+ * remove all admins but prompt if more
+ * than one.
*/
if (!prompt_remove_resource(cmd, "admin"))
return;
- if ((err = zonecfg_delete_admins(handle, zone)) != Z_OK)
- z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err, B_TRUE);
+ if ((err = zonecfg_delete_admins(handle, zone))
+ != Z_OK)
+ z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
+ err, B_TRUE);
else
need_to_commit = B_TRUE;
+ }
}
static void
remove_resource(cmd_t *cmd)
{
int type;
int arg;
boolean_t arg_err = B_FALSE;
- boolean_t force = B_FALSE;
if ((type = cmd->cmd_res_type) == RT_UNKNOWN) {
long_usage(CMD_REMOVE, B_TRUE);
return;
}
@@ -3639,11 +3519,10 @@
case '?':
longer_usage(CMD_REMOVE);
arg_err = B_TRUE;
break;
case 'F':
- force = B_TRUE;
break;
default:
short_usage(CMD_REMOVE);
arg_err = B_TRUE;
break;
@@ -3655,38 +3534,38 @@
if (initialize(B_TRUE) != Z_OK)
return;
switch (type) {
case RT_FS:
- remove_fs(cmd, force);
+ remove_fs(cmd);
return;
case RT_NET:
- remove_net(cmd, force);
+ remove_net(cmd);
return;
case RT_DEVICE:
- remove_device(cmd, force);
+ remove_device(cmd);
return;
case RT_RCTL:
- remove_rctl(cmd, force);
+ remove_rctl(cmd);
return;
case RT_ATTR:
- remove_attr(cmd, force);
+ remove_attr(cmd);
return;
case RT_DATASET:
- remove_dataset(cmd, force);
+ remove_dataset(cmd);
return;
case RT_DCPU:
- remove_pset(force);
+ remove_pset();
return;
case RT_PCAP:
- remove_pcap(force);
+ remove_pcap();
return;
case RT_MCAP:
- remove_mcap(force);
+ remove_mcap();
return;
case RT_ADMIN:
- remove_admin(cmd, force);
+ remove_admin(cmd);
return;
default:
zone_perror(rt_to_str(type), Z_NO_RESOURCE_TYPE, B_TRUE);
long_usage(CMD_REMOVE, B_TRUE);
usage(B_FALSE, HELP_RESOURCES);
@@ -3701,30 +3580,11 @@
int err, res_type, prop_type;
property_value_ptr_t pp;
struct zone_rctlvaltab *rctlvaltab;
struct zone_res_attrtab *np;
complex_property_ptr_t cx;
- int arg;
- boolean_t force = B_FALSE;
- boolean_t arg_err = B_FALSE;
- optind = 0;
- while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "F")) != EOF) {
- switch (arg) {
- case 'F':
- force = B_TRUE;
- break;
- default:
- arg_err = B_TRUE;
- break;
- }
- }
- if (arg_err) {
- saw_error = B_TRUE;
- return;
- }
-
res_type = resource_scope;
prop_type = cmd->cmd_prop_name[0];
if (res_type == RT_UNKNOWN || prop_type == PT_UNKNOWN) {
long_usage(CMD_REMOVE, B_TRUE);
return;
@@ -3761,11 +3621,11 @@
return;
}
prop_id = pp->pv_simple;
err = zonecfg_remove_fs_option(&in_progress_fstab,
prop_id);
- if (err != Z_OK && !force)
+ if (err != Z_OK)
zone_perror(pt_to_str(prop_type), err, B_TRUE);
} else {
list_property_ptr_t list;
for (list = pp->pv_list; list != NULL;
@@ -3773,11 +3633,11 @@
prop_id = list->lp_simple;
if (prop_id == NULL)
break;
err = zonecfg_remove_fs_option(
&in_progress_fstab, prop_id);
- if (err != Z_OK && !force)
+ if (err != Z_OK)
zone_perror(pt_to_str(prop_type), err,
B_TRUE);
}
}
return;
@@ -3826,11 +3686,11 @@
&(in_progress_nwiftab.zone_nwif_attrp), np);
} else { /* RT_DEVICE */
err = zonecfg_remove_res_attr(
&(in_progress_devtab.zone_dev_attrp), np);
}
- if (err != Z_OK && !force)
+ if (err != Z_OK)
zone_perror(pt_to_str(prop_type), err, B_TRUE);
return;
case RT_RCTL:
if (prop_type != PT_VALUE) {
zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
@@ -3877,11 +3737,11 @@
}
}
rctlvaltab->zone_rctlval_next = NULL;
err = zonecfg_remove_rctl_value(&in_progress_rctltab,
rctlvaltab);
- if (err != Z_OK && !force)
+ if (err != Z_OK)
zone_perror(pt_to_str(prop_type), err, B_TRUE);
zonecfg_free_rctl_value_list(rctlvaltab);
return;
default:
zone_perror(rt_to_str(res_type), Z_NO_RESOURCE_TYPE, B_TRUE);
@@ -4002,12 +3862,10 @@
switch (type) {
case PT_ZONENAME:
/* FALLTHRU */
case PT_ZONEPATH:
/* FALLTHRU */
- case PT_UUID:
- /* FALLTHRU */
case PT_BRAND:
zone_perror(pt_to_str(type), Z_CLEAR_DISALLOW, B_TRUE);
return;
case PT_AUTOBOOT:
/* false is default; we'll treat as equivalent to clearing */
@@ -4066,13 +3924,10 @@
remove_aliased_rctl(PT_MAXSEMIDS, ALIAS_MAXSEMIDS);
return;
case PT_SHARES:
remove_aliased_rctl(PT_SHARES, ALIAS_SHARES);
return;
- case PT_ZFSPRI:
- remove_aliased_rctl(PT_ZFSPRI, ALIAS_ZFSPRI);
- return;
case PT_HOSTID:
if ((err = zonecfg_set_hostid(handle, NULL)) != Z_OK)
z_cmd_rt_perror(CMD_CLEAR, RT_HOSTID, err, B_TRUE);
else
need_to_commit = B_TRUE;
@@ -4559,14 +4414,10 @@
res_type = RT_SHARES;
} else if (prop_type == PT_HOSTID) {
res_type = RT_HOSTID;
} else if (prop_type == PT_FS_ALLOWED) {
res_type = RT_FS_ALLOWED;
- } else if (prop_type == PT_ZFSPRI) {
- res_type = RT_ZFSPRI;
- } else if (prop_type == PT_UUID) {
- res_type = RT_UUID;
} else {
zerr(gettext("Cannot set a resource-specific property "
"from the global scope."));
saw_error = B_TRUE;
return;
@@ -4770,13 +4621,10 @@
set_aliased_rctl(ALIAS_MAXSEMIDS, prop_type, prop_id);
return;
case RT_SHARES:
set_aliased_rctl(ALIAS_SHARES, prop_type, prop_id);
return;
- case RT_ZFSPRI:
- set_aliased_rctl(ALIAS_ZFSPRI, prop_type, prop_id);
- return;
case RT_HOSTID:
if ((err = zonecfg_set_hostid(handle, prop_id)) != Z_OK) {
if (err == Z_TOO_BIG) {
zerr(gettext("hostid string is too large: %s"),
prop_id);
@@ -4786,19 +4634,10 @@
}
return;
}
need_to_commit = B_TRUE;
return;
- case RT_UUID:
- /*
- * We can't set here. We have to wait until commit since the
- * uuid will be updating the index file and we may not have
- * created the zone yet.
- */
- (void) strlcpy(new_uuid, prop_id, sizeof (new_uuid));
- need_to_commit = B_TRUE;
- return;
case RT_FS_ALLOWED:
if ((err = zonecfg_set_fs_allowed(handle, prop_id)) != Z_OK)
zone_perror(zone, err, B_TRUE);
else
need_to_commit = B_TRUE;
@@ -4870,11 +4709,11 @@
(void) strlcpy(in_progress_nwiftab.zone_nwif_physical,
prop_id,
sizeof (in_progress_nwiftab.zone_nwif_physical));
break;
case PT_MAC:
- normalize_mac_addr(in_progress_nwiftab.zone_nwif_mac,
+ (void) strlcpy(in_progress_nwiftab.zone_nwif_mac,
prop_id,
sizeof (in_progress_nwiftab.zone_nwif_mac));
break;
case PT_VLANID:
(void) strlcpy(in_progress_nwiftab.zone_nwif_vlan_id,
@@ -5395,27 +5234,10 @@
zone_perror(zone, err, B_TRUE);
}
}
static void
-info_uuid(FILE *fp)
-{
- uuid_t uuid;
- char suuid[UUID_PRINTABLE_STRING_LENGTH];
-
- if (new_uuid[0] != '\0') {
- (void) fprintf(fp, "%s: %s\n", pt_to_str(PT_UUID), new_uuid);
- } else if (zonecfg_get_uuid(zone, uuid) == Z_OK &&
- !uuid_is_null(uuid)) {
- uuid_unparse(uuid, suuid);
- (void) fprintf(fp, "%s: %s\n", pt_to_str(PT_UUID), suuid);
- } else {
- (void) fprintf(fp, "%s:\n", pt_to_str(PT_UUID));
- }
-}
-
-static void
info_fs_allowed(zone_dochandle_t handle, FILE *fp)
{
char fsallowedp[ZONE_FS_ALLOWED_MAX];
int err;
@@ -5921,11 +5743,10 @@
int type;
int res1, res2, res3;
uint64_t swap_limit;
uint64_t locked_limit;
uint64_t phys_limit;
- struct stat statbuf;
assert(cmd != NULL);
if (initialize(B_TRUE) != Z_OK)
return;
@@ -6011,20 +5832,18 @@
info_limitpriv(handle, fp);
info_sched(handle, fp);
info_iptype(handle, fp);
info_hostid(handle, fp);
info_fs_allowed(handle, fp);
- info_uuid(fp);
}
info_aliased_rctl(handle, fp, ALIAS_MAXLWPS);
info_aliased_rctl(handle, fp, ALIAS_MAXPROCS);
info_aliased_rctl(handle, fp, ALIAS_MAXSHMMEM);
info_aliased_rctl(handle, fp, ALIAS_MAXSHMIDS);
info_aliased_rctl(handle, fp, ALIAS_MAXMSGIDS);
info_aliased_rctl(handle, fp, ALIAS_MAXSEMIDS);
info_aliased_rctl(handle, fp, ALIAS_SHARES);
- info_aliased_rctl(handle, fp, ALIAS_ZFSPRI);
if (!global_zone) {
info_fs(handle, fp, cmd);
info_net(handle, fp, cmd);
info_dev(handle, fp, cmd);
}
@@ -6084,13 +5903,10 @@
info_aliased_rctl(handle, fp, ALIAS_MAXSEMIDS);
break;
case RT_SHARES:
info_aliased_rctl(handle, fp, ALIAS_SHARES);
break;
- case RT_ZFSPRI:
- info_aliased_rctl(handle, fp, ALIAS_ZFSPRI);
- break;
case RT_FS:
info_fs(handle, fp, cmd);
break;
case RT_NET:
info_net(handle, fp, cmd);
@@ -6117,13 +5933,10 @@
info_mcap(handle, fp);
break;
case RT_HOSTID:
info_hostid(handle, fp);
break;
- case RT_UUID:
- info_uuid(fp);
- break;
case RT_ADMIN:
info_auth(handle, fp, cmd);
break;
case RT_FS_ALLOWED:
info_fs_allowed(handle, fp);
@@ -6611,28 +6424,11 @@
if ((ret_val = zonecfg_save(handle)) == Z_OK) {
need_to_commit = B_FALSE;
(void) strlcpy(revert_zone, zone,
sizeof (revert_zone));
-
- if (is_create) {
- zonecfg_notify_create(handle);
- is_create = B_FALSE;
}
- }
-
- /*
- * Commit a new uuid at this point since we now know the
- * zone index entry will exist.
- */
- if (new_uuid[0] != '\0') {
- if ((err = zonecfg_set_uuid(zone, zonepath,
- new_uuid)) != Z_OK)
- zone_perror(zone, err, B_FALSE);
- else
- new_uuid[0] = '\0';
- }
} else {
zerr(gettext("Zone %s failed to verify"), zone);
}
}
if (ret_val != Z_OK)
@@ -7678,14 +7474,12 @@
}
int
main(int argc, char *argv[])
{
- int err, arg, uflag = 0, zflag = 0;
+ int err, arg;
struct stat st;
- uuid_t uuidin;
- char zonename[ZONENAME_MAX + 1];
/* This must be before anything goes to stdout. */
setbuf(stdout, NULL);
saw_error = B_FALSE;
@@ -7708,11 +7502,11 @@
if (strcmp(argv[1], cmd_to_str(CMD_HELP)) == 0) {
(void) one_command_at_a_time(argc - 1, &(argv[1]));
exit(Z_OK);
}
- while ((arg = getopt(argc, argv, "?f:R:z:u:")) != EOF) {
+ while ((arg = getopt(argc, argv, "?f:R:z:")) != EOF) {
switch (arg) {
case '?':
if (optopt == '?')
usage(B_TRUE, HELP_USAGE | HELP_SUBCMDS);
else
@@ -7735,25 +7529,10 @@
optarg);
exit(Z_USAGE);
}
zonecfg_set_root(optarg);
break;
- case 'u':
- if (uuid_parse((char *)optarg, uuidin) == -1)
- return (Z_INVALID_PROPERTY);
-
- if (zonecfg_get_name_by_uuid(uuidin, zonename,
- ZONENAME_MAX) != Z_OK) {
- zone_perror(optarg, Z_BOGUS_ZONE_NAME, B_TRUE);
- usage(B_FALSE, HELP_SYNTAX);
- exit(Z_USAGE);
- }
-
- (void) strlcpy(zone, zonename, sizeof (zone));
- (void) strlcpy(revert_zone, zonename, sizeof (zone));
- uflag = 1;
- break;
case 'z':
if (strcmp(optarg, GLOBAL_ZONENAME) == 0) {
global_zone = B_TRUE;
} else if (zonecfg_validate_zonename(optarg) != Z_OK) {
zone_perror(optarg, Z_BOGUS_ZONE_NAME, B_TRUE);
@@ -7760,19 +7539,18 @@
usage(B_FALSE, HELP_SYNTAX);
exit(Z_USAGE);
}
(void) strlcpy(zone, optarg, sizeof (zone));
(void) strlcpy(revert_zone, optarg, sizeof (zone));
- zflag = 1;
break;
default:
usage(B_FALSE, HELP_USAGE);
exit(Z_USAGE);
}
}
- if (optind > argc || strcmp(zone, "") == 0 || (uflag && zflag)) {
+ if (optind > argc || strcmp(zone, "") == 0) {
usage(B_FALSE, HELP_USAGE);
exit(Z_USAGE);
}
if ((err = zonecfg_access(zone, W_OK)) == Z_OK) {