Print this page
3347 zonecfg(1M) is confused about selection
4956 zonecfg won't use a valid pager
*** 20,29 ****
--- 20,30 ----
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Gary Mills
*/
/*
* zonecfg is a lex/yacc based command interpreter used to manage zone
* configurations. The lexer (see zonecfg_lex.l) builds up tokens, which
*** 929,948 ****
pager = PAGER;
space = strchr(pager, ' ');
if (space)
*space = '\0';
! if (stat(pager, &statbuf) == 0) {
if (space)
*space = ' ';
! if ((newfp = popen(pager, "w")) != NULL) {
need_to_close = B_TRUE;
fp = newfp;
}
- } else {
- zerr(gettext("PAGER %s does not exist (%s)."),
- pager, strerror(errno));
}
}
if (flags & HELP_META) {
(void) fprintf(fp, gettext("More help is available for the "
--- 930,952 ----
pager = PAGER;
space = strchr(pager, ' ');
if (space)
*space = '\0';
! if (*pager == '/' && stat(pager, &statbuf) != 0) {
! zerr(gettext("PAGER %s does not exist (%s)."),
! pager, strerror(errno));
! } else {
if (space)
*space = ' ';
! if ((newfp = popen(pager, "w")) == NULL) {
! zerr(gettext("PAGER %s open failed (%s)."),
! pager, strerror(errno));
! } else {
need_to_close = B_TRUE;
fp = newfp;
}
}
}
if (flags & HELP_META) {
(void) fprintf(fp, gettext("More help is available for the "
*** 1271,1282 ****
pt_to_str(PT_PHYSICAL), pt_to_str(PT_SWAP),
pt_to_str(PT_LOCKED));
(void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_ADMIN),
pt_to_str(PT_USER), pt_to_str(PT_AUTHS));
}
! if (need_to_close)
! (void) pclose(fp);
}
static void
zone_perror(char *prefix, int err, boolean_t set_saw)
{
--- 1275,1295 ----
pt_to_str(PT_PHYSICAL), pt_to_str(PT_SWAP),
pt_to_str(PT_LOCKED));
(void) fprintf(fp, "\t%s\t\t%s, %s\n", rt_to_str(RT_ADMIN),
pt_to_str(PT_USER), pt_to_str(PT_AUTHS));
}
! if (need_to_close) {
! int status;
!
! status = pclose(fp);
! if (status == -1)
! zerr(gettext("PAGER %s close failed (%s)."),
! pager, strerror(errno));
! else if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
! zerr(gettext("PAGER %s exit code: %d."),
! pager, WEXITSTATUS(status));
! }
}
static void
zone_perror(char *prefix, int err, boolean_t set_saw)
{
*** 5360,5380 ****
if ((pager = getenv("PAGER")) == NULL)
pager = PAGER;
space = strchr(pager, ' ');
if (space)
*space = '\0';
! if (stat(pager, &statbuf) == 0) {
if (space)
*space = ' ';
! if ((fp = popen(pager, "w")) != NULL)
! need_to_close = B_TRUE;
! else
fp = stdout;
! } else {
! zerr(gettext("PAGER %s does not exist (%s)."),
pager, strerror(errno));
}
setbuf(fp, NULL);
}
if (!global_scope) {
--- 5373,5396 ----
if ((pager = getenv("PAGER")) == NULL)
pager = PAGER;
space = strchr(pager, ' ');
if (space)
*space = '\0';
! if (*pager == '/' && stat(pager, &statbuf) != 0) {
! zerr(gettext("PAGER %s does not exist (%s)."),
! pager, strerror(errno));
! } else {
if (space)
*space = ' ';
! if ((fp = popen(pager, "w")) == NULL) {
fp = stdout;
! zerr(gettext("PAGER %s open failed (%s)."),
pager, strerror(errno));
+ } else {
+ need_to_close = B_TRUE;
}
+ }
setbuf(fp, NULL);
}
if (!global_scope) {
*** 5559,5570 ****
zone_perror(rt_to_str(cmd->cmd_res_type), Z_NO_RESOURCE_TYPE,
B_TRUE);
}
cleanup:
! if (need_to_close)
! (void) pclose(fp);
}
/*
* Helper function for verify-- checks that a required string property
* exists.
--- 5575,5595 ----
zone_perror(rt_to_str(cmd->cmd_res_type), Z_NO_RESOURCE_TYPE,
B_TRUE);
}
cleanup:
! if (need_to_close) {
! int status;
!
! status = pclose(fp);
! if (status == -1)
! zerr(gettext("PAGER %s close failed (%s)."),
! pager, strerror(errno));
! else if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
! zerr(gettext("PAGER %s exit code: %d."),
! pager, WEXITSTATUS(status));
! }
}
/*
* Helper function for verify-- checks that a required string property
* exists.