Print this page
3315 svccfg export -a drops values in PG "general"
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/svccfg/svccfg_libscf.c
          +++ new/usr/src/cmd/svc/svccfg/svccfg_libscf.c
↓ open down ↓ 9073 lines elided ↑ open up ↑
9074 9074                  if (ret2 == -1)
9075 9075                          scfdie();
9076 9076  
9077 9077                  scf_iter_destroy(eiter);
9078 9078          } else
9079 9079                  err = 1;
9080 9080  
9081 9081          if (err) {
9082 9082                  xmlFreeNode(n);
9083 9083  
9084      -                export_pg(pg, eelts, 0);
     9084 +                export_pg(pg, eelts, SCE_ALL_VALUES);
9085 9085  
9086 9086                  return;
9087 9087          }
9088 9088  
9089 9089          /* Iterate through the properties & handle each. */
9090 9090          if (scf_iter_pg_properties(exp_prop_iter, pg) != SCF_SUCCESS)
9091 9091                  scfdie();
9092 9092  
9093 9093          (void) memset(&elts, 0, sizeof (elts));
9094 9094  
↓ open down ↓ 14 lines elided ↑ open up ↑
9109 9109                                  uu_die(emsg_create_xml);
9110 9110  
9111 9111                          if (set_attr_from_prop(exp_prop, m, value_attr) == 0) {
9112 9112                                  elts.stability = m;
9113 9113                                  continue;
9114 9114                          }
9115 9115  
9116 9116                          xmlFreeNode(m);
9117 9117                  }
9118 9118  
9119      -                export_property(exp_prop, exp_str, &elts, 0);
     9119 +                export_property(exp_prop, exp_str, &elts, SCE_ALL_VALUES);
9120 9120          }
9121 9121          if (ret == -1)
9122 9122                  scfdie();
9123 9123  
9124 9124          (void) xmlAddChild(n, elts.stability);
9125 9125          (void) xmlAddChildList(n, elts.propvals);
9126 9126          (void) xmlAddChildList(n, elts.properties);
9127 9127  
9128 9128          if (eelts->dependencies == NULL)
9129 9129                  eelts->dependencies = n;
↓ open down ↓ 107 lines elided ↑ open up ↑
9237 9237                          uu_die(gettext("Could not create string"));
9238 9238  
9239 9239                  safe_setprop(n, "timeout_seconds", str);
9240 9240                  free(str);
9241 9241          } else
9242 9242                  err = 1;
9243 9243  
9244 9244          if (err) {
9245 9245                  xmlFreeNode(n);
9246 9246  
9247      -                export_pg(pg, eelts, 0);
     9247 +                export_pg(pg, eelts, SCE_ALL_VALUES);
9248 9248  
9249 9249                  return;
9250 9250          }
9251 9251  
9252 9252  
9253 9253          /*
9254 9254           * If we're going to have a method_context child, we need to know
9255 9255           * before we iterate through the properties.  Since method_context's
9256 9256           * are optional, we don't want to complain about any properties
9257 9257           * missing if none of them are there.  Thus we can't use the
↓ open down ↓ 156 lines elided ↑ open up ↑
9414 9414                          if (nonenv && !use_profile)
9415 9415                                  continue;
9416 9416                  } else if (strcmp(exp_str, SCF_PROPERTY_PROFILE) == 0) {
9417 9417                          if (nonenv && use_profile)
9418 9418                                  continue;
9419 9419                  } else if (strcmp(exp_str, SCF_PROPERTY_ENVIRONMENT) == 0) {
9420 9420                          if (env != NULL)
9421 9421                                  continue;
9422 9422                  }
9423 9423  
9424      -                export_property(exp_prop, exp_str, &elts, 0);
     9424 +                export_property(exp_prop, exp_str, &elts, SCE_ALL_VALUES);
9425 9425          }
9426 9426          if (ret == -1)
9427 9427                  scfdie();
9428 9428  
9429 9429          (void) xmlAddChild(n, elts.stability);
9430 9430          (void) xmlAddChildList(n, elts.propvals);
9431 9431          (void) xmlAddChildList(n, elts.properties);
9432 9432  
9433 9433          if (eelts->exec_methods == NULL)
9434 9434                  eelts->exec_methods = n;
↓ open down ↓ 95 lines elided ↑ open up ↑
9530 9530                                  uu_die(emsg_create_xml);
9531 9531  
9532 9532                          if (set_attr_from_prop(exp_prop, s, value_attr) == 0) {
9533 9533                                  selts->stability = s;
9534 9534                                  continue;
9535 9535                          }
9536 9536  
9537 9537                          xmlFreeNode(s);
9538 9538                  }
9539 9539  
9540      -                export_property(exp_prop, exp_str, &elts, 0);
     9540 +                export_property(exp_prop, exp_str, &elts, SCE_ALL_VALUES);
9541 9541          }
9542 9542          if (ret == -1)
9543 9543                  scfdie();
9544 9544  
9545 9545          if (elts.propvals != NULL || elts.properties != NULL)
9546 9546                  export_pg_elts(&elts, scf_pg_general, scf_group_framework,
9547 9547                      selts);
9548 9548  }
9549 9549  
9550 9550  static void
↓ open down ↓ 75 lines elided ↑ open up ↑
9626 9626                  } else {
9627 9627                          /* Can't have generic properties in method_context's */
9628 9628                          err = 1;
9629 9629                  }
9630 9630          }
9631 9631          if (ret == -1)
9632 9632                  scfdie();
9633 9633  
9634 9634          if (err && env == NULL) {
9635 9635                  xmlFreeNode(n);
9636      -                export_pg(pg, elts, 0);
     9636 +                export_pg(pg, elts, SCE_ALL_VALUES);
9637 9637                  return;
9638 9638          }
9639 9639  
9640 9640          elts->method_context = n;
9641 9641  }
9642 9642  
9643 9643  /*
9644 9644   * Given a dependency property group in the tfmri entity (target fmri), return
9645 9645   * a dependent element which represents it.
9646 9646   */
↓ open down ↓ 93 lines elided ↑ open up ↑
9740 9740                                  uu_die(emsg_create_xml);
9741 9741  
9742 9742                          if (set_attr_from_prop(exp_prop, s, value_attr) == 0) {
9743 9743                                  pgelts.stability = s;
9744 9744                                  continue;
9745 9745                          }
9746 9746  
9747 9747                          xmlFreeNode(s);
9748 9748                  }
9749 9749  
9750      -                export_property(exp_prop, exp_str, &pgelts, 0);
     9750 +                export_property(exp_prop, exp_str, &pgelts, SCE_ALL_VALUES);
