Changeset 23535
- Timestamp:
- 2008-03-05 18:16:37 (7 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 7 modified
-
launchctl.c (modified) (1 diff)
-
launchd_core_logic.c (modified) (4 diffs)
-
launchd_runtime.c (modified) (1 diff)
-
libbootstrap.c (modified) (2 diffs)
-
libbootstrap_public.h (modified) (2 diffs)
-
libvproc_public.h (modified) (2 diffs)
-
protocol_job.defs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchctl.c
r23530 r23535 1795 1795 continue; 1796 1796 } 1797 if ((kr = bootstrap_c reate_service(msr, (char*)sn, &msv)) != KERN_SUCCESS) {1797 if ((kr = bootstrap_check_in(msr, (char*)sn, &msv)) != KERN_SUCCESS) { 1798 1798 fprintf(stderr, "%s: bootstrap_create_service(): %d\n", getprogname(), kr); 1799 mach_port_ destroy(mach_task_self(), msr);1799 mach_port_mod_refs(mach_task_self(), msv, MACH_PORT_RIGHT_RECEIVE, -1); 1800 1800 continue; 1801 1801 } -
trunk/launchd/src/launchd_core_logic.c
r23533 r23535 426 426 static job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv) __attribute__((malloc, nonnull(1,2), warn_unused_result)); 427 427 static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond) __attribute__((malloc, nonnull, warn_unused_result)); 428 static const char *job_prog(job_t j);429 428 static void job_kill(job_t j); 430 429 static void job_uncork_fork(job_t j); … … 4134 4133 4135 4134 const char * 4136 job_prog(job_t j)4137 {4138 if (j->prog) {4139 return j->prog;4140 } else if (likely(j->argv)) {4141 return j->argv[0];4142 } else {4143 return "";4144 }4145 }4146 4147 const char *4148 4135 job_active(job_t j) 4149 4136 { … … 5927 5914 ms = jobmgr_lookup_service(j->mgr, servicename, true, 0); 5928 5915 5929 if (unlikely(ms == NULL)) { 5930 job_log(j, LOG_DEBUG, "Check-in of Mach service failed. Unknown: %s", servicename); 5931 return BOOTSTRAP_UNKNOWN_SERVICE; 5916 if (ms == NULL) { 5917 *serviceportp = MACH_PORT_NULL; 5918 ms = machservice_new(j, servicename, serviceportp, false); 5919 5920 if (unlikely(ms == NULL)) { 5921 return BOOTSTRAP_NO_MEMORY; 5922 } 5923 5924 job_checkin(j); 5932 5925 } 5933 5926 … … 6576 6569 6577 6570 kern_return_t 6578 job_mig_create_service(job_t j, name_t servicename, mach_port_t *serviceportp)6579 {6580 struct machservice *ms;6581 6582 if (!launchd_assumes(j != NULL)) {6583 return BOOTSTRAP_NO_MEMORY;6584 }6585 6586 if (unlikely(job_prog(j)[0] == '\0')) {6587 job_log(j, LOG_ERR, "Mach service creation requires a target server: %s", servicename);6588 return BOOTSTRAP_NOT_PRIVILEGED;6589 }6590 6591 if (unlikely(!j->legacy_mach_job)) {6592 job_log(j, LOG_ERR, "bootstrap_create_service() is only allowed against legacy Mach jobs: %s", servicename);6593 return BOOTSTRAP_NOT_PRIVILEGED;6594 }6595 6596 ms = jobmgr_lookup_service(j->mgr, servicename, false, 0);6597 if (unlikely(ms)) {6598 job_log(j, LOG_DEBUG, "Mach service creation attempt for failed. Already exists: %s", servicename);6599 return BOOTSTRAP_NAME_IN_USE;6600 }6601 6602 job_checkin(j);6603 6604 *serviceportp = MACH_PORT_NULL;6605 ms = machservice_new(j, servicename, serviceportp, false);6606 6607 if (!job_assumes(j, ms != NULL)) {6608 return BOOTSTRAP_NO_MEMORY;6609 }6610 6611 return BOOTSTRAP_SUCCESS;6612 }6613 6614 kern_return_t6615 6571 job_mig_embedded_wait(job_t j, name_t targetlabel, integer_t *waitstatus) 6616 6572 { -
trunk/launchd/src/launchd_runtime.c
r23530 r23535 1 1 /* 2 * Copyright (c) 1999-200 6Apple Computer, Inc. All rights reserved.2 * Copyright (c) 1999-2008 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * @APPLE_APACHE_LICENSE_HEADER_START@ -
trunk/launchd/src/libbootstrap.c
r23207 r23535 101 101 bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp) 102 102 { 103 return vproc_mig_create_service(bp, service_name, sp); 103 kern_return_t kr; 104 105 if ((kr = bootstrap_check_in(bp, service_name, sp))) { 106 return kr; 107 } 108 109 if ((kr = mach_port_mod_refs(mach_task_self(), *sp, MACH_PORT_RIGHT_RECEIVE, -1))) { 110 return kr; 111 } 112 113 return bootstrap_look_up(bp, service_name, sp); 104 114 } 105 115 … … 161 171 bootstrap_status(mach_port_t bp, name_t service_name, bootstrap_status_t *service_active) 162 172 { 173 kern_return_t kr; 163 174 mach_port_t p; 175 176 if ((kr = bootstrap_look_up(bp, service_name, &p))) { 177 return kr; 178 } 179 180 mach_port_deallocate(mach_task_self(), p); 181 *service_active = BOOTSTRAP_STATUS_ACTIVE; 164 182 165 183 if (bootstrap_check_in(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { 166 184 mach_port_mod_refs(mach_task_self(), p, MACH_PORT_RIGHT_RECEIVE, -1); 167 185 *service_active = BOOTSTRAP_STATUS_ON_DEMAND; 168 return BOOTSTRAP_SUCCESS; 169 } else if (bootstrap_look_up(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { 170 mach_port_deallocate(mach_task_self(), p); 171 *service_active = BOOTSTRAP_STATUS_ACTIVE; 172 return BOOTSTRAP_SUCCESS; 173 } 174 175 return BOOTSTRAP_UNKNOWN_SERVICE; 186 } 187 188 return BOOTSTRAP_SUCCESS; 176 189 } 177 190 -
trunk/launchd/src/libbootstrap_public.h
r22914 r23535 234 234 * This API is deprecated. Old scenarios and recommendations: 235 235 * 236 * 1) If the code was registering a well known name, please switch to launchd. 237 * 238 * 2) If the code was registering a dynamically generated string and passing 236 * 1) Code that used to call bootstrap_check_in() and then bootstrap_register() 237 * can now always call bootstrap_check_in(). 238 * 239 * 2) If the code was registering a well known name, please switch to launchd. 240 * 241 * 3) If the code was registering a dynamically generated string and passing 239 242 * the string to other applications, please rewrite the code to send a Mach 240 243 * send-right directly. 241 244 * 242 * 3) If the launchd job maintained an optional Mach service, please reserve245 * 4) If the launchd job maintained an optional Mach service, please reserve 243 246 * the name with launchd and control the presense of the service through 244 247 * ownership of the Mach receive right like so. … … 262 265 * register or checked-in. 263 266 */ 264 kern_return_t bootstrap_register( 265 mach_port_t bp, 266 name_t service_name, 267 mach_port_t sp) 268 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; 267 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 268 kern_return_t 269 bootstrap_register(mach_port_t bp, name_t service_name, mach_port_t sp); 269 270 270 271 /* 271 272 * bootstrap_create_service() 272 273 * 273 * Creates a service named "service_name" and returns send rightsto that274 * Creates a service named "service_name" and returns a send right to that 274 275 * port in "service_port." The port may later be checked in as if this 275 276 * port were configured in the bootstrap configuration file. 276 277 * 278 * This API is deprecated. Please call bootstrap_check_in() instead. 279 * 277 280 * Errors: Returns appropriate kernel errors on rpc failure. 278 281 * Returns BOOTSTRAP_SERVICE_ACTIVE, if service already exists. 279 282 */ 280 kern_return_t bootstrap_create_service( 281 mach_port_t bp, 282 name_t service_name, 283 mach_port_t *sp); 283 #ifdef AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 284 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 285 #endif 286 kern_return_t 287 bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp); 284 288 285 289 /* -
trunk/launchd/src/libvproc_public.h
r23524 r23535 95 95 * @function vproc_transaction_complete 96 96 * 97 * @param 97 * @param handle 98 98 * The handle previously created with vproc_transaction_prepare(). 99 99 * … … 131 131 * @function vproc_standby_complete 132 132 * 133 * @param 133 * @param handle 134 134 * The handle previously created with vproc_standby_prepare(). 135 135 * -
trunk/launchd/src/protocol_job.defs
r23486 r23535 95 95 out __subset_port : mach_port_make_send_t); 96 96 97 routine create_service( 98 __bs_port : job_t; 99 __service_name : name_t; 100 out __service_port : mach_port_t); 97 skip; /* create_service prior to 10.6 */ 101 98 102 99 routine take_subset(

