Print this page
3347 zonecfg(1M) is confused about selection
4956 zonecfg won't use a valid pager

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zonecfg/zonecfg.c
          +++ new/usr/src/cmd/zonecfg/zonecfg.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright 2014 Gary Mills
  25   26   */
  26   27  
  27   28  /*
  28   29   * zonecfg is a lex/yacc based command interpreter used to manage zone
  29   30   * configurations.  The lexer (see zonecfg_lex.l) builds up tokens, which
  30   31   * the grammar (see zonecfg_grammar.y) builds up into commands, some of
  31   32   * which takes resources and/or properties as arguments.  See the block
  32   33   * comments near the end of zonecfg_grammar.y for how the data structures
  33   34   * which keep track of these resources and properties are built up.
  34   35   *
↓ open down ↓ 889 lines elided ↑ open up ↑
 924  925          struct stat statbuf;
 925  926  
 926  927          /* don't page error output */
 927  928          if (verbose && interactive_mode) {
 928  929                  if ((pager = getenv("PAGER")) == NULL)
 929  930                          pager = PAGER;
 930  931  
 931  932                  space = strchr(pager, ' ');
 932  933                  if (space)
 933  934                          *space = '\0';
 934      -                if (stat(pager, &statbuf) == 0) {
      935 +                if (*pager == '/' && stat(pager, &statbuf) != 0) {
      936 +                        zerr(gettext("PAGER %s does not exist (%s)."),
      937 +                            pager, strerror(errno));
      938 +                } else {
 935  939                          if (space)
 936  940                                  *space = ' ';
 937      -                        if ((newfp = popen(pager, "w")) != NULL) {
      941 +                        if ((newfp = popen(pager, "w")) == NULL) {
      942 +                                zerr(gettext("PAGER %s open failed (%s)."),
      943 +                                    pager, strerror(errno));
      944 +                        } else {
 938  945                                  need_to_close = B_TRUE;
 939  946                                  fp = newfp;
 940  947                          }
 941      -                } else {
 942      -                        zerr(gettext("PAGER %s does not exist (%s)."),
 943      -                            pager, strerror(errno));
 944  948                  }
 945  949          }
 946  950  
 947  951          if (flags & HELP_META) {
 948  952                  (void) fprintf(fp, gettext("More help is available for the "
 949  953                      "following:\n"));
 950  954                  (void) fprintf(fp, "\n\tcommands ('%s commands')\n",
 951  955                      cmd_to_str(CMD_HELP));
 952  956                  (void) fprintf(fp, "\tsyntax ('%s syntax')\n",
 953  957                      cmd_to_str(CMD_HELP));
↓ open down ↓ 312 lines elided ↑ open up ↑
1266 1270                  (void) fprintf(fp, "\t%s\t%s, %s\n", rt_to_str(RT_DCPU),
1267 1271                      pt_to_str(PT_NCPUS), pt_to_str(PT_IMPORTANCE));
1268 1272                  (void) fprintf(fp, "\t%s\t%s\n", rt_to_str(RT_PCAP),
1269 1273                      pt_to_str(PT_NCPUS));
1270 1274                  (void) fprintf(fp, "\t%s\t%s, %s, %s\n", rt_to_str(RT_MCAP),
1271 1275                      pt_to_str(PT_PHYSICAL), pt_to_str(PT_SWAP),
1272 1276                      pt_to_str(PT_LOCKED));
1273 1277                  (void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_ADMIN),
1274 1278                      pt_to_str(PT_USER), pt_to_str(PT_AUTHS));
1275 1279          }
1276      -        if (need_to_close)
1277      -                (void) pclose(fp);
     1280 +        if (need_to_close) {
     1281 +                int status;
     1282 +
     1283 +                status = pclose(fp);
     1284 +                if (status == -1)
     1285 +                        zerr(gettext("PAGER %s close failed (%s)."),
     1286 +                            pager, strerror(errno));
     1287 +                else if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
     1288 +                        zerr(gettext("PAGER %s exit code: %d."),
     1289 +                            pager, WEXITSTATUS(status));
     1290 +        }
1278 1291  }
1279 1292  
1280 1293  static void
1281 1294  zone_perror(char *prefix, int err, boolean_t set_saw)
1282 1295  {
1283 1296          zerr("%s: %s", prefix, zonecfg_strerror(err));
1284 1297          if (set_saw)
1285 1298                  saw_error = B_TRUE;
1286 1299  }
1287 1300  
↓ open down ↓ 4067 lines elided ↑ open up ↑
5355 5368          if (initialize(B_TRUE) != Z_OK)
5356 5369                  return;
5357 5370  
5358 5371          /* don't page error output */
5359 5372          if (interactive_mode) {
5360 5373                  if ((pager = getenv("PAGER")) == NULL)
5361 5374                          pager = PAGER;
5362 5375                  space = strchr(pager, ' ');
5363 5376                  if (space)
5364 5377                          *space = '\0';
5365      -                if (stat(pager, &statbuf) == 0) {
     5378 +                if (*pager == '/' && stat(pager, &statbuf) != 0) {
     5379 +                        zerr(gettext("PAGER %s does not exist (%s)."),
     5380 +                            pager, strerror(errno));
     5381 +                } else {
5366 5382                          if (space)
5367 5383                                  *space = ' ';
5368      -                        if ((fp = popen(pager, "w")) != NULL)
5369      -                                need_to_close = B_TRUE;
5370      -                        else
     5384 +                        if ((fp = popen(pager, "w")) == NULL) {
5371 5385                                  fp = stdout;
5372      -                } else {
5373      -                        zerr(gettext("PAGER %s does not exist (%s)."),
5374      -                            pager, strerror(errno));
     5386 +                                zerr(gettext("PAGER %s open failed (%s)."),
     5387 +                                    pager, strerror(errno));
     5388 +                        } else {
     5389 +                                need_to_close = B_TRUE;
     5390 +                        }
5375 5391                  }
5376 5392  
5377 5393                  setbuf(fp, NULL);
5378 5394          }
5379 5395  
5380 5396          if (!global_scope) {
5381 5397                  switch (resource_scope) {
5382 5398                  case RT_FS:
5383 5399                          output_fs(fp, &in_progress_fstab);
5384 5400                          break;
↓ open down ↓ 169 lines elided ↑ open up ↑
5554 5570                  break;
5555 5571          case RT_FS_ALLOWED:
5556 5572                  info_fs_allowed(handle, fp);
5557 5573                  break;
5558 5574          default:
5559 5575                  zone_perror(rt_to_str(cmd->cmd_res_type), Z_NO_RESOURCE_TYPE,
5560 5576                      B_TRUE);
5561 5577          }
5562 5578  
5563 5579  cleanup:
5564      -        if (need_to_close)
5565      -                (void) pclose(fp);
     5580 +        if (need_to_close) {
     5581 +                int status;
     5582 +
     5583 +                status = pclose(fp);
     5584 +                if (status == -1)
     5585 +                        zerr(gettext("PAGER %s close failed (%s)."),
     5586 +                            pager, strerror(errno));
     5587 +                else if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
     5588 +                        zerr(gettext("PAGER %s exit code: %d."),
     5589 +                            pager, WEXITSTATUS(status));
     5590 +        }
5566 5591  }
5567 5592  
5568 5593  /*
5569 5594   * Helper function for verify-- checks that a required string property
5570 5595   * exists.
5571 5596   */
5572 5597  static void
5573 5598  check_reqd_prop(char *attr, int rt, int pt, int *ret_val)
5574 5599  {
5575 5600          if (strlen(attr) == 0) {
↓ open down ↓ 1654 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX