Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zonecfg/zonecfg.c
          +++ new/usr/src/cmd/zonecfg/zonecfg.c
↓ open down ↓ 72 lines elided ↑ open up ↑
  73   73  #include <wait.h>
  74   74  #include <libtecla.h>
  75   75  #include <libzfs.h>
  76   76  #include <sys/brand.h>
  77   77  #include <libbrand.h>
  78   78  #include <sys/systeminfo.h>
  79   79  #include <libdladm.h>
  80   80  #include <libinetutil.h>
  81   81  #include <pwd.h>
  82   82  #include <inet/ip.h>
  83      -#include <uuid/uuid.h>
  84   83  
  85   84  #include <libzonecfg.h>
  86   85  #include "zonecfg.h"
  87   86  
  88   87  #if !defined(TEXT_DOMAIN)               /* should be defined by cc -D */
  89   88  #define TEXT_DOMAIN     "SYS_TEST"      /* Use this only if it wasn't */
  90   89  #endif
  91   90  
  92   91  #define PAGER   "/usr/bin/more"
  93   92  #define EXEC_PREFIX     "exec "
↓ open down ↓ 27 lines elided ↑ open up ↑
 121  120  #define SHELP_CREATE    "create [-F] [ -a <path> | -b | -t <template> ]"
 122  121  #define SHELP_DELETE    "delete [-F]"
 123  122  #define SHELP_END       "end"
 124  123  #define SHELP_EXIT      "exit [-F]"
 125  124  #define SHELP_EXPORT    "export [-f output-file]"
 126  125  #define SHELP_HELP      "help [commands] [syntax] [usage] [<command-name>]"
 127  126  #define SHELP_INFO      "info [<resource-type> [property-name=property-value]*]"
 128  127  #define SHELP_REMOVE    "remove [-F] <resource-type> " \
 129  128          "[ <property-name>=<property-value> ]*\n" \
 130  129          "\t(global scope)\n" \
 131      -        "remove [-F] <property-name> <property-value>\n" \
      130 +        "remove <property-name> <property-value>\n" \
 132  131          "\t(resource scope)"
 133  132  #define SHELP_REVERT    "revert [-F]"
 134  133  #define SHELP_SELECT    "select <resource-type> { <property-name>=" \
 135  134          "<property-value> }"
 136  135  #define SHELP_SET       "set <property-name>=<property-value>"
 137  136  #define SHELP_VERIFY    "verify"
 138  137  
 139  138  static struct help helptab[] = {
 140  139          { CMD_ADD,      "add",          HELP_RES_PROPS, SHELP_ADD, },
 141  140          { CMD_CANCEL,   "cancel",       0,              SHELP_CANCEL, },
↓ open down ↓ 40 lines elided ↑ open up ↑
 182  181          ALIAS_MAXMSGIDS,
 183  182          ALIAS_MAXSEMIDS,
 184  183          ALIAS_SHARES,
 185  184          "scheduling-class",
 186  185          "ip-type",
 187  186          "capped-cpu",
 188  187          "hostid",
 189  188          "admin",
 190  189          "fs-allowed",
 191  190          ALIAS_MAXPROCS,
 192      -        ALIAS_ZFSPRI,
 193      -        "uuid",
 194  191          NULL
 195  192  };
 196  193  
 197  194  /* These *must* match the order of the PT_ define's from zonecfg.h */
 198  195  char *prop_types[] = {
 199  196          "unknown",
 200  197          "zonename",
 201  198          "zonepath",
 202  199          "autoboot",
 203  200          "pool",
↓ open down ↓ 32 lines elided ↑ open up ↑
 236  233          "user",
 237  234          "auths",
 238  235          "fs-allowed",
 239  236          ALIAS_MAXPROCS,
 240  237          "allowed-address",
 241  238          ALIAS_ZFSPRI,
 242  239          "mac-addr",
 243  240          "vlan-id",
 244  241          "global-nic",
 245  242          "property",
 246      -        "uuid",
 247  243          NULL
 248  244  };
 249  245  
 250  246  /* These *must* match the order of the PROP_VAL_ define's from zonecfg.h */
 251  247  static char *prop_val_types[] = {
 252  248          "simple",
 253  249          "complex",
 254  250          "list",
 255  251  };
 256  252  
↓ open down ↓ 45 lines elided ↑ open up ↑
 302  298          "clear bootargs",
 303  299          "clear scheduling-class",
 304  300          "clear ip-type",
 305  301          "clear " ALIAS_MAXLWPS,
 306  302          "clear " ALIAS_MAXSHMMEM,
 307  303          "clear " ALIAS_MAXSHMIDS,
 308  304          "clear " ALIAS_MAXMSGIDS,
 309  305          "clear " ALIAS_MAXSEMIDS,
 310  306          "clear " ALIAS_SHARES,
 311  307          "clear " ALIAS_MAXPROCS,
 312      -        "clear " ALIAS_ZFSPRI,
 313  308          NULL
 314  309  };
 315  310  
 316  311  static const char *remove_cmds[] = {
 317  312          "remove fs ",
 318  313          "remove net ",
 319  314          "remove device ",
 320  315          "remove rctl ",
 321  316          "remove attr ",
 322  317          "remove dataset ",
↓ open down ↓ 30 lines elided ↑ open up ↑
 353  348          "set ip-type=",
 354  349          "set " ALIAS_MAXLWPS "=",
 355  350          "set " ALIAS_MAXSHMMEM "=",
 356  351          "set " ALIAS_MAXSHMIDS "=",
 357  352          "set " ALIAS_MAXMSGIDS "=",
 358  353          "set " ALIAS_MAXSEMIDS "=",
 359  354          "set " ALIAS_SHARES "=",
 360  355          "set hostid=",
 361  356          "set fs-allowed=",
 362  357          "set " ALIAS_MAXPROCS "=",
 363      -        "set " ALIAS_ZFSPRI "=",
 364      -        "set uuid=",
 365  358          NULL
 366  359  };
 367  360  
 368  361  static const char *info_cmds[] = {
 369  362          "info fs ",
 370  363          "info net ",
 371  364          "info device ",
 372  365          "info rctl ",
 373  366          "info attr ",
 374  367          "info dataset ",
↓ open down ↓ 12 lines elided ↑ open up ↑
 387  380          "info max-lwps",
 388  381          "info max-shm-memory",
 389  382          "info max-shm-ids",
 390  383          "info max-msg-ids",
 391  384          "info max-sem-ids",
 392  385          "info cpu-shares",
 393  386          "info hostid",
 394  387          "info admin",
 395  388          "info fs-allowed",
 396  389          "info max-processes",
 397      -        "info uuid",
 398  390          NULL
 399  391  };
 400  392  
 401  393  static const char *fs_res_scope_cmds[] = {
 402  394          "add options ",
 403  395          "cancel",
 404  396          "end",
 405  397          "exit",
 406  398          "help",
 407  399          "info",
↓ open down ↓ 136 lines elided ↑ open up ↑
 544  536  
 545  537  /* set early in main(), never modified thereafter, used all over the place */
 546  538  static char *execname;
 547  539  
 548  540  /* set in main(), used all over the place */
 549  541  static zone_dochandle_t handle;
 550  542  
 551  543  /* used all over the place */
 552  544  static char zone[ZONENAME_MAX];
 553  545  static char revert_zone[ZONENAME_MAX];
 554      -static char new_uuid[UUID_PRINTABLE_STRING_LENGTH];
 555  546  
 556  547  /* global brand operations */
 557  548  static brand_handle_t brand;
 558  549  
 559  550  /* set in modifying functions, checked in read_input() */
 560  551  static boolean_t need_to_commit = B_FALSE;
 561      -static boolean_t is_create = B_FALSE;
 562  552  boolean_t saw_error;
 563  553  
 564  554  /* set in yacc parser, checked in read_input() */
 565  555  boolean_t newline_terminated;
 566  556  
 567  557  /* set in main(), checked in lex error handler */
 568  558  boolean_t cmd_file_mode;
 569  559  
 570  560  /* set in exit_func(), checked in read_input() */
 571  561  static boolean_t time_to_exit = B_FALSE, force_exit = B_FALSE;
↓ open down ↓ 421 lines elided ↑ open up ↑
 993  983                  if (stat(fname, &stat_buf) != -1) {
 994  984                          /* successful find of the file */
 995  985                          return (0);
 996  986                  }
 997  987          } while (cp != NULL);
 998  988  
 999  989          return (-1);
1000  990  }
1001  991  
1002  992  static FILE *
1003      -pager_open(void)
1004      -{
      993 +pager_open(void) {
1005  994          FILE *newfp;
1006  995          char *pager, *space;
1007  996  
1008  997          pager = getenv("PAGER");
1009  998          if (pager == NULL || *pager == '\0')
1010  999                  pager = PAGER;
1011 1000  
1012 1001          space = strchr(pager, ' ');
1013 1002          if (space)
1014 1003                  *space = '\0';
↓ open down ↓ 5 lines elided ↑ open up ↑
1020 1009                              strerror(errno));
1021 1010                  return (newfp);
1022 1011          } else {
1023 1012                  zerr(gettext("PAGER %s does not exist (%s)."),
1024 1013                      pager, strerror(errno));
1025 1014          }
1026 1015          return (NULL);
1027 1016  }
1028 1017  
1029 1018  static void
1030      -pager_close(FILE *fp)
1031      -{
     1019 +pager_close(FILE *fp) {
1032 1020          int status;
1033 1021  
1034 1022          status = pclose(fp);
1035 1023          if (status == -1)
1036 1024                  zerr(gettext("PAGER close failed (%s)."),
1037 1025                      strerror(errno));
1038 1026  }
1039 1027  
1040 1028  /*
1041 1029   * Called with verbose TRUE when help is explicitly requested, FALSE for
↓ open down ↓ 234 lines elided ↑ open up ↑
1276 1264                  (void) fprintf(fp, "\t%s\t%s\n", cmd_to_str(CMD_END),
1277 1265                      gettext("(to conclude this operation)"));
1278 1266                  (void) fprintf(fp, "\t%s\t%s\n", cmd_to_str(CMD_CANCEL),
1279 1267                      gettext("(to cancel this operation)"));
1280 1268                  (void) fprintf(fp, "\t%s\t%s\n", cmd_to_str(CMD_EXIT),
1281 1269                      gettext("(to exit the zonecfg utility)"));
1282 1270          }
1283 1271          if (flags & HELP_USAGE) {
1284 1272                  (void) fprintf(fp, "%s:\t%s %s\n", gettext("usage"),
1285 1273                      execname, cmd_to_str(CMD_HELP));
1286      -                (void) fprintf(fp, "\t%s {-z <zone>|-u <uuid>}\t\t\t(%s)\n",
     1274 +                (void) fprintf(fp, "\t%s -z <zone>\t\t\t(%s)\n",
1287 1275                      execname, gettext("interactive"));
1288      -                (void) fprintf(fp, "\t%s {-z <zone>|-u <uuid>} <command>\n",
     1276 +                (void) fprintf(fp, "\t%s -z <zone> <command>\n", execname);
     1277 +                (void) fprintf(fp, "\t%s -z <zone> -f <command-file>\n",
1289 1278                      execname);
1290      -                (void) fprintf(fp,
1291      -                    "\t%s {-z <zone>|-u <uuid>} -f <command-file>\n",
1292      -                    execname);
1293 1279          }
1294 1280          if (flags & HELP_SUBCMDS) {
1295 1281                  (void) fprintf(fp, "%s:\n\n", gettext("Commands"));
1296 1282                  for (i = 0; i <= CMD_MAX; i++) {
1297 1283                          (void) fprintf(fp, "%s\n", helptab[i].short_usage);
1298 1284                          if (verbose)
1299 1285                                  (void) fprintf(fp, "\t%s\n\n", long_help(i));
1300 1286                  }
1301 1287          }
1302 1288          if (flags & HELP_SYNTAX) {
↓ open down ↓ 67 lines elided ↑ open up ↑
1370 1356                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1371 1357                      pt_to_str(PT_MAXSHMMEM));
1372 1358                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1373 1359                      pt_to_str(PT_MAXSHMIDS));
1374 1360                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1375 1361                      pt_to_str(PT_MAXMSGIDS));
1376 1362                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1377 1363                      pt_to_str(PT_MAXSEMIDS));
1378 1364                  (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1379 1365                      pt_to_str(PT_SHARES));
1380      -                (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1381      -                    pt_to_str(PT_UUID));
1382      -                (void) fprintf(fp, "\t%s\t%s\n", gettext("(global)"),
1383      -                    pt_to_str(PT_ZFSPRI));
1384 1366                  (void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s\n",
1385 1367                      rt_to_str(RT_FS), pt_to_str(PT_DIR),
1386 1368                      pt_to_str(PT_SPECIAL), pt_to_str(PT_RAW),
1387 1369                      pt_to_str(PT_TYPE), pt_to_str(PT_OPTIONS));
1388 1370                  (void) fprintf(fp, "\t%s\t\t%s, %s, %s, %s, %s, %s, %s %s\n",
1389 1371                      rt_to_str(RT_NET),
1390 1372                      pt_to_str(PT_ADDRESS), pt_to_str(PT_ALLOWED_ADDRESS),
1391 1373                      pt_to_str(PT_GNIC), pt_to_str(PT_MAC),
1392 1374                      pt_to_str(PT_PHYSICAL), pt_to_str(PT_NPROP),
1393 1375                      pt_to_str(PT_VLANID), pt_to_str(PT_DEFROUTER));
↓ open down ↓ 316 lines elided ↑ open up ↑
1710 1692  void
1711 1693  create_func(cmd_t *cmd)
1712 1694  {
1713 1695          int err, arg;
1714 1696          char zone_template[ZONENAME_MAX];
1715 1697          char attach_path[MAXPATHLEN];
1716 1698          zone_dochandle_t tmphandle;
1717 1699          boolean_t force = B_FALSE;
1718 1700          boolean_t attach = B_FALSE;
1719 1701          boolean_t arg_err = B_FALSE;
1720      -        uuid_t uuid;
1721 1702  
1722 1703          assert(cmd != NULL);
1723 1704  
1724 1705          /* This is the default if no arguments are given. */
1725 1706          (void) strlcpy(zone_template, "SUNWdefault", sizeof (zone_template));
1726 1707  
1727 1708          optind = 0;
1728      -        while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?a:bFt:X"))
     1709 +        while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?a:bFt:"))
1729 1710              != EOF) {
1730 1711                  switch (arg) {
1731 1712                  case '?':
1732 1713                          if (optopt == '?')
1733 1714                                  longer_usage(CMD_CREATE);
1734 1715                          else
1735 1716                                  short_usage(CMD_CREATE);
1736 1717                          arg_err = B_TRUE;
1737 1718                          break;
1738 1719                  case 'a':
↓ open down ↓ 69 lines elided ↑ open up ↑
1808 1789                              "detached zone\n"));
1809 1790                  else if (attach && err == Z_INVALID_DOCUMENT)
1810 1791                          (void) fprintf(stderr, gettext("Cannot attach to an "
1811 1792                              "earlier release of the operating system\n"));
1812 1793                  else
1813 1794                          zone_perror(zone_template, err, B_TRUE);
1814 1795                  return;
1815 1796          }
1816 1797  
1817 1798          need_to_commit = B_TRUE;
1818      -        is_create = B_TRUE;
1819 1799          zonecfg_fini_handle(handle);
1820 1800          handle = tmphandle;
1821 1801          got_handle = B_TRUE;
1822      -
1823      -        /* Allocate a new uuid for this new zone */
1824      -        uuid_generate(uuid);
1825      -        uuid_unparse(uuid, new_uuid);
1826 1802  }
1827 1803  
1828 1804  /*
1829 1805   * This malloc()'s memory, which must be freed by the caller.
1830 1806   */
1831 1807  static char *
1832 1808  quoteit(char *instr)
1833 1809  {
1834 1810          char *outstr;
1835 1811          size_t outstrsize = strlen(instr) + 3;  /* 2 quotes + '\0' */
↓ open down ↓ 40 lines elided ↑ open up ↑
1876 1852          char zonepath[MAXPATHLEN], outfile[MAXPATHLEN], pool[MAXNAMELEN];
1877 1853          char bootargs[BOOTARGS_MAX];
1878 1854          char sched[MAXNAMELEN];
1879 1855          char brand[MAXNAMELEN];
1880 1856          char hostidp[HW_HOSTID_LEN];
1881 1857          char fsallowedp[ZONE_FS_ALLOWED_MAX];
1882 1858          char *limitpriv;
1883 1859          FILE *of;
1884 1860          boolean_t autoboot;
1885 1861          zone_iptype_t iptype;
1886      -        uuid_t uuid;
1887 1862          boolean_t need_to_close = B_FALSE;
1888 1863          boolean_t arg_err = B_FALSE;
1889 1864  
1890 1865          assert(cmd != NULL);
1891 1866  
1892 1867          outfile[0] = '\0';
1893 1868          optind = 0;
1894 1869          while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?f:")) != EOF) {
1895 1870                  switch (arg) {
1896 1871                  case '?':
↓ open down ↓ 90 lines elided ↑ open up ↑
1987 1962                  (void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
1988 1963                      pt_to_str(PT_HOSTID), hostidp);
1989 1964          }
1990 1965  
1991 1966          if (zonecfg_get_fs_allowed(handle, fsallowedp,
1992 1967              sizeof (fsallowedp)) == Z_OK) {
1993 1968                  (void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
1994 1969                      pt_to_str(PT_FS_ALLOWED), fsallowedp);
1995 1970          }
1996 1971  
1997      -        if (zonecfg_get_uuid(zone, uuid) == Z_OK && !uuid_is_null(uuid)) {
1998      -                char suuid[UUID_PRINTABLE_STRING_LENGTH];
1999      -
2000      -                uuid_unparse(uuid, suuid);
2001      -                (void) fprintf(of, "%s %s=%s\n", cmd_to_str(CMD_SET),
2002      -                    pt_to_str(PT_UUID), suuid);
2003      -        }
2004      -
2005 1972          if ((err = zonecfg_setfsent(handle)) != Z_OK) {
2006 1973                  zone_perror(zone, err, B_FALSE);
2007 1974                  goto done;
2008 1975          }
2009 1976          while (zonecfg_getfsent(handle, &fstab) == Z_OK) {
2010 1977                  zone_fsopt_t *optptr;
2011 1978  
2012 1979                  (void) fprintf(of, "%s %s\n", cmd_to_str(CMD_ADD),
2013 1980                      rt_to_str(RT_FS));
2014 1981                  export_prop(of, PT_DIR, fstab.zone_fs_dir);
↓ open down ↓ 447 lines elided ↑ open up ↑
2462 2429          }
2463 2430  
2464 2431          for (cp = cpp; cp != NULL; cp = cp->cp_next) {
2465 2432                  switch (cp->cp_type) {
2466 2433                  case PT_NAME:
2467 2434                          if (seen_name) {
2468 2435                                  zerr(gettext("%s already specified"),
2469 2436                                      pt_to_str(PT_NAME));
2470 2437                                  goto bad;
2471 2438                          }
2472      -                        if (strlcpy(np->zone_res_attr_name, cp->cp_value,
2473      -                            sizeof (np->zone_res_attr_name)) >=
2474      -                            sizeof (np->zone_res_attr_name)) {
2475      -                                zerr(gettext("Input for %s is too long"),
2476      -                                    pt_to_str(PT_NAME));
2477      -                                goto bad;
2478      -                        }
     2439 +                        (void) strlcpy(np->zone_res_attr_name, cp->cp_value,
     2440 +                            sizeof (np->zone_res_attr_name));
2479 2441                          seen_name = B_TRUE;
2480 2442                          break;
2481 2443                  case PT_VALUE:
2482 2444                          if (seen_value) {
2483 2445                                  zerr(gettext("%s already specified"),
2484 2446                                      pt_to_str(PT_VALUE));
2485 2447                                  goto bad;
2486 2448                          }
2487      -                        if (strlcpy(np->zone_res_attr_value, cp->cp_value,
2488      -                            sizeof (np->zone_res_attr_value)) >=
2489      -                            sizeof (np->zone_res_attr_value)) {
2490      -                                zerr(gettext("Input for %s is too long"),
2491      -                                    pt_to_str(PT_VALUE));
2492      -                                goto bad;
2493      -                        }
2494      -
     2449 +                        (void) strlcpy(np->zone_res_attr_value, cp->cp_value,
     2450 +                            sizeof (np->zone_res_attr_value));
2495 2451                          seen_value = B_TRUE;
2496 2452                          break;
2497 2453                  default:
2498 2454                          zone_perror(pt_to_str(PT_NPROP), Z_NO_PROPERTY_TYPE,
2499 2455                              B_TRUE);
2500 2456                          long_usage(CMD_ADD, B_TRUE);
2501 2457                          usage(B_FALSE, HELP_PROPS);
2502 2458                          zonecfg_free_res_attr_list(np);
2503 2459                          return;
2504 2460                  }
↓ open down ↓ 155 lines elided ↑ open up ↑
2660 2616  {
2661 2617          return (global_zone && (type == RT_FS ||
2662 2618              type == RT_NET || type == RT_DEVICE || type == RT_ATTR ||
2663 2619              type == RT_DATASET));
2664 2620  }
2665 2621  
2666 2622  static boolean_t
2667 2623  gz_invalid_rt_property(int type)
2668 2624  {
2669 2625          return (global_zone && (type == RT_ZONENAME || type == RT_ZONEPATH ||
2670      -            type == RT_AUTOBOOT || type == RT_LIMITPRIV || type == RT_UUID ||
     2626 +            type == RT_AUTOBOOT || type == RT_LIMITPRIV ||
2671 2627              type == RT_BOOTARGS || type == RT_BRAND || type == RT_SCHED ||
2672 2628              type == RT_IPTYPE || type == RT_HOSTID || type == RT_FS_ALLOWED));
2673 2629  }
2674 2630  
2675 2631  static boolean_t
2676 2632  gz_invalid_property(int type)
2677 2633  {
2678 2634          return (global_zone && (type == PT_ZONENAME || type == PT_ZONEPATH ||
2679      -            type == PT_AUTOBOOT || type == PT_LIMITPRIV || type == PT_UUID ||
     2635 +            type == PT_AUTOBOOT || type == PT_LIMITPRIV ||
2680 2636              type == PT_BOOTARGS || type == PT_BRAND || type == PT_SCHED ||
2681 2637              type == PT_IPTYPE || type == PT_HOSTID || type == PT_FS_ALLOWED));
2682 2638  }
2683 2639  
2684 2640  void
2685 2641  add_func(cmd_t *cmd)
2686 2642  {
2687 2643          int arg;
2688 2644          boolean_t arg_err = B_FALSE;
2689 2645  
↓ open down ↓ 197 lines elided ↑ open up ↑
2887 2843                          zone_perror(pt_to_str(cmd->cmd_prop_name[i]),
2888 2844                              Z_NO_PROPERTY_TYPE, B_TRUE);
2889 2845                          return (Z_INSUFFICIENT_SPEC);
2890 2846                  }
2891 2847          }
2892 2848          if (fill_in_only)
2893 2849                  return (Z_OK);
2894 2850          return (zonecfg_lookup_filesystem(handle, fstab));
2895 2851  }
2896 2852  
2897      -/*
2898      - * Turn an addr that looks like f:2:0:44:5:6C into 0f:02:00:44:05:6c
2899      - * We're expecting a dst of at least MAXMACADDRLEN size here.
2900      - */
2901      -static void
2902      -normalize_mac_addr(char *dst, const char *src, int len)
2903      -{
2904      -        char *p, *e, *sep = "";
2905      -        long n;
2906      -        char buf[MAXMACADDRLEN], tmp[4];
2907      -
2908      -        *dst = '\0';
2909      -        (void) strlcpy(buf, src, sizeof (buf));
2910      -        p = strtok(buf, ":");
2911      -        while (p != NULL) {
2912      -                n = strtol(p, &e, 16);
2913      -                if (*e != NULL || n > 0xff)
2914      -                        return;
2915      -                (void) snprintf(tmp, sizeof (tmp), "%s%02x", sep, n);
2916      -                (void) strlcat(dst, tmp, len);
2917      -
2918      -                sep = ":";
2919      -                p = strtok(NULL, ":");
2920      -        }
2921      -}
2922      -
2923 2853  static int
2924 2854  fill_in_nwiftab(cmd_t *cmd, struct zone_nwiftab *nwiftab,
2925 2855      boolean_t fill_in_only)
2926 2856  {
2927 2857          int err, i;
2928 2858          property_value_ptr_t pp;
2929 2859  
2930 2860          if ((err = initialize(B_TRUE)) != Z_OK)
2931 2861                  return (err);
2932 2862  
↓ open down ↓ 14 lines elided ↑ open up ↑
2947 2877                          (void) strlcpy(nwiftab->zone_nwif_allowed_address,
2948 2878                              pp->pv_simple,
2949 2879                              sizeof (nwiftab->zone_nwif_allowed_address));
2950 2880                          break;
2951 2881                  case PT_PHYSICAL:
2952 2882                          (void) strlcpy(nwiftab->zone_nwif_physical,
2953 2883                              pp->pv_simple,
2954 2884                              sizeof (nwiftab->zone_nwif_physical));
2955 2885                          break;
2956 2886                  case PT_MAC:
2957      -                        normalize_mac_addr(nwiftab->zone_nwif_mac,
     2887 +                        (void) strlcpy(nwiftab->zone_nwif_mac,
2958 2888                              pp->pv_simple,
2959 2889                              sizeof (nwiftab->zone_nwif_mac));
2960 2890                          break;
2961 2891                  case PT_VLANID:
2962 2892                          (void) strlcpy(nwiftab->zone_nwif_vlan_id,
2963 2893                              pp->pv_simple,
2964 2894                              sizeof (nwiftab->zone_nwif_vlan_id));
2965 2895                          break;
2966 2896                  case PT_GNIC:
2967 2897                          (void) strlcpy(nwiftab->zone_nwif_gnic,
↓ open down ↓ 243 lines elided ↑ open up ↑
3211 3141                          break;
3212 3142                  }
3213 3143          }
3214 3144          if (arg_err)
3215 3145                  return (B_FALSE);
3216 3146  
3217 3147  
3218 3148          num = zonecfg_num_resources(handle, rsrc);
3219 3149  
3220 3150          if (num == 0) {
3221      -                if (force)
3222      -                        return (B_TRUE);
3223 3151                  z_cmd_rt_perror(CMD_REMOVE, cmd->cmd_res_type, Z_NO_ENTRY,
3224 3152                      B_TRUE);
3225 3153                  return (B_FALSE);
3226 3154          }
3227 3155          if (num > 1 && !force) {
3228 3156                  if (!interactive_mode) {
3229 3157                          zerr(gettext("There are multiple instances of this "
3230 3158                              "resource.  Either qualify the resource to\n"
3231 3159                              "remove a single instance or use the -F option to "
3232 3160                              "remove all instances."));
↓ open down ↓ 8 lines elided ↑ open up ↑
3241 3169                          zerr(gettext("Resource incomplete."));
3242 3170                          return (B_FALSE);
3243 3171                  }
3244 3172                  if (answer != 1)
3245 3173                          return (B_FALSE);
3246 3174          }
3247 3175          return (B_TRUE);
3248 3176  }
3249 3177  
3250 3178  static void
3251      -remove_fs(cmd_t *cmd, boolean_t force)
     3179 +remove_fs(cmd_t *cmd)