9751 9751          }
9752 9752          if (ret == -1)
9753 9753                  scfdie();
9754 9754  
9755 9755          (void) xmlAddChild(n, pgelts.stability);
9756 9756          (void) xmlAddChildList(n, pgelts.propvals);
9757 9757          (void) xmlAddChildList(n, pgelts.properties);
9758 9758  
9759 9759          return (n);
9760 9760  }
↓ open down ↓ 28 lines elided ↑ open up ↑
9789 9789                  void *entity;
9790 9790                  int isservice;
9791 9791                  scf_type_t ty;
9792 9792  
9793 9793                  if (scf_property_type(exp_prop, &ty) != SCF_SUCCESS)
9794 9794                          scfdie();
9795 9795  
9796 9796                  if ((ty != SCF_TYPE_ASTRING &&
9797 9797                      prop_check_type(exp_prop, SCF_TYPE_FMRI) != 0) ||
9798 9798                      prop_get_val(exp_prop, exp_val) != 0) {
9799      -                        export_property(exp_prop, NULL, &pgelts, 0);
     9799 +                        export_property(exp_prop, NULL, &pgelts,
     9800 +                            SCE_ALL_VALUES);
9800 9801                          continue;
9801 9802                  }
9802 9803  
9803 9804                  if (scf_property_get_name(exp_prop, exp_str, exp_str_sz) < 0)
9804 9805                          scfdie();
9805 9806  
9806 9807                  if (scf_value_get_astring(exp_val, fmri,
9807 9808                      max_scf_fmri_len + 2) < 0)
9808 9809                          scfdie();
9809 9810  
↓ open down ↓ 10 lines elided ↑ open up ↑
9820 9821                  case SCF_ERROR_INVALID_ARGUMENT:
9821 9822                          if (g_verbose) {
9822 9823                                  if (scf_property_to_fmri(exp_prop, fmri,
9823 9824                                      max_scf_fmri_len + 2) < 0)
9824 9825                                          scfdie();
9825 9826  
9826 9827                                  warn(gettext("The value of %s is not a valid "
9827 9828                                      "FMRI.\n"), fmri);
9828 9829                          }
9829 9830  
9830      -                        export_property(exp_prop, exp_str, &pgelts, 0);
     9831 +                        export_property(exp_prop, exp_str, &pgelts,
     9832 +                            SCE_ALL_VALUES);
9831 9833                          continue;
9832 9834  
9833 9835                  case SCF_ERROR_CONSTRAINT_VIOLATED:
9834 9836                          if (g_verbose) {
9835 9837                                  if (scf_property_to_fmri(exp_prop, fmri,
9836 9838                                      max_scf_fmri_len + 2) < 0)
9837 9839                                          scfdie();
9838 9840  
9839 9841                                  warn(gettext("The value of %s does not specify "
9840 9842                                      "a service or an instance.\n"), fmri);
9841 9843                          }
9842 9844  
9843      -                        export_property(exp_prop, exp_str, &pgelts, 0);
     9845 +                        export_property(exp_prop, exp_str, &pgelts,
     9846 +                            SCE_ALL_VALUES);
9844 9847                          continue;
9845 9848  
9846 9849                  case SCF_ERROR_NOT_FOUND:
9847 9850                          if (g_verbose) {
9848 9851                                  if (scf_property_to_fmri(exp_prop, fmri,
9849 9852                                      max_scf_fmri_len + 2) < 0)
9850 9853                                          scfdie();
9851 9854  
9852 9855                                  warn(gettext("The entity specified by %s does "
9853 9856                                      "not exist.\n"), fmri);
9854 9857                          }
9855 9858  
9856      -                        export_property(exp_prop, exp_str, &pgelts, 0);
     9859 +                        export_property(exp_prop, exp_str, &pgelts,
     9860 +                            SCE_ALL_VALUES);
