Print this page
12721 would like svcadm disable -c

@@ -20,11 +20,11 @@
  */
 
 /*
  * 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.
  */
 
 /*
  * Service state explanation.  For select services, display a description, the
  * state, and possibly why the service is in that state, what's causing it to

@@ -131,10 +131,12 @@
         uint8_t enabled;
         int temporary;
         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;
         uu_list_t *baddeps;             /* list of dependency's */
         uu_list_t *causes;              /* list of svcptrs */

@@ -401,11 +403,11 @@
 static void
 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;
 
         h = hash_name(svcname) & SVC_HASH_MASK;

@@ -477,11 +479,14 @@
                 instp->aux_fmri = safe_strdup(g_fmri);
 
         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:
                         break;
 

@@ -506,17 +511,24 @@
         }
 
         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,
             g_fmri, g_fmri_sz, 0) == 0)
                 instp->restarter = safe_strdup(g_fmri);
         else
                 instp->restarter = SCF_SERVICE_STARTD;

@@ -1734,16 +1746,27 @@
                         dc = DC_RSTRDEAD;
                 }
 
         } 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;
                 }
 
         } else if (strcmp(svcp->state, SCF_STATE_STRING_MAINT) == 0) {
                 if (strcmp(svcp->aux_state, "administrative_request") == 0) {