3252 3180  {
3253 3181          int err;
3254 3182  
3255 3183          /* traditional, qualified fs removal */
3256 3184          if (cmd->cmd_prop_nv_pairs > 0) {
3257 3185                  struct zone_fstab fstab;
3258 3186  
3259 3187                  if ((err = fill_in_fstab(cmd, &fstab, B_FALSE)) != Z_OK) {
3260      -                        if (!force)
3261      -                                z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
     3188 +                        z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
3262 3189                          return;
3263 3190                  }
3264      -                if ((err = zonecfg_delete_filesystem(handle, &fstab)) != Z_OK) {
3265      -                        if (!force)
3266      -                                z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
3267      -                } else {
     3191 +                if ((err = zonecfg_delete_filesystem(handle, &fstab)) != Z_OK)
     3192 +                        z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
     3193 +                else
3268 3194                          need_to_commit = B_TRUE;
3269      -                }
3270 3195                  zonecfg_free_fs_option_list(fstab.zone_fs_options);
3271 3196                  return;
3272 3197          }
3273 3198  
3274 3199          /*
3275 3200           * unqualified fs removal.  remove all fs's but prompt if more
3276 3201           * than one.
3277 3202           */
3278 3203          if (!prompt_remove_resource(cmd, "fs"))
3279 3204                  return;
3280 3205  
3281 3206          if ((err = zonecfg_del_all_resources(handle, "fs")) != Z_OK)
3282 3207                  z_cmd_rt_perror(CMD_REMOVE, RT_FS, err, B_TRUE);
3283 3208          else
3284 3209                  need_to_commit = B_TRUE;
3285 3210  }
3286 3211  
3287 3212  static void
3288      -remove_net(cmd_t *cmd, boolean_t force)
     3213 +remove_net(cmd_t *cmd)
