Print this page
7806 svccfg restore segfaults in upgrade_manifestfiles
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Jason King <jason.brian.king@gmail.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 ↓ 15 lines elided ↑ open up ↑
  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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2015 Joyent, Inc.
  25   25   * Copyright 2012 Milan Jurik. All rights reserved.
       26 + * Copyright 2017 RackTop Systems.
  26   27   */
  27   28  
  28   29  
  29   30  #include <alloca.h>
  30   31  #include <assert.h>
  31   32  #include <ctype.h>
  32   33  #include <door.h>
  33   34  #include <errno.h>
  34   35  #include <fcntl.h>
  35   36  #include <fnmatch.h>
↓ open down ↓ 3852 lines elided ↑ open up ↑
3888 3889   *
3889 3890   * Get the old list and the new file name
3890 3891   * If the new file name is in the list return
3891 3892   * If not then add the file to the list.
3892 3893   * As we process the list check to see if the files in the old list exist
3893 3894   *      if not then remove the file from the list.
3894 3895   * Commit the list of manifest file names.
3895 3896   *
3896 3897   */
3897 3898  static int
3898      -upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
     3899 +upgrade_manifestfiles(pgroup_t *pg, entity_t *ient,
3899 3900      const scf_snaplevel_t *running, void *ent)
3900 3901  {
3901 3902          scf_propertygroup_t *ud_mfsts_pg = NULL;
3902 3903          scf_property_t *ud_prop = NULL;
3903 3904          scf_iter_t *ud_prop_iter;
3904 3905          scf_value_t *fname_value;
3905 3906          scf_callback_t cbdata;
3906 3907          pgroup_t *mfst_pgroup;
3907 3908          property_t *mfst_prop;
3908 3909          property_t *old_prop;
↓ open down ↓ 49 lines elided ↑ open up ↑
3958 3959                  cbdata.sc_source_fmri = ient->sc_fmri;
3959 3960                  cbdata.sc_target_fmri = ient->sc_fmri;
3960 3961  
3961 3962                  if (entity_pgroup_import(pg, &cbdata) != UU_WALK_NEXT)
3962 3963                          return (cbdata.sc_err);
3963 3964  
3964 3965                  return (0);
3965 3966          }
3966 3967  
3967 3968          /* Fetch the new manifests property group */
3968      -        for (mfst_pgroup = uu_list_first(ient->sc_pgroups);
3969      -            mfst_pgroup != NULL;
3970      -            mfst_pgroup = uu_list_next(ient->sc_pgroups, mfst_pgroup)) {
3971      -                if (strcmp(mfst_pgroup->sc_pgroup_name,
3972      -                    SCF_PG_MANIFESTFILES) == 0)
3973      -                        break;
3974      -        }
     3969 +        mfst_pgroup = internal_pgroup_find_or_create(ient,
     3970 +            SCF_PG_MANIFESTFILES, SCF_GROUP_FRAMEWORK);
     3971 +        assert(mfst_pgroup != NULL);
3975 3972  
3976 3973          if ((r = scf_iter_pg_properties(ud_prop_iter, ud_mfsts_pg)) !=
3977 3974              SCF_SUCCESS)
3978 3975                  return (-1);
3979 3976  
3980 3977          if ((pname = malloc(MAXPATHLEN)) == NULL)
3981 3978                  return (ENOMEM);
3982 3979          if ((fval = malloc(MAXPATHLEN)) == NULL) {
3983 3980                  free(pname);
3984 3981                  return (ENOMEM);
↓ open down ↓ 13644 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX