Print this page
2831 svc.startd and svc.configd waste memory.


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 #include <libintl.h>
  27 #include <librestart.h>
  28 #include <librestart_priv.h>
  29 #include <libscf.h>
  30 #include <libscf_priv.h>
  31 
  32 #include <assert.h>
  33 #include <ctype.h>
  34 #include <dlfcn.h>
  35 #include <errno.h>
  36 #include <exec_attr.h>
  37 #include <grp.h>
  38 #include <libsysevent.h>
  39 #include <libuutil.h>
  40 #include <limits.h>
  41 #include <link.h>
  42 #include <malloc.h>
  43 #include <pool.h>


3316                         default:
3317                                 bad_fail("scf_pg_get_property", ret);
3318                         }
3319                 }
3320 
3321                 if (strcmp(cip->vbuf, ":default") != 0) {
3322                         cip->resource_pool = strdup(cip->vbuf);
3323                         if (cip->resource_pool == NULL) {
3324                                 err = mc_error_create(err, ENOMEM, ALLOCFAIL);
3325                                 goto out;
3326                         }
3327                 }
3328         }
3329 
3330         /*
3331          * A method_context was not used for any configurable
3332          * elements or attributes, so reset and use the simple
3333          * defaults that provide historic init behavior.
3334          */
3335         if (mc_used == 0) {




3336                 (void) memset(cip, 0, sizeof (*cip));
3337                 cip->uid = 0;
3338                 cip->gid = 0;
3339                 cip->euid = (uid_t)-1;
3340                 cip->egid = (gid_t)-1;
3341         }
3342 
3343         *mcpp = cip;
3344 
3345 out:
3346         (void) scf_value_destroy(val);
3347         scf_property_destroy(prop);
3348         scf_pg_destroy(instpg);
3349         scf_pg_destroy(methpg);
3350 
3351         if (cip->pwbuf != NULL)
3352                 free(cip->pwbuf);



3353         free(cip->vbuf);
3354 
3355         if (err->type != 0) {
3356                 restarter_free_method_context(cip);
3357         } else {
3358                 restarter_mc_error_destroy(err);
3359                 err = NULL;
3360         }
3361 
3362         return (err);
3363 }
3364 
3365 /*
3366  * Modify the current process per the given method_context.  On success, returns
3367  * 0.  Note that the environment is not modified by this function to include the
3368  * environment variables in cip->env.
3369  *
3370  * On failure, sets *fp to NULL or the name of the function which failed,
3371  * and returns one of the following error codes.  The words in parentheses are
3372  * the values to which *fp may be set for the error case.




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  25  */
  26 
  27 #include <libintl.h>
  28 #include <librestart.h>
  29 #include <librestart_priv.h>
  30 #include <libscf.h>
  31 #include <libscf_priv.h>
  32 
  33 #include <assert.h>
  34 #include <ctype.h>
  35 #include <dlfcn.h>
  36 #include <errno.h>
  37 #include <exec_attr.h>
  38 #include <grp.h>
  39 #include <libsysevent.h>
  40 #include <libuutil.h>
  41 #include <limits.h>
  42 #include <link.h>
  43 #include <malloc.h>
  44 #include <pool.h>


3317                         default:
3318                                 bad_fail("scf_pg_get_property", ret);
3319                         }
3320                 }
3321 
3322                 if (strcmp(cip->vbuf, ":default") != 0) {
3323                         cip->resource_pool = strdup(cip->vbuf);
3324                         if (cip->resource_pool == NULL) {
3325                                 err = mc_error_create(err, ENOMEM, ALLOCFAIL);
3326                                 goto out;
3327                         }
3328                 }
3329         }
3330 
3331         /*
3332          * A method_context was not used for any configurable
3333          * elements or attributes, so reset and use the simple
3334          * defaults that provide historic init behavior.
3335          */
3336         if (mc_used == 0) {
3337                 free(cip->pwbuf);
3338                 free(cip->vbuf);
3339                 free(cip->working_dir);
3340 
3341                 (void) memset(cip, 0, sizeof (*cip));
3342                 cip->uid = 0;
3343                 cip->gid = 0;
3344                 cip->euid = (uid_t)-1;
3345                 cip->egid = (gid_t)-1;
3346         }
3347 
3348         *mcpp = cip;
3349 
3350 out:
3351         (void) scf_value_destroy(val);
3352         scf_property_destroy(prop);
3353         scf_pg_destroy(instpg);
3354         scf_pg_destroy(methpg);
3355 
3356         if (cip->pwbuf != NULL) {
3357                 free(cip->pwbuf);
3358                 cip->pwbuf = NULL;
3359         }
3360 
3361         free(cip->vbuf);
3362 
3363         if (err->type != 0) {
3364                 restarter_free_method_context(cip);
3365         } else {
3366                 restarter_mc_error_destroy(err);
3367                 err = NULL;
3368         }
3369 
3370         return (err);
3371 }
3372 
3373 /*
3374  * Modify the current process per the given method_context.  On success, returns
3375  * 0.  Note that the environment is not modified by this function to include the
3376  * environment variables in cip->env.
3377  *
3378  * On failure, sets *fp to NULL or the name of the function which failed,
3379  * and returns one of the following error codes.  The words in parentheses are
3380  * the values to which *fp may be set for the error case.