3289 3214  {
3290 3215          int err;
3291 3216  
3292 3217          /* traditional, qualified net removal */
3293 3218          if (cmd->cmd_prop_nv_pairs > 0) {
3294 3219                  struct zone_nwiftab nwiftab;
3295 3220  
3296 3221                  if ((err = fill_in_nwiftab(cmd, &nwiftab, B_FALSE)) != Z_OK) {
3297      -                        if (!force)
3298      -                                z_cmd_rt_perror(CMD_REMOVE, RT_NET, err,
3299      -                                    B_TRUE);
     3222 +                        z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
3300 3223                          return;
3301 3224                  }
3302      -                if ((err = zonecfg_delete_nwif(handle, &nwiftab)) != Z_OK) {
3303      -                        if (!force)
3304      -                                z_cmd_rt_perror(CMD_REMOVE, RT_NET, err,
3305      -                                    B_TRUE);
3306      -                } else {
     3225 +                if ((err = zonecfg_delete_nwif(handle, &nwiftab)) != Z_OK)
     3226 +                        z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
     3227 +                else
3307 3228                          need_to_commit = B_TRUE;
3308      -                }
3309 3229                  return;
3310 3230          }
3311 3231  
3312 3232          /*
3313 3233           * unqualified net removal.  remove all nets but prompt if more
3314 3234           * than one.
3315 3235           */
3316 3236          if (!prompt_remove_resource(cmd, "net"))
3317 3237                  return;
3318 3238  
3319 3239          if ((err = zonecfg_del_all_resources(handle, "net")) != Z_OK)
3320 3240                  z_cmd_rt_perror(CMD_REMOVE, RT_NET, err, B_TRUE);
3321 3241          else
3322 3242                  need_to_commit = B_TRUE;
3323 3243  }
3324 3244  
3325 3245  static void
3326      -remove_device(cmd_t *cmd, boolean_t force)
     3246 +remove_device(cmd_t *cmd)
3327 3247  {
3328 3248          int err;
3329 3249  
3330 3250          /* traditional, qualified device removal */
3331 3251          if (cmd->cmd_prop_nv_pairs > 0) {
3332 3252                  struct zone_devtab devtab;
3333 3253  
3334 3254                  if ((err = fill_in_devtab(cmd, &devtab, B_FALSE)) != Z_OK) {
3335      -                        if (!force)
3336      -                                z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err,
3337      -                                    B_TRUE);
     3255 +                        z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
3338 3256                          return;
3339 3257                  }
3340      -                if ((err = zonecfg_delete_dev(handle, &devtab)) != Z_OK) {
3341      -                        if (!force)
3342      -                                z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err,
3343      -                                    B_TRUE);
3344      -                } else {
     3258 +                if ((err = zonecfg_delete_dev(handle, &devtab)) != Z_OK)
     3259 +                        z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
     3260 +                else
3345 3261                          need_to_commit = B_TRUE;
3346      -                }
3347 3262                  return;
3348 3263          }
3349 3264  
3350 3265          /*
3351 3266           * unqualified device removal.  remove all devices but prompt if more
3352 3267           * than one.
3353 3268           */
3354 3269          if (!prompt_remove_resource(cmd, "device"))
3355 3270                  return;
3356 3271  
3357 3272          if ((err = zonecfg_del_all_resources(handle, "device")) != Z_OK)
3358 3273                  z_cmd_rt_perror(CMD_REMOVE, RT_DEVICE, err, B_TRUE);
3359 3274          else
3360 3275                  need_to_commit = B_TRUE;
3361 3276  }
3362 3277  
3363 3278  static void
3364      -remove_attr(cmd_t *cmd, boolean_t force)
     3279 +remove_attr(cmd_t *cmd)
3365 3280  {
3366 3281          int err;
3367 3282  
3368 3283          /* traditional, qualified attr removal */
3369 3284          if (cmd->cmd_prop_nv_pairs > 0) {
3370 3285                  struct zone_attrtab attrtab;
3371 3286  
3372 3287                  if ((err = fill_in_attrtab(cmd, &attrtab, B_FALSE)) != Z_OK) {
3373      -                        if (!force)
3374      -                                z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err,
3375      -                                    B_TRUE);
     3288 +                        z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
3376 3289                          return;
3377 3290                  }
3378      -                if ((err = zonecfg_delete_attr(handle, &attrtab)) != Z_OK) {
3379      -                        if (!force)
3380      -                                z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err,
3381      -                                    B_TRUE);
3382      -                } else {
     3291 +                if ((err = zonecfg_delete_attr(handle, &attrtab)) != Z_OK)
     3292 +                        z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
     3293 +                else
3383 3294                          need_to_commit = B_TRUE;
3384      -                }
3385 3295                  return;
3386 3296          }
3387 3297  
3388 3298          /*
3389 3299           * unqualified attr removal.  remove all attrs but prompt if more
3390 3300           * than one.
3391 3301           */
3392 3302          if (!prompt_remove_resource(cmd, "attr"))
3393 3303                  return;
3394 3304  
3395 3305          if ((err = zonecfg_del_all_resources(handle, "attr")) != Z_OK)
3396 3306                  z_cmd_rt_perror(CMD_REMOVE, RT_ATTR, err, B_TRUE);
3397 3307          else
3398 3308                  need_to_commit = B_TRUE;
3399 3309  }
3400 3310  
3401 3311  static void
3402      -remove_dataset(cmd_t *cmd, boolean_t force)
     3312 +remove_dataset(cmd_t *cmd)
3403 3313  {
3404 3314          int err;
3405 3315  
3406 3316          /* traditional, qualified dataset removal */
3407 3317          if (cmd->cmd_prop_nv_pairs > 0) {
3408 3318                  struct zone_dstab dstab;
3409 3319  
3410 3320                  if ((err = fill_in_dstab(cmd, &dstab, B_FALSE)) != Z_OK) {
3411      -                        if (!force)
3412      -                                z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err,
3413      -                                    B_TRUE);
     3321 +                        z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
3414 3322                          return;
3415 3323                  }
3416      -                if ((err = zonecfg_delete_ds(handle, &dstab)) != Z_OK) {
3417      -                        if (!force)
3418      -                                z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err,
3419      -                                    B_TRUE);
3420      -                } else {
     3324 +                if ((err = zonecfg_delete_ds(handle, &dstab)) != Z_OK)
     3325 +                        z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
     3326 +                else
3421 3327                          need_to_commit = B_TRUE;
3422      -                }
3423 3328                  return;
3424 3329          }
3425 3330  
3426 3331          /*
3427 3332           * unqualified dataset removal.  remove all datasets but prompt if more
3428 3333           * than one.
3429 3334           */
3430 3335          if (!prompt_remove_resource(cmd, "dataset"))
3431 3336                  return;
3432 3337  
3433 3338          if ((err = zonecfg_del_all_resources(handle, "dataset")) != Z_OK)
3434 3339                  z_cmd_rt_perror(CMD_REMOVE, RT_DATASET, err, B_TRUE);
3435 3340          else
3436 3341                  need_to_commit = B_TRUE;
3437 3342  }
3438 3343  
3439 3344  static void
3440      -remove_rctl(cmd_t *cmd, boolean_t force)
     3345 +remove_rctl(cmd_t *cmd)
3441 3346  {
3442 3347          int err;
3443 3348  
3444 3349          /* traditional, qualified rctl removal */
3445 3350          if (cmd->cmd_prop_nv_pairs > 0) {
3446 3351                  struct zone_rctltab rctltab;
3447 3352  
3448 3353                  if ((err = fill_in_rctltab(cmd, &rctltab, B_FALSE)) != Z_OK) {
3449      -                        if (!force)
3450      -                                z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err,
3451      -                                    B_TRUE);
     3354 +                        z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
3452 3355                          return;
3453 3356                  }
3454      -                if ((err = zonecfg_delete_rctl(handle, &rctltab)) != Z_OK) {
3455      -                        if (!force)
3456      -                                z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err,
3457      -                                    B_TRUE);
3458      -                } else {
     3357 +                if ((err = zonecfg_delete_rctl(handle, &rctltab)) != Z_OK)
     3358 +                        z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
     3359 +                else
3459 3360                          need_to_commit = B_TRUE;
3460      -                }
3461 3361                  zonecfg_free_rctl_value_list(rctltab.zone_rctl_valptr);
3462 3362                  return;
3463 3363          }
3464 3364  
3465 3365          /*
3466 3366           * unqualified rctl removal.  remove all rctls but prompt if more
3467 3367           * than one.
3468 3368           */
3469 3369          if (!prompt_remove_resource(cmd, "rctl"))
3470 3370                  return;
3471 3371  
3472 3372          if ((err = zonecfg_del_all_resources(handle, "rctl")) != Z_OK)
3473 3373                  z_cmd_rt_perror(CMD_REMOVE, RT_RCTL, err, B_TRUE);
3474 3374          else
3475 3375                  need_to_commit = B_TRUE;
3476 3376  }
3477 3377  
3478 3378  static void
3479      -remove_pset(boolean_t force)
     3379 +remove_pset()