9857 9861                          continue;
9858 9862  
9859 9863                  default:
9860 9864  #ifndef NDEBUG
9861 9865                          (void) fprintf(stderr, "%s:%d: %s() failed with "
9862 9866                              "unexpected error %d.\n", __FILE__, __LINE__,
9863 9867                              "fmri_to_entity", serr);
9864 9868  #endif
9865 9869                          abort();
9866 9870                  }
9867 9871  
9868 9872                  if (entity_get_pg(entity, isservice, exp_str, opg) != 0) {
9869 9873                          if (scf_error() != SCF_ERROR_NOT_FOUND)
9870 9874                                  scfdie();
9871 9875  
9872 9876                          warn(gettext("Entity %s is missing dependency property "
9873 9877                              "group %s.\n"), fmri, exp_str);
9874 9878  
9875      -                        export_property(exp_prop, NULL, &pgelts, 0);
     9879 +                        export_property(exp_prop, NULL, &pgelts,
     9880 +                            SCE_ALL_VALUES);
9876 9881                          continue;
9877 9882                  }
9878 9883  
9879 9884                  if (scf_pg_get_type(opg, type, max_scf_pg_type_len + 1) < 0)
9880 9885                          scfdie();
9881 9886  
9882 9887                  if (strcmp(type, SCF_GROUP_DEPENDENCY) != 0) {
9883 9888                          if (scf_pg_to_fmri(opg, fmri, max_scf_fmri_len + 2) < 0)
9884 9889                                  scfdie();
9885 9890  
9886 9891                          warn(gettext("Property group %s is not of "
9887 9892                              "expected type %s.\n"), fmri, SCF_GROUP_DEPENDENCY);
9888 9893  
9889      -                        export_property(exp_prop, NULL, &pgelts, 0);
     9894 +                        export_property(exp_prop, NULL, &pgelts,
     9895 +                            SCE_ALL_VALUES);
9890 9896                          continue;
9891 9897                  }
9892 9898  
9893 9899                  n = export_dependent(opg, exp_str, fmri);
9894      -                if (n == NULL)
9895      -                        export_property(exp_prop, exp_str, &pgelts, 0);
9896      -                else {
     9900 +                if (n == NULL) {
     9901 +                        export_property(exp_prop, exp_str, &pgelts,
     9902 +                            SCE_ALL_VALUES);
     9903 +                } else {
9897 9904                          if (eelts->dependents == NULL)
9898 9905                                  eelts->dependents = n;
9899 9906                          else
9900 9907                                  (void) xmlAddSibling(eelts->dependents,
9901 9908                                      n);
9902 9909                  }
9903 9910          }
9904 9911          if (ret == -1)
9905 9912                  scfdie();
9906 9913  
↓ open down ↓ 103 lines elided ↑ open up ↑
10010 10017          size_t mansz = strlen(SCF_PG_TM_MAN_PREFIX);
10011 10018          size_t docsz = strlen(SCF_PG_TM_DOC_PREFIX);
10012 10019          xmlNodePtr child = NULL;
10013 10020  
10014 10021          if (scf_pg_get_name(pg, exp_str, exp_str_sz) < 0)
10015 10022                  scfdie();
10016 10023  
10017 10024          if (strcmp(exp_str, SCF_PG_TM_COMMON_NAME) == 0) {
10018 10025                  telts->common_name = export_tm_loctext(pg, "common_name");
10019 10026                  if (telts->common_name == NULL)
10020      -                        export_pg(pg, elts, 0);
     10027 +                        export_pg(pg, elts, SCE_ALL_VALUES);
10021 10028                  return;
10022 10029          } else if (strcmp(exp_str, SCF_PG_TM_DESCRIPTION) == 0) {
10023 10030                  telts->description = export_tm_loctext(pg, "description");
10024 10031                  if (telts->description == NULL)
10025      -                        export_pg(pg, elts, 0);
     10032 +                        export_pg(pg, elts, SCE_ALL_VALUES);
10026 10033                  return;
10027 10034          }
10028 10035  
10029 10036          if (strncmp(exp_str, SCF_PG_TM_MAN_PREFIX, mansz) == 0) {
10030 10037                  child = export_tm_manpage(pg);
10031 10038          } else if (strncmp(exp_str, SCF_PG_TM_DOC_PREFIX, docsz) == 0) {
10032 10039                  child = export_tm_doc_link(pg);
10033 10040          }
10034 10041  
10035 10042          if (child != NULL) {
10036 10043                  make_node(&telts->documentation, "documentation");
10037 10044                  (void) xmlAddChild(telts->documentation, child);
10038 10045          } else {
10039      -                export_pg(pg, elts, 0);
     10046 +                export_pg(pg, elts, SCE_ALL_VALUES);
10040 10047          }
10041 10048  }
10042 10049  
10043 10050  /*
10044 10051   * Process parameter and paramval elements
10045 10052   */
10046 10053  static void
10047 10054  export_parameter(scf_property_t *prop, const char *name,
10048 10055      struct params_elts *elts)
10049 10056  {
↓ open down ↓ 132 lines elided ↑ open up ↑
10182 10189          }
10183 10190  
10184 10191          if (ret == -1)
10185 10192                  scfdie();
10186 10193  
10187 10194          if (err == 1) {
10188 10195                  for (i = 0; i < URI_SCHEME_NUM; ++i)
10189 10196                          xmlFree(type[i]);
10190 10197                  free(type);
10191 10198  
10192      -                export_pg(pg, elts, 0);
     10199 +                export_pg(pg, elts, SCE_ALL_VALUES);
10193 10200  
10194 10201                  return;
10195 10202          } else {
10196 10203                  for (i = 0; i < URI_SCHEME_NUM; ++i)
10197 10204                          if (type[i] != NULL) {
10198 10205                                  (void) xmlAddChildList(type[i],
10199 10206                                      eelts[i].paramval);
10200 10207                                  (void) xmlAddChildList(type[i],
10201 10208                                      eelts[i].parameter);
10202 10209                                  (void) xmlAddSibling(event, type[i]);
↓ open down ↓ 55 lines elided ↑ open up ↑
10258 10265  
10259 10266                          if (set_attr_from_prop(exp_prop, sfnode,
10260 10267                              value_attr) == 0) {
10261 10268                                  elts->restarter = rnode;
10262 10269                                  continue;
10263 10270                          }
10264 10271  
10265 10272                          xmlFreeNode(rnode);
10266 10273                  }
10267 10274  
10268      -                export_property(exp_prop, exp_str, &pgelts, 0);
     10275 +                export_property(exp_prop, exp_str, &pgelts, SCE_ALL_VALUES);
10269 10276          }
10270 10277          if (ret == -1)
10271 10278                  scfdie();
10272 10279  
10273 10280          if (pgelts.propvals != NULL || pgelts.properties != NULL)
10274 10281                  export_pg_elts(&pgelts, scf_pg_general, scf_group_framework,
10275 10282                      elts);
10276 10283  }
10277 10284  
10278 10285  /*
↓ open down ↓ 7051 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX