corectl.c (7c478bd95313f5f23a4c958a745db2134aa03244) | corectl.c (3f2f09c1efd66f6d2995998ea72c5df8c70c9a97) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. | 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. |
8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 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/* |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <sys/proc.h> 30#include <sys/systm.h> 31#include <sys/param.h> --- 14 unchanged lines hidden (view full) --- 46 * structures. The corectl_content_t structure is fairly straightforward -- 47 * the only subtlety is that we only really _need_ the mutex on architectures 48 * on which 64-bit memory operations are not atomic. The corectl_path_t 49 * structure is slightly trickier in that it contains a refstr_t rather than 50 * just a char * string. This is to allow consumers of the data in that 51 * structure (the core dumping sub-system for example) to safely use the 52 * string without holding any locks on it in light of updates. 53 * | 23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28#include <sys/proc.h> 29#include <sys/systm.h> 30#include <sys/param.h> --- 14 unchanged lines hidden (view full) --- 45 * structures. The corectl_content_t structure is fairly straightforward -- 46 * the only subtlety is that we only really _need_ the mutex on architectures 47 * on which 64-bit memory operations are not atomic. The corectl_path_t 48 * structure is slightly trickier in that it contains a refstr_t rather than 49 * just a char * string. This is to allow consumers of the data in that 50 * structure (the core dumping sub-system for example) to safely use the 51 * string without holding any locks on it in light of updates. 52 * |
54 * At system boot, init_core() sets init(1M)'s core file path and content to 55 * the same value as the fields core_default_path and core_default_content 56 * respectively (for the global zone). All subsequent children of init(1M) 57 * reference those same settings. During boot coreadm(1M) is invoked with 58 * the -u option to update the system settings from /etc/coreadm.conf. This 59 * has the effect of also changing the values in core_default_path and 60 * core_default_content which updates the core file settings for all 61 * processes in the zone. Each zone has different default settings; when 62 * processes enter a non-global zone, their core file path and content are 63 * set to the zone's default path and content. | 53 * At system and zone boot, init_core() sets init(1M)'s core file path and 54 * content to the same value as the fields core_default_path and 55 * core_default_content respectively (for the global zone). All subsequent 56 * children of init(1M) reference those same settings. During boot coreadm(1M) 57 * is invoked with the -u option to update the system settings from 58 * /etc/coreadm.conf. This has the effect of also changing the values in 59 * core_default_path and core_default_content which updates the core file 60 * settings for all processes in the zone. Each zone has different default 61 * settings; when processes enter a non-global zone, their core file path and 62 * content are set to the zone's default path and content. |
64 * 65 * Processes that have their core file settings explicitly overridden using 66 * coreadm(1M) no longer reference core_default_path or core_default_content 67 * so subsequent changes to the default will not affect them. 68 */ 69 70zone_key_t core_zone_key; 71 --- 130 unchanged lines hidden (view full) --- 202 if (cg->core_file != NULL) 203 refstr_rele(cg->core_file); 204 corectl_path_rele(cg->core_default_path); 205 corectl_content_rele(cg->core_default_content); 206 kmem_free(cg, sizeof (*cg)); 207} 208 209/* | 63 * 64 * Processes that have their core file settings explicitly overridden using 65 * coreadm(1M) no longer reference core_default_path or core_default_content 66 * so subsequent changes to the default will not affect them. 67 */ 68 69zone_key_t core_zone_key; 70 --- 130 unchanged lines hidden (view full) --- 201 if (cg->core_file != NULL) 202 refstr_rele(cg->core_file); 203 corectl_path_rele(cg->core_default_path); 204 corectl_content_rele(cg->core_default_content); 205 kmem_free(cg, sizeof (*cg)); 206} 207 208/* |
210 * Called once, from icode(), to set init's core file path and content. | 209 * Called from start_init_common(), to set init's core file path and content. |
211 */ 212void 213init_core(void) 214{ 215 struct core_globals *cg; 216 | 210 */ 211void 212init_core(void) 213{ 214 struct core_globals *cg; 215 |
217 zone_key_create(&core_zone_key, core_init_zone, NULL, core_free_zone); | 216 /* 217 * The first time we hit this, in the global zone, we have to 218 * initialize the zsd key. 219 */ 220 if (INGLOBALZONE(curproc)) { 221 zone_key_create(&core_zone_key, core_init_zone, NULL, 222 core_free_zone); 223 } |
218 219 /* 220 * zone_key_create will have called core_init_zone for the 221 * global zone, which sets up the default path and content 222 * variables. 223 */ | 224 225 /* 226 * zone_key_create will have called core_init_zone for the 227 * global zone, which sets up the default path and content 228 * variables. 229 */ |
224 cg = zone_getspecific(core_zone_key, global_zone); 225 ASSERT(cg != NULL); | 230 VERIFY((cg = zone_getspecific(core_zone_key, curproc->p_zone)) != NULL); |
226 227 corectl_path_hold(cg->core_default_path); 228 corectl_content_hold(cg->core_default_content); 229 230 curproc->p_corefile = cg->core_default_path; 231 curproc->p_content = cg->core_default_content; 232} 233 --- 54 unchanged lines hidden (view full) --- 288 mutex_exit(&p->p_lock); 289 } 290 } 291 if (rp == NULL) { 292 if (error == 0 && suword8((void *)arg1, 0)) 293 error = EFAULT; 294 } else { 295 error = copyoutstr(refstr_value(rp), (char *)arg1, | 231 232 corectl_path_hold(cg->core_default_path); 233 corectl_content_hold(cg->core_default_content); 234 235 curproc->p_corefile = cg->core_default_path; 236 curproc->p_content = cg->core_default_content; 237} 238 --- 54 unchanged lines hidden (view full) --- 293 mutex_exit(&p->p_lock); 294 } 295 } 296 if (rp == NULL) { 297 if (error == 0 && suword8((void *)arg1, 0)) 298 error = EFAULT; 299 } else { 300 error = copyoutstr(refstr_value(rp), (char *)arg1, |
296 (size_t)arg2, NULL); | 301 (size_t)arg2, NULL); |
297 refstr_rele(rp); 298 } 299 break; 300 301 case CC_SET_GLOBAL_PATH: 302 case CC_SET_DEFAULT_PATH: 303 if ((error = secpolicy_coreadm(CRED())) != 0) 304 break; --- 254 unchanged lines hidden --- | 302 refstr_rele(rp); 303 } 304 break; 305 306 case CC_SET_GLOBAL_PATH: 307 case CC_SET_DEFAULT_PATH: 308 if ((error = secpolicy_coreadm(CRED())) != 0) 309 break; --- 254 unchanged lines hidden --- |