3480 3380  {
3481 3381          int err;
3482 3382          struct zone_psettab psettab;
3483 3383  
3484 3384          if ((err = zonecfg_lookup_pset(handle, &psettab)) != Z_OK) {
3485      -                if (!force)
3486      -                        z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
     3385 +                z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
3487 3386                  return;
3488 3387          }
3489      -        if ((err = zonecfg_delete_pset(handle)) != Z_OK) {
3490      -                if (!force)
3491      -                        z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
3492      -        } else {
     3388 +        if ((err = zonecfg_delete_pset(handle)) != Z_OK)
     3389 +                z_cmd_rt_perror(CMD_REMOVE, RT_DCPU, err, B_TRUE);
     3390 +        else
3493 3391                  need_to_commit = B_TRUE;
3494      -        }
3495 3392  }
3496 3393  
3497 3394  static void
3498      -remove_pcap(boolean_t force)
     3395 +remove_pcap()
3499 3396  {
3500 3397          int err;
3501 3398          uint64_t tmp;
3502 3399  
3503 3400          if (zonecfg_get_aliased_rctl(handle, ALIAS_CPUCAP, &tmp) != Z_OK) {
3504      -                if (!force) {
3505      -                        zerr("%s %s: %s", cmd_to_str(CMD_REMOVE),
3506      -                            rt_to_str(RT_PCAP),
3507      -                            zonecfg_strerror(Z_NO_RESOURCE_TYPE));
3508      -                        saw_error = B_TRUE;
3509      -                }
     3401 +                zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_PCAP),
     3402 +                    zonecfg_strerror(Z_NO_RESOURCE_TYPE));
     3403 +                saw_error = B_TRUE;
3510 3404                  return;
3511 3405          }
3512 3406  
3513      -        if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_CPUCAP)) != Z_OK) {
3514      -                if (!force)
3515      -                        z_cmd_rt_perror(CMD_REMOVE, RT_PCAP, err, B_TRUE);
3516      -        } else {
     3407 +        if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_CPUCAP)) != Z_OK)
     3408 +                z_cmd_rt_perror(CMD_REMOVE, RT_PCAP, err, B_TRUE);
     3409 +        else
3517 3410                  need_to_commit = B_TRUE;
3518      -        }
3519 3411  }
3520 3412  
3521 3413  static void
3522      -remove_mcap(boolean_t force)
     3414 +remove_mcap()
3523 3415  {
3524 3416          int err, res1, res2, res3;
3525 3417          uint64_t tmp;
3526 3418          boolean_t revert = B_FALSE;
3527 3419  
3528 3420          res1 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXPHYSMEM, &tmp);
3529 3421          res2 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXSWAP, &tmp);
3530 3422          res3 = zonecfg_get_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM, &tmp);
3531 3423  
3532 3424          /* if none of these exist, there is no resource to remove */
3533 3425          if (res1 != Z_OK && res2 != Z_OK && res3 != Z_OK) {
3534      -                if (!force) {
3535      -                        zerr("%s %s: %s", cmd_to_str(CMD_REMOVE),
3536      -                            rt_to_str(RT_MCAP),
3537      -                            zonecfg_strerror(Z_NO_RESOURCE_TYPE));
3538      -                        saw_error = B_TRUE;
3539      -                }
     3426 +                zerr("%s %s: %s", cmd_to_str(CMD_REMOVE), rt_to_str(RT_MCAP),
     3427 +                    zonecfg_strerror(Z_NO_RESOURCE_TYPE));
     3428 +                saw_error = B_TRUE;
3540 3429                  return;
3541 3430          }
3542 3431          if (res1 == Z_OK) {
3543 3432                  if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXPHYSMEM))
3544 3433                      != Z_OK) {
3545      -                        if (!force) {
3546      -                                z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
3547      -                                    B_TRUE);
3548      -                                revert = B_TRUE;
3549      -                        }
     3434 +                        z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
     3435 +                        revert = B_TRUE;
3550 3436                  } else {
3551 3437                          need_to_commit = B_TRUE;
3552 3438                  }
3553 3439          }
3554 3440  
3555 3441          if (res2 == Z_OK) {
3556 3442                  if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXSWAP))
3557 3443                      != Z_OK) {
3558      -                        if (!force) {
3559      -                                z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
3560      -                                    B_TRUE);
3561      -                                revert = B_TRUE;
3562      -                        }
     3444 +                        z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
     3445 +                        revert = B_TRUE;
3563 3446                  } else {
3564 3447                          need_to_commit = B_TRUE;
3565 3448                  }
3566 3449          }
3567 3450          if (res3 == Z_OK) {
3568 3451                  if ((err = zonecfg_rm_aliased_rctl(handle, ALIAS_MAXLOCKEDMEM))
3569 3452                      != Z_OK) {
3570      -                        if (!force) {
3571      -                                z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err,
3572      -                                    B_TRUE);
3573      -                                revert = B_TRUE;
3574      -                        }
     3453 +                        z_cmd_rt_perror(CMD_REMOVE, RT_MCAP, err, B_TRUE);
     3454 +                        revert = B_TRUE;
3575 3455                  } else {
3576 3456                          need_to_commit = B_TRUE;
3577 3457                  }
3578 3458          }
3579 3459  
3580 3460          if (revert)
3581 3461                  need_to_commit = B_FALSE;
3582 3462  }
3583 3463  
3584 3464  static void
3585      -remove_admin(cmd_t *cmd, boolean_t force)
     3465 +remove_admin(cmd_t *cmd)
3586 3466  {
3587 3467          int err;
3588 3468  
3589 3469          /* traditional, qualified attr removal */
3590 3470          if (cmd->cmd_prop_nv_pairs > 0) {
3591 3471                  struct zone_admintab admintab;
3592 3472  
3593 3473                  if ((err = fill_in_admintab(cmd, &admintab, B_FALSE)) != Z_OK) {
3594      -                        if (!force)
3595      -                                z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err,
3596      -                                    B_TRUE);
     3474 +                        z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
     3475 +                            err, B_TRUE);
3597 3476                          return;
3598 3477                  }
3599 3478                  if ((err = zonecfg_delete_admin(handle, &admintab,
3600      -                    zone)) != Z_OK) {
3601      -                        if (!force)
3602      -                                z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err,
3603      -                                    B_TRUE);
3604      -                } else {
     3479 +                    zone))
     3480 +                    != Z_OK)
     3481 +                        z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
     3482 +                            err, B_TRUE);
     3483 +                else
3605 3484                          need_to_commit = B_TRUE;
3606      -                }
3607 3485                  return;
3608      -        }
     3486 +        } else {
     3487 +                /*
     3488 +                 * unqualified admin removal.
     3489 +                 * remove all admins but prompt if more
     3490 +                 * than one.
     3491 +                 */
     3492 +                if (!prompt_remove_resource(cmd, "admin"))
     3493 +                        return;
3609 3494  
3610      -        /*
3611      -         * unqualified admin removal.
3612      -         * remove all admins but prompt if more than one.
3613      -         */
3614      -        if (!prompt_remove_resource(cmd, "admin"))
3615      -                return;
3616      -
3617      -        if ((err = zonecfg_delete_admins(handle, zone)) != Z_OK)
3618      -                z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN, err, B_TRUE);
3619      -        else
3620      -                need_to_commit = B_TRUE;
     3495 +                if ((err = zonecfg_delete_admins(handle, zone))
     3496 +                    != Z_OK)
     3497 +                        z_cmd_rt_perror(CMD_REMOVE, RT_ADMIN,
     3498 +                            err, B_TRUE);
     3499 +                else
     3500 +                        need_to_commit = B_TRUE;
     3501 +        }
