Projects
Browse Source     Search     Timeline     Wiki

Changeset 23535

Show
Ignore:
Timestamp:
2008-03-05 18:16:37 (7 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/5783944> Deprecate bootstrap_create_service() in favor of bootstrap_check_in()

Location:
trunk/launchd/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchctl.c

    r23530 r23535  
    17951795                        continue; 
    17961796                } 
    1797                 if ((kr = bootstrap_create_service(msr, (char*)sn, &msv)) != KERN_SUCCESS) { 
     1797                if ((kr = bootstrap_check_in(msr, (char*)sn, &msv)) != KERN_SUCCESS) { 
    17981798                        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); 
    18001800                        continue; 
    18011801                } 
  • trunk/launchd/src/launchd_core_logic.c

    r23533 r23535  
    426426static 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)); 
    427427static 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); 
    429428static void job_kill(job_t j); 
    430429static void job_uncork_fork(job_t j); 
     
    41344133 
    41354134const 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 * 
    41484135job_active(job_t j) 
    41494136{ 
     
    59275914        ms = jobmgr_lookup_service(j->mgr, servicename, true, 0); 
    59285915 
    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); 
    59325925        } 
    59335926 
     
    65766569 
    65776570kern_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_t 
    66156571job_mig_embedded_wait(job_t j, name_t targetlabel, integer_t *waitstatus) 
    66166572{ 
  • trunk/launchd/src/launchd_runtime.c

    r23530 r23535  
    11/* 
    2  * Copyright (c) 1999-2006 Apple Computer, Inc. All rights reserved. 
     2 * Copyright (c) 1999-2008 Apple Computer, Inc. All rights reserved. 
    33 * 
    44 * @APPLE_APACHE_LICENSE_HEADER_START@ 
  • trunk/launchd/src/libbootstrap.c

    r23207 r23535  
    101101bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp) 
    102102{ 
    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); 
    104114} 
    105115 
     
    161171bootstrap_status(mach_port_t bp, name_t service_name, bootstrap_status_t *service_active) 
    162172{ 
     173        kern_return_t kr; 
    163174        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; 
    164182 
    165183        if (bootstrap_check_in(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { 
    166184                mach_port_mod_refs(mach_task_self(), p, MACH_PORT_RIGHT_RECEIVE, -1); 
    167185                *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; 
    176189} 
    177190 
  • trunk/launchd/src/libbootstrap_public.h

    r22914 r23535  
    234234 * This API is deprecated. Old scenarios and recommendations: 
    235235 * 
    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 
    239242 *    the string to other applications, please rewrite the code to send a Mach 
    240243 *    send-right directly. 
    241244 * 
    242  * 3) If the launchd job maintained an optional Mach service, please reserve 
     245 * 4) If the launchd job maintained an optional Mach service, please reserve 
    243246 *    the name with launchd and control the presense of the service through 
    244247 *    ownership of the Mach receive right like so. 
     
    262265 *                      register or checked-in. 
    263266 */ 
    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; 
     267AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 
     268kern_return_t 
     269bootstrap_register(mach_port_t bp, name_t service_name, mach_port_t sp); 
    269270 
    270271/* 
    271272 * bootstrap_create_service() 
    272273 * 
    273  * Creates a service named "service_name" and returns send rights to that 
     274 * Creates a service named "service_name" and returns a send right to that 
    274275 * port in "service_port."  The port may later be checked in as if this 
    275276 * port were configured in the bootstrap configuration file. 
    276277 * 
     278 * This API is deprecated. Please call bootstrap_check_in() instead. 
     279 * 
    277280 * Errors:      Returns appropriate kernel errors on rpc failure. 
    278281 *              Returns BOOTSTRAP_SERVICE_ACTIVE, if service already exists. 
    279282 */ 
    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 
     284AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 
     285#endif 
     286kern_return_t 
     287bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp); 
    284288 
    285289/* 
  • trunk/launchd/src/libvproc_public.h

    r23524 r23535  
    9595 * @function vproc_transaction_complete 
    9696 * 
    97  * @param 
     97 * @param       handle 
    9898 * The handle previously created with vproc_transaction_prepare(). 
    9999 * 
     
    131131 * @function vproc_standby_complete 
    132132 * 
    133  * @param 
     133 * @param       handle 
    134134 * The handle previously created with vproc_standby_prepare(). 
    135135 * 
  • trunk/launchd/src/protocol_job.defs

    r23486 r23535  
    9595        out     __subset_port   : mach_port_make_send_t); 
    9696 
    97 routine create_service( 
    98                 __bs_port       : job_t; 
    99                 __service_name  : name_t; 
    100         out     __service_port  : mach_port_t); 
     97skip;   /* create_service prior to 10.6 */ 
    10198 
    10299routine take_subset(