diff options
Diffstat (limited to 'usr/src/cmd/svc/svcs/explain.c')
-rw-r--r-- | usr/src/cmd/svc/svcs/explain.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/usr/src/cmd/svc/svcs/explain.c b/usr/src/cmd/svc/svcs/explain.c index 533437cbee..331a5375fd 100644 --- a/usr/src/cmd/svc/svcs/explain.c +++ b/usr/src/cmd/svc/svcs/explain.c @@ -22,7 +22,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright (c) 2015, Joyent, Inc. All rights reserved. + * Copyright 2020 Joyent, Inc. */ /* @@ -133,6 +133,8 @@ typedef struct { const char *restarter; uu_list_t *dependencies; /* list of dependency_group's */ + char comment[SCF_COMMENT_MAX_LENGTH]; + int active; /* In use? (cycle detection) */ int restarter_bad; const char *summary; @@ -403,7 +405,7 @@ add_instance(const char *svcname, const char *instname, scf_instance_t *inst) { inst_t *instp; svc_t *svcp; - int have_enabled = 0; + int ovr_set = 0; uint8_t i; uint32_t h; int r; @@ -479,7 +481,10 @@ add_instance(const char *svcname, const char *instname, scf_instance_t *inst) if (scf_instance_get_pg(inst, SCF_PG_GENERAL_OVR, g_pg) == 0) { if (pg_get_single_val(g_pg, SCF_PROPERTY_ENABLED, SCF_TYPE_BOOLEAN, &instp->enabled, 0, 0) == 0) - have_enabled = 1; + ovr_set = 1; + (void) pg_get_single_val(g_pg, SCF_PROPERTY_COMMENT, + SCF_TYPE_ASTRING, instp->comment, + sizeof (instp->comment), EMPTY_OK); } else { switch (scf_error()) { case SCF_ERROR_NOT_FOUND: @@ -508,11 +513,18 @@ add_instance(const char *svcname, const char *instname, scf_instance_t *inst) if (pg_get_single_val(g_pg, SCF_PROPERTY_ENABLED, SCF_TYPE_BOOLEAN, &i, 0, 0) != 0) return; - if (!have_enabled) { + + if (ovr_set) { + instp->temporary = (instp->enabled != i); + } else { instp->enabled = i; instp->temporary = 0; - } else { - instp->temporary = (instp->enabled != i); + } + + if (!instp->temporary) { + (void) pg_get_single_val(g_pg, SCF_PROPERTY_COMMENT, + SCF_TYPE_ASTRING, instp->comment, + sizeof (instp->comment), EMPTY_OK); } if (pg_get_single_val(g_pg, SCF_PROPERTY_RESTARTER, SCF_TYPE_ASTRING, @@ -1736,12 +1748,23 @@ print_reasons(const inst_t *svcp, int verbose) } else if (strcmp(svcp->state, SCF_STATE_STRING_DISABLED) == 0) { if (!svcp->temporary) { - (void) puts(gettext( - "Reason: Disabled by an administrator.")); + if (svcp->comment[0] != '\0') { + (void) printf(gettext("Reason: Disabled by " + "an administrator: %s\n"), svcp->comment); + } else { + (void) printf(gettext("Reason: Disabled by " + "an administrator.\n")); + } dc = DC_DISABLED; } else { - (void) puts(gettext("Reason: " - "Temporarily disabled by an administrator.")); + if (svcp->comment[0] != '\0') { + (void) printf(gettext("Reason: Temporarily " + "disabled by an administrator: %s\n"), + svcp->comment); + } else { + (void) printf(gettext("Reason: Temporarily " + "disabled by an administrator.\n")); + } dc = DC_TEMPDISABLED; } |