3621 3502  }
3622 3503  
3623 3504  static void
3624 3505  remove_resource(cmd_t *cmd)
3625 3506  {
3626 3507          int type;
3627 3508          int arg;
3628 3509          boolean_t arg_err = B_FALSE;
3629      -        boolean_t force = B_FALSE;
3630 3510  
3631 3511          if ((type = cmd->cmd_res_type) == RT_UNKNOWN) {
3632 3512                  long_usage(CMD_REMOVE, B_TRUE);
3633 3513                  return;
3634 3514          }
3635 3515  
3636 3516          optind = 0;
3637 3517          while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "?F")) != EOF) {
3638 3518                  switch (arg) {
3639 3519                  case '?':
3640 3520                          longer_usage(CMD_REMOVE);
3641 3521                          arg_err = B_TRUE;
3642 3522                          break;
3643 3523                  case 'F':
3644      -                        force = B_TRUE;
3645 3524                          break;
3646 3525                  default:
3647 3526                          short_usage(CMD_REMOVE);
3648 3527                          arg_err = B_TRUE;
3649 3528                          break;
3650 3529                  }
3651 3530          }
3652 3531          if (arg_err)
3653 3532                  return;
3654 3533  
3655 3534          if (initialize(B_TRUE) != Z_OK)
3656 3535                  return;
3657 3536  
3658 3537          switch (type) {
3659 3538          case RT_FS:
3660      -                remove_fs(cmd, force);
     3539 +                remove_fs(cmd);
3661 3540                  return;
3662 3541          case RT_NET:
3663      -                remove_net(cmd, force);
     3542 +                remove_net(cmd);
3664 3543                  return;
3665 3544          case RT_DEVICE:
3666      -                remove_device(cmd, force);
     3545 +                remove_device(cmd);
3667 3546                  return;
3668 3547          case RT_RCTL:
3669      -                remove_rctl(cmd, force);
     3548 +                remove_rctl(cmd);
3670 3549                  return;
3671 3550          case RT_ATTR:
3672      -                remove_attr(cmd, force);
     3551 +                remove_attr(cmd);
3673 3552                  return;
3674 3553          case RT_DATASET:
3675      -                remove_dataset(cmd, force);
     3554 +                remove_dataset(cmd);
3676 3555                  return;
3677 3556          case RT_DCPU:
3678      -                remove_pset(force);
     3557 +                remove_pset();
3679 3558                  return;
3680 3559          case RT_PCAP:
3681      -                remove_pcap(force);
     3560 +                remove_pcap();
3682 3561                  return;
3683 3562          case RT_MCAP:
3684      -                remove_mcap(force);
     3563 +                remove_mcap();
3685 3564                  return;
3686 3565          case RT_ADMIN:
3687      -                remove_admin(cmd, force);
     3566 +                remove_admin(cmd);
3688 3567                  return;
3689 3568          default:
3690 3569                  zone_perror(rt_to_str(type), Z_NO_RESOURCE_TYPE, B_TRUE);
3691 3570                  long_usage(CMD_REMOVE, B_TRUE);
3692 3571                  usage(B_FALSE, HELP_RESOURCES);
3693 3572                  return;
3694 3573          }
3695 3574  }
3696 3575  
3697 3576  static void
3698 3577  remove_property(cmd_t *cmd)
3699 3578  {
3700 3579          char *prop_id;
3701 3580          int err, res_type, prop_type;
3702 3581          property_value_ptr_t pp;
3703 3582          struct zone_rctlvaltab *rctlvaltab;
3704 3583          struct zone_res_attrtab *np;
3705 3584          complex_property_ptr_t cx;
3706      -        int arg;
3707      -        boolean_t force = B_FALSE;
3708      -        boolean_t arg_err = B_FALSE;
3709 3585  
3710      -        optind = 0;
3711      -        while ((arg = getopt(cmd->cmd_argc, cmd->cmd_argv, "F")) != EOF) {
3712      -                switch (arg) {
3713      -                case 'F':
3714      -                        force = B_TRUE;
3715      -                        break;
3716      -                default:
3717      -                        arg_err = B_TRUE;
3718      -                        break;
3719      -                }
3720      -        }
3721      -        if (arg_err) {
3722      -                saw_error = B_TRUE;
3723      -                return;
3724      -        }
3725      -
3726 3586          res_type = resource_scope;
3727 3587          prop_type = cmd->cmd_prop_name[0];
3728 3588          if (res_type == RT_UNKNOWN || prop_type == PT_UNKNOWN) {
3729 3589                  long_usage(CMD_REMOVE, B_TRUE);
3730 3590                  return;
3731 3591          }
3732 3592  
3733 3593          if (cmd->cmd_prop_nv_pairs != 1) {
3734 3594                  long_usage(CMD_ADD, B_TRUE);
3735 3595                  return;
↓ open down ↓ 20 lines elided ↑ open up ↑
3756 3616                          return;
3757 3617                  }
3758 3618                  if (pp->pv_type == PROP_VAL_SIMPLE) {
3759 3619                          if (pp->pv_simple == NULL) {
3760 3620                                  long_usage(CMD_ADD, B_TRUE);
3761 3621                                  return;
3762 3622                          }
3763 3623                          prop_id = pp->pv_simple;
3764 3624                          err = zonecfg_remove_fs_option(&in_progress_fstab,
3765 3625                              prop_id);
3766      -                        if (err != Z_OK && !force)
     3626 +                        if (err != Z_OK)
3767 3627                                  zone_perror(pt_to_str(prop_type), err, B_TRUE);
3768 3628                  } else {
3769 3629                          list_property_ptr_t list;
3770 3630  
3771 3631                          for (list = pp->pv_list; list != NULL;
3772 3632                              list = list->lp_next) {
3773 3633                                  prop_id = list->lp_simple;
3774 3634                                  if (prop_id == NULL)
3775 3635                                          break;
3776 3636                                  err = zonecfg_remove_fs_option(
3777 3637                                      &in_progress_fstab, prop_id);
3778      -                                if (err != Z_OK && !force)
     3638 +                                if (err != Z_OK)
3779 3639                                          zone_perror(pt_to_str(prop_type), err,
3780 3640                                              B_TRUE);
3781 3641                          }
3782 3642                  }
3783 3643                  return;
3784 3644          case RT_NET:            /* FALLTHRU */
3785 3645          case RT_DEVICE:
3786 3646                  if (prop_type != PT_NPROP) {
3787 3647                          zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
3788 3648                              B_TRUE);
↓ open down ↓ 32 lines elided ↑ open up ↑
3821 3681                  }
3822 3682                  np->zone_res_attr_next = NULL;
3823 3683  
3824 3684                  if (res_type == RT_NET) {
3825 3685                          err = zonecfg_remove_res_attr(
3826 3686                              &(in_progress_nwiftab.zone_nwif_attrp), np);
3827 3687                  } else {                                /* RT_DEVICE */
3828 3688                          err = zonecfg_remove_res_attr(
3829 3689                              &(in_progress_devtab.zone_dev_attrp), np);
3830 3690                  }
3831      -                if (err != Z_OK && !force)
     3691 +                if (err != Z_OK)
3832 3692                          zone_perror(pt_to_str(prop_type), err, B_TRUE);
3833 3693                  return;
3834 3694          case RT_RCTL:
3835 3695                  if (prop_type != PT_VALUE) {
3836 3696                          zone_perror(pt_to_str(prop_type), Z_NO_PROPERTY_TYPE,
3837 3697                              B_TRUE);
3838 3698                          long_usage(CMD_REMOVE, B_TRUE);
3839 3699                          usage(B_FALSE, HELP_PROPS);
3840 3700                          return;
3841 3701                  }
↓ open down ↓ 30 lines elided ↑ open up ↑
3872 3732                                      Z_NO_PROPERTY_TYPE, B_TRUE);
3873 3733                                  long_usage(CMD_ADD, B_TRUE);
3874 3734                                  usage(B_FALSE, HELP_PROPS);
3875 3735                                  zonecfg_free_rctl_value_list(rctlvaltab);
3876 3736                                  return;
3877 3737                          }
3878 3738                  }
3879 3739                  rctlvaltab->zone_rctlval_next = NULL;
3880 3740                  err = zonecfg_remove_rctl_value(&in_progress_rctltab,
3881 3741                      rctlvaltab);
3882      -                if (err != Z_OK && !force)
     3742 +                if (err != Z_OK)
3883 3743                          zone_perror(pt_to_str(prop_type), err, B_TRUE);
3884 3744                  zonecfg_free_rctl_value_list(rctlvaltab);
3885 3745                  return;
3886 3746          default:
3887 3747                  zone_perror(rt_to_str(res_type), Z_NO_RESOURCE_TYPE, B_TRUE);
3888 3748                  long_usage(CMD_REMOVE, B_TRUE);
3889 3749                  usage(B_FALSE, HELP_RESOURCES);
3890 3750                  return;
3891 3751          }
3892 3752  }
↓ open down ↓ 104 lines elided ↑ open up ↑
3997 3857          }
3998 3858  
3999 3859          if (initialize(B_TRUE) != Z_OK)
4000 3860                  return;
4001 3861  
4002 3862          switch (type) {
4003 3863          case PT_ZONENAME:
4004 3864                  /* FALLTHRU */
4005 3865          case PT_ZONEPATH:
4006 3866                  /* FALLTHRU */
4007      -        case PT_UUID:
4008      -                /* FALLTHRU */
4009 3867          case PT_BRAND:
4010 3868                  zone_perror(pt_to_str(type), Z_CLEAR_DISALLOW, B_TRUE);
4011 3869                  return;
4012 3870          case PT_AUTOBOOT:
4013 3871                  /* false is default; we'll treat as equivalent to clearing */
4014 3872                  if ((err = zonecfg_set_autoboot(handle, B_FALSE)) != Z_OK)
4015 3873                          z_cmd_rt_perror(CMD_CLEAR, RT_AUTOBOOT, err, B_TRUE);
4016 3874                  else
4017 3875                          need_to_commit = B_TRUE;
4018 3876                  return;
↓ open down ↓ 42 lines elided ↑ open up ↑
4061 3919                  return;
4062 3920          case PT_MAXMSGIDS:
4063 3921                  remove_aliased_rctl(PT_MAXMSGIDS, ALIAS_MAXMSGIDS);
4064 3922                  return;
4065 3923          case PT_MAXSEMIDS:
4066 3924                  remove_aliased_rctl(PT_MAXSEMIDS, ALIAS_MAXSEMIDS);
4067 3925                  return;
4068 3926          case PT_SHARES:
4069 3927                  remove_aliased_rctl(PT_SHARES, ALIAS_SHARES);
4070 3928                  return;
4071      -        case PT_ZFSPRI:
4072      -                remove_aliased_rctl(PT_ZFSPRI, ALIAS_ZFSPRI);
4073      -                return;
4074 3929          case PT_HOSTID:
4075 3930                  if ((err = zonecfg_set_hostid(handle, NULL)) != Z_OK)
4076 3931                          z_cmd_rt_perror(CMD_CLEAR, RT_HOSTID, err, B_TRUE);
4077 3932                  else
4078 3933                          need_to_commit = B_TRUE;
4079 3934                  return;
4080 3935          case PT_FS_ALLOWED:
4081 3936                  if ((err = zonecfg_set_fs_allowed(handle, NULL)) != Z_OK)
4082 3937                          z_cmd_rt_perror(CMD_CLEAR, RT_FS_ALLOWED, err, B_TRUE);
4083 3938                  else
↓ open down ↓ 470 lines elided ↑ open up ↑
4554 4409                  } else if (prop_type == PT_MAXMSGIDS) {
4555 4410                          res_type = RT_MAXMSGIDS;
4556 4411                  } else if (prop_type == PT_MAXSEMIDS) {
4557 4412                          res_type = RT_MAXSEMIDS;
4558 4413                  } else if (prop_type == PT_SHARES) {
4559 4414                          res_type = RT_SHARES;
4560 4415                  } else if (prop_type == PT_HOSTID) {
4561 4416                          res_type = RT_HOSTID;
4562 4417                  } else if (prop_type == PT_FS_ALLOWED) {
4563 4418                          res_type = RT_FS_ALLOWED;
4564      -                } else if (prop_type == PT_ZFSPRI) {
4565      -                        res_type = RT_ZFSPRI;
4566      -                } else if (prop_type == PT_UUID) {
4567      -                        res_type = RT_UUID;
4568 4419                  } else {
4569 4420                          zerr(gettext("Cannot set a resource-specific property "
4570 4421                              "from the global scope."));
4571 4422                          saw_error = B_TRUE;
4572 4423                          return;
4573 4424                  }
4574 4425          } else {
4575 4426                  res_type = resource_scope;
4576 4427          }
4577 4428  
↓ open down ↓ 187 lines elided ↑ open up ↑
4765 4616                  return;
4766 4617          case RT_MAXMSGIDS:
4767 4618                  set_aliased_rctl(ALIAS_MAXMSGIDS, prop_type, prop_id);
4768 4619                  return;
4769 4620          case RT_MAXSEMIDS:
4770 4621                  set_aliased_rctl(ALIAS_MAXSEMIDS, prop_type, prop_id);
4771 4622                  return;
4772 4623          case RT_SHARES:
4773 4624                  set_aliased_rctl(ALIAS_SHARES, prop_type, prop_id);
4774 4625                  return;
4775      -        case RT_ZFSPRI:
4776      -                set_aliased_rctl(ALIAS_ZFSPRI, prop_type, prop_id);
4777      -                return;
4778 4626          case RT_HOSTID:
4779 4627                  if ((err = zonecfg_set_hostid(handle, prop_id)) != Z_OK) {
4780 4628                          if (err == Z_TOO_BIG) {
4781 4629                                  zerr(gettext("hostid string is too large: %s"),
4782 4630                                      prop_id);
4783 4631                                  saw_error = B_TRUE;
4784 4632                          } else {
4785 4633                                  zone_perror(pt_to_str(prop_type), err, B_TRUE);
4786 4634                          }
4787 4635                          return;
4788 4636                  }
4789 4637                  need_to_commit = B_TRUE;
4790 4638                  return;
4791      -        case RT_UUID:
4792      -                /*
4793      -                 * We can't set here.  We have to wait until commit since the
4794      -                 * uuid will be updating the index file and we may not have
4795      -                 * created the zone yet.
4796      -                 */
4797      -                (void) strlcpy(new_uuid, prop_id, sizeof (new_uuid));
4798      -                need_to_commit = B_TRUE;
4799      -                return;
4800 4639          case RT_FS_ALLOWED:
4801 4640                  if ((err = zonecfg_set_fs_allowed(handle, prop_id)) != Z_OK)
4802 4641                          zone_perror(zone, err, B_TRUE);
4803 4642                  else
4804 4643                          need_to_commit = B_TRUE;
4805 4644                  return;
4806 4645          case RT_FS:
4807 4646                  switch (prop_type) {
4808 4647                  case PT_DIR:
4809 4648                          (void) strlcpy(in_progress_fstab.zone_fs_dir, prop_id,
↓ open down ↓ 55 lines elided ↑ open up ↑
4865 4704                  case PT_PHYSICAL:
4866 4705                          if (validate_net_physical_syntax(prop_id) != Z_OK) {
4867 4706                                  saw_error = B_TRUE;
4868 4707                                  return;
4869 4708                          }
4870 4709                          (void) strlcpy(in_progress_nwiftab.zone_nwif_physical,
4871 4710                              prop_id,
4872 4711                              sizeof (in_progress_nwiftab.zone_nwif_physical));
4873 4712                          break;
4874 4713                  case PT_MAC:
4875      -                        normalize_mac_addr(in_progress_nwiftab.zone_nwif_mac,
     4714 +                        (void) strlcpy(in_progress_nwiftab.zone_nwif_mac,
4876 4715                              prop_id,
4877 4716                              sizeof (in_progress_nwiftab.zone_nwif_mac));
4878 4717                          break;
4879 4718                  case PT_VLANID:
4880 4719                          (void) strlcpy(in_progress_nwiftab.zone_nwif_vlan_id,
4881 4720                              prop_id,
4882 4721                              sizeof (in_progress_nwiftab.zone_nwif_vlan_id));
4883 4722                          break;
4884 4723                  case PT_GNIC:
4885 4724                          (void) strlcpy(in_progress_nwiftab.zone_nwif_gnic,
↓ open down ↓ 504 lines elided ↑ open up ↑
5390 5229              sizeof (hostidp))) == Z_OK) {
5391 5230                  (void) fprintf(fp, "%s: %s\n", pt_to_str(PT_HOSTID), hostidp);
5392 5231          } else if (err == Z_BAD_PROPERTY) {
5393 5232                  (void) fprintf(fp, "%s: \n", pt_to_str(PT_HOSTID));
5394 5233          } else {
5395 5234                  zone_perror(zone, err, B_TRUE);
5396 5235          }
5397 5236  }
5398 5237  
5399 5238  static void
5400      -info_uuid(FILE *fp)
5401      -{
5402      -        uuid_t uuid;
5403      -        char suuid[UUID_PRINTABLE_STRING_LENGTH];
5404      -
5405      -        if (new_uuid[0] != '\0') {
5406      -                (void) fprintf(fp, "%s: %s\n", pt_to_str(PT_UUID), new_uuid);
5407      -        } else if (zonecfg_get_uuid(zone, uuid) == Z_OK &&
5408      -            !uuid_is_null(uuid)) {
5409      -                uuid_unparse(uuid, suuid);
5410      -                (void) fprintf(fp, "%s: %s\n", pt_to_str(PT_UUID), suuid);
5411      -        } else {
5412      -                (void) fprintf(fp, "%s:\n", pt_to_str(PT_UUID));
5413      -        }
5414      -}
5415      -
5416      -static void
5417 5239  info_fs_allowed(zone_dochandle_t handle, FILE *fp)
5418 5240  {
5419 5241          char fsallowedp[ZONE_FS_ALLOWED_MAX];
5420 5242          int err;
5421 5243  
5422 5244          if ((err = zonecfg_get_fs_allowed(handle, fsallowedp,
5423 5245              sizeof (fsallowedp))) == Z_OK) {
5424 5246                  (void) fprintf(fp, "%s: %s\n", pt_to_str(PT_FS_ALLOWED),
5425 5247                      fsallowedp);
5426 5248          } else if (err == Z_BAD_PROPERTY) {
↓ open down ↓ 489 lines elided ↑ open up ↑
5916 5738  void
5917 5739  info_func(cmd_t *cmd)
5918 5740  {
5919 5741          FILE *fp = stdout;
5920 5742          boolean_t need_to_close = B_FALSE;
5921 5743          int type;
5922 5744          int res1, res2, res3;
5923 5745          uint64_t swap_limit;
5924 5746          uint64_t locked_limit;
5925 5747          uint64_t phys_limit;
5926      -        struct stat statbuf;
5927 5748  
5928 5749          assert(cmd != NULL);
5929 5750  
5930 5751          if (initialize(B_TRUE) != Z_OK)
5931 5752                  return;
5932 5753  
5933 5754          /* don't page error output */
5934 5755          if (interactive_mode) {
5935 5756                  if ((fp = pager_open()) != NULL)
5936 5757                          need_to_close = B_TRUE;
↓ open down ↓ 69 lines elided ↑ open up ↑
6006 5827                          info_autoboot(handle, fp);
6007 5828                          info_bootargs(handle, fp);
6008 5829                  }
6009 5830                  info_pool(handle, fp);
6010 5831                  if (!global_zone) {
6011 5832                          info_limitpriv(handle, fp);
6012 5833                          info_sched(handle, fp);
6013 5834                          info_iptype(handle, fp);
6014 5835                          info_hostid(handle, fp);
6015 5836                          info_fs_allowed(handle, fp);
6016      -                        info_uuid(fp);
6017 5837                  }
6018 5838                  info_aliased_rctl(handle, fp, ALIAS_MAXLWPS);
6019 5839                  info_aliased_rctl(handle, fp, ALIAS_MAXPROCS);
6020 5840                  info_aliased_rctl(handle, fp, ALIAS_MAXSHMMEM);
6021 5841                  info_aliased_rctl(handle, fp, ALIAS_MAXSHMIDS);
6022 5842                  info_aliased_rctl(handle, fp, ALIAS_MAXMSGIDS);
6023 5843                  info_aliased_rctl(handle, fp, ALIAS_MAXSEMIDS);
6024 5844                  info_aliased_rctl(handle, fp, ALIAS_SHARES);
6025      -                info_aliased_rctl(handle, fp, ALIAS_ZFSPRI);
6026 5845                  if (!global_zone) {
6027 5846                          info_fs(handle, fp, cmd);
6028 5847                          info_net(handle, fp, cmd);
6029 5848                          info_dev(handle, fp, cmd);
6030 5849                  }
6031 5850                  info_pset(handle, fp);
6032 5851                  info_pcap(fp);
6033 5852                  info_mcap(handle, fp);
6034 5853                  if (!global_zone) {
6035 5854                          info_attr(handle, fp, cmd);
↓ open down ↓ 43 lines elided ↑ open up ↑
6079 5898                  break;
6080 5899          case RT_MAXMSGIDS:
6081 5900                  info_aliased_rctl(handle, fp, ALIAS_MAXMSGIDS);
6082 5901                  break;
6083 5902          case RT_MAXSEMIDS:
6084 5903                  info_aliased_rctl(handle, fp, ALIAS_MAXSEMIDS);
6085 5904                  break;
6086 5905          case RT_SHARES:
6087 5906                  info_aliased_rctl(handle, fp, ALIAS_SHARES);
6088 5907                  break;
6089      -        case RT_ZFSPRI:
6090      -                info_aliased_rctl(handle, fp, ALIAS_ZFSPRI);
6091      -                break;
6092 5908          case RT_FS:
6093 5909                  info_fs(handle, fp, cmd);
6094 5910                  break;
6095 5911          case RT_NET:
6096 5912                  info_net(handle, fp, cmd);
6097 5913                  break;
6098 5914          case RT_DEVICE:
6099 5915                  info_dev(handle, fp, cmd);
6100 5916                  break;
6101 5917          case RT_RCTL:
↓ open down ↓ 10 lines elided ↑ open up ↑
6112 5928                  break;
6113 5929          case RT_PCAP:
6114 5930                  info_pcap(fp);
6115 5931                  break;
6116 5932          case RT_MCAP:
6117 5933                  info_mcap(handle, fp);
6118 5934                  break;
6119 5935          case RT_HOSTID:
6120 5936                  info_hostid(handle, fp);
6121 5937                  break;
6122      -        case RT_UUID:
6123      -                info_uuid(fp);
6124      -                break;
6125 5938          case RT_ADMIN:
6126 5939                  info_auth(handle, fp, cmd);
6127 5940                  break;
6128 5941          case RT_FS_ALLOWED:
6129 5942                  info_fs_allowed(handle, fp);
6130 5943                  break;
6131 5944          default:
6132 5945                  zone_perror(rt_to_str(cmd->cmd_res_type), Z_NO_RESOURCE_TYPE,
6133 5946                      B_TRUE);
6134 5947          }
↓ open down ↓ 471 lines elided ↑ open up ↑
6606 6419                          /*
6607 6420                           * If the zone doesn't yet have a debug ID, set one now.
6608 6421                           */
6609 6422                          if (zonecfg_get_did(handle) == -1)
6610 6423                                  zonecfg_set_did(handle);
6611 6424  
6612 6425                          if ((ret_val = zonecfg_save(handle)) == Z_OK) {
6613 6426                                  need_to_commit = B_FALSE;
6614 6427                                  (void) strlcpy(revert_zone, zone,
6615 6428                                      sizeof (revert_zone));
6616      -
6617      -                                if (is_create) {
6618      -                                        zonecfg_notify_create(handle);
6619      -                                        is_create = B_FALSE;
6620      -                                }
6621 6429                          }
6622      -
6623      -                        /*
6624      -                         * Commit a new uuid at this point since we now know the
6625      -                         * zone index entry will exist.
6626      -                         */
6627      -                        if (new_uuid[0] != '\0') {
6628      -                                if ((err = zonecfg_set_uuid(zone, zonepath,
6629      -                                    new_uuid)) != Z_OK)
6630      -                                        zone_perror(zone, err, B_FALSE);
6631      -                                else
6632      -                                        new_uuid[0] = '\0';
6633      -                        }
6634 6430                  } else {
6635 6431                          zerr(gettext("Zone %s failed to verify"), zone);
6636 6432                  }
6637 6433          }
6638 6434          if (ret_val != Z_OK)
6639 6435                  zone_perror(zone, ret_val, B_TRUE);
6640 6436  }
6641 6437  
6642 6438  void
6643 6439  cancel_func(cmd_t *cmd)
↓ open down ↓ 1029 lines elided ↑ open up ↑
7673 7469                          }
7674 7470                          break;
7675 7471                  }
7676 7472          }
7677 7473          return (execbasename);
7678 7474  }
7679 7475  
7680 7476  int
7681 7477  main(int argc, char *argv[])
7682 7478  {
7683      -        int err, arg, uflag = 0, zflag = 0;
     7479 +        int err, arg;
7684 7480          struct stat st;
7685      -        uuid_t uuidin;
7686      -        char zonename[ZONENAME_MAX + 1];
7687 7481  
7688 7482          /* This must be before anything goes to stdout. */
7689 7483          setbuf(stdout, NULL);
7690 7484  
7691 7485          saw_error = B_FALSE;
7692 7486          cmd_file_mode = B_FALSE;
7693 7487          execname = get_execbasename(argv[0]);
7694 7488  
7695 7489          (void) setlocale(LC_ALL, "");
7696 7490          (void) textdomain(TEXT_DOMAIN);
↓ open down ↓ 6 lines elided ↑ open up ↑
7703 7497  
7704 7498          if (argc < 2) {
7705 7499                  usage(B_FALSE, HELP_USAGE | HELP_SUBCMDS);
7706 7500                  exit(Z_USAGE);
7707 7501          }
7708 7502          if (strcmp(argv[1], cmd_to_str(CMD_HELP)) == 0) {
7709 7503                  (void) one_command_at_a_time(argc - 1, &(argv[1]));
7710 7504                  exit(Z_OK);
7711 7505          }
7712 7506  
7713      -        while ((arg = getopt(argc, argv, "?f:R:z:u:")) != EOF) {
     7507 +        while ((arg = getopt(argc, argv, "?f:R:z:")) != EOF) {
7714 7508                  switch (arg) {
7715 7509                  case '?':
7716 7510                          if (optopt == '?')
7717 7511                                  usage(B_TRUE, HELP_USAGE | HELP_SUBCMDS);
7718 7512                          else
7719 7513                                  usage(B_FALSE, HELP_USAGE);
7720 7514                          exit(Z_USAGE);
7721 7515                          /* NOTREACHED */
7722 7516                  case 'f':
7723 7517                          cmd_file_name = optarg;
↓ open down ↓ 6 lines elided ↑ open up ↑
7730 7524                                  exit(Z_USAGE);
7731 7525                          }
7732 7526                          if (stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
7733 7527                                  zerr(gettext(
7734 7528                                      "root path must be a directory: %s"),
7735 7529                                      optarg);
7736 7530                                  exit(Z_USAGE);
7737 7531                          }
7738 7532                          zonecfg_set_root(optarg);
7739 7533                          break;
7740      -                case 'u':
7741      -                        if (uuid_parse((char *)optarg, uuidin) == -1)
7742      -                                return (Z_INVALID_PROPERTY);
7743      -
7744      -                        if (zonecfg_get_name_by_uuid(uuidin, zonename,
7745      -                            ZONENAME_MAX) != Z_OK) {
7746      -                                zone_perror(optarg, Z_BOGUS_ZONE_NAME, B_TRUE);
7747      -                                usage(B_FALSE, HELP_SYNTAX);
7748      -                                exit(Z_USAGE);
7749      -                        }
7750      -
7751      -                        (void) strlcpy(zone, zonename, sizeof (zone));
7752      -                        (void) strlcpy(revert_zone, zonename, sizeof (zone));
7753      -                        uflag = 1;
7754      -                        break;
7755 7534                  case 'z':
7756 7535                          if (strcmp(optarg, GLOBAL_ZONENAME) == 0) {
7757 7536                                  global_zone = B_TRUE;
7758 7537                          } else if (zonecfg_validate_zonename(optarg) != Z_OK) {
7759 7538                                  zone_perror(optarg, Z_BOGUS_ZONE_NAME, B_TRUE);
7760 7539                                  usage(B_FALSE, HELP_SYNTAX);
7761 7540                                  exit(Z_USAGE);
7762 7541                          }
7763 7542                          (void) strlcpy(zone, optarg, sizeof (zone));
7764 7543                          (void) strlcpy(revert_zone, optarg, sizeof (zone));
7765      -                        zflag = 1;
7766 7544                          break;
7767 7545                  default:
7768 7546                          usage(B_FALSE, HELP_USAGE);
7769 7547                          exit(Z_USAGE);
7770 7548                  }
7771 7549          }
7772 7550  
7773      -        if (optind > argc || strcmp(zone, "") == 0 || (uflag && zflag)) {
     7551 +        if (optind > argc || strcmp(zone, "") == 0) {
7774 7552                  usage(B_FALSE, HELP_USAGE);
7775 7553                  exit(Z_USAGE);
7776 7554          }
7777 7555  
7778 7556          if ((err = zonecfg_access(zone, W_OK)) == Z_OK) {
7779 7557                  read_only_mode = B_FALSE;
7780 7558          } else if (err == Z_ACCES) {
7781 7559                  read_only_mode = B_TRUE;
7782 7560                  /* skip this message in one-off from command line mode */
7783 7561                  if (optind == argc)
↓ open down ↓ 39 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX