From source_changes at macosforge.org Tue Oct 10 17:09:20 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22889] trunk/launchd/src/launchctl.c Message-ID: <20061011000920.8AF251F57D6@cvs.opensource.apple.com> Revision: 22889 http://trac.macosforge.org/projects/launchd/changeset/22889 Author: zarzycki@apple.com Date: 2006-10-10 17:09:19 -0700 (Tue, 10 Oct 2006) Log Message: ----------- "typo" Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-09-28 19:38:17 UTC (rev 22888) +++ trunk/launchd/src/launchctl.c 2006-10-11 00:09:19 UTC (rev 22889) @@ -2581,7 +2581,7 @@ void empty_dir(const char *path) { - assumes(chflags(path, 0) != -1); + assumes(lchflags(path, 0) != -1); assumes(remove(path) != -1); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061010/9e094107/attachment.html From source_changes at macosforge.org Thu Oct 12 12:13:23 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22890] trunk/launchd/src Message-ID: <20061012191323.D8A6C200E11@cvs.opensource.apple.com> Revision: 22890 http://trac.macosforge.org/projects/launchd/changeset/22890 Author: zarzycki@apple.com Date: 2006-10-12 12:13:23 -0700 (Thu, 12 Oct 2006) Log Message: ----------- Make the remote creds accessible at any time. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/protocol_legacy.defs Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-11 00:09:19 UTC (rev 22889) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-12 19:13:23 UTC (rev 22890) @@ -88,16 +88,6 @@ static au_asid_t inherited_asid; mach_port_t inherited_bootstrap_port; -struct ldcred { - uid_t euid; - uid_t uid; - gid_t egid; - gid_t gid; - pid_t pid; - au_asid_t asid; -}; - -static void audit_token_to_launchd_cred(audit_token_t au_tok, struct ldcred *ldc); static bool trusted_client_check(job_t j, struct ldcred *ldc); @@ -3473,13 +3463,12 @@ } kern_return_t -job_mig_create_server(job_t j, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, - audit_token_t au_tok, mach_port_t *server_portp) +job_mig_create_server(job_t j, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_portp) { struct ldcred ldc; job_t js; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); job_log(j, LOG_DEBUG, "Server create attempt: %s", server_cmd); @@ -3527,12 +3516,12 @@ } kern_return_t -job_mig_get_self(job_t j, audit_token_t au_tok, mach_port_t *unprivportp) +job_mig_get_self(job_t j, mach_port_t *unprivportp) { struct ldcred ldc; job_t j2; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); job_log(j, LOG_DEBUG, "Requested unprivileged bootstrap port"); @@ -3557,13 +3546,13 @@ kern_return_t -job_mig_check_in(job_t j, name_t servicename, audit_token_t au_tok, mach_port_t *serviceportp) +job_mig_check_in(job_t j, name_t servicename, mach_port_t *serviceportp) { static pid_t last_warned_pid = 0; struct machservice *ms; struct ldcred ldc; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); ms = job_lookup_service(j, servicename, true); @@ -3593,13 +3582,13 @@ } kern_return_t -job_mig_register(job_t j, audit_token_t au_tok, name_t servicename, mach_port_t serviceport) +job_mig_register(job_t j, name_t servicename, mach_port_t serviceport) { struct machservice *ms; struct ldcred ldc; job_t j2; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); if (j == job_get_bs(j)) { j2 = job_find_by_pid(j, ldc.pid, false); @@ -3641,12 +3630,12 @@ } kern_return_t -job_mig_look_up(job_t j, audit_token_t au_tok, name_t servicename, mach_port_t *serviceportp, mach_msg_type_name_t *ptype) +job_mig_look_up(job_t j, name_t servicename, mach_port_t *serviceportp, mach_msg_type_name_t *ptype) { struct machservice *ms; struct ldcred ldc; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); ms = job_lookup_service(j, servicename, true); @@ -3896,17 +3885,17 @@ } kern_return_t -job_mig_wait(job_t j, mach_port_t srp, audit_token_t au_tok, integer_t *waitstatus) +job_mig_wait(job_t j, mach_port_t srp, integer_t *waitstatus) { #if 0 struct ldcred ldc; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); #endif return job_handle_mpm_wait(j, srp, waitstatus); } kern_return_t -job_mig_uncork_fork(job_t j, audit_token_t au_tok) +job_mig_uncork_fork(job_t j) { if (!j) { return BOOTSTRAP_NOT_PRIVILEGED; @@ -3918,8 +3907,7 @@ } kern_return_t -job_mig_spawn(job_t j, audit_token_t au_tok, - _internal_string_t charbuf, mach_msg_type_number_t charbuf_cnt, +job_mig_spawn(job_t j, _internal_string_t charbuf, mach_msg_type_number_t charbuf_cnt, uint32_t argc, uint32_t envc, uint64_t flags, uint16_t mig_umask, pid_t *child_pid, mach_port_t *obsvr_port) { @@ -3933,7 +3921,7 @@ const char *workingdir = NULL; size_t argv_i = 0, env_i = 0; - audit_token_to_launchd_cred(au_tok, &ldc); + runtime_get_caller_creds(&ldc); #if 0 if (ldc.asid != inherited_asid) { @@ -3993,14 +3981,6 @@ return BOOTSTRAP_SUCCESS; } -void -audit_token_to_launchd_cred(audit_token_t au_tok, struct ldcred *ldc) -{ - audit_token_to_au32(au_tok, /* audit UID */ NULL, &ldc->euid, - &ldc->egid, &ldc->uid, &ldc->gid, &ldc->pid, - &ldc->asid, /* au_tid_t */ NULL); -} - bool trusted_client_check(job_t j, struct ldcred *ldc) { Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2006-10-11 00:09:19 UTC (rev 22889) +++ trunk/launchd/src/launchd_runtime.c 2006-10-12 19:13:23 UTC (rev 22890) @@ -79,6 +79,7 @@ static size_t mig_cb_table_sz; static timeout_callback runtime_idle_callback; static mach_msg_timeout_t runtime_idle_timeout; +static audit_token_t *au_tok; void launchd_runtime_init(void) @@ -475,6 +476,38 @@ return KERN_SUCCESS; } +static void +record_caller_creds(mach_msg_header_t *mh) +{ + mach_msg_max_trailer_t *tp; + size_t trailer_size; + + tp = (mach_msg_max_trailer_t *)((vm_offset_t)mh + round_msg(mh->msgh_size)); + + trailer_size = tp->msgh_trailer_size - (mach_msg_size_t)(sizeof(mach_msg_trailer_type_t) - sizeof(mach_msg_trailer_size_t)); + + if (trailer_size < (mach_msg_size_t)sizeof(audit_token_t)) { + au_tok = NULL; + return; + } + + au_tok = &tp->msgh_audit; +} + +bool +runtime_get_caller_creds(struct ldcred *ldc) +{ + if (!au_tok) { + return false; + } + + audit_token_to_au32(*au_tok, /* audit UID */ NULL, &ldc->euid, + &ldc->egid, &ldc->uid, &ldc->gid, &ldc->pid, + &ldc->asid, /* au_tid_t */ NULL); + + return true; +} + void launchd_runtime2(mach_msg_size_t msg_size, mig_reply_error_t *bufRequest, mig_reply_error_t *bufReply) { @@ -555,6 +588,8 @@ break; } + record_caller_creds(&bufRequest->Head); + if (the_demux(&bufRequest->Head, &bufReply->Head) == FALSE) { /* XXX - also gross */ if (bufRequest->Head.msgh_id == MACH_NOTIFY_NO_SENDERS) { Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2006-10-11 00:09:19 UTC (rev 22889) +++ trunk/launchd/src/launchd_runtime.h 2006-10-12 19:13:23 UTC (rev 22890) @@ -22,6 +22,15 @@ #include +struct ldcred { + uid_t euid; + uid_t uid; + gid_t egid; + gid_t gid; + pid_t pid; + au_asid_t asid; +}; + /* * Use launchd_assumes() when we can recover, even if it means we leak or limp along. * @@ -50,7 +59,9 @@ void runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to); kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); kern_return_t runtime_remove_mport(mach_port_t name); +bool runtime_get_caller_creds(struct ldcred *ldc); + int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata); kern_return_t launchd_set_bport(mach_port_t name); Modified: trunk/launchd/src/protocol_legacy.defs =================================================================== --- trunk/launchd/src/protocol_legacy.defs 2006-10-11 00:09:19 UTC (rev 22889) +++ trunk/launchd/src/protocol_legacy.defs 2006-10-12 19:13:23 UTC (rev 22890) @@ -39,7 +39,6 @@ __server_cmd : cmd_t; __server_uid : natural_t; __on_demand : boolean_t; - ServerAuditToken __token : audit_token_t; out __server_port : mach_port_make_send_t); skip; /* Last used in 10.4. Was bootstrap_unprivileged() */ @@ -47,18 +46,15 @@ routine check_in( __bs_port : job_t; __service_name : name_t; - ServerAuditToken __token : audit_token_t; out __service_port : mach_port_move_receive_t); routine register( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; __service_name : name_t; __service_port : mach_port_t); routine look_up( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; __service_name : name_t; out __service_port : mach_port_send_t); @@ -99,7 +95,6 @@ routine spawn( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; __chars : _internal_string_t; __argc : uint32_t; __envc : uint32_t; @@ -111,15 +106,12 @@ routine wait( __bs_port : job_t; sreplyport __rport : mach_port_make_send_once_t; - ServerAuditToken __token : audit_token_t; out __waitval : integer_t); routine uncork_fork( - __bs_port : job_t; - ServerAuditToken __token : audit_token_t); + __bs_port : job_t); /* Essentially the inverse of bootstrap_unprivileged() */ routine get_self( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; out __job_port : mach_port_make_send_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061012/dc1d5738/attachment.html From source_changes at macosforge.org Thu Oct 12 17:54:01 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22891] trunk/launchd/src/launchd.c Message-ID: <20061013005401.E5288201A94@cvs.opensource.apple.com> Revision: 22891 http://trac.macosforge.org/projects/launchd/changeset/22891 Author: zarzycki@apple.com Date: 2006-10-12 17:54:01 -0700 (Thu, 12 Oct 2006) Log Message: ----------- Better internal crash reporting. Modified Paths: -------------- trunk/launchd/src/launchd.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-12 19:13:23 UTC (rev 22890) +++ trunk/launchd/src/launchd.c 2006-10-13 00:54:01 UTC (rev 22891) @@ -94,13 +94,14 @@ static void testfd_or_openfd(int fd, const char *path, int flags); static bool get_network_state(void); static void monitor_networking_state(void); -static void fatal_signal_handler(int sig); +static void fatal_signal_handler(int sig, siginfo_t *si, void *uap); static bool re_exec_in_single_user_mode = false; static char *pending_stdout = NULL; static char *pending_stderr = NULL; static job_t rlcj = NULL; static jmp_buf doom_doom_doom; +static void *crash_addr; sigset_t blocked_signals = 0; bool shutdown_in_progress = false; @@ -116,6 +117,7 @@ SIGTTIN, SIGTTOU, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGINFO, SIGUSR1, SIGUSR2 }; + struct sigaction fsa; bool sflag = false, dflag = false, Dflag = false; mach_msg_type_number_t l2l_name_cnt = 0, l2l_port_cnt = 0, l2l_pid_cnt = 0; pid_t *l2l_pids = NULL; @@ -330,18 +332,37 @@ init_pre_kevent(); } - launchd_assert(setjmp(doom_doom_doom) == 0); - launchd_assumes(signal(SIGILL, fatal_signal_handler) != SIG_ERR); - launchd_assumes(signal(SIGFPE, fatal_signal_handler) != SIG_ERR); - launchd_assumes(signal(SIGBUS, fatal_signal_handler) != SIG_ERR); - launchd_assumes(signal(SIGSEGV, fatal_signal_handler) != SIG_ERR); + switch (setjmp(doom_doom_doom)) { + case SIGILL: + case SIGFPE: + syslog(LOG_EMERG, "We crashed at instruction: %p", crash_addr); + abort(); + case SIGBUS: + case SIGSEGV: + syslog(LOG_EMERG, "We crashed trying to read/write: %p", crash_addr); + abort(); + default: + abort(); + case 0: + break; + } + fsa.sa_sigaction = fatal_signal_handler; + fsa.sa_flags = SA_SIGINFO; + sigemptyset(&fsa.sa_mask); + + launchd_assumes(sigaction(SIGILL, &fsa, NULL) != -1); + launchd_assumes(sigaction(SIGFPE, &fsa, NULL) != -1); + launchd_assumes(sigaction(SIGBUS, &fsa, NULL) != -1); + launchd_assumes(sigaction(SIGSEGV, &fsa, NULL) != -1); + launchd_runtime(); } void -fatal_signal_handler(int sig) +fatal_signal_handler(int sig, siginfo_t *si, void *uap) { + crash_addr = si->si_addr; longjmp(doom_doom_doom, sig); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061012/315e6f01/attachment.html From source_changes at macosforge.org Thu Oct 12 18:21:54 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22892] trunk/launchd/src Message-ID: <20061013012154.B580F201B0F@cvs.opensource.apple.com> Revision: 22892 http://trac.macosforge.org/projects/launchd/changeset/22892 Author: zarzycki@apple.com Date: 2006-10-12 18:21:54 -0700 (Thu, 12 Oct 2006) Log Message: ----------- Merge all anonymous jobs into one to keep our sanity... Modified Paths: -------------- trunk/launchd/src/bootstrap_private.h trunk/launchd/src/bootstrap_public.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/protocol_legacy.defs Modified: trunk/launchd/src/bootstrap_private.h =================================================================== --- trunk/launchd/src/bootstrap_private.h 2006-10-13 00:54:01 UTC (rev 22891) +++ trunk/launchd/src/bootstrap_private.h 2006-10-13 01:21:54 UTC (rev 22892) @@ -37,7 +37,6 @@ kern_return_t _launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - vm_offset_t *service_pids, mach_msg_type_number_t *service_pidsCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt); kern_return_t bootstrap_getsocket(mach_port_t bp, name_t); Modified: trunk/launchd/src/bootstrap_public.c =================================================================== --- trunk/launchd/src/bootstrap_public.c 2006-10-13 00:54:01 UTC (rev 22891) +++ trunk/launchd/src/bootstrap_public.c 2006-10-13 01:21:54 UTC (rev 22892) @@ -41,10 +41,9 @@ kern_return_t _launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - vm_offset_t *service_pids, mach_msg_type_number_t *service_pidsCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt) { - return vproc_mig_transfer_subset(bp, reqport, rcvright, service_names, service_namesCnt, service_pids, service_pidsCnt, ports, portCnt); + return vproc_mig_transfer_subset(bp, reqport, rcvright, service_names, service_namesCnt, ports, portCnt); } pid_t Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-13 00:54:01 UTC (rev 22891) +++ trunk/launchd/src/launchd.c 2006-10-13 01:21:54 UTC (rev 22892) @@ -119,8 +119,7 @@ }; struct sigaction fsa; bool sflag = false, dflag = false, Dflag = false; - mach_msg_type_number_t l2l_name_cnt = 0, l2l_port_cnt = 0, l2l_pid_cnt = 0; - pid_t *l2l_pids = NULL; + mach_msg_type_number_t l2l_name_cnt = 0, l2l_port_cnt = 0; name_array_t l2l_names = NULL; mach_port_array_t l2l_ports = NULL; char ldconf[PATH_MAX] = PID1LAUNCHD_CONF; @@ -251,17 +250,16 @@ launchd_assert(bootstrap_parent(bootstrap_port, &newparent) == BOOTSTRAP_SUCCESS); launchd_assert(_launchd_to_launchd(bootstrap_port, &req_mport, &checkin_mport, - &l2l_names, &l2l_name_cnt, (vm_offset_t *)&l2l_pids, &l2l_pid_cnt, - &l2l_ports, &l2l_port_cnt) == BOOTSTRAP_SUCCESS); + &l2l_names, &l2l_name_cnt, &l2l_ports, &l2l_port_cnt) == BOOTSTRAP_SUCCESS); - launchd_assert(l2l_name_cnt == l2l_port_cnt && l2l_name_cnt == (l2l_pid_cnt / sizeof(pid_t))); + launchd_assert(l2l_name_cnt == l2l_port_cnt); task_set_bootstrap_port(mach_task_self(), newparent); launchd_assumes(mach_port_deallocate(mach_task_self(), bootstrap_port) == KERN_SUCCESS); bootstrap_port = newparent; } - mach_init_init(req_mport, checkin_mport, l2l_names, l2l_ports, l2l_pids, l2l_name_cnt); + mach_init_init(req_mport, checkin_mport, l2l_names, l2l_ports, l2l_name_cnt); if (l2l_names) { mig_deallocate((vm_address_t)l2l_names, l2l_name_cnt * sizeof(l2l_names[0])); @@ -269,9 +267,6 @@ if (l2l_ports) { mig_deallocate((vm_address_t)l2l_ports, l2l_port_cnt * sizeof(l2l_ports[0])); } - if (l2l_pids) { - mig_deallocate((vm_address_t)l2l_pids, l2l_pid_cnt); - } if (h) { sprintf(ldconf, "%s/%s", h, LAUNCHD_CONF); Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2006-10-13 00:54:01 UTC (rev 22891) +++ trunk/launchd/src/launchd.h 2006-10-13 01:21:54 UTC (rev 22892) @@ -59,7 +59,7 @@ void catatonia(void); void mach_start_shutdown(void); -void mach_init_init(mach_port_t, mach_port_t, name_array_t, mach_port_array_t, pid_t *, mach_msg_type_number_t); +void mach_init_init(mach_port_t, mach_port_t, name_array_t, mach_port_array_t, mach_msg_type_number_t); int _fd(int fd); Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-13 00:54:01 UTC (rev 22891) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-13 01:21:54 UTC (rev 22892) @@ -267,7 +267,8 @@ static job_t job_new_spawn(const char *label, const char *path, const char *workingdir, const char *const *argv, const char *const *env, mode_t *u_mask, bool w4d, bool fppc); static job_t job_new_via_mach_init(job_t jbs, const char *cmd, uid_t uid, bool ond); static job_t job_new_bootstrap(job_t p, mach_port_t requestorport, mach_port_t checkin_port); -static job_t job_new_anonymous(job_t p, pid_t who); +static bool job_new_anonymous(job_t p); +static job_t job_find_anonymous(job_t p); static const char *job_prog(job_t j); static pid_t job_get_pid(job_t j); static mach_port_t job_get_bsport(job_t j); @@ -759,33 +760,32 @@ } job_t -job_new_anonymous(job_t p, pid_t who) +job_find_anonymous(job_t p) { - int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, who }; - char newlabel[1000], *procname = "unknown"; - struct kinfo_proc kp; - size_t kplen = sizeof(kp); - job_t jr; + job_t ji = NULL; - if (who) { - if (sysctl(mib, 4, &kp, &kplen, NULL, 0) == -1) { - return NULL; + SLIST_FOREACH(ji, &p->jobs, sle) { + if (ji->anonymous) { + break; } - procname = kp.kp_proc.p_comm; } - sprintf(newlabel, "anonymous-%u.%s", who, procname); + return ji; +} - jr = job_new(p, newlabel, procname, NULL, NULL, MACH_PORT_NULL); +bool +job_new_anonymous(job_t p) +{ + char newlabel[1000], *procname = "unknown"; + job_t jr; - if (!jr) { - return NULL; + sprintf(newlabel, "%u.anonymous", MACH_PORT_INDEX(p->bs_port)); + + if ((jr = job_new(p, newlabel, procname, NULL, NULL, MACH_PORT_NULL))) { + jr->anonymous = true; } - jr->anonymous = true; - jr->p = who; - - return jr; + return jr ? true : false; } job_t @@ -1413,7 +1413,26 @@ job_t job_mig_intran(mach_port_t p) { - return job_find_by_port2(root_job, p); + struct ldcred ldc; + job_t jp, jr = NULL; + + runtime_get_caller_creds(&ldc); + + if (launchd_assumes((jp = job_find_by_port2(root_job, p)) != NULL)) { + if (jp->req_port) { + if (!(jr = job_find_by_pid(jp, ldc.pid, false))) { + jr = job_find_anonymous(jp); + } + } else { + jr = jp; + } + } + + if (!launchd_assumes(jr != NULL)) { + syslog(LOG_EMERG, "@@@@@ jp->label == %s", jp->label); + } + + return jr; } void @@ -1658,7 +1677,7 @@ job_assumes(j, launchd_mport_notify_req(j->bs_port, MACH_NOTIFY_NO_SENDERS) == KERN_SUCCESS); } - switch (c = job_fork(j->legacy_mach_job ? j : j->parent)) { + switch (c = job_fork(j->parent)) { case -1: job_log_error(j, LOG_ERR, "fork() failed, will try again in one second"); job_assumes(j, close(execspair[0]) == 0); @@ -2898,6 +2917,8 @@ job_log(p, LOG_DEBUG, "Mach sub-bootstrap created: %s", j->label); } + job_assumes(j, job_new_anonymous(j)); + return j; out_bad: @@ -2940,10 +2961,6 @@ return job_remove(j); } } - - if (j->anonymous && SLIST_EMPTY(&j->machservices)) { - job_remove(j); - } } struct machservice * @@ -3519,27 +3536,17 @@ job_mig_get_self(job_t j, mach_port_t *unprivportp) { struct ldcred ldc; - job_t j2; runtime_get_caller_creds(&ldc); job_log(j, LOG_DEBUG, "Requested unprivileged bootstrap port"); - j2 = job_find_by_pid(j, ldc.pid, false); - - if (!j2) { - if (ldc.uid == getuid() && ldc.euid == geteuid()) { - j2 = job_new_anonymous(j, ldc.pid); - if (!j2) { - return BOOTSTRAP_NO_MEMORY; - } - } else { - job_log(j, LOG_NOTICE, "PID %u not managed by launchd", ldc.pid); - return BOOTSTRAP_NOT_PRIVILEGED; - } + if (j->anonymous) { + job_log(j, LOG_NOTICE, "PID %u not managed by %s", ldc.pid, getprogname()); + return BOOTSTRAP_NOT_PRIVILEGED; } - *unprivportp = job_get_bsport(j2); + *unprivportp = job_get_bsport(j); return BOOTSTRAP_SUCCESS; } @@ -3586,20 +3593,9 @@ { struct machservice *ms; struct ldcred ldc; - job_t j2; runtime_get_caller_creds(&ldc); - if (j == job_get_bs(j)) { - j2 = job_find_by_pid(j, ldc.pid, false); - if (!j2) { - j2 = job_new_anonymous(j, ldc.pid); - } - if (j2) { - j = j2; - } - } - job_log(j, LOG_NOTICE, "bootstrap_register() is deprecated. PID: %u Service: %s", ldc.pid, servicename); job_log(j, LOG_DEBUG, "Mach service registration attempt: %s", servicename); @@ -3691,7 +3687,6 @@ name_array_t service_names; bootstrap_status_array_t service_actives; mach_port_array_t ports; - pid_t *pids; unsigned int i; }; @@ -3708,7 +3703,6 @@ info_resp->service_actives[info_resp->i] = machservice_status(ms); } else { info_resp->ports[info_resp->i] = machservice_port(ms); - info_resp->pids[info_resp->i] = job_get_pid(machservice_job(ms)); } info_resp->i++; } @@ -3717,7 +3711,7 @@ job_mig_info(job_t j, name_array_t *servicenamesp, unsigned int *servicenames_cnt, bootstrap_status_array_t *serviceactivesp, unsigned int *serviceactives_cnt) { - struct x_bootstrap_info_copyservices_cb info_resp = { NULL, NULL, NULL, NULL, 0 }; + struct x_bootstrap_info_copyservices_cb info_resp = { NULL, NULL, NULL, 0 }; unsigned int cnt = 0; job_t ji; @@ -3759,12 +3753,15 @@ kern_return_t job_mig_transfer_subset(job_t j, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *servicenamesp, unsigned int *servicenames_cnt, - vm_offset_t *service_pids, mach_msg_type_number_t *service_pidsCnt, mach_port_array_t *ports, unsigned int *ports_cnt) { - struct x_bootstrap_info_copyservices_cb info_resp = { NULL, NULL, NULL, NULL, 0 }; + struct x_bootstrap_info_copyservices_cb info_resp = { NULL, NULL, NULL, 0 }; unsigned int cnt = 0; + if (j->anonymous) { + j = j->parent; + } + if (getpid() != 1) { job_log(j, LOG_ERR, "Only the system launchd will transfer Mach sub-bootstraps."); return BOOTSTRAP_NOT_PRIVILEGED; @@ -3787,11 +3784,6 @@ goto out_bad; } - mig_allocate((vm_address_t *)&info_resp.pids, cnt * sizeof(pid_t)); - if (!launchd_assumes(info_resp.pids != NULL)) { - goto out_bad; - } - job_foreach_service(j, job_mig_info_copyservices, &info_resp, true); launchd_assumes(info_resp.i == cnt); @@ -3799,8 +3791,6 @@ *servicenamesp = info_resp.service_names; *ports = info_resp.ports; *servicenames_cnt = *ports_cnt = cnt; - *service_pids = (vm_offset_t)info_resp.pids; - *service_pidsCnt = cnt * sizeof(pid_t); *reqport = job_get_reqport(j); *rcvright = job_get_bsport(j); @@ -3818,9 +3808,6 @@ if (info_resp.ports) { mig_deallocate((vm_address_t)info_resp.ports, cnt * sizeof(info_resp.ports[0])); } - if (info_resp.pids) { - mig_deallocate((vm_address_t)info_resp.pids, cnt * sizeof(pid_t)); - } return BOOTSTRAP_NO_MEMORY; } @@ -4019,7 +4006,7 @@ void mach_init_init(mach_port_t req_port, mach_port_t checkin_port, - name_array_t l2l_names, mach_port_array_t l2l_ports, pid_t *l2l_pids, mach_msg_type_number_t l2l_cnt) + name_array_t l2l_names, mach_port_array_t l2l_ports, mach_msg_type_number_t l2l_cnt) { mach_msg_type_number_t l2l_i; auditinfo_t inherited_audit; @@ -4030,6 +4017,8 @@ launchd_assert((root_job = job_new_bootstrap(NULL, req_port ? req_port : mach_task_self(), checkin_port)) != NULL); + launchd_assert((anon_job = job_find_anonymous(root_job)) != NULL); + launchd_assert(launchd_get_bport(&inherited_bootstrap_port) == KERN_SUCCESS); if (getpid() != 1) { @@ -4049,10 +4038,6 @@ for (l2l_i = 0; l2l_i < l2l_cnt; l2l_i++) { struct machservice *ms; - if (!(anon_job = job_find_by_pid(root_job, l2l_pids[l2l_i], false))) { - launchd_assert(anon_job = job_new_anonymous(root_job, l2l_pids[l2l_i])); - } - if ((ms = machservice_new(anon_job, l2l_names[l2l_i], &l2l_ports[l2l_i]))) { machservice_watch(ms); } Modified: trunk/launchd/src/protocol_legacy.defs =================================================================== --- trunk/launchd/src/protocol_legacy.defs 2006-10-13 00:54:01 UTC (rev 22891) +++ trunk/launchd/src/protocol_legacy.defs 2006-10-13 01:21:54 UTC (rev 22892) @@ -86,7 +86,6 @@ out __bs_reqport : mach_port_t; out __bs_rcvright : mach_port_move_receive_t; out __service_names : name_array_t, dealloc; - out __service_pids : pointer_t, dealloc; out __service_ports : mach_port_array_t, dealloc); routine getsocket( -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061012/58f70338/attachment.html From source_changes at macosforge.org Fri Oct 13 07:52:19 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22893] trunk/launchd/src Message-ID: <20061013145219.54680204EFD@cvs.opensource.apple.com> Revision: 22893 http://trac.macosforge.org/projects/launchd/changeset/22893 Author: zarzycki@apple.com Date: 2006-10-13 07:52:18 -0700 (Fri, 13 Oct 2006) Log Message: ----------- Now that the job MIG intran hook can lookup by both port and PID, we no longer need The "get_self" MIG routine. Modified Paths: -------------- trunk/launchd/src/bootstrap_public.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/protocol_legacy.defs Modified: trunk/launchd/src/bootstrap_public.c =================================================================== --- trunk/launchd/src/bootstrap_public.c 2006-10-13 01:21:54 UTC (rev 22892) +++ trunk/launchd/src/bootstrap_public.c 2006-10-13 14:52:18 UTC (rev 22893) @@ -34,10 +34,6 @@ #include #include -static mach_port_t vproc_self; - -static void vproc_get_self(void); - kern_return_t _launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, @@ -204,13 +200,7 @@ kern_return_t bootstrap_check_in(mach_port_t bp, name_t service_name, mach_port_t *sp) { - if(bp != bootstrap_port) { - return BOOTSTRAP_NOT_PRIVILEGED; - } - - vproc_get_self(); - - return vproc_mig_check_in(vproc_self, service_name, sp); + return vproc_mig_check_in(bp, service_name, sp); } kern_return_t @@ -278,22 +268,6 @@ } -void -vproc_get_self(void) -{ - mach_port_t bp_self; - - if (vproc_self != MACH_PORT_NULL) { - return; - } - - if (vproc_mig_get_self(bootstrap_port, &bp_self) != 0) { - return; - } - - vproc_self = bp_self; -} - const char * bootstrap_strerror(kern_return_t r) { Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-13 01:21:54 UTC (rev 22892) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-13 14:52:18 UTC (rev 22893) @@ -3533,26 +3533,6 @@ } kern_return_t -job_mig_get_self(job_t j, mach_port_t *unprivportp) -{ - struct ldcred ldc; - - runtime_get_caller_creds(&ldc); - - job_log(j, LOG_DEBUG, "Requested unprivileged bootstrap port"); - - if (j->anonymous) { - job_log(j, LOG_NOTICE, "PID %u not managed by %s", ldc.pid, getprogname()); - return BOOTSTRAP_NOT_PRIVILEGED; - } - - *unprivportp = job_get_bsport(j); - - return BOOTSTRAP_SUCCESS; -} - - -kern_return_t job_mig_check_in(job_t j, name_t servicename, mach_port_t *serviceportp) { static pid_t last_warned_pid = 0; Modified: trunk/launchd/src/protocol_legacy.defs =================================================================== --- trunk/launchd/src/protocol_legacy.defs 2006-10-13 01:21:54 UTC (rev 22892) +++ trunk/launchd/src/protocol_legacy.defs 2006-10-13 14:52:18 UTC (rev 22893) @@ -109,8 +109,3 @@ routine uncork_fork( __bs_port : job_t); - -/* Essentially the inverse of bootstrap_unprivileged() */ -routine get_self( - __bs_port : job_t; - out __job_port : mach_port_make_send_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061013/be867680/attachment.html From source_changes at macosforge.org Fri Oct 13 08:00:25 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22894] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061013150025.65BBE204FCF@cvs.opensource.apple.com> Revision: 22894 http://trac.macosforge.org/projects/launchd/changeset/22894 Author: zarzycki@apple.com Date: 2006-10-13 08:00:25 -0700 (Fri, 13 Oct 2006) Log Message: ----------- Only allocate the per-job Mach port as needed. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-13 14:52:18 UTC (rev 22893) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-13 15:00:25 UTC (rev 22894) @@ -683,6 +683,10 @@ j->legacy_mach_job = true; j->priv_port_has_senders = true; /* the IPC that called us will make-send on this port */ + if (!job_setup_machport(j)) { + goto out_bad; + } + if (!job_assumes(j, launchd_mport_notify_req(j->bs_port, MACH_NOTIFY_NO_SENDERS) == KERN_SUCCESS)) { job_assumes(j, launchd_mport_close_recv(j->bs_port) == KERN_SUCCESS); goto out_bad; @@ -816,10 +820,6 @@ j->checkedin = true; j->firstborn = (strcmp(label, FIRSTBORN_LABEL) == 0); - if (!job_setup_machport(j)) { - goto out_bad; - } - if (reqport != MACH_PORT_NULL) { j->req_port = reqport; if (!job_assumes(j, launchd_mport_notify_req(reqport, MACH_NOTIFY_DEAD_NAME) == KERN_SUCCESS)) { @@ -1673,10 +1673,6 @@ time(&j->start_time); - if (j->bs_port) { - job_assumes(j, launchd_mport_notify_req(j->bs_port, MACH_NOTIFY_NO_SENDERS) == KERN_SUCCESS); - } - switch (c = job_fork(j->parent)) { case -1: job_log_error(j, LOG_ERR, "fork() failed, will try again in one second"); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061013/9a664d4e/attachment.html From source_changes at macosforge.org Mon Oct 16 10:15:04 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22895] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061016171504.2A1502184F1@cvs.opensource.apple.com> Revision: 22895 http://trac.macosforge.org/projects/launchd/changeset/22895 Author: zarzycki@apple.com Date: 2006-10-16 10:15:04 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Fix a 'think-o' with respect to the re-design of bootstraps and the notion of a privileged bootstrap port. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-13 15:00:25 UTC (rev 22894) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-16 17:15:04 UTC (rev 22895) @@ -1426,12 +1426,9 @@ } else { jr = jp; } + job_assumes(jp, jr != NULL); } - if (!launchd_assumes(jr != NULL)) { - syslog(LOG_EMERG, "@@@@@ jp->label == %s", jp->label); - } - return jr; } @@ -1704,9 +1701,6 @@ job_start_child(j, execspair[1]); break; default: - if (!SLIST_EMPTY(&j->machservices)) { - j->priv_port_has_senders = true; - } j->p = c; total_children++; job_assumes(j, close(execspair[1]) == 0); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/37d2b74d/attachment.html From source_changes at macosforge.org Mon Oct 16 10:34:19 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22896] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061016173419.5992C218675@cvs.opensource.apple.com> Revision: 22896 http://trac.macosforge.org/projects/launchd/changeset/22896 Author: zarzycki@apple.com Date: 2006-10-16 10:34:18 -0700 (Mon, 16 Oct 2006) Log Message: ----------- All curly braces. All the time. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-16 17:15:04 UTC (rev 22895) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-16 17:34:18 UTC (rev 22896) @@ -330,14 +330,17 @@ struct machservice *ms; struct watchpath *wp; - SLIST_FOREACH(sg, &j->sockets, sle) + SLIST_FOREACH(sg, &j->sockets, sle) { socketgroup_ignore(j, sg); + } - SLIST_FOREACH(wp, &j->vnodes, sle) + SLIST_FOREACH(wp, &j->vnodes, sle) { watchpath_ignore(j, wp); + } - SLIST_FOREACH(ms, &j->machservices, sle) + SLIST_FOREACH(ms, &j->machservices, sle) { job_assumes(j, runtime_remove_mport(ms->port) == KERN_SUCCESS); + } } void @@ -347,14 +350,17 @@ struct machservice *ms; struct watchpath *wp; - SLIST_FOREACH(sg, &j->sockets, sle) + SLIST_FOREACH(sg, &j->sockets, sle) { socketgroup_watch(j, sg); + } - SLIST_FOREACH(wp, &j->vnodes, sle) + SLIST_FOREACH(wp, &j->vnodes, sle) { watchpath_watch(j, wp); + } - SLIST_FOREACH(ms, &j->machservices, sle) + SLIST_FOREACH(ms, &j->machservices, sle) { job_assumes(j, runtime_add_mport(ms->port, NULL, 0) == KERN_SUCCESS); + } } void -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/2097c476/attachment.html From source_changes at macosforge.org Mon Oct 16 14:16:29 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22897] trunk/launchd/src Message-ID: <20061016211629.B5F3B2192D4@cvs.opensource.apple.com> Revision: 22897 http://trac.macosforge.org/projects/launchd/changeset/22897 Author: zarzycki@apple.com Date: 2006-10-16 14:16:29 -0700 (Mon, 16 Oct 2006) Log Message: ----------- setsockopt() with the executable path as the argument Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-16 17:34:18 UTC (rev 22896) +++ trunk/launchd/src/Makefile.am 2006-10-16 21:16:29 UTC (rev 22897) @@ -34,7 +34,7 @@ sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown -launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden +launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -fvisibility=hidden Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-16 17:34:18 UTC (rev 22896) +++ trunk/launchd/src/Makefile.in 2006-10-16 21:16:29 UTC (rev 22897) @@ -232,7 +232,7 @@ @LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c bootstrap_public.c @LIBS_ONLY_FALSE@sbin_SCRIPTS = service @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown -@LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden +@LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders @LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib @LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -fvisibility=hidden @LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-16 17:34:18 UTC (rev 22896) +++ trunk/launchd/src/launchctl.c 2006-10-16 21:16:29 UTC (rev 22897) @@ -131,6 +131,7 @@ static int touch_file(const char *path, mode_t m); static void do_sysversion_sysctl(void); static void workaround4465949(void); +static void do_application_firewal_magic(int sfd, launch_data_t thejob); static int bootstrap_cmd(int argc, char *const argv[]); static int load_and_unload_cmd(int argc, char *const argv[]); @@ -842,6 +843,9 @@ fprintf(stderr, "socket(): %s\n", strerror(errno)); return; } + + do_application_firewal_magic(sfd, thejob); + if (hints.ai_flags & AI_PASSIVE) { if (AF_INET6 == res->ai_family && -1 == setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&sock_opt, sizeof(sock_opt))) { @@ -2661,3 +2665,62 @@ CFRelease(versdict); } + +void +do_application_firewal_magic(int sfd, launch_data_t thejob) +{ + const char *prog = NULL, *partialprog = NULL; + char *path, *pathtmp, **pathstmp; + char *paths[100]; + launch_data_t tmp; + + /* + * Sigh... + * setsockopt() with the executable path as the argument + */ + + if ((tmp = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_PROGRAM))) { + prog = launch_data_get_string(tmp); + } + + if (!prog) { + if ((tmp = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_PROGRAMARGUMENTS))) { + if ((tmp = launch_data_array_get_index(tmp, 0))) { + if (assumes((partialprog = launch_data_get_string(tmp)) != NULL)) { + if (partialprog[0] == '/') { + prog = partialprog; + } + } + } + } + } + + if (!prog) { + pathtmp = path = strdup(getenv("PATH")); + + pathstmp = paths; + + while ((*pathstmp = strsep(&pathtmp, ":"))) { + if (**pathstmp != '\0') { + pathstmp++; + } + } + + free(path); + pathtmp = alloca(MAXPATHLEN); + + pathstmp = paths; + + for (; *pathstmp; pathstmp++) { + snprintf(pathtmp, MAXPATHLEN, "%s/%s", *pathstmp, partialprog); + if (path_check(pathtmp)) { + prog = pathtmp; + break; + } + } + } + + if (assumes(prog != NULL)) { + assumes(setsockopt(sfd, SOL_SOCKET, SO_EXECPATH, prog, strlen(prog) + 1) != -1); + } +} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/27bdc793/attachment.html From source_changes at macosforge.org Mon Oct 16 14:18:21 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22898] trunk/launchd/src Message-ID: <20061016211821.EE9DC2192EA@cvs.opensource.apple.com> Revision: 22898 http://trac.macosforge.org/projects/launchd/changeset/22898 Author: zarzycki@apple.com Date: 2006-10-16 14:18:21 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Add the dummy header back. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Added Paths: ----------- trunk/launchd/src/vproc.h Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-16 21:16:29 UTC (rev 22897) +++ trunk/launchd/src/Makefile.am 2006-10-16 21:18:21 UTC (rev 22898) @@ -81,6 +81,7 @@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec mkdir -p $(DESTDIR)/usr/include/servers cp $(srcdir)/launch.h $(DESTDIR)/usr/include + cp $(srcdir)/vproc.h $(DESTDIR)/usr/include cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h mkdir -p $(DESTDIR)/usr/local/include Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-16 21:16:29 UTC (rev 22897) +++ trunk/launchd/src/Makefile.in 2006-10-16 21:18:21 UTC (rev 22898) @@ -1049,6 +1049,7 @@ @LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/include/servers @LIBS_ONLY_FALSE@ cp $(srcdir)/launch.h $(DESTDIR)/usr/include +@LIBS_ONLY_FALSE@ cp $(srcdir)/vproc.h $(DESTDIR)/usr/include @LIBS_ONLY_FALSE@ cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h @LIBS_ONLY_FALSE@ cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/local/include Added: trunk/launchd/src/vproc.h =================================================================== --- trunk/launchd/src/vproc.h (rev 0) +++ trunk/launchd/src/vproc.h 2006-10-16 21:18:21 UTC (rev 22898) @@ -0,0 +1,78 @@ +#ifndef _VPROC_H_ +#define _VPROC_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +__BEGIN_DECLS + +typedef void * vproc_t; +typedef void * vprocmgr_t; +typedef void * vproc_err_t; + +/* By default, pass NULL for vprocmgr_t or vproc_t to get notions of self or "my manager" */ + +vproc_err_t vprocmgr_create_vproc(vprocmgr_t vpm, launch_data_t the_vproc, vproc_t *vp); + +/* If creating multiple jobs, it is wise to create them atomically with respect to each other */ +vproc_err_t vprocmgr_create_vprocs(vprocmgr_t vpm, launch_data_t *the_vprocs, vproc_t *vp, size_t cnt); + +vproc_err_t vprocmgr_delete_vproc(vprocmgr_t vpm, vproc_t vp); + +/* The virtual process managers are arranged in a hierarchy */ +vproc_err_t vprocmgr_get_parent(vprocmgr_t vpm, vprocmgr_t *vpm_parent); + +vproc_err_t vprocmgr_get_all_vprocs(vprocmgr_t vpm, vproc_t **vps, size_t *vp_cnt); + +vproc_err_t vprocmgr_lookup_vproc(vprocmgr_t vpm, const char *label, vproc_t *vp); + +vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm); + +vproc_err_t vprocmgr_lookup_mach_service(vprocmgr_t vpm, const char *service, mach_port_t *service_port); + +/* For controlling speculative and optimistical spawning of vprocs */ +vproc_err_t vprocmgr_set_force_on_demand(vproc_mgr_t vpm, bool force); +vproc_err_t vprocmgr_get_force_on_demand(vproc_mgr_t vpm, bool *force); + +/* Only release those vprocmgr_t objects that returned from APIs. */ +vproc_err_t vprocmgr_release(vprocmgr_t vpm); + + +/* Get meta-data and IPC handles from launchd */ +vproc_err_t vproc_checkin(launch_data_t *out); + +/* Get only meta-data from launchd */ +vproc_err_t vproc_get_info(vproc_t vp, launch_data_t *out); + +/* Lookup a Mach service amongst our peers and progenitors */ +vproc_err_t vproc_lookup_mach_service(vproc_t vp, const char *service, mach_port_t *service_port); + +/* Sending signals to a program that isn't running will return an error */ +vproc_err_t vproc_send_signal(vproc_t vp, int signum); + +/* Only release those vproc_t objects that returned from APIs. */ +vproc_err_t vproc_release(vproc_t vp); + + + +const char *vproc_strerror(vproc_err_t r); + +__END_DECLS + +#endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/458c858f/attachment.html From source_changes at macosforge.org Mon Oct 16 14:57:28 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22899] trunk/launchd/src Message-ID: <20061016215728.8AB412194BC@cvs.opensource.apple.com> Revision: 22899 http://trac.macosforge.org/projects/launchd/changeset/22899 Author: zarzycki@apple.com Date: 2006-10-16 14:57:27 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Launchd needs "launch once and only once" capability Modified Paths: -------------- trunk/launchd/src/launch.h trunk/launchd/src/launchd.plist.5 trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launch.h =================================================================== --- trunk/launchd/src/launch.h 2006-10-16 21:18:21 UTC (rev 22898) +++ trunk/launchd/src/launch.h 2006-10-16 21:57:27 UTC (rev 22899) @@ -93,6 +93,7 @@ #define LAUNCH_JOBKEY_PID "PID" #define LAUNCH_JOBKEY_SUBJOBS "SubJobs" #define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" +#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2006-10-16 21:18:21 UTC (rev 22898) +++ trunk/launchd/src/launchd.plist.5 2006-10-16 21:57:27 UTC (rev 22899) @@ -172,7 +172,7 @@ The recommended idle time out (in seconds) to pass to the job. If no value is specified, a default time out will be supplied by .Nm launchd for use by the job at check in time. -.It Sy ThrottleInternval +.It Sy ThrottleInterval This key lets one override the default throttling policy imposed on jobs by .Nm launchd . The value is in seconds, and by default, jobs will not be spawned more than once every 10 seconds. @@ -265,20 +265,31 @@ value should be applied to the daemon. .It Sy LowPriorityIO This optional key specifies whether the kernel should consider this daemon to be low priority when doing file system I/O. -.It Sy MachServices +.It Sy LaunchOnlyOnce +This optional key specifies whether the job can only be run once and only once. +In other words, if the job cannot be safely respawned without a full machine +reboot, then set this key to be true. +.It Sy MachServices This optional key is used to specify Mach services to be registered with the Mach bootstrap sub-system. Each key in this dictionary should be the name of -service to be advertised. The value of the key must be a boolean. If the -boolean is true, the port is recycled, thus leaving clients to remain oblivious -to the demand nature of job. If the value is set to false, clients receive port +service to be advertised. The value of the key must be a boolean and set to true. +Alternatively, a dictionary can be used instead of a simple true value. +.Bl -ohang -offset indent +.It Sy ResetAtClose +If this boolean is false, the port is recycled, thus leaving clients to remain oblivious +to the demand nature of job. If the value is set to true, clients receive port death notifications when the job lets go of the receive right. The port will be recreated atomically with respect to bootstrap_look_up() calls, so that clients can trust that after receiving a port death notification, the new port will -have already been recreated. Setting the value to false should be done with -care. Not all clients may be able to handle this behavior. Finally, for the job -itself, the values will be replaced with Mach ports at the time of check-in -with +have already been recreated. Setting the value to true should be done with +care. Not all clients may be able to handle this behavior. The default value is false. +.It Sy HideUntilCheckIn +Reserve the name in the namespace, but cause bootstrap_look_up() to fail until the job has checked in with .Nm launchd . +.El +.Pp +Finally, for the job itself, the values will be replaced with Mach ports at the time of check-in with +.Nm launchd . .It Sy Sockets This optional key is used to specify launch on demand sockets that can be used to let .Nm launchd Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-16 21:18:21 UTC (rev 22898) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-16 21:57:27 UTC (rev 22899) @@ -229,10 +229,12 @@ time_t min_run_time; unsigned int start_interval; unsigned int checkedin:1, firstborn:1, debug:1, inetcompat:1, inetcompat_wait:1, - ondemand:1, session_create:1, low_pri_io:1, no_init_groups:1, priv_port_has_senders:1, - importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1, anonymous:1; + ondemand:1, session_create:1, low_pri_io:1, no_init_groups:1, priv_port_has_senders:1, + importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1, + anonymous:1; mode_t mask; - unsigned int globargv:1, wait4debugger:1, transfer_bstrap:1, unload_at_exit:1, force_ppc:1, stall_before_exec:1, __pad:26; + unsigned int globargv:1, wait4debugger:1, transfer_bstrap:1, unload_at_exit:1, force_ppc:1, + stall_before_exec:1, only_once:1; char label[0]; }; @@ -967,6 +969,8 @@ case 'L': if (strcasecmp(key, LAUNCH_JOBKEY_LOWPRIORITYIO) == 0) { j->low_pri_io = value; + } else if (strcasecmp(key, LAUNCH_JOBKEY_LAUNCHONLYONCE) == 0) { + j->only_once = value; } break; case 'i': @@ -2489,7 +2493,9 @@ bool job_useless(job_t j) { - if (j->unload_at_exit && j->start_time != 0) { + /* Yes, j->unload_at_exit and j->j->only_once seem the same, but they'll differ someday... */ + + if ((j->unload_at_exit || j->only_once) && j->start_time != 0) { job_log(j, LOG_INFO, "Exited. Was only configured to run once."); return true; } else if (shutdown_in_progress) { @@ -2608,14 +2614,6 @@ } if (j->priv_port_has_senders) { - if (j->start_time && !j->checkedin) { - if (j->legacy_mach_job) { - job_log(j, LOG_NOTICE, "Daemonized. Extremely expensive no-op."); - } else if (!j->unload_at_exit) { - job_log(j, LOG_ERR, "Daemonization is not supported under launchd."); - return false; - } - } return true; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/10891a42/attachment.html From source_changes at macosforge.org Mon Oct 16 14:57:58 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22900] trunk/launchd/src/launchctl.c Message-ID: <20061016215758.E0CDC2194C7@cvs.opensource.apple.com> Revision: 22900 http://trac.macosforge.org/projects/launchd/changeset/22900 Author: zarzycki@apple.com Date: 2006-10-16 14:57:58 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Typo Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-16 21:57:27 UTC (rev 22899) +++ trunk/launchd/src/launchctl.c 2006-10-16 21:57:58 UTC (rev 22900) @@ -131,7 +131,7 @@ static int touch_file(const char *path, mode_t m); static void do_sysversion_sysctl(void); static void workaround4465949(void); -static void do_application_firewal_magic(int sfd, launch_data_t thejob); +static void do_application_firewall_magic(int sfd, launch_data_t thejob); static int bootstrap_cmd(int argc, char *const argv[]); static int load_and_unload_cmd(int argc, char *const argv[]); @@ -844,7 +844,7 @@ return; } - do_application_firewal_magic(sfd, thejob); + do_application_firewall_magic(sfd, thejob); if (hints.ai_flags & AI_PASSIVE) { if (AF_INET6 == res->ai_family && -1 == setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, @@ -2667,7 +2667,7 @@ } void -do_application_firewal_magic(int sfd, launch_data_t thejob) +do_application_firewall_magic(int sfd, launch_data_t thejob) { const char *prog = NULL, *partialprog = NULL; char *path, *pathtmp, **pathstmp; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/432292f1/attachment.html From source_changes at macosforge.org Mon Oct 16 16:43:11 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22901] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061016234311.03A8B219CD1@cvs.opensource.apple.com> Revision: 22901 http://trac.macosforge.org/projects/launchd/changeset/22901 Author: zarzycki@apple.com Date: 2006-10-16 16:43:11 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Bug: launchd_core_logic.c:2170 (22866):2: kevent_mod(sg->fds[i], EVFILT_READ, EV_DELETE, 0, 0, NULL) != -1 Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-16 21:57:58 UTC (rev 22900) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-16 23:43:11 UTC (rev 22901) @@ -234,7 +234,7 @@ anonymous:1; mode_t mask; unsigned int globargv:1, wait4debugger:1, transfer_bstrap:1, unload_at_exit:1, force_ppc:1, - stall_before_exec:1, only_once:1; + stall_before_exec:1, only_once:1, currently_ignored:1; char label[0]; }; @@ -332,6 +332,12 @@ struct machservice *ms; struct watchpath *wp; + if (j->currently_ignored) { + return; + } + + j->currently_ignored = true; + SLIST_FOREACH(sg, &j->sockets, sle) { socketgroup_ignore(j, sg); } @@ -352,6 +358,12 @@ struct machservice *ms; struct watchpath *wp; + if (!job_assumes(j, j->currently_ignored)) { + return; + } + + j->currently_ignored = false; + SLIST_FOREACH(sg, &j->sockets, sle) { socketgroup_watch(j, sg); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/1a9ef77d/attachment.html From source_changes at macosforge.org Mon Oct 16 16:44:45 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22902] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061016234445.C02C3219CEF@cvs.opensource.apple.com> Revision: 22902 http://trac.macosforge.org/projects/launchd/changeset/22902 Author: zarzycki@apple.com Date: 2006-10-16 16:44:45 -0700 (Mon, 16 Oct 2006) Log Message: ----------- Better logging. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-16 23:43:11 UTC (rev 22901) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-16 23:44:45 UTC (rev 22902) @@ -280,6 +280,7 @@ static void job_uncork_fork(job_t j); static struct machservice *job_lookup_service(job_t jbs, const char *name, bool check_parent); static void job_foreach_service(job_t jbs, void (*bs_iter)(struct machservice *, void *), void *context, bool only_anonymous); +static void job_logv(job_t j, int pri, const char *msg, va_list ap); static void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); static void job_log_error(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); static void job_log_bug(job_t j, const char *rcs_rev, const char *path, unsigned int line, const char *test); @@ -335,7 +336,7 @@ if (j->currently_ignored) { return; } - + j->currently_ignored = true; SLIST_FOREACH(sg, &j->sockets, sle) { @@ -836,6 +837,7 @@ j->parent = p ? job_get_bs(p) : NULL; j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME; j->timeout = LAUNCHD_ADVISABLE_IDLE_TIMEOUT; + j->currently_ignored = true; j->ondemand = true; j->checkedin = true; j->firstborn = (strcmp(label, FIRSTBORN_LABEL) == 0); @@ -1567,13 +1569,7 @@ job_callback(void *obj, struct kevent *kev) { job_t j = obj; - bool d = j->debug; - int oldmask = 0; - if (d) { - oldmask = setlogmask(LOG_UPTO(LOG_DEBUG)); - } - switch (kev->filter) { case EVFILT_PROC: job_reap(j); @@ -1631,11 +1627,6 @@ job_assumes(j, false); break; } - - if (d) { - /* the job might have been removed, must not call job_log() */ - setlogmask(oldmask); - } } void @@ -2086,34 +2077,47 @@ } void -job_log_error(job_t j, int pri, const char *msg, ...) +job_logv(job_t j, int pri, const char *msg, va_list ap) { char newmsg[10000]; - va_list ap; + int oldmask = 0; size_t o; o = job_prep_log_preface(j, newmsg); - sprintf(newmsg + o, ": %s: %s", msg, strerror(errno)); + sprintf(newmsg + o, ": %s", msg); - va_start(ap, msg); + if (j->debug) { + oldmask = setlogmask(LOG_UPTO(LOG_DEBUG)); + } + vsyslog(pri, newmsg, ap); - va_end(ap); + + if (j->debug) { + setlogmask(oldmask); + } } void -job_log(job_t j, int pri, const char *msg, ...) +job_log_error(job_t j, int pri, const char *msg, ...) { char newmsg[10000]; va_list ap; - size_t o; - o = job_prep_log_preface(j, newmsg); + sprintf(newmsg, "%s: %s", msg, strerror(errno)); - sprintf(newmsg + o, ": %s", msg); + va_start(ap, msg); + job_logv(j, pri, newmsg, ap); + va_end(ap); +} +void +job_log(job_t j, int pri, const char *msg, ...) +{ + va_list ap; + va_start(ap, msg); - vsyslog(pri, newmsg, ap); + job_logv(j, pri, msg, ap); va_end(ap); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/2dce86e4/attachment.html From source_changes at macosforge.org Mon Oct 16 16:58:59 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22903] trunk/launchd/src/launchd.plist.5 Message-ID: <20061016235859.01AB5219DC0@cvs.opensource.apple.com> Revision: 22903 http://trac.macosforge.org/projects/launchd/changeset/22903 Author: zarzycki@apple.com Date: 2006-10-16 16:58:59 -0700 (Mon, 16 Oct 2006) Log Message: ----------- 9A283: First elem of ProgramArguments being used as argv[0] even though Program present Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2006-10-16 23:44:45 UTC (rev 22902) +++ trunk/launchd/src/launchd.plist.5 2006-10-16 23:58:59 UTC (rev 22903) @@ -106,13 +106,17 @@ This configuration file only applies to sessions of the type specified. This key is used in concert with the -S flag to .Nm launchctl . -.It Sy ProgramArguments -This required key maps to the second argument of -.Xr execvp 3 . .It Sy Program -This optional key maps to the first argument of +This key maps to the first argument of .Xr execvp 3 . If this key is missing, then the first element of the array of strings provided to the ProgramArguments will be used instead. +This key is required in the absence of the ProgramArguments key. +.It Sy ProgramArguments +This key maps to the second argument of +.Xr execvp 3 . +This key is required in the absence of the Program key. Please note! Many people are confused by this key. Please read +.Xr execvp 3 +very carefully! .It Sy EnableGlobbing This flag causes .Nm launchd -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/02e2ccbd/attachment.html From source_changes at macosforge.org Tue Oct 17 10:56:59 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22904] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061017175659.7510C21FF62@cvs.opensource.apple.com> Revision: 22904 http://trac.macosforge.org/projects/launchd/changeset/22904 Author: zarzycki@apple.com Date: 2006-10-17 10:56:58 -0700 (Tue, 17 Oct 2006) Log Message: ----------- 9A282 launchd throttling tftpd Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-16 23:58:59 UTC (rev 22903) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-17 17:56:58 UTC (rev 22904) @@ -1654,7 +1654,7 @@ td = time(NULL) - j->start_time; - if (td < j->min_run_time && !j->legacy_mach_job) { + if (td < j->min_run_time && !j->legacy_mach_job && !j->inetcompat) { time_t respawn_delta = j->min_run_time - td; job_log(j, LOG_WARNING, "Throttling respawn: Will start in %ld seconds", respawn_delta); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061017/e857d0ac/attachment.html From source_changes at macosforge.org Tue Oct 17 11:29:45 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22905] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061017182945.08D4622031E@cvs.opensource.apple.com> Revision: 22905 http://trac.macosforge.org/projects/launchd/changeset/22905 Author: zarzycki@apple.com Date: 2006-10-17 11:29:44 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Deallocate the per job Mach port sooner. This port is used if-and-only-if the job is created via bootstrap_create_server(). Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-17 17:56:58 UTC (rev 22904) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-17 18:29:44 UTC (rev 22905) @@ -689,10 +689,12 @@ } /* preflight the string so we know how big it is */ - sprintf(buf, "100000.%s", basename((char *)argv[0])); + sprintf(buf, "%s.%s", sizeof(void *) == 8 ? "0xdeadbeeffeedface" : "0xbabecafe", basename((char *)argv[0])); j = job_new(jbs, buf, NULL, argv, NULL, MACH_PORT_NULL); + sprintf(j->label, "%p.%s", j, basename(j->argv[0])); + free(argv); if (!job_assumes(jbs, j != NULL)) { @@ -713,10 +715,8 @@ goto out_bad; } - sprintf(j->label, "%d.%s", MACH_PORT_INDEX(j->bs_port), basename(j->argv[0])); + job_log(j, LOG_INFO, "Legacy%s server created in bootstrap: %x", ond ? " on-demand" : "", jbs->bs_port); - job_log(j, LOG_INFO, "New%s server in bootstrap: %x", ond ? " on-demand" : "", jbs->bs_port); - return j; out_bad: @@ -3175,6 +3175,9 @@ { j->priv_port_has_senders = false; + job_assumes(j, launchd_mport_close_recv(j->bs_port) == KERN_SUCCESS); + j->bs_port = 0; + job_log(j, LOG_DEBUG, "No more senders on privileged Mach bootstrap port"); job_dispatch(j, false); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061017/701f18ca/attachment.html From source_changes at macosforge.org Tue Oct 17 13:46:21 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:33 2007 Subject: [launchd-changes] [22906] tags/launchd-164/ Message-ID: <20061017204621.DA43C220C20@cvs.opensource.apple.com> Revision: 22906 http://trac.macosforge.org/projects/launchd/changeset/22906 Author: zarzycki@apple.com Date: 2006-10-17 13:46:21 -0700 (Tue, 17 Oct 2006) Log Message: ----------- "Tagging launchd-164 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-164/ Copied: tags/launchd-164 (from rev 22905, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061017/e62fd856/attachment.html From source_changes at macosforge.org Thu Oct 19 15:44:06 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22907] trunk/launchd/src/launchd.c Message-ID: <20061019224406.B8EC122F0A7@cvs.opensource.apple.com> Revision: 22907 http://trac.macosforge.org/projects/launchd/changeset/22907 Author: zarzycki@apple.com Date: 2006-10-19 15:44:06 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Note to self. Modified Paths: -------------- trunk/launchd/src/launchd.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-17 20:46:21 UTC (rev 22906) +++ trunk/launchd/src/launchd.c 2006-10-19 22:44:06 UTC (rev 22907) @@ -429,6 +429,8 @@ shutdown_in_progress = true; if (stat("/var/db/debugShutdownHangs", &sb) != -1) { + // When this changes to a more sustainable API, update this: + // http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown debug_shutdown_hangs = true; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061019/50852cbc/attachment.html From source_changes at macosforge.org Fri Oct 20 16:24:00 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22908] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061020232400.33D26235474@cvs.opensource.apple.com> Revision: 22908 http://trac.macosforge.org/projects/launchd/changeset/22908 Author: zarzycki@apple.com Date: 2006-10-20 16:23:59 -0700 (Fri, 20 Oct 2006) Log Message: ----------- launchd-164 breaks LaunchServices-232.1, in that the uncork_fork() stuff doesn't work Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-19 22:44:06 UTC (rev 22907) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-20 23:23:59 UTC (rev 22908) @@ -3951,6 +3951,11 @@ return BOOTSTRAP_NO_MEMORY; } + if (!job_setup_machport(jr)) { + job_remove(jr); + return BOOTSTRAP_NO_MEMORY; + } + job_log(j, LOG_INFO, "Spawned with flags:%s%s", flags & SPAWN_WANTS_FORCE_PPC ? " ppc": "", flags & SPAWN_WANTS_WAIT4DEBUGGER ? " stopped": ""); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061020/ca7bae3c/attachment.html From source_changes at macosforge.org Fri Oct 20 16:24:08 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22909] tags/launchd-165/ Message-ID: <20061020232408.3AF8C235478@cvs.opensource.apple.com> Revision: 22909 http://trac.macosforge.org/projects/launchd/changeset/22909 Author: zarzycki@apple.com Date: 2006-10-20 16:24:08 -0700 (Fri, 20 Oct 2006) Log Message: ----------- "Tagging launchd-165 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-165/ Copied: tags/launchd-165 (from rev 22908, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061020/2bf1f689/attachment.html From source_changes at macosforge.org Mon Oct 23 10:46:26 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22910] trunk/launchd/src Message-ID: <20061023174626.2A591249E21@cvs.opensource.apple.com> Revision: 22910 http://trac.macosforge.org/projects/launchd/changeset/22910 Author: zarzycki@apple.com Date: 2006-10-23 10:46:23 -0700 (Mon, 23 Oct 2006) Log Message: ----------- First stage in the activation of the vproc APIs. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchctl.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch.c trunk/launchd/src/protocol_job.defs trunk/launchd/src/protocol_job_reply.defs trunk/launchd/src/vproc.h Added Paths: ----------- trunk/launchd/src/libbootstrap.c trunk/launchd/src/libvproc.c trunk/launchd/src/vproc_priv.h Removed Paths: ------------- trunk/launchd/src/bootstrap_private.h trunk/launchd/src/bootstrap_public.c trunk/launchd/src/protocol_legacy.defs Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/Makefile.am 2006-10-23 17:46:23 UTC (rev 22910) @@ -1,22 +1,22 @@ AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -CLEANFILES = bootstrap.h bootstrapServer.c bootstrapUser.c bootstrapServer.h \ +CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.h launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h -bootstrap.h bootstrapServer.c bootstrapUser.c bootstrapServer.h: $(srcdir)/protocol_legacy.defs - mig $(MIGFLAGS) -sheader bootstrapServer.h $(srcdir)/protocol_legacy.defs +protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h: $(srcdir)/protocol_job.defs + mig $(MIGFLAGS) -sheader protocol_vprocServer.h $(srcdir)/protocol_job.defs if LIBS_ONLY noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -liblaunch_a_SOURCES = liblaunch.c bootstrap_public.c +liblaunch_a_SOURCES = liblaunch.c libvproc.c liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) -liblaunch_profile_a_SOURCES = liblaunch.c bootstrap_public.c +liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c -$(srcdir)/bootstrap_public.c:: bootstrap.h +$(srcdir)/libvproc.c:: protocol_vproc.h install-data-hook: mkdir -p $(DESTDIR)/usr/local/lib/system @@ -43,10 +43,10 @@ launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter -fvisibility=hidden launchd_LDFLAGS = -lbsm -launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c init.c bootstrapServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c +launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c init.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime.c:: notifyServer.h launchd_internal.h -launchd_core_logic.c:: bootstrap.h job_reply.h bootstrap.h bootstrapServer.h +launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h launchproxy_LDFLAGS = -weak_framework Security Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/Makefile.in 2006-10-23 17:46:23 UTC (rev 22910) @@ -56,16 +56,16 @@ ARFLAGS = cru liblaunch_a_AR = $(AR) $(ARFLAGS) liblaunch_a_LIBADD = -am__liblaunch_a_SOURCES_DIST = liblaunch.c bootstrap_public.c +am__liblaunch_a_SOURCES_DIST = liblaunch.c libvproc.c @LIBS_ONLY_TRUE@am_liblaunch_a_OBJECTS = liblaunch.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ bootstrap_public.$(OBJEXT) +@LIBS_ONLY_TRUE@ libvproc.$(OBJEXT) liblaunch_a_OBJECTS = $(am_liblaunch_a_OBJECTS) liblaunch_profile_a_AR = $(AR) $(ARFLAGS) liblaunch_profile_a_LIBADD = -am__liblaunch_profile_a_SOURCES_DIST = liblaunch.c bootstrap_public.c +am__liblaunch_profile_a_SOURCES_DIST = liblaunch.c libvproc.c @LIBS_ONLY_TRUE@am_liblaunch_profile_a_OBJECTS = \ @LIBS_ONLY_TRUE@ liblaunch_profile_a-liblaunch.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ liblaunch_profile_a-bootstrap_public.$(OBJEXT) +@LIBS_ONLY_TRUE@ liblaunch_profile_a-libvproc.$(OBJEXT) liblaunch_profile_a_OBJECTS = $(am_liblaunch_profile_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" \ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(sbindir)" \ @@ -86,14 +86,14 @@ launchctl_OBJECTS = launchctl-launchctl.$(OBJEXT) launchctl_LDADD = $(LDADD) am__launchd_SOURCES_DIST = launchd.c launchd_core_logic.c \ - launchd_unix_ipc.c init.c bootstrapServer.c notifyServer.c \ - launchd_internalUser.c launchd_internalServer.c \ + launchd_unix_ipc.c init.c protocol_vprocServer.c \ + notifyServer.c launchd_internalUser.c launchd_internalServer.c \ job_replyUser.c launchd_runtime.c @LIBS_ONLY_FALSE@am_launchd_OBJECTS = launchd-launchd.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_core_logic.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_unix_ipc.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-init.$(OBJEXT) \ -@LIBS_ONLY_FALSE@ launchd-bootstrapServer.$(OBJEXT) \ +@LIBS_ONLY_FALSE@ launchd-protocol_vprocServer.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-notifyServer.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_internalUser.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_internalServer.$(OBJEXT) \ @@ -222,14 +222,14 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -CLEANFILES = bootstrap.h bootstrapServer.c bootstrapUser.c bootstrapServer.h \ +CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.h launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -@LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c bootstrap_public.c +@LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c @LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) -@LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c bootstrap_public.c +@LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c @LIBS_ONLY_FALSE@sbin_SCRIPTS = service @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown @LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders @@ -239,7 +239,7 @@ @LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter -fvisibility=hidden @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm -@LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c init.c bootstrapServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c +@LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c init.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 @@ -420,9 +420,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-IPC.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-StartupItems.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemStarter-SystemStarter.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bootstrap_public.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchctl-launchctl.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-bootstrapServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-init.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-job_replyUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd.Po@am__quote@ @@ -432,10 +430,12 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_unix_ipc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchproxy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-liblaunch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libvproc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvproc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wait4path.Po@am__quote@ .c.o: @@ -466,19 +466,19 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-liblaunch.obj `if test -f 'liblaunch.c'; then $(CYGPATH_W) 'liblaunch.c'; else $(CYGPATH_W) '$(srcdir)/liblaunch.c'; fi` -liblaunch_profile_a-bootstrap_public.o: bootstrap_public.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-bootstrap_public.o -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Tpo" -c -o liblaunch_profile_a-bootstrap_public.o `test -f 'bootstrap_public.c' || echo '$(srcdir)/'`bootstrap_public.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Tpo" "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bootstrap_public.c' object='liblaunch_profile_a-bootstrap_public.o' libtool=no @AMDEPBACKSLASH@ +liblaunch_profile_a-libvproc.o: libvproc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-libvproc.o -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-libvproc.Tpo" -c -o liblaunch_profile_a-libvproc.o `test -f 'libvproc.c' || echo '$(srcdir)/'`libvproc.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-libvproc.Tpo" "$(DEPDIR)/liblaunch_profile_a-libvproc.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-libvproc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libvproc.c' object='liblaunch_profile_a-libvproc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-bootstrap_public.o `test -f 'bootstrap_public.c' || echo '$(srcdir)/'`bootstrap_public.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-libvproc.o `test -f 'libvproc.c' || echo '$(srcdir)/'`libvproc.c -liblaunch_profile_a-bootstrap_public.obj: bootstrap_public.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-bootstrap_public.obj -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Tpo" -c -o liblaunch_profile_a-bootstrap_public.obj `if test -f 'bootstrap_public.c'; then $(CYGPATH_W) 'bootstrap_public.c'; else $(CYGPATH_W) '$(srcdir)/bootstrap_public.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Tpo" "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-bootstrap_public.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bootstrap_public.c' object='liblaunch_profile_a-bootstrap_public.obj' libtool=no @AMDEPBACKSLASH@ +liblaunch_profile_a-libvproc.obj: libvproc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-libvproc.obj -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-libvproc.Tpo" -c -o liblaunch_profile_a-libvproc.obj `if test -f 'libvproc.c'; then $(CYGPATH_W) 'libvproc.c'; else $(CYGPATH_W) '$(srcdir)/libvproc.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-libvproc.Tpo" "$(DEPDIR)/liblaunch_profile_a-libvproc.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-libvproc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libvproc.c' object='liblaunch_profile_a-libvproc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-bootstrap_public.obj `if test -f 'bootstrap_public.c'; then $(CYGPATH_W) 'bootstrap_public.c'; else $(CYGPATH_W) '$(srcdir)/bootstrap_public.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-libvproc.obj `if test -f 'libvproc.c'; then $(CYGPATH_W) 'libvproc.c'; else $(CYGPATH_W) '$(srcdir)/libvproc.c'; fi` SystemStarter-StartupItems.o: StartupItems.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(SystemStarter_CFLAGS) $(CFLAGS) -MT SystemStarter-StartupItems.o -MD -MP -MF "$(DEPDIR)/SystemStarter-StartupItems.Tpo" -c -o SystemStarter-StartupItems.o `test -f 'StartupItems.c' || echo '$(srcdir)/'`StartupItems.c; \ @@ -592,19 +592,19 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-init.obj `if test -f 'init.c'; then $(CYGPATH_W) 'init.c'; else $(CYGPATH_W) '$(srcdir)/init.c'; fi` -launchd-bootstrapServer.o: bootstrapServer.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-bootstrapServer.o -MD -MP -MF "$(DEPDIR)/launchd-bootstrapServer.Tpo" -c -o launchd-bootstrapServer.o `test -f 'bootstrapServer.c' || echo '$(srcdir)/'`bootstrapServer.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/launchd-bootstrapServer.Tpo" "$(DEPDIR)/launchd-bootstrapServer.Po"; else rm -f "$(DEPDIR)/launchd-bootstrapServer.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bootstrapServer.c' object='launchd-bootstrapServer.o' libtool=no @AMDEPBACKSLASH@ +launchd-protocol_vprocServer.o: protocol_vprocServer.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-protocol_vprocServer.o -MD -MP -MF "$(DEPDIR)/launchd-protocol_vprocServer.Tpo" -c -o launchd-protocol_vprocServer.o `test -f 'protocol_vprocServer.c' || echo '$(srcdir)/'`protocol_vprocServer.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/launchd-protocol_vprocServer.Tpo" "$(DEPDIR)/launchd-protocol_vprocServer.Po"; else rm -f "$(DEPDIR)/launchd-protocol_vprocServer.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='protocol_vprocServer.c' object='launchd-protocol_vprocServer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-bootstrapServer.o `test -f 'bootstrapServer.c' || echo '$(srcdir)/'`bootstrapServer.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-protocol_vprocServer.o `test -f 'protocol_vprocServer.c' || echo '$(srcdir)/'`protocol_vprocServer.c -launchd-bootstrapServer.obj: bootstrapServer.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-bootstrapServer.obj -MD -MP -MF "$(DEPDIR)/launchd-bootstrapServer.Tpo" -c -o launchd-bootstrapServer.obj `if test -f 'bootstrapServer.c'; then $(CYGPATH_W) 'bootstrapServer.c'; else $(CYGPATH_W) '$(srcdir)/bootstrapServer.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/launchd-bootstrapServer.Tpo" "$(DEPDIR)/launchd-bootstrapServer.Po"; else rm -f "$(DEPDIR)/launchd-bootstrapServer.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bootstrapServer.c' object='launchd-bootstrapServer.obj' libtool=no @AMDEPBACKSLASH@ +launchd-protocol_vprocServer.obj: protocol_vprocServer.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-protocol_vprocServer.obj -MD -MP -MF "$(DEPDIR)/launchd-protocol_vprocServer.Tpo" -c -o launchd-protocol_vprocServer.obj `if test -f 'protocol_vprocServer.c'; then $(CYGPATH_W) 'protocol_vprocServer.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocServer.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/launchd-protocol_vprocServer.Tpo" "$(DEPDIR)/launchd-protocol_vprocServer.Po"; else rm -f "$(DEPDIR)/launchd-protocol_vprocServer.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='protocol_vprocServer.c' object='launchd-protocol_vprocServer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-bootstrapServer.obj `if test -f 'bootstrapServer.c'; then $(CYGPATH_W) 'bootstrapServer.c'; else $(CYGPATH_W) '$(srcdir)/bootstrapServer.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-protocol_vprocServer.obj `if test -f 'protocol_vprocServer.c'; then $(CYGPATH_W) 'protocol_vprocServer.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocServer.c'; fi` launchd-notifyServer.o: notifyServer.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-notifyServer.o -MD -MP -MF "$(DEPDIR)/launchd-notifyServer.Tpo" -c -o launchd-notifyServer.o `test -f 'notifyServer.c' || echo '$(srcdir)/'`notifyServer.c; \ @@ -1013,10 +1013,10 @@ uninstall-sbinSCRIPTS uninstall-sysconfDATA -bootstrap.h bootstrapServer.c bootstrapUser.c bootstrapServer.h: $(srcdir)/protocol_legacy.defs - mig $(MIGFLAGS) -sheader bootstrapServer.h $(srcdir)/protocol_legacy.defs +protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h: $(srcdir)/protocol_job.defs + mig $(MIGFLAGS) -sheader protocol_vprocServer.h $(srcdir)/protocol_job.defs -@LIBS_ONLY_TRUE@$(srcdir)/bootstrap_public.c:: bootstrap.h +@LIBS_ONLY_TRUE@$(srcdir)/libvproc.c:: protocol_vproc.h @LIBS_ONLY_TRUE@install-data-hook: @LIBS_ONLY_TRUE@ mkdir -p $(DESTDIR)/usr/local/lib/system @@ -1025,7 +1025,7 @@ @LIBS_ONLY_TRUE@ cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h -@LIBS_ONLY_FALSE@launchd_core_logic.c:: bootstrap.h job_reply.h bootstrap.h bootstrapServer.h +@LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h @LIBS_ONLY_FALSE@notifyServer.c notifyServer.h: /usr/include/mach/notify.defs @LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs Deleted: trunk/launchd/src/bootstrap_private.h =================================================================== --- trunk/launchd/src/bootstrap_private.h 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/bootstrap_private.h 2006-10-23 17:46:23 UTC (rev 22910) @@ -1,62 +0,0 @@ -#ifndef _BOOTSTRAP_PRIVATE_H_ -#define _BOOTSTRAP_PRIVATE_H_ -/* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -typedef char * _internal_string_t; -typedef mach_port_t vproc_mig_t; - -#ifdef bootstrap_MSG_COUNT -/* HACK */ -#include "launchd_core_logic.h" -#endif - -#define SPAWN_HAS_PATH 0x0001 -#define SPAWN_HAS_WDIR 0x0002 -#define SPAWN_HAS_UMASK 0x0004 -#define SPAWN_WANTS_WAIT4DEBUGGER 0x0008 -#define SPAWN_WANTS_FORCE_PPC 0x0010 - -kern_return_t -_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - mach_port_array_t *ports, mach_msg_type_number_t *portCnt); - -kern_return_t bootstrap_getsocket(mach_port_t bp, name_t); - - -kern_return_t -bootstrap_look_up_array( - mach_port_t bp, - name_array_t service_names, - mach_msg_type_number_t service_namesCnt, - mach_port_array_t *sps, - mach_msg_type_number_t *service_portsCnt, - boolean_t *all_services_known); - -kern_return_t -bootstrap_info( - mach_port_t bp, - name_array_t *service_names, - mach_msg_type_number_t *service_namesCnt, - bootstrap_status_array_t *service_active, - mach_msg_type_number_t *service_activeCnt); - -#endif Deleted: trunk/launchd/src/bootstrap_public.c =================================================================== --- trunk/launchd/src/bootstrap_public.c 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/bootstrap_public.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -1,291 +0,0 @@ -/* - * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -#include -#include - -#include "bootstrap_public.h" -#include "bootstrap_private.h" -#include "launch.h" -#include "launch_priv.h" - -#define mig_external static -#include "bootstrap.h" -#include "bootstrapUser.c" - -#include -#include -#include - -kern_return_t -_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - mach_port_array_t *ports, mach_msg_type_number_t *portCnt) -{ - return vproc_mig_transfer_subset(bp, reqport, rcvright, service_names, service_namesCnt, ports, portCnt); -} - -pid_t -_spawn_via_launchd(const char *label, const char *const *argv, const struct spawn_via_launchd_attr *spawn_attrs, int struct_version) -{ - kern_return_t kr; - const char *const *tmpp; - size_t len, buf_len = strlen(label) + 1; - char *buf = strdup(label); - uint64_t flags = 0; - uint32_t argc = 0; - uint32_t envc = 0; - pid_t p = -1; - mode_t u_mask = CMASK; - mach_port_t obsvr_port = MACH_PORT_NULL; - - for (tmpp = argv; *tmpp; tmpp++) { - argc++; - len = strlen(*tmpp) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, *tmpp); - buf_len += len; - } - - if (spawn_attrs) switch (struct_version) { - case 0: - if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_STOPPED) { - flags |= SPAWN_WANTS_WAIT4DEBUGGER; - } - if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_FORCE_PPC) { - flags |= SPAWN_WANTS_FORCE_PPC; - } - - if (spawn_attrs->spawn_env) { - for (tmpp = spawn_attrs->spawn_env; *tmpp; tmpp++) { - envc++; - len = strlen(*tmpp) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, *tmpp); - buf_len += len; - } - } - - if (spawn_attrs->spawn_path) { - flags |= SPAWN_HAS_PATH; - len = strlen(spawn_attrs->spawn_path) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, spawn_attrs->spawn_path); - buf_len += len; - } - - if (spawn_attrs->spawn_chdir) { - flags |= SPAWN_HAS_WDIR; - len = strlen(spawn_attrs->spawn_chdir) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, spawn_attrs->spawn_chdir); - buf_len += len; - } - - if (spawn_attrs->spawn_umask) { - flags |= SPAWN_HAS_UMASK; - u_mask = *spawn_attrs->spawn_umask; - } - - break; - default: - break; - } - - kr = vproc_mig_spawn(bootstrap_port, buf, buf_len, argc, envc, flags, u_mask, &p, &obsvr_port); - - free(buf); - - if (kr == BOOTSTRAP_SUCCESS) { - if (spawn_attrs && spawn_attrs->spawn_observer_port) { - *spawn_attrs->spawn_observer_port = obsvr_port; - } else { - mach_port_deallocate(mach_task_self(), obsvr_port); - } - return p; - } - - switch (kr) { - case BOOTSTRAP_NOT_PRIVILEGED: - errno = EPERM; break; - case BOOTSTRAP_NO_MEMORY: - errno = ENOMEM; break; - default: - errno = EINVAL; break; - } - return -1; -} - -kern_return_t -mpm_wait(mach_port_t ajob, int *wstatus) -{ - return vproc_mig_wait(ajob, wstatus); -} - -kern_return_t -mpm_uncork_fork(mach_port_t ajob) -{ - return vproc_mig_uncork_fork(ajob); -} - -kern_return_t -bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port) -{ - return vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port); -} - -kern_return_t -bootstrap_subset(mach_port_t bp, mach_port_t requestor_port, mach_port_t *subset_port) -{ - return vproc_mig_subset(bp, requestor_port, subset_port); -} - -kern_return_t -bootstrap_unprivileged(mach_port_t bp, mach_port_t *unpriv_port) -{ - kern_return_t kr; - - *unpriv_port = MACH_PORT_NULL; - - kr = mach_port_mod_refs(mach_task_self(), bp, MACH_PORT_RIGHT_SEND, 1); - - if (kr == KERN_SUCCESS) { - *unpriv_port = bp; - } - - return kr; -} - -kern_return_t -bootstrap_getsocket(mach_port_t bp, name_t sockpath) -{ - return vproc_mig_getsocket(bp, sockpath); -} - -kern_return_t -bootstrap_parent(mach_port_t bp, mach_port_t *parent_port) -{ - return vproc_mig_parent(bp, parent_port); -} - -kern_return_t -bootstrap_register(mach_port_t bp, name_t service_name, mach_port_t sp) -{ - return vproc_mig_register(bp, service_name, sp); -} - -kern_return_t -bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp) -{ - return vproc_mig_create_service(bp, service_name, sp); -} - -kern_return_t -bootstrap_check_in(mach_port_t bp, name_t service_name, mach_port_t *sp) -{ - return vproc_mig_check_in(bp, service_name, sp); -} - -kern_return_t -bootstrap_look_up(mach_port_t bp, name_t service_name, mach_port_t *sp) -{ - return vproc_mig_look_up(bp, service_name, sp); -} - -kern_return_t -bootstrap_look_up_array(mach_port_t bp, - name_array_t names, mach_msg_type_number_t name_cnt, - mach_port_array_t *ports, mach_msg_type_number_t *port_cnt, - boolean_t *all) -{ - unsigned int i; - kern_return_t r; - - if (name_cnt > BOOTSTRAP_MAX_LOOKUP_COUNT) - return BOOTSTRAP_BAD_COUNT; - - *port_cnt = name_cnt; - - r = vm_allocate(mach_task_self(), (vm_address_t *)&ports, name_cnt * sizeof(mach_port_t), true); - - if (r != KERN_SUCCESS) - return r; - - *all = true; - - for (i = 0; i < name_cnt; i++) { - if (bootstrap_look_up(bp, names[i], &((*ports)[i])) == BOOTSTRAP_SUCCESS) - continue; - *all = false; - ports[i] = MACH_PORT_NULL; - } - - return BOOTSTRAP_SUCCESS; -} - -kern_return_t -bootstrap_status(mach_port_t bp, name_t service_name, bootstrap_status_t *service_active) -{ - mach_port_t p; - - if (bootstrap_check_in(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { - mach_port_mod_refs(mach_task_self(), p, MACH_PORT_RIGHT_RECEIVE, -1); - *service_active = BOOTSTRAP_STATUS_ON_DEMAND; - return BOOTSTRAP_SUCCESS; - } else if (bootstrap_look_up(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { - mach_port_deallocate(mach_task_self(), p); - *service_active = BOOTSTRAP_STATUS_ACTIVE; - return BOOTSTRAP_SUCCESS; - } - - return BOOTSTRAP_UNKNOWN_SERVICE; -} - -kern_return_t -bootstrap_info(mach_port_t bp, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - bootstrap_status_array_t *service_active, mach_msg_type_number_t *service_activeCnt) -{ - return vproc_mig_info(bp, service_names, service_namesCnt, - service_active, service_activeCnt); -} - - -const char * -bootstrap_strerror(kern_return_t r) -{ - switch (r) { - case BOOTSTRAP_SUCCESS: - return "Success"; - case BOOTSTRAP_NOT_PRIVILEGED: - return "Permission denied"; - case BOOTSTRAP_NAME_IN_USE: - case BOOTSTRAP_SERVICE_ACTIVE: - return "Service name already exists"; - case BOOTSTRAP_UNKNOWN_SERVICE: - return "Unknown service name"; - case BOOTSTRAP_BAD_COUNT: - return "Too many lookups were requested in one request"; - case BOOTSTRAP_NO_MEMORY: - return "Out of memory"; - default: - return mach_error_string(r); - } -} Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/launchctl.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -60,7 +60,7 @@ #include #include "bootstrap_public.h" -#include "bootstrap_private.h" +#include "vproc_priv.h" #include "launch.h" #include "launch_priv.h" Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/launchd.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -62,7 +62,7 @@ #include #include "bootstrap_public.h" -#include "bootstrap_private.h" +#include "vproc_priv.h" #include "launch.h" #include "launch_priv.h" #include "launchd.h" Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -77,9 +77,9 @@ #include "launchd_core_logic.h" #include "launchd_unix_ipc.h" #include "bootstrap_public.h" -#include "bootstrap_private.h" -#include "bootstrap.h" -#include "bootstrapServer.h" +#include "vproc_priv.h" +#include "protocol_vproc.h" +#include "protocol_vprocServer.h" #include "job_reply.h" #define LAUNCHD_MIN_JOB_RUN_TIME 10 @@ -661,12 +661,12 @@ } /* Sigh... at the moment, MIG has maxsize == sizeof(reply union) */ - mxmsgsz = sizeof(union __RequestUnion__job_mig_bootstrap_subsystem); - if (job_mig_bootstrap_subsystem.maxsize > mxmsgsz) { - mxmsgsz = job_mig_bootstrap_subsystem.maxsize; + mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); + if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { + mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; } - if (!job_assumes(j, runtime_add_mport(j->bs_port, bootstrap_server, mxmsgsz) == KERN_SUCCESS)) { + if (!job_assumes(j, runtime_add_mport(j->bs_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS)) { goto out_bad2; } @@ -2914,12 +2914,12 @@ sprintf(j->label, "%d", MACH_PORT_INDEX(j->bs_port)); /* Sigh... at the moment, MIG has maxsize == sizeof(reply union) */ - mxmsgsz = sizeof(union __RequestUnion__job_mig_bootstrap_subsystem); - if (job_mig_bootstrap_subsystem.maxsize > mxmsgsz) { - mxmsgsz = job_mig_bootstrap_subsystem.maxsize; + mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); + if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { + mxmsgsz = job_mig_protocol_vproc_subsystem.maxsize; } - if (!job_assumes(j, runtime_add_mport(j->bs_port, bootstrap_server, mxmsgsz) == KERN_SUCCESS)) { + if (!job_assumes(j, runtime_add_mport(j->bs_port, protocol_vproc_server, mxmsgsz) == KERN_SUCCESS)) { goto out_bad; } @@ -3842,6 +3842,11 @@ return BOOTSTRAP_NOT_PRIVILEGED; } + if (!j->legacy_mach_job) { + job_log(j, LOG_ERR, "bootstrap_create_service() is only allowed against legacy Mach jobs: %s", servicename); + return BOOTSTRAP_NOT_PRIVILEGED; + } + ms = job_lookup_service(j, servicename, false); if (ms) { job_log(j, LOG_DEBUG, "Mach service creation attempt for failed. Already exists: %s", servicename); Copied: trunk/launchd/src/libbootstrap.c (from rev 22901, trunk/launchd/src/bootstrap_public.c) =================================================================== --- trunk/launchd/src/libbootstrap.c (rev 0) +++ trunk/launchd/src/libbootstrap.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -0,0 +1,291 @@ +/* + * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#include +#include + +#include "bootstrap_public.h" +#include "bootstrap_private.h" +#include "launch.h" +#include "launch_priv.h" + +#define mig_external static +#include "bootstrap.h" +#include "bootstrapUser.c" + +#include +#include +#include + +kern_return_t +_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + mach_port_array_t *ports, mach_msg_type_number_t *portCnt) +{ + return vproc_mig_transfer_subset(bp, reqport, rcvright, service_names, service_namesCnt, ports, portCnt); +} + +pid_t +_spawn_via_launchd(const char *label, const char *const *argv, const struct spawn_via_launchd_attr *spawn_attrs, int struct_version) +{ + kern_return_t kr; + const char *const *tmpp; + size_t len, buf_len = strlen(label) + 1; + char *buf = strdup(label); + uint64_t flags = 0; + uint32_t argc = 0; + uint32_t envc = 0; + pid_t p = -1; + mode_t u_mask = CMASK; + mach_port_t obsvr_port = MACH_PORT_NULL; + + for (tmpp = argv; *tmpp; tmpp++) { + argc++; + len = strlen(*tmpp) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, *tmpp); + buf_len += len; + } + + if (spawn_attrs) switch (struct_version) { + case 0: + if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_STOPPED) { + flags |= SPAWN_WANTS_WAIT4DEBUGGER; + } + if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_FORCE_PPC) { + flags |= SPAWN_WANTS_FORCE_PPC; + } + + if (spawn_attrs->spawn_env) { + for (tmpp = spawn_attrs->spawn_env; *tmpp; tmpp++) { + envc++; + len = strlen(*tmpp) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, *tmpp); + buf_len += len; + } + } + + if (spawn_attrs->spawn_path) { + flags |= SPAWN_HAS_PATH; + len = strlen(spawn_attrs->spawn_path) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, spawn_attrs->spawn_path); + buf_len += len; + } + + if (spawn_attrs->spawn_chdir) { + flags |= SPAWN_HAS_WDIR; + len = strlen(spawn_attrs->spawn_chdir) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, spawn_attrs->spawn_chdir); + buf_len += len; + } + + if (spawn_attrs->spawn_umask) { + flags |= SPAWN_HAS_UMASK; + u_mask = *spawn_attrs->spawn_umask; + } + + break; + default: + break; + } + + kr = vproc_mig_spawn(bootstrap_port, buf, buf_len, argc, envc, flags, u_mask, &p, &obsvr_port); + + free(buf); + + if (kr == BOOTSTRAP_SUCCESS) { + if (spawn_attrs && spawn_attrs->spawn_observer_port) { + *spawn_attrs->spawn_observer_port = obsvr_port; + } else { + mach_port_deallocate(mach_task_self(), obsvr_port); + } + return p; + } + + switch (kr) { + case BOOTSTRAP_NOT_PRIVILEGED: + errno = EPERM; break; + case BOOTSTRAP_NO_MEMORY: + errno = ENOMEM; break; + default: + errno = EINVAL; break; + } + return -1; +} + +kern_return_t +mpm_wait(mach_port_t ajob, int *wstatus) +{ + return vproc_mig_wait(ajob, wstatus); +} + +kern_return_t +mpm_uncork_fork(mach_port_t ajob) +{ + return vproc_mig_uncork_fork(ajob); +} + +kern_return_t +bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port) +{ + return vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port); +} + +kern_return_t +bootstrap_subset(mach_port_t bp, mach_port_t requestor_port, mach_port_t *subset_port) +{ + return vproc_mig_subset(bp, requestor_port, subset_port); +} + +kern_return_t +bootstrap_unprivileged(mach_port_t bp, mach_port_t *unpriv_port) +{ + kern_return_t kr; + + *unpriv_port = MACH_PORT_NULL; + + kr = mach_port_mod_refs(mach_task_self(), bp, MACH_PORT_RIGHT_SEND, 1); + + if (kr == KERN_SUCCESS) { + *unpriv_port = bp; + } + + return kr; +} + +kern_return_t +bootstrap_getsocket(mach_port_t bp, name_t sockpath) +{ + return vproc_mig_getsocket(bp, sockpath); +} + +kern_return_t +bootstrap_parent(mach_port_t bp, mach_port_t *parent_port) +{ + return vproc_mig_parent(bp, parent_port); +} + +kern_return_t +bootstrap_register(mach_port_t bp, name_t service_name, mach_port_t sp) +{ + return vproc_mig_register(bp, service_name, sp); +} + +kern_return_t +bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp) +{ + return vproc_mig_create_service(bp, service_name, sp); +} + +kern_return_t +bootstrap_check_in(mach_port_t bp, name_t service_name, mach_port_t *sp) +{ + return vproc_mig_check_in(bp, service_name, sp); +} + +kern_return_t +bootstrap_look_up(mach_port_t bp, name_t service_name, mach_port_t *sp) +{ + return vproc_mig_look_up(bp, service_name, sp); +} + +kern_return_t +bootstrap_look_up_array(mach_port_t bp, + name_array_t names, mach_msg_type_number_t name_cnt, + mach_port_array_t *ports, mach_msg_type_number_t *port_cnt, + boolean_t *all) +{ + unsigned int i; + kern_return_t r; + + if (name_cnt > BOOTSTRAP_MAX_LOOKUP_COUNT) + return BOOTSTRAP_BAD_COUNT; + + *port_cnt = name_cnt; + + r = vm_allocate(mach_task_self(), (vm_address_t *)&ports, name_cnt * sizeof(mach_port_t), true); + + if (r != KERN_SUCCESS) + return r; + + *all = true; + + for (i = 0; i < name_cnt; i++) { + if (bootstrap_look_up(bp, names[i], &((*ports)[i])) == BOOTSTRAP_SUCCESS) + continue; + *all = false; + ports[i] = MACH_PORT_NULL; + } + + return BOOTSTRAP_SUCCESS; +} + +kern_return_t +bootstrap_status(mach_port_t bp, name_t service_name, bootstrap_status_t *service_active) +{ + mach_port_t p; + + if (bootstrap_check_in(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { + mach_port_mod_refs(mach_task_self(), p, MACH_PORT_RIGHT_RECEIVE, -1); + *service_active = BOOTSTRAP_STATUS_ON_DEMAND; + return BOOTSTRAP_SUCCESS; + } else if (bootstrap_look_up(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { + mach_port_deallocate(mach_task_self(), p); + *service_active = BOOTSTRAP_STATUS_ACTIVE; + return BOOTSTRAP_SUCCESS; + } + + return BOOTSTRAP_UNKNOWN_SERVICE; +} + +kern_return_t +bootstrap_info(mach_port_t bp, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + bootstrap_status_array_t *service_active, mach_msg_type_number_t *service_activeCnt) +{ + return vproc_mig_info(bp, service_names, service_namesCnt, + service_active, service_activeCnt); +} + + +const char * +bootstrap_strerror(kern_return_t r) +{ + switch (r) { + case BOOTSTRAP_SUCCESS: + return "Success"; + case BOOTSTRAP_NOT_PRIVILEGED: + return "Permission denied"; + case BOOTSTRAP_NAME_IN_USE: + case BOOTSTRAP_SERVICE_ACTIVE: + return "Service name already exists"; + case BOOTSTRAP_UNKNOWN_SERVICE: + return "Unknown service name"; + case BOOTSTRAP_BAD_COUNT: + return "Too many lookups were requested in one request"; + case BOOTSTRAP_NO_MEMORY: + return "Out of memory"; + default: + return mach_error_string(r); + } +} Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/liblaunch.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -36,7 +36,7 @@ #include "launch.h" #include "launch_priv.h" #include "bootstrap_public.h" -#include "bootstrap_private.h" +#include "vproc_priv.h" /* __OSBogusByteSwap__() must not really exist in the symbol namespace * in order for the following to generate an error at build time. @@ -133,8 +133,8 @@ int fd; }; -static void make_msg_and_cmsg(launch_data_t, void **, size_t *, int **, size_t *); -static launch_data_t make_data(launch_t, size_t *, size_t *); +static void launch_data_pack(launch_data_t, void **, size_t *, int **, size_t *); +static launch_data_t launch_data_unpack(launch_t, size_t *, size_t *); static launch_data_t launch_data_array_pop_first(launch_data_t where); static int _fd(int fd); static void launch_client_init(void); @@ -565,7 +565,7 @@ } void -make_msg_and_cmsg(launch_data_t d, void **where, size_t *len, int **fd_where, size_t *fdcnt) +launch_data_pack(launch_data_t d, void **where, size_t *len, int **fd_where, size_t *fdcnt) { launch_data_t o_in_w; size_t i; @@ -619,14 +619,15 @@ *len += d->_array_cnt * sizeof(launch_data_t); for (i = 0; i < d->_array_cnt; i++) - make_msg_and_cmsg(d->_array[i], where, len, fd_where, fdcnt); + launch_data_pack(d->_array[i], where, len, fd_where, fdcnt); break; default: break; } } -static launch_data_t make_data(launch_t conn, size_t *data_offset, size_t *fdoffset) +launch_data_t +launch_data_unpack(launch_t conn, size_t *data_offset, size_t *fdoffset) { launch_data_t r = conn->recvbuf + *data_offset; size_t i, tmpcnt; @@ -646,7 +647,7 @@ r->_array = conn->recvbuf + *data_offset; *data_offset += tmpcnt * sizeof(launch_data_t); for (i = 0; i < tmpcnt; i++) { - r->_array[i] = make_data(conn, data_offset, fdoffset); + r->_array[i] = launch_data_unpack(conn, data_offset, fdoffset); if (r->_array[i] == NULL) return NULL; } @@ -716,7 +717,7 @@ if (d) { uint64_t msglen = lh->sendlen; - make_msg_and_cmsg(d, &lh->sendbuf, &lh->sendlen, &lh->sendfds, &lh->sendfdcnt); + launch_data_pack(d, &lh->sendbuf, &lh->sendlen, &lh->sendfds, &lh->sendfdcnt); msglen = (lh->sendlen - msglen) + sizeof(struct launch_msg_header); lmh.len = host2big(msglen); @@ -953,7 +954,7 @@ goto need_more_data; } - if ((rmsg = make_data(lh, &data_offset, &fd_offset)) == NULL) { + if ((rmsg = launch_data_unpack(lh, &data_offset, &fd_offset)) == NULL) { errno = EBADRPC; goto out_bad; } Copied: trunk/launchd/src/libvproc.c (from rev 22901, trunk/launchd/src/bootstrap_public.c) =================================================================== --- trunk/launchd/src/libvproc.c (rev 0) +++ trunk/launchd/src/libvproc.c 2006-10-23 17:46:23 UTC (rev 22910) @@ -0,0 +1,291 @@ +/* + * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#include +#include + +#include "bootstrap_public.h" +#include "vproc_priv.h" +#include "launch.h" +#include "launch_priv.h" + +#define mig_external static +#include "protocol_vproc.h" +#include "protocol_vprocUser.c" + +#include +#include +#include + +kern_return_t +_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + mach_port_array_t *ports, mach_msg_type_number_t *portCnt) +{ + return vproc_mig_transfer_subset(bp, reqport, rcvright, service_names, service_namesCnt, ports, portCnt); +} + +pid_t +_spawn_via_launchd(const char *label, const char *const *argv, const struct spawn_via_launchd_attr *spawn_attrs, int struct_version) +{ + kern_return_t kr; + const char *const *tmpp; + size_t len, buf_len = strlen(label) + 1; + char *buf = strdup(label); + uint64_t flags = 0; + uint32_t argc = 0; + uint32_t envc = 0; + pid_t p = -1; + mode_t u_mask = CMASK; + mach_port_t obsvr_port = MACH_PORT_NULL; + + for (tmpp = argv; *tmpp; tmpp++) { + argc++; + len = strlen(*tmpp) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, *tmpp); + buf_len += len; + } + + if (spawn_attrs) switch (struct_version) { + case 0: + if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_STOPPED) { + flags |= SPAWN_WANTS_WAIT4DEBUGGER; + } + if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_FORCE_PPC) { + flags |= SPAWN_WANTS_FORCE_PPC; + } + + if (spawn_attrs->spawn_env) { + for (tmpp = spawn_attrs->spawn_env; *tmpp; tmpp++) { + envc++; + len = strlen(*tmpp) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, *tmpp); + buf_len += len; + } + } + + if (spawn_attrs->spawn_path) { + flags |= SPAWN_HAS_PATH; + len = strlen(spawn_attrs->spawn_path) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, spawn_attrs->spawn_path); + buf_len += len; + } + + if (spawn_attrs->spawn_chdir) { + flags |= SPAWN_HAS_WDIR; + len = strlen(spawn_attrs->spawn_chdir) + 1; + buf = reallocf(buf, buf_len + len); + strcpy(buf + buf_len, spawn_attrs->spawn_chdir); + buf_len += len; + } + + if (spawn_attrs->spawn_umask) { + flags |= SPAWN_HAS_UMASK; + u_mask = *spawn_attrs->spawn_umask; + } + + break; + default: + break; + } + + kr = vproc_mig_spawn(bootstrap_port, buf, buf_len, argc, envc, flags, u_mask, &p, &obsvr_port); + + free(buf); + + if (kr == BOOTSTRAP_SUCCESS) { + if (spawn_attrs && spawn_attrs->spawn_observer_port) { + *spawn_attrs->spawn_observer_port = obsvr_port; + } else { + mach_port_deallocate(mach_task_self(), obsvr_port); + } + return p; + } + + switch (kr) { + case BOOTSTRAP_NOT_PRIVILEGED: + errno = EPERM; break; + case BOOTSTRAP_NO_MEMORY: + errno = ENOMEM; break; + default: + errno = EINVAL; break; + } + return -1; +} + +kern_return_t +mpm_wait(mach_port_t ajob, int *wstatus) +{ + return vproc_mig_wait(ajob, wstatus); +} + +kern_return_t +mpm_uncork_fork(mach_port_t ajob) +{ + return vproc_mig_uncork_fork(ajob); +} + +kern_return_t +bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port) +{ + return vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port); +} + +kern_return_t +bootstrap_subset(mach_port_t bp, mach_port_t requestor_port, mach_port_t *subset_port) +{ + return vproc_mig_subset(bp, requestor_port, subset_port); +} + +kern_return_t +bootstrap_unprivileged(mach_port_t bp, mach_port_t *unpriv_port) +{ + kern_return_t kr; + + *unpriv_port = MACH_PORT_NULL; + + kr = mach_port_mod_refs(mach_task_self(), bp, MACH_PORT_RIGHT_SEND, 1); + + if (kr == KERN_SUCCESS) { + *unpriv_port = bp; + } + + return kr; +} + +kern_return_t +bootstrap_getsocket(mach_port_t bp, name_t sockpath) +{ + return vproc_mig_getsocket(bp, sockpath); +} + +kern_return_t +bootstrap_parent(mach_port_t bp, mach_port_t *parent_port) +{ + return vproc_mig_parent(bp, parent_port); +} + +kern_return_t +bootstrap_register(mach_port_t bp, name_t service_name, mach_port_t sp) +{ + return vproc_mig_register(bp, service_name, sp); +} + +kern_return_t +bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp) +{ + return vproc_mig_create_service(bp, service_name, sp); +} + +kern_return_t +bootstrap_check_in(mach_port_t bp, name_t service_name, mach_port_t *sp) +{ + return vproc_mig_check_in(bp, service_name, sp); +} + +kern_return_t +bootstrap_look_up(mach_port_t bp, name_t service_name, mach_port_t *sp) +{ + return vproc_mig_look_up(bp, service_name, sp); +} + +kern_return_t +bootstrap_look_up_array(mach_port_t bp, + name_array_t names, mach_msg_type_number_t name_cnt, + mach_port_array_t *ports, mach_msg_type_number_t *port_cnt, + boolean_t *all) +{ + unsigned int i; + kern_return_t r; + + if (name_cnt > BOOTSTRAP_MAX_LOOKUP_COUNT) + return BOOTSTRAP_BAD_COUNT; + + *port_cnt = name_cnt; + + r = vm_allocate(mach_task_self(), (vm_address_t *)&ports, name_cnt * sizeof(mach_port_t), true); + + if (r != KERN_SUCCESS) + return r; + + *all = true; + + for (i = 0; i < name_cnt; i++) { + if (bootstrap_look_up(bp, names[i], &((*ports)[i])) == BOOTSTRAP_SUCCESS) + continue; + *all = false; + ports[i] = MACH_PORT_NULL; + } + + return BOOTSTRAP_SUCCESS; +} + +kern_return_t +bootstrap_status(mach_port_t bp, name_t service_name, bootstrap_status_t *service_active) +{ + mach_port_t p; + + if (bootstrap_check_in(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { + mach_port_mod_refs(mach_task_self(), p, MACH_PORT_RIGHT_RECEIVE, -1); + *service_active = BOOTSTRAP_STATUS_ON_DEMAND; + return BOOTSTRAP_SUCCESS; + } else if (bootstrap_look_up(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { + mach_port_deallocate(mach_task_self(), p); + *service_active = BOOTSTRAP_STATUS_ACTIVE; + return BOOTSTRAP_SUCCESS; + } + + return BOOTSTRAP_UNKNOWN_SERVICE; +} + +kern_return_t +bootstrap_info(mach_port_t bp, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + bootstrap_status_array_t *service_active, mach_msg_type_number_t *service_activeCnt) +{ + return vproc_mig_info(bp, service_names, service_namesCnt, + service_active, service_activeCnt); +} + + +const char * +bootstrap_strerror(kern_return_t r) +{ + switch (r) { + case BOOTSTRAP_SUCCESS: + return "Success"; + case BOOTSTRAP_NOT_PRIVILEGED: + return "Permission denied"; + case BOOTSTRAP_NAME_IN_USE: + case BOOTSTRAP_SERVICE_ACTIVE: + return "Service name already exists"; + case BOOTSTRAP_UNKNOWN_SERVICE: + return "Unknown service name"; + case BOOTSTRAP_BAD_COUNT: + return "Too many lookups were requested in one request"; + case BOOTSTRAP_NO_MEMORY: + return "Out of memory"; + default: + return mach_error_string(r); + } +} Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/protocol_job.defs 2006-10-23 17:46:23 UTC (rev 22910) @@ -23,13 +23,13 @@ * Copyright, 1990. All rights reserved. */ -subsystem bootstrap 400; +subsystem protocol_vproc 400; #include #include #include "launchd_mig_types.defs" -import "bootstrap_public.h"; -import "bootstrap_private.h"; +import "vproc.h"; +import "vproc_priv.h"; userprefix vproc_mig_; serverprefix job_mig_; @@ -39,7 +39,6 @@ __server_cmd : cmd_t; __server_uid : natural_t; __on_demand : boolean_t; - ServerAuditToken __token : audit_token_t; out __server_port : mach_port_make_send_t); skip; /* Last used in 10.4. Was bootstrap_unprivileged() */ @@ -47,18 +46,15 @@ routine check_in( __bs_port : job_t; __service_name : name_t; - ServerAuditToken __token : audit_token_t; out __service_port : mach_port_move_receive_t); routine register( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; __service_name : name_t; __service_port : mach_port_t); routine look_up( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; __service_name : name_t; out __service_port : mach_port_send_t); @@ -90,7 +86,6 @@ out __bs_reqport : mach_port_t; out __bs_rcvright : mach_port_move_receive_t; out __service_names : name_array_t, dealloc; - out __service_pids : pointer_t, dealloc; out __service_ports : mach_port_array_t, dealloc); routine getsocket( @@ -99,7 +94,6 @@ routine spawn( __bs_port : job_t; - ServerAuditToken __token : audit_token_t; __chars : _internal_string_t; __argc : uint32_t; __envc : uint32_t; @@ -111,15 +105,7 @@ routine wait( __bs_port : job_t; sreplyport __rport : mach_port_make_send_once_t; - ServerAuditToken __token : audit_token_t; out __waitval : integer_t); routine uncork_fork( - __bs_port : job_t; - ServerAuditToken __token : audit_token_t); - -/* Essentially the inverse of bootstrap_unprivileged() */ -routine get_self( - __bs_port : job_t; - ServerAuditToken __token : audit_token_t; - out __job_port : mach_port_make_send_t); + __bs_port : job_t); Modified: trunk/launchd/src/protocol_job_reply.defs =================================================================== --- trunk/launchd/src/protocol_job_reply.defs 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/protocol_job_reply.defs 2006-10-23 17:46:23 UTC (rev 22910) @@ -24,7 +24,7 @@ #include #include "launchd_mig_types.defs" import "bootstrap_public.h"; -import "bootstrap_private.h"; +import "vproc_priv.h"; skip; /* create_server */ Deleted: trunk/launchd/src/protocol_legacy.defs =================================================================== --- trunk/launchd/src/protocol_legacy.defs 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/protocol_legacy.defs 2006-10-23 17:46:23 UTC (rev 22910) @@ -1,111 +0,0 @@ -/* - * Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ -/* - * bootstrap -- fundamental service initiator and port server - * Mike DeMoney, NeXT, Inc. - * Copyright, 1990. All rights reserved. - */ - -subsystem bootstrap 400; - -#include -#include -#include "launchd_mig_types.defs" -import "bootstrap_public.h"; -import "bootstrap_private.h"; - -userprefix vproc_mig_; -serverprefix job_mig_; - -routine create_server( - __bs_port : job_t; - __server_cmd : cmd_t; - __server_uid : natural_t; - __on_demand : boolean_t; - out __server_port : mach_port_make_send_t); - -skip; /* Last used in 10.4. Was bootstrap_unprivileged() */ - -routine check_in( - __bs_port : job_t; - __service_name : name_t; - out __service_port : mach_port_move_receive_t); - -routine register( - __bs_port : job_t; - __service_name : name_t; - __service_port : mach_port_t); - -routine look_up( - __bs_port : job_t; - __service_name : name_t; - out __service_port : mach_port_send_t); - -skip; /* last used in 10.4 */ - -routine parent( - __bs_port : job_t; - out __parent_port : mach_port_send_t); - -skip; /* last used in 10.4 */ - -routine info( - __bs_port : job_t; - out __service_names : name_array_t, dealloc; - out __service_active : bootstrap_status_array_t, dealloc); - -routine subset( - __bs_port : job_t; - __requestor_port: mach_port_t; - out __subset_port : mach_port_make_send_t); - -routine create_service( - __bs_port : job_t; - __service_name : name_t; - out __service_port : mach_port_t); - -routine transfer_subset( - __bs_port : job_t; - out __bs_reqport : mach_port_t; - out __bs_rcvright : mach_port_move_receive_t; - out __service_names : name_array_t, dealloc; - out __service_ports : mach_port_array_t, dealloc); - -routine getsocket( - __bs_port : job_t; - out __sockpath : name_t); - -routine spawn( - __bs_port : job_t; - __chars : _internal_string_t; - __argc : uint32_t; - __envc : uint32_t; - __flags : uint64_t; - __umask : uint16_t; - out __pid : pid_t; - out __obsvr_port : mach_port_make_send_t); - -routine wait( - __bs_port : job_t; - sreplyport __rport : mach_port_make_send_once_t; - out __waitval : integer_t); - -routine uncork_fork( - __bs_port : job_t); Modified: trunk/launchd/src/vproc.h =================================================================== --- trunk/launchd/src/vproc.h 2006-10-20 23:24:08 UTC (rev 22909) +++ trunk/launchd/src/vproc.h 2006-10-23 17:46:23 UTC (rev 22910) @@ -20,8 +20,12 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include + __BEGIN_DECLS +#if 0 + typedef void * vproc_t; typedef void * vprocmgr_t; typedef void * vproc_err_t; @@ -42,7 +46,7 @@ vproc_err_t vprocmgr_lookup_vproc(vprocmgr_t vpm, const char *label, vproc_t *vp); -vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm); +vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm_out); vproc_err_t vprocmgr_lookup_mach_service(vprocmgr_t vpm, const char *service, mach_port_t *service_port); @@ -73,6 +77,8 @@ const char *vproc_strerror(vproc_err_t r); +#endif + __END_DECLS #endif Copied: trunk/launchd/src/vproc_priv.h (from rev 22901, trunk/launchd/src/bootstrap_private.h) =================================================================== --- trunk/launchd/src/vproc_priv.h (rev 0) +++ trunk/launchd/src/vproc_priv.h 2006-10-23 17:46:23 UTC (rev 22910) @@ -0,0 +1,62 @@ +#ifndef _BOOTSTRAP_PRIVATE_H_ +#define _BOOTSTRAP_PRIVATE_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +typedef char * _internal_string_t; +typedef mach_port_t vproc_mig_t; + +#ifdef protocol_vproc_MSG_COUNT +/* HACK */ +#include "launchd_core_logic.h" +#endif + +#define SPAWN_HAS_PATH 0x0001 +#define SPAWN_HAS_WDIR 0x0002 +#define SPAWN_HAS_UMASK 0x0004 +#define SPAWN_WANTS_WAIT4DEBUGGER 0x0008 +#define SPAWN_WANTS_FORCE_PPC 0x0010 + +kern_return_t +_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + mach_port_array_t *ports, mach_msg_type_number_t *portCnt); + +kern_return_t bootstrap_getsocket(mach_port_t bp, name_t); + + +kern_return_t +bootstrap_look_up_array( + mach_port_t bp, + name_array_t service_names, + mach_msg_type_number_t service_namesCnt, + mach_port_array_t *sps, + mach_msg_type_number_t *service_portsCnt, + boolean_t *all_services_known); + +kern_return_t +bootstrap_info( + mach_port_t bp, + name_array_t *service_names, + mach_msg_type_number_t *service_namesCnt, + bootstrap_status_array_t *service_active, + mach_msg_type_number_t *service_activeCnt); + +#endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/85658ce2/attachment.html From source_changes at macosforge.org Mon Oct 23 13:10:12 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22911] trunk/launchd/src Message-ID: <20061023201012.4F2DB24ABBD@cvs.opensource.apple.com> Revision: 22911 http://trac.macosforge.org/projects/launchd/changeset/22911 Author: zarzycki@apple.com Date: 2006-10-23 13:10:11 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Let's put all the old bootstrap_*() APIs in their own file. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/bootstrap_public.h trunk/launchd/src/launch.h trunk/launchd/src/launch_priv.h trunk/launchd/src/libbootstrap.c trunk/launchd/src/libvproc.c trunk/launchd/src/vproc_priv.h Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/Makefile.am 2006-10-23 20:10:11 UTC (rev 22911) @@ -1,4 +1,4 @@ -AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 +AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.h launchd_internalUser.c \ @@ -11,13 +11,15 @@ noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -liblaunch_a_SOURCES = liblaunch.c libvproc.c +liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) -liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c +liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c $(srcdir)/libvproc.c:: protocol_vproc.h +$(srcdir)/protocol_vprocUser.c:: protocol_vproc.h + install-data-hook: mkdir -p $(DESTDIR)/usr/local/lib/system cp liblaunch.a $(DESTDIR)/usr/local/lib/system @@ -34,14 +36,14 @@ sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown -launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders +launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib -SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -fvisibility=hidden +SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) SystemStarter_LDFLAGS = -framework CoreFoundation SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c -launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter -fvisibility=hidden +launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter launchd_LDFLAGS = -lbsm launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c init.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/Makefile.in 2006-10-23 20:10:11 UTC (rev 22911) @@ -56,16 +56,21 @@ ARFLAGS = cru liblaunch_a_AR = $(AR) $(ARFLAGS) liblaunch_a_LIBADD = -am__liblaunch_a_SOURCES_DIST = liblaunch.c libvproc.c +am__liblaunch_a_SOURCES_DIST = liblaunch.c libvproc.c libbootstrap.c \ + protocol_vprocUser.c @LIBS_ONLY_TRUE@am_liblaunch_a_OBJECTS = liblaunch.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ libvproc.$(OBJEXT) +@LIBS_ONLY_TRUE@ libvproc.$(OBJEXT) libbootstrap.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ protocol_vprocUser.$(OBJEXT) liblaunch_a_OBJECTS = $(am_liblaunch_a_OBJECTS) liblaunch_profile_a_AR = $(AR) $(ARFLAGS) liblaunch_profile_a_LIBADD = -am__liblaunch_profile_a_SOURCES_DIST = liblaunch.c libvproc.c +am__liblaunch_profile_a_SOURCES_DIST = liblaunch.c libvproc.c \ + libbootstrap.c protocol_vprocUser.c @LIBS_ONLY_TRUE@am_liblaunch_profile_a_OBJECTS = \ @LIBS_ONLY_TRUE@ liblaunch_profile_a-liblaunch.$(OBJEXT) \ -@LIBS_ONLY_TRUE@ liblaunch_profile_a-libvproc.$(OBJEXT) +@LIBS_ONLY_TRUE@ liblaunch_profile_a-libvproc.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_profile_a-libbootstrap.$(OBJEXT) \ +@LIBS_ONLY_TRUE@ liblaunch_profile_a-protocol_vprocUser.$(OBJEXT) liblaunch_profile_a_OBJECTS = $(am_liblaunch_profile_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" \ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(sbindir)" \ @@ -221,23 +226,23 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 +AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.h launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -@LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c +@LIBS_ONLY_TRUE@liblaunch_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c @LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg $(AM_CFLAGS) -@LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c +@LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c @LIBS_ONLY_FALSE@sbin_SCRIPTS = service @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown -@LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders +@LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders @LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib -@LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -fvisibility=hidden +@LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) @LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation @LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c -@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter -fvisibility=hidden +@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c init.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security @@ -432,10 +437,14 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchproxy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbootstrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libbootstrap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-liblaunch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-libvproc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvproc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_vprocUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wait4path.Po@am__quote@ .c.o: @@ -480,6 +489,34 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-libvproc.obj `if test -f 'libvproc.c'; then $(CYGPATH_W) 'libvproc.c'; else $(CYGPATH_W) '$(srcdir)/libvproc.c'; fi` +liblaunch_profile_a-libbootstrap.o: libbootstrap.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-libbootstrap.o -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Tpo" -c -o liblaunch_profile_a-libbootstrap.o `test -f 'libbootstrap.c' || echo '$(srcdir)/'`libbootstrap.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Tpo" "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libbootstrap.c' object='liblaunch_profile_a-libbootstrap.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-libbootstrap.o `test -f 'libbootstrap.c' || echo '$(srcdir)/'`libbootstrap.c + +liblaunch_profile_a-libbootstrap.obj: libbootstrap.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-libbootstrap.obj -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Tpo" -c -o liblaunch_profile_a-libbootstrap.obj `if test -f 'libbootstrap.c'; then $(CYGPATH_W) 'libbootstrap.c'; else $(CYGPATH_W) '$(srcdir)/libbootstrap.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Tpo" "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-libbootstrap.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libbootstrap.c' object='liblaunch_profile_a-libbootstrap.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-libbootstrap.obj `if test -f 'libbootstrap.c'; then $(CYGPATH_W) 'libbootstrap.c'; else $(CYGPATH_W) '$(srcdir)/libbootstrap.c'; fi` + +liblaunch_profile_a-protocol_vprocUser.o: protocol_vprocUser.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-protocol_vprocUser.o -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Tpo" -c -o liblaunch_profile_a-protocol_vprocUser.o `test -f 'protocol_vprocUser.c' || echo '$(srcdir)/'`protocol_vprocUser.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Tpo" "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='protocol_vprocUser.c' object='liblaunch_profile_a-protocol_vprocUser.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-protocol_vprocUser.o `test -f 'protocol_vprocUser.c' || echo '$(srcdir)/'`protocol_vprocUser.c + +liblaunch_profile_a-protocol_vprocUser.obj: protocol_vprocUser.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -MT liblaunch_profile_a-protocol_vprocUser.obj -MD -MP -MF "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Tpo" -c -o liblaunch_profile_a-protocol_vprocUser.obj `if test -f 'protocol_vprocUser.c'; then $(CYGPATH_W) 'protocol_vprocUser.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocUser.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Tpo" "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Po"; else rm -f "$(DEPDIR)/liblaunch_profile_a-protocol_vprocUser.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='protocol_vprocUser.c' object='liblaunch_profile_a-protocol_vprocUser.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblaunch_profile_a_CFLAGS) $(CFLAGS) -c -o liblaunch_profile_a-protocol_vprocUser.obj `if test -f 'protocol_vprocUser.c'; then $(CYGPATH_W) 'protocol_vprocUser.c'; else $(CYGPATH_W) '$(srcdir)/protocol_vprocUser.c'; fi` + SystemStarter-StartupItems.o: StartupItems.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(SystemStarter_CFLAGS) $(CFLAGS) -MT SystemStarter-StartupItems.o -MD -MP -MF "$(DEPDIR)/SystemStarter-StartupItems.Tpo" -c -o SystemStarter-StartupItems.o `test -f 'StartupItems.c' || echo '$(srcdir)/'`StartupItems.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/SystemStarter-StartupItems.Tpo" "$(DEPDIR)/SystemStarter-StartupItems.Po"; else rm -f "$(DEPDIR)/SystemStarter-StartupItems.Tpo"; exit 1; fi @@ -1018,6 +1055,8 @@ @LIBS_ONLY_TRUE@$(srcdir)/libvproc.c:: protocol_vproc.h +@LIBS_ONLY_TRUE@$(srcdir)/protocol_vprocUser.c:: protocol_vproc.h + @LIBS_ONLY_TRUE@install-data-hook: @LIBS_ONLY_TRUE@ mkdir -p $(DESTDIR)/usr/local/lib/system @LIBS_ONLY_TRUE@ cp liblaunch.a $(DESTDIR)/usr/local/lib/system Modified: trunk/launchd/src/bootstrap_public.h =================================================================== --- trunk/launchd/src/bootstrap_public.h 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/bootstrap_public.h 2006-10-23 20:10:11 UTC (rev 22911) @@ -86,6 +86,8 @@ __BEGIN_DECLS +#pragma GCC visibility push(default) + #define BOOTSTRAP_MAX_NAME_LEN 128 #define BOOTSTRAP_MAX_CMD_LEN 512 @@ -342,6 +344,8 @@ */ const char *bootstrap_strerror(kern_return_t r) __attribute__((__nothrow__, __pure__, __warn_unused_result__)); +#pragma GCC visibility pop + __END_DECLS #endif Modified: trunk/launchd/src/launch.h =================================================================== --- trunk/launchd/src/launch.h 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/launch.h 2006-10-23 20:10:11 UTC (rev 22911) @@ -25,6 +25,8 @@ #include #include +#pragma GCC visibility push(default) + __BEGIN_DECLS #ifdef __GNUC__ @@ -214,4 +216,6 @@ __END_DECLS +#pragma GCC visibility pop + #endif Modified: trunk/launchd/src/launch_priv.h =================================================================== --- trunk/launchd/src/launch_priv.h 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/launch_priv.h 2006-10-23 20:10:11 UTC (rev 22911) @@ -22,6 +22,8 @@ #include +#pragma GCC visibility push(default) + __BEGIN_DECLS #define LAUNCH_KEY_GETUSERENVIRONMENT "GetUserEnvironment" @@ -115,4 +117,7 @@ __END_DECLS +#pragma GCC visibility pop + + #endif Modified: trunk/launchd/src/libbootstrap.c =================================================================== --- trunk/launchd/src/libbootstrap.c 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/libbootstrap.c 2006-10-23 20:10:11 UTC (rev 22911) @@ -22,130 +22,17 @@ #include #include "bootstrap_public.h" -#include "bootstrap_private.h" +#include "vproc_priv.h" #include "launch.h" #include "launch_priv.h" -#define mig_external static -#include "bootstrap.h" -#include "bootstrapUser.c" +#include "protocol_vproc.h" #include #include #include kern_return_t -_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - mach_port_array_t *ports, mach_msg_type_number_t *portCnt) -{ - return vproc_mig_transfer_subset(bp, reqport, rcvright, service_names, service_namesCnt, ports, portCnt); -} - -pid_t -_spawn_via_launchd(const char *label, const char *const *argv, const struct spawn_via_launchd_attr *spawn_attrs, int struct_version) -{ - kern_return_t kr; - const char *const *tmpp; - size_t len, buf_len = strlen(label) + 1; - char *buf = strdup(label); - uint64_t flags = 0; - uint32_t argc = 0; - uint32_t envc = 0; - pid_t p = -1; - mode_t u_mask = CMASK; - mach_port_t obsvr_port = MACH_PORT_NULL; - - for (tmpp = argv; *tmpp; tmpp++) { - argc++; - len = strlen(*tmpp) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, *tmpp); - buf_len += len; - } - - if (spawn_attrs) switch (struct_version) { - case 0: - if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_STOPPED) { - flags |= SPAWN_WANTS_WAIT4DEBUGGER; - } - if (spawn_attrs->spawn_flags & SPAWN_VIA_LAUNCHD_FORCE_PPC) { - flags |= SPAWN_WANTS_FORCE_PPC; - } - - if (spawn_attrs->spawn_env) { - for (tmpp = spawn_attrs->spawn_env; *tmpp; tmpp++) { - envc++; - len = strlen(*tmpp) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, *tmpp); - buf_len += len; - } - } - - if (spawn_attrs->spawn_path) { - flags |= SPAWN_HAS_PATH; - len = strlen(spawn_attrs->spawn_path) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, spawn_attrs->spawn_path); - buf_len += len; - } - - if (spawn_attrs->spawn_chdir) { - flags |= SPAWN_HAS_WDIR; - len = strlen(spawn_attrs->spawn_chdir) + 1; - buf = reallocf(buf, buf_len + len); - strcpy(buf + buf_len, spawn_attrs->spawn_chdir); - buf_len += len; - } - - if (spawn_attrs->spawn_umask) { - flags |= SPAWN_HAS_UMASK; - u_mask = *spawn_attrs->spawn_umask; - } - - break; - default: - break; - } - - kr = vproc_mig_spawn(bootstrap_port, buf, buf_len, argc, envc, flags, u_mask, &p, &obsvr_port); - - free(buf); - - if (kr == BOOTSTRAP_SUCCESS) { - if (spawn_attrs && spawn_attrs->spawn_observer_port) { - *spawn_attrs->spawn_observer_port = obsvr_port; - } else { - mach_port_deallocate(mach_task_self(), obsvr_port); - } - return p; - } - - switch (kr) { - case BOOTSTRAP_NOT_PRIVILEGED: - errno = EPERM; break; - case BOOTSTRAP_NO_MEMORY: - errno = ENOMEM; break; - default: - errno = EINVAL; break; - } - return -1; -} - -kern_return_t -mpm_wait(mach_port_t ajob, int *wstatus) -{ - return vproc_mig_wait(ajob, wstatus); -} - -kern_return_t -mpm_uncork_fork(mach_port_t ajob) -{ - return vproc_mig_uncork_fork(ajob); -} - -kern_return_t bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port) { return vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port); @@ -174,12 +61,6 @@ } kern_return_t -bootstrap_getsocket(mach_port_t bp, name_t sockpath) -{ - return vproc_mig_getsocket(bp, sockpath); -} - -kern_return_t bootstrap_parent(mach_port_t bp, mach_port_t *parent_port) { return vproc_mig_parent(bp, parent_port); @@ -267,7 +148,6 @@ service_active, service_activeCnt); } - const char * bootstrap_strerror(kern_return_t r) { Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/libvproc.c 2006-10-23 20:10:11 UTC (rev 22911) @@ -26,9 +26,7 @@ #include "launch.h" #include "launch_priv.h" -#define mig_external static #include "protocol_vproc.h" -#include "protocol_vprocUser.c" #include #include @@ -146,146 +144,7 @@ } kern_return_t -bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port) -{ - return vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port); -} - -kern_return_t -bootstrap_subset(mach_port_t bp, mach_port_t requestor_port, mach_port_t *subset_port) -{ - return vproc_mig_subset(bp, requestor_port, subset_port); -} - -kern_return_t -bootstrap_unprivileged(mach_port_t bp, mach_port_t *unpriv_port) -{ - kern_return_t kr; - - *unpriv_port = MACH_PORT_NULL; - - kr = mach_port_mod_refs(mach_task_self(), bp, MACH_PORT_RIGHT_SEND, 1); - - if (kr == KERN_SUCCESS) { - *unpriv_port = bp; - } - - return kr; -} - -kern_return_t bootstrap_getsocket(mach_port_t bp, name_t sockpath) { return vproc_mig_getsocket(bp, sockpath); } - -kern_return_t -bootstrap_parent(mach_port_t bp, mach_port_t *parent_port) -{ - return vproc_mig_parent(bp, parent_port); -} - -kern_return_t -bootstrap_register(mach_port_t bp, name_t service_name, mach_port_t sp) -{ - return vproc_mig_register(bp, service_name, sp); -} - -kern_return_t -bootstrap_create_service(mach_port_t bp, name_t service_name, mach_port_t *sp) -{ - return vproc_mig_create_service(bp, service_name, sp); -} - -kern_return_t -bootstrap_check_in(mach_port_t bp, name_t service_name, mach_port_t *sp) -{ - return vproc_mig_check_in(bp, service_name, sp); -} - -kern_return_t -bootstrap_look_up(mach_port_t bp, name_t service_name, mach_port_t *sp) -{ - return vproc_mig_look_up(bp, service_name, sp); -} - -kern_return_t -bootstrap_look_up_array(mach_port_t bp, - name_array_t names, mach_msg_type_number_t name_cnt, - mach_port_array_t *ports, mach_msg_type_number_t *port_cnt, - boolean_t *all) -{ - unsigned int i; - kern_return_t r; - - if (name_cnt > BOOTSTRAP_MAX_LOOKUP_COUNT) - return BOOTSTRAP_BAD_COUNT; - - *port_cnt = name_cnt; - - r = vm_allocate(mach_task_self(), (vm_address_t *)&ports, name_cnt * sizeof(mach_port_t), true); - - if (r != KERN_SUCCESS) - return r; - - *all = true; - - for (i = 0; i < name_cnt; i++) { - if (bootstrap_look_up(bp, names[i], &((*ports)[i])) == BOOTSTRAP_SUCCESS) - continue; - *all = false; - ports[i] = MACH_PORT_NULL; - } - - return BOOTSTRAP_SUCCESS; -} - -kern_return_t -bootstrap_status(mach_port_t bp, name_t service_name, bootstrap_status_t *service_active) -{ - mach_port_t p; - - if (bootstrap_check_in(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { - mach_port_mod_refs(mach_task_self(), p, MACH_PORT_RIGHT_RECEIVE, -1); - *service_active = BOOTSTRAP_STATUS_ON_DEMAND; - return BOOTSTRAP_SUCCESS; - } else if (bootstrap_look_up(bp, service_name, &p) == BOOTSTRAP_SUCCESS) { - mach_port_deallocate(mach_task_self(), p); - *service_active = BOOTSTRAP_STATUS_ACTIVE; - return BOOTSTRAP_SUCCESS; - } - - return BOOTSTRAP_UNKNOWN_SERVICE; -} - -kern_return_t -bootstrap_info(mach_port_t bp, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - bootstrap_status_array_t *service_active, mach_msg_type_number_t *service_activeCnt) -{ - return vproc_mig_info(bp, service_names, service_namesCnt, - service_active, service_activeCnt); -} - - -const char * -bootstrap_strerror(kern_return_t r) -{ - switch (r) { - case BOOTSTRAP_SUCCESS: - return "Success"; - case BOOTSTRAP_NOT_PRIVILEGED: - return "Permission denied"; - case BOOTSTRAP_NAME_IN_USE: - case BOOTSTRAP_SERVICE_ACTIVE: - return "Service name already exists"; - case BOOTSTRAP_UNKNOWN_SERVICE: - return "Unknown service name"; - case BOOTSTRAP_BAD_COUNT: - return "Too many lookups were requested in one request"; - case BOOTSTRAP_NO_MEMORY: - return "Out of memory"; - default: - return mach_error_string(r); - } -} Modified: trunk/launchd/src/vproc_priv.h =================================================================== --- trunk/launchd/src/vproc_priv.h 2006-10-23 17:46:23 UTC (rev 22910) +++ trunk/launchd/src/vproc_priv.h 2006-10-23 20:10:11 UTC (rev 22911) @@ -20,6 +20,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ + typedef char * _internal_string_t; typedef mach_port_t vproc_mig_t; @@ -28,6 +29,8 @@ #include "launchd_core_logic.h" #endif +#pragma GCC visibility push(default) + #define SPAWN_HAS_PATH 0x0001 #define SPAWN_HAS_WDIR 0x0002 #define SPAWN_HAS_UMASK 0x0004 @@ -59,4 +62,6 @@ bootstrap_status_array_t *service_active, mach_msg_type_number_t *service_activeCnt); +#pragma GCC visibility pop + #endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/7ae5da37/attachment.html From source_changes at macosforge.org Mon Oct 23 13:19:59 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22912] trunk/launchd/src Message-ID: <20061023201959.16AEF24ABEF@cvs.opensource.apple.com> Revision: 22912 http://trac.macosforge.org/projects/launchd/changeset/22912 Author: zarzycki@apple.com Date: 2006-10-23 13:19:58 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Internal API rename. Modified Paths: -------------- trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/vproc_priv.h Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2006-10-23 20:10:11 UTC (rev 22911) +++ trunk/launchd/src/liblaunch.c 2006-10-23 20:19:58 UTC (rev 22912) @@ -1200,7 +1200,7 @@ if ((ldp = fexecv_as_user(login, u, g, ldargv)) == -1) return -1; - while (bootstrap_getsocket(bootstrap_port, sp) != BOOTSTRAP_SUCCESS) + while (vprocmgr_getsocket(bootstrap_port, sp) != BOOTSTRAP_SUCCESS) usleep(20000); setenv(LAUNCHD_SOCKET_ENV, sp, 1); Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-23 20:10:11 UTC (rev 22911) +++ trunk/launchd/src/libvproc.c 2006-10-23 20:19:58 UTC (rev 22912) @@ -144,7 +144,7 @@ } kern_return_t -bootstrap_getsocket(mach_port_t bp, name_t sockpath) +vprocmgr_getsocket(mach_port_t bp, name_t sockpath) { return vproc_mig_getsocket(bp, sockpath); } Modified: trunk/launchd/src/vproc_priv.h =================================================================== --- trunk/launchd/src/vproc_priv.h 2006-10-23 20:10:11 UTC (rev 22911) +++ trunk/launchd/src/vproc_priv.h 2006-10-23 20:19:58 UTC (rev 22912) @@ -42,7 +42,7 @@ name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt); -kern_return_t bootstrap_getsocket(mach_port_t bp, name_t); +kern_return_t vprocmgr_getsocket(mach_port_t bp, name_t); kern_return_t -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/eb2336db/attachment.html From source_changes at macosforge.org Mon Oct 23 14:04:26 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22913] trunk/launchd/src Message-ID: <20061023210426.C558624ACE6@cvs.opensource.apple.com> Revision: 22913 http://trac.macosforge.org/projects/launchd/changeset/22913 Author: zarzycki@apple.com Date: 2006-10-23 14:04:26 -0700 (Mon, 23 Oct 2006) Log Message: ----------- More header housekeeping. Modified Paths: -------------- trunk/launchd/src/launch_priv.h trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/launchd_unix_ipc.c trunk/launchd/src/launchd_unix_ipc.h trunk/launchd/src/libbootstrap.c trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/vproc_priv.h Modified: trunk/launchd/src/launch_priv.h =================================================================== --- trunk/launchd/src/launch_priv.h 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launch_priv.h 2006-10-23 21:04:26 UTC (rev 22913) @@ -20,6 +20,7 @@ #ifndef _LAUNCH_PRIV_H_ #define _LAUNCH_PRIV_H_ +#include #include #pragma GCC visibility push(default) Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launchd.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -20,6 +20,9 @@ static const char *const __rcs_file_version__ = "$Revision$"; +#include "config.h" +#include "launchd.h" + #include #include #include @@ -65,7 +68,6 @@ #include "vproc_priv.h" #include "launch.h" #include "launch_priv.h" -#include "launchd.h" #include "launchd_runtime.h" #include "launchd_core_logic.h" #include "launchd_unix_ipc.h" Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -20,6 +20,9 @@ static const char *const __rcs_file_version__ = "$Revision$"; +#include "config.h" +#include "launchd_core_logic.h" + #include #include #include @@ -74,7 +77,6 @@ #include "launch_priv.h" #include "launchd.h" #include "launchd_runtime.h" -#include "launchd_core_logic.h" #include "launchd_unix_ipc.h" #include "bootstrap_public.h" #include "vproc_priv.h" Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launchd_runtime.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -20,6 +20,9 @@ static const char *const __rcs_file_version__ = "$Revision$"; +#include "config.h" +#include "launchd_runtime.h" + #include #include #include @@ -47,8 +50,6 @@ #include #include -#include "launchd_runtime.h" - #include "launchd_internalServer.h" #include "launchd_internal.h" #include "notifyServer.h" Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launchd_runtime.h 2006-10-23 21:04:26 UTC (rev 22913) @@ -21,6 +21,9 @@ #define __LAUNCHD_RUNTIME_H__ #include +#include +#include +#include struct ldcred { uid_t euid; Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launchd_unix_ipc.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -20,6 +20,9 @@ static const char *const __rcs_file_version__ = "$Revision$"; +#include "config.h" +#include "launchd_unix_ipc.h" + #include #include #include @@ -50,7 +53,6 @@ #include "launchd.h" #include "launchd_runtime.h" #include "launchd_core_logic.h" -#include "launchd_unix_ipc.h" extern char **environ; Modified: trunk/launchd/src/launchd_unix_ipc.h =================================================================== --- trunk/launchd/src/launchd_unix_ipc.h 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/launchd_unix_ipc.h 2006-10-23 21:04:26 UTC (rev 22913) @@ -20,6 +20,12 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include + +#include "launchd_runtime.h" +#include "launchd_core_logic.h" +#include "launch_priv.h" + struct conncb { kq_callback kqconn_callback; SLIST_ENTRY(conncb) sle; Modified: trunk/launchd/src/libbootstrap.c =================================================================== --- trunk/launchd/src/libbootstrap.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/libbootstrap.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -18,20 +18,14 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include "config.h" +#include "bootstrap_public.h" + #include #include -#include "bootstrap_public.h" -#include "vproc_priv.h" -#include "launch.h" -#include "launch_priv.h" - #include "protocol_vproc.h" -#include -#include -#include - kern_return_t bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port) { Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/liblaunch.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -17,6 +17,11 @@ * * @APPLE_APACHE_LICENSE_HEADER_END@ */ + +#include "config.h" +#include "launch.h" +#include "launch_priv.h" + #include #include #include @@ -33,8 +38,6 @@ #include #include -#include "launch.h" -#include "launch_priv.h" #include "bootstrap_public.h" #include "vproc_priv.h" Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/libvproc.c 2006-10-23 21:04:26 UTC (rev 22913) @@ -18,11 +18,13 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include "config.h" +#include "vproc.h" +#include "vproc_priv.h" + #include #include -#include "bootstrap_public.h" -#include "vproc_priv.h" #include "launch.h" #include "launch_priv.h" Modified: trunk/launchd/src/vproc_priv.h =================================================================== --- trunk/launchd/src/vproc_priv.h 2006-10-23 20:19:58 UTC (rev 22912) +++ trunk/launchd/src/vproc_priv.h 2006-10-23 21:04:26 UTC (rev 22913) @@ -1,5 +1,5 @@ -#ifndef _BOOTSTRAP_PRIVATE_H_ -#define _BOOTSTRAP_PRIVATE_H_ +#ifndef _VPROC_PRIVATE_H_ +#define _VPROC_PRIVATE_H_ /* * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. * @@ -20,6 +20,8 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include +#include "bootstrap_public.h" typedef char * _internal_string_t; typedef mach_port_t vproc_mig_t; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/9f5cb7f1/attachment.html From source_changes at macosforge.org Mon Oct 23 14:32:53 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22914] trunk/launchd/src Message-ID: <20061023213253.CB06524ADC5@cvs.opensource.apple.com> Revision: 22914 http://trac.macosforge.org/projects/launchd/changeset/22914 Author: zarzycki@apple.com Date: 2006-10-23 14:32:53 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Even more header file re-organization. Now all headers for libraries share the same prefix as the library they vend APIs for. Also, I'm converging on the following scheme: libexample_public.h Safe for third-party consumption. libexample_private.h In flux. They are often written with one client in mind. libexample_internal.h Meant only for consumption by launchd itself. Modified Paths: -------------- trunk/launchd/src/IPC.c trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchctl.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/libbootstrap.c trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/protocol_job.defs trunk/launchd/src/protocol_job_reply.defs Added Paths: ----------- trunk/launchd/src/libbootstrap_public.h trunk/launchd/src/liblaunch_private.h trunk/launchd/src/liblaunch_public.h trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_public.h Removed Paths: ------------- trunk/launchd/src/bootstrap_public.h trunk/launchd/src/launch.h trunk/launchd/src/launch_priv.h trunk/launchd/src/vproc.h trunk/launchd/src/vproc_priv.h Modified: trunk/launchd/src/IPC.c =================================================================== --- trunk/launchd/src/IPC.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/IPC.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -30,7 +30,8 @@ #include #include -#include "bootstrap_public.h" +#include "libbootstrap_public.h" + #include "IPC.h" #include "StartupItems.h" #include "SystemStarter.h" Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/Makefile.am 2006-10-23 21:32:53 UTC (rev 22914) @@ -82,12 +82,12 @@ mkdir -p $(DESTDIR)/usr/libexec cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec mkdir -p $(DESTDIR)/usr/include/servers - cp $(srcdir)/launch.h $(DESTDIR)/usr/include - cp $(srcdir)/vproc.h $(DESTDIR)/usr/include - cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h - cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h + cp $(srcdir)/liblaunch_public.h $(DESTDIR)/usr/include/launch.h + cp $(srcdir)/libvproc_public.h $(DESTDIR)/usr/include/vproc.h + cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h + cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h mkdir -p $(DESTDIR)/usr/local/include - cp $(srcdir)/launch_priv.h $(DESTDIR)/usr/local/include + cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d mkdir -p $(DESTDIR)/Library/LaunchDaemons Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/Makefile.in 2006-10-23 21:32:53 UTC (rev 22914) @@ -1087,12 +1087,12 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/libexec @LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/include/servers -@LIBS_ONLY_FALSE@ cp $(srcdir)/launch.h $(DESTDIR)/usr/include -@LIBS_ONLY_FALSE@ cp $(srcdir)/vproc.h $(DESTDIR)/usr/include -@LIBS_ONLY_FALSE@ cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h -@LIBS_ONLY_FALSE@ cp $(srcdir)/bootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/liblaunch_public.h $(DESTDIR)/usr/include/launch.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libvproc_public.h $(DESTDIR)/usr/include/vproc.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/local/include -@LIBS_ONLY_FALSE@ cp $(srcdir)/launch_priv.h $(DESTDIR)/usr/local/include +@LIBS_ONLY_FALSE@ cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchDaemons Deleted: trunk/launchd/src/bootstrap_public.h =================================================================== --- trunk/launchd/src/bootstrap_public.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/bootstrap_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,351 +0,0 @@ -#ifndef _BOOTSTRAP_H_ -#define _BOOTSTRAP_H_ -/* - * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -/* - * bootstrap -- fundamental service initiator and port server - * Mike DeMoney, NeXT, Inc. - * Copyright, 1990. All rights reserved. - */ - -/* - * Interface: Bootstrap server - * - * The bootstrap server is the first user-mode task initiated by the Mach - * kernel at system boot time. The bootstrap server provides two services, - * it initiates other system tasks, and manages a table of name-port bindings - * for fundamental system services (e.g. lookupd, Window Manager, etc...). - * - * Name-port bindings can be established with the bootstrap server by either - * of two mechanisms: - * - * 1. The binding can be indicated, in advance of the service that backs it - * being available, via a "service create" request. In this case, bootstrap - * will immediately create a port and bind the indicated name with that port. - * At a later time, a service may "checkin" for the name-port - * binding and will be returned receive rights for the bound port. Lookup's - * on bindings created by this mechanism will return send rights to the port, - * even if no service has "checked-in". In this case, requests sent to the - * bound port will be queued until a server has checked-in and can satisfy the - * request. - * - * 2. Bindings can be established dynamically via a "register" request. In - * this case, the register request provides bootstrap with a name and send - * rights for a port. Bootstrap will provide send rights for the bound port - * to any requestor via the lookup request. - * - * Bootstrap provides its service port to descendant tasks via the Mach - * "bootstrap" special task port. All direct descendants of bootstrap receive - * a "privileged" bootstrap service port. System services that initiate - * untrusted tasks should replace the Mach bootstrap task special port with - * a subset bootstrap port to prevent them from infecting the namespace. - * - * The bootstrap server creates a "backup" port for each service that it - * creates. This is used to detect when a checked out service is no longer - * being served. The bootstrap server regains all rights to the port and - * it is marked available for check-out again. This allows crashed servers to - * resume service to previous clients. Lookup's on this named port will - * continue to be serviced by bootstrap while holding receive rights for the - * bound port. A client may detect that the service is inactive via the - * bootstrap status request. If an inactive service re-registers rather - * than "checking-in" the original bound port is destroyed. - * - * The status of a named service may be obtained via the "status" request. - * A service is "active" if a name-port binding exists and receive rights - * to the bound port are held by a task other than bootstrap. - * - * The bootstrap server may also (re)start server processes associated with - * with a set of services. The definition of the server process is done - * through the "create server" request. The server will be launched in the - * same bootstrap context in which it was registered. - */ -#include -#include -#include -#include -#include -#include - -__BEGIN_DECLS - -#pragma GCC visibility push(default) - -#define BOOTSTRAP_MAX_NAME_LEN 128 -#define BOOTSTRAP_MAX_CMD_LEN 512 - -typedef char name_t[BOOTSTRAP_MAX_NAME_LEN]; -typedef char cmd_t[BOOTSTRAP_MAX_CMD_LEN]; -typedef name_t *name_array_t; -typedef int bootstrap_status_t; -typedef bootstrap_status_t *bootstrap_status_array_t; - -typedef boolean_t *bool_array_t; - -#define BOOTSTRAP_MAX_LOOKUP_COUNT 20 - -#define BOOTSTRAP_SUCCESS 0 -#define BOOTSTRAP_NOT_PRIVILEGED 1100 -#define BOOTSTRAP_NAME_IN_USE 1101 -#define BOOTSTRAP_UNKNOWN_SERVICE 1102 -#define BOOTSTRAP_SERVICE_ACTIVE 1103 -#define BOOTSTRAP_BAD_COUNT 1104 -#define BOOTSTRAP_NO_MEMORY 1105 - -#define BOOTSTRAP_STATUS_INACTIVE 0 -#define BOOTSTRAP_STATUS_ACTIVE 1 -#define BOOTSTRAP_STATUS_ON_DEMAND 2 - -/* - * After main() starts, it is safe to assume that this variable is always set. - */ -extern mach_port_t bootstrap_port; - -/* - * bootstrap_create_server() - * - * Declares a server that mach_init will re-spawn within the specified - * bootstrap context. The server is considered already "active" - * (i.e. will not be re-spawned) until the returned server_port is - * deallocated. - * - * In the meantime, services can be declared against the server, - * by using the server_port as the privileged bootstrap target of - * subsequent bootstrap_create_service() calls. - * - * When mach_init re-spawns the server, its task bootstrap port - * is set to the privileged sever_port. Through this special - * bootstrap port, it can access all of parent bootstrap's context - * (and all services are created in the parent's namespace). But - * all additional service declarations (and declaration removals) - * will be associated with this particular server. - * - * Only a holder of the server_port privilege bootstrap port can - * check in or register over those services. - * - * When all services associated with a server are deleted, and the server - * exits, it will automatically be deleted itself. - * - * If the server is declared "on_demand," then a non-running server - * will be re-launched on first use of one of the service ports - * registered against it. Otherwise, it will be re-launched - * immediately upon exiting (whether any client is actively using - * any of the service ports or not). - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_NOT_PRIVILEGED, bootstrap or uid invalid. - */ -kern_return_t bootstrap_create_server( - mach_port_t bp, - cmd_t server_cmd, - uid_t server_uid, - boolean_t on_demand, - mach_port_t *server_port); - -/* - * bootstrap_subset() - * - * Returns a new port to use as a bootstrap port. This port behaves - * exactly like the previous bootstrap_port, except that ports dynamically - * registered via bootstrap_register() are available only to users of this - * specific subset_port. Lookups on the subset_port will return ports - * registered with this port specifically, and ports registered with - * ancestors of this subset_port. Duplications of services already - * registered with an ancestor port may be registered with the subset port - * are allowed. Services already advertised may then be effectively removed - * by registering PORT_NULL for the service. - * When it is detected that the requestor_port is destroyed the subset - * port and all services advertized by it are destroyed as well. - * - * Errors: Returns appropriate kernel errors on rpc failure. - */ -kern_return_t bootstrap_subset( - mach_port_t bp, - mach_port_t requestor_port, - mach_port_t *subset_port); - -/* - * bootstrap_unprivileged() - * - * Given a bootstrap port, return its unprivileged equivalent. If - * the port is already unprivileged, another reference to the same - * port is returned. - * - * This is most often used by servers, which are launched with their - * bootstrap port set to the privileged port for the server, to get - * an unprivileged version of the same port for use by its unprivileged - * children (or any offspring that it does not want to count as part - * of the "server" for mach_init registration and re-launch purposes). - * - * Native launchd jobs are always started with an unprivileged port. - */ -kern_return_t bootstrap_unprivileged( - mach_port_t bp, - mach_port_t *unpriv_port) - AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; - -/* - * bootstrap_parent() - * - * Given a bootstrap subset port, return the parent bootstrap port. - * If the specified bootstrap port is already the root subset, - * the same port will be returned. Much like "." and ".." are the same - * in the file system name space for the root directory ("/"). - * - * Errors: - * Returns BOOTSTRAP_NOT_PRIVILEGED if the caller is not running - * with an effective user id of root (as determined by the security - * token in the message trailer). - */ -kern_return_t bootstrap_parent( - mach_port_t bp, - mach_port_t *parent_port); - -/* - * bootstrap_register() - * - * Registers a send right for service_port with the service identified by - * service_name. Attempts to register a service where an active binding - * already exists are rejected. - * - * If the service was previously declared with bootstrap_create_service(), - * but is not currently active, this call can be used to undeclare the - * service. The bootstrap port used must have sufficient privilege to - * do so. (Registering MACH_PORT_NULL is especially useful for shutting - * down declared services). - * - * This API is deprecated. Old scenarios and recommendations: - * - * 1) If the code was registering a well known name, please switch to launchd. - * - * 2) If the code was registering a dynamically generated string and passing - * the string to other applications, please rewrite the code to send a Mach - * send-right directly. - * - * 3) If the launchd job maintained an optional Mach service, please reserve - * the name with launchd and control the presense of the service through - * ownership of the Mach receive right like so. - * - * MachServices - * - * com.apple.windowserver - * - * com.apple.windowserver.active - * - * HideUntilCheckIn - * - * - * - * - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to - * bootstrap port without privilege. - * Returns BOOTSTRAP_NAME_IN_USE, if service has already been - * register or checked-in. - */ -kern_return_t bootstrap_register( - mach_port_t bp, - name_t service_name, - mach_port_t sp) - AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; - -/* - * bootstrap_create_service() - * - * Creates a service named "service_name" and returns send rights to that - * port in "service_port." The port may later be checked in as if this - * port were configured in the bootstrap configuration file. - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_SERVICE_ACTIVE, if service already exists. - */ -kern_return_t bootstrap_create_service( - mach_port_t bp, - name_t service_name, - mach_port_t *sp); - -/* - * bootstrap_check_in() - * - * Returns the receive right for the service named by service_name. The - * service must have previously been declared in this bootstrap context via - * a call to bootstrap_create_service(). Attempts to check_in a service - * which is already active are not allowed. - * - * If the service was declared as being associated with a server, the - * check_in must come from the server's privileged port (server_port). - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. - * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to - * bootstrap port without privilege. - * Returns BOOTSTRAP_SERVICE_ACTIVE, if service has already been - * registered or checked-in. - */ -kern_return_t bootstrap_check_in( - mach_port_t bp, - name_t service_name, - mach_port_t *sp); - -/* - * bootstrap_look_up() - * - * Returns a send right for the service port declared/registered under the - * name service_name. The service is not guaranteed to be active. Use the - * bootstrap_status call to determine the status of the service. - * - * Errors: Returns appropriate kernel errors on rpc failure. - * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. - */ -kern_return_t bootstrap_look_up( - mach_port_t bp, - name_t service_name, - mach_port_t *sp); - -/* - * bootstrap_status() - * - * In practice, this call was used to preflight whether the following two - * APIs would succeed. - * - * bootstrap_look_up() - * bootstrap_check_in() - * - * Please don't bother. Just call the above two APIs directly and check - * for failure. - */ -kern_return_t bootstrap_status( - mach_port_t bp, - name_t service_name, - bootstrap_status_t *service_active) - AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; - -/* bootstrap_strerror() - * - * Translate a return value from the bootstrap_*() APIs to a string. - */ -const char *bootstrap_strerror(kern_return_t r) __attribute__((__nothrow__, __pure__, __warn_unused_result__)); - -#pragma GCC visibility pop - -__END_DECLS - -#endif Deleted: trunk/launchd/src/launch.h =================================================================== --- trunk/launchd/src/launch.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launch.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ -#ifndef _LAUNCH_H_ -#define _LAUNCH_H_ - -#include -#include -#include -#include - -#pragma GCC visibility push(default) - -__BEGIN_DECLS - -#ifdef __GNUC__ -#define __ld_normal __attribute__((__nothrow__)) -#define __ld_setter __attribute__((__nothrow__, __nonnull__)) -#define __ld_getter __attribute__((__nothrow__, __nonnull__, __pure__, __warn_unused_result__)) -#define __ld_iterator(x, y) __attribute__((__nonnull__(x, y))) -#define __ld_allocator __attribute__((__nothrow__, __malloc__, __nonnull__, __warn_unused_result__)) -#else -#define __ld_normal -#define __ld_setter -#define __ld_getter -#define __ld_iterator(x, y) -#define __ld_allocator -#endif - - -#define LAUNCH_KEY_SUBMITJOB "SubmitJob" -#define LAUNCH_KEY_REMOVEJOB "RemoveJob" -#define LAUNCH_KEY_STARTJOB "StartJob" -#define LAUNCH_KEY_STOPJOB "StopJob" -#define LAUNCH_KEY_GETJOB "GetJob" -#define LAUNCH_KEY_GETJOBWITHHANDLES "GetJobWithHandles" -#define LAUNCH_KEY_GETJOBS "GetJobs" -#define LAUNCH_KEY_CHECKIN "CheckIn" - -#define LAUNCH_JOBKEY_LABEL "Label" -#define LAUNCH_JOBKEY_DISABLED "Disabled" -#define LAUNCH_JOBKEY_USERNAME "UserName" -#define LAUNCH_JOBKEY_GROUPNAME "GroupName" -#define LAUNCH_JOBKEY_TIMEOUT "TimeOut" -#define LAUNCH_JOBKEY_INITGROUPS "InitGroups" -#define LAUNCH_JOBKEY_SOCKETS "Sockets" -#define LAUNCH_JOBKEY_MACHSERVICES "MachServices" -#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility" -#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing" -#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments" -#define LAUNCH_JOBKEY_PROGRAM "Program" -#define LAUNCH_JOBKEY_ONDEMAND "OnDemand" -#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive" -#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts" -#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts" -#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType" -#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad" -#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory" -#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory" -#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables" -#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables" -#define LAUNCH_JOBKEY_FORCEPOWERPC "ForcePowerPC" -#define LAUNCH_JOBKEY_UMASK "Umask" -#define LAUNCH_JOBKEY_NICE "Nice" -#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" -#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" -#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" -#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" -#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" -#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath" -#define LAUNCH_JOBKEY_DEBUG "Debug" -#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger" -#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories" -#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths" -#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval" -#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval" -#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs" -#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus" -#define LAUNCH_JOBKEY_PID "PID" -#define LAUNCH_JOBKEY_SUBJOBS "SubJobs" -#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" -#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" - -#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" - -#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" -#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn" - -#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" -#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" -#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState" - -#define LAUNCH_JOBKEY_CAL_MINUTE "Minute" -#define LAUNCH_JOBKEY_CAL_HOUR "Hour" -#define LAUNCH_JOBKEY_CAL_DAY "Day" -#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday" -#define LAUNCH_JOBKEY_CAL_MONTH "Month" - -#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core" -#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU" -#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data" -#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize" -#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock" -#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles" -#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses" -#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize" -#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack" - -#define LAUNCH_JOBSOCKETKEY_TYPE "SockType" -#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive" -#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour" -#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey" -#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName" -#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode" -#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName" -#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName" -#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily" -#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol" -#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup" - -typedef struct _launch_data *launch_data_t; - -typedef enum { - LAUNCH_DATA_DICTIONARY = 1, - LAUNCH_DATA_ARRAY, - LAUNCH_DATA_FD, - LAUNCH_DATA_INTEGER, - LAUNCH_DATA_REAL, - LAUNCH_DATA_BOOL, - LAUNCH_DATA_STRING, - LAUNCH_DATA_OPAQUE, - LAUNCH_DATA_ERRNO, - LAUNCH_DATA_MACHPORT, -} launch_data_type_t; - -launch_data_t launch_data_alloc(launch_data_type_t) __ld_allocator; -launch_data_t launch_data_copy(launch_data_t) __ld_allocator; -launch_data_type_t launch_data_get_type(const launch_data_t) __ld_getter; -void launch_data_free(launch_data_t) __ld_setter; - -/* Generic Dictionaries */ -/* the value should not be changed while iterating */ -bool launch_data_dict_insert(launch_data_t, const launch_data_t, const char *) __ld_setter; -launch_data_t launch_data_dict_lookup(const launch_data_t, const char *) __ld_getter; -bool launch_data_dict_remove(launch_data_t, const char *) __ld_setter; -void launch_data_dict_iterate(const launch_data_t, void (*)(const launch_data_t, const char *, void *), void *) __ld_iterator(1, 2); -size_t launch_data_dict_get_count(const launch_data_t) __ld_getter; - -/* Generic Arrays */ -bool launch_data_array_set_index(launch_data_t, const launch_data_t, size_t) __ld_setter; -launch_data_t launch_data_array_get_index(const launch_data_t, size_t) __ld_getter; -size_t launch_data_array_get_count(const launch_data_t) __ld_getter; - -launch_data_t launch_data_new_fd(int) __ld_allocator; -launch_data_t launch_data_new_machport(mach_port_t) __ld_allocator; -launch_data_t launch_data_new_integer(long long) __ld_allocator; -launch_data_t launch_data_new_bool(bool) __ld_allocator; -launch_data_t launch_data_new_real(double) __ld_allocator; -launch_data_t launch_data_new_string(const char *) __ld_allocator; -launch_data_t launch_data_new_opaque(const void *, size_t) __ld_allocator; - -bool launch_data_set_fd(launch_data_t, int) __ld_setter; -bool launch_data_set_machport(launch_data_t, mach_port_t) __ld_setter; -bool launch_data_set_integer(launch_data_t, long long) __ld_setter; -bool launch_data_set_bool(launch_data_t, bool) __ld_setter; -bool launch_data_set_real(launch_data_t, double) __ld_setter; -bool launch_data_set_string(launch_data_t, const char *) __ld_setter; -bool launch_data_set_opaque(launch_data_t, const void *, size_t) __ld_setter; - -int launch_data_get_fd(const launch_data_t) __ld_getter; -mach_port_t launch_data_get_machport(const launch_data_t) __ld_getter; -long long launch_data_get_integer(const launch_data_t) __ld_getter; -bool launch_data_get_bool(const launch_data_t) __ld_getter; -double launch_data_get_real(const launch_data_t) __ld_getter; -const char * launch_data_get_string(const launch_data_t) __ld_getter; -void * launch_data_get_opaque(const launch_data_t) __ld_getter; -size_t launch_data_get_opaque_size(const launch_data_t) __ld_getter; -int launch_data_get_errno(const launch_data_t) __ld_getter; - - -/* launch_get_fd() - * - * Use this to get the FD if you're doing asynchronous I/O with select(), - * poll() or kevent(). - */ -int launch_get_fd(void) __ld_normal; - -/* launch_msg() - * - * Use this API to send and receive messages. - * Calling launch_msg() with no message to send is a valid way to get - * asynchronously received messages. - * - * If a message was to be sent, it returns NULL and errno on failure. - * - * If no messages were to be sent, it returns NULL and errno is set to zero if - * no more asynchronous messages are available. - */ -launch_data_t launch_msg(const launch_data_t) __ld_normal; - -__END_DECLS - -#pragma GCC visibility pop - -#endif Deleted: trunk/launchd/src/launch_priv.h =================================================================== --- trunk/launchd/src/launch_priv.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launch_priv.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ -#ifndef _LAUNCH_PRIV_H_ -#define _LAUNCH_PRIV_H_ - -#include -#include - -#pragma GCC visibility push(default) - -__BEGIN_DECLS - -#define LAUNCH_KEY_GETUSERENVIRONMENT "GetUserEnvironment" -#define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment" -#define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment" -#define LAUNCH_KEY_SETSTDOUT "SetStandardOut" -#define LAUNCH_KEY_SETSTDERR "SetStandardError" -#define LAUNCH_KEY_SHUTDOWN "Shutdown" -#define LAUNCH_KEY_SINGLEUSER "SingleUser" -#define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits" -#define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits" -#define LAUNCH_KEY_RELOADTTYS "ReloadTTYS" -#define LAUNCH_KEY_SETLOGMASK "SetLogMask" -#define LAUNCH_KEY_GETLOGMASK "GetLogMask" -#define LAUNCH_KEY_SETUMASK "SetUmask" -#define LAUNCH_KEY_GETUMASK "GetUmask" -#define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf" -#define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren" - -#define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET" -#define LAUNCHD_SOCK_PREFIX "/var/tmp/launchd" -#define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD" -#define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage" -#define LAUNCH_KEY_BATCHCONTROL "BatchControl" -#define LAUNCH_KEY_BATCHQUERY "BatchQuery" - -#define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" -#define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" -#define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort" -#define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" - -typedef struct _launch *launch_t; - -launch_t launchd_fdopen(int); -int launchd_getfd(launch_t); -void launchd_close(launch_t); - -launch_data_t launch_data_new_errno(int); -bool launch_data_set_errno(launch_data_t, int); - -int launchd_msg_send(launch_t, launch_data_t); -int launchd_msg_recv(launch_t, void (*)(launch_data_t, void *), void *); - -/* For LoginWindow. - * - * After this call, the task's bootstrap port is set to the per session launchd. - * - * This returns the PID on of the per session launchd, and -1 on failure. - * - * If launchd terminates, loginwindow should exit. - * If loginwindow terminates, launchd will exit. - */ -#define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 -pid_t create_and_switch_to_per_session_launchd(const char *login, int flags, ...); - -/* batch jobs will be implicity re-enabled when the last application who - * disabled them exits. - * - * This API is really a hack to work around the lack of real-time APIs - * at the VFS layer. - */ -void launchd_batch_enable(bool); -bool launchd_batch_query(void); - -/* For CoreProcesses - */ - -#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 -#define SPAWN_VIA_LAUNCHD_FORCE_PPC 0x0002 - -struct spawn_via_launchd_attr { - uint64_t spawn_flags; - const char * spawn_path; - const char * spawn_chdir; - const char *const * spawn_env; - const mode_t * spawn_umask; - mach_port_t * spawn_observer_port; -}; - -#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 0) -pid_t _spawn_via_launchd( - const char *label, - const char *const *argv, - const struct spawn_via_launchd_attr *spawn_attrs, - int struct_version); - -kern_return_t mpm_wait(mach_port_t ajob, int *wstatus); - -kern_return_t mpm_uncork_fork(mach_port_t ajob); - - -__END_DECLS - -#pragma GCC visibility pop - - -#endif Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchctl.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -59,10 +59,10 @@ #include #include -#include "bootstrap_public.h" -#include "vproc_priv.h" -#include "launch.h" -#include "launch_priv.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" #define LAUNCH_SECDIR "/tmp/launch-XXXXXX" Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -64,10 +64,11 @@ #include #include -#include "bootstrap_public.h" -#include "vproc_priv.h" -#include "launch.h" -#include "launch_priv.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" + #include "launchd_runtime.h" #include "launchd_core_logic.h" #include "launchd_unix_ipc.h" Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -22,9 +22,9 @@ #include #include -#include "launch.h" +#include "liblaunch_public.h" +#include "libbootstrap_public.h" #include "launchd_runtime.h" -#include "bootstrap_public.h" #define FIRSTBORN_LABEL "com.apple.launchd.firstborn" #define READCONF_LABEL "com.apple.launchd.readconfig" Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -73,13 +73,14 @@ #include #include -#include "launch.h" -#include "launch_priv.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" + #include "launchd.h" #include "launchd_runtime.h" #include "launchd_unix_ipc.h" -#include "bootstrap_public.h" -#include "vproc_priv.h" #include "protocol_vproc.h" #include "protocol_vprocServer.h" #include "job_reply.h" Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/launchd_core_logic.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -20,8 +20,8 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ -#include "bootstrap_public.h" -#include "launch.h" +#include "libbootstrap_public.h" +#include "liblaunch_public.h" typedef struct job_s *job_t; Modified: trunk/launchd/src/libbootstrap.c =================================================================== --- trunk/launchd/src/libbootstrap.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/libbootstrap.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -19,7 +19,7 @@ */ #include "config.h" -#include "bootstrap_public.h" +#include "libbootstrap_public.h" #include #include Copied: trunk/launchd/src/libbootstrap_public.h (from rev 22913, trunk/launchd/src/bootstrap_public.h) =================================================================== --- trunk/launchd/src/libbootstrap_public.h (rev 0) +++ trunk/launchd/src/libbootstrap_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,351 @@ +#ifndef _BOOTSTRAP_H_ +#define _BOOTSTRAP_H_ +/* + * Copyright (c) 1999-2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +/* + * bootstrap -- fundamental service initiator and port server + * Mike DeMoney, NeXT, Inc. + * Copyright, 1990. All rights reserved. + */ + +/* + * Interface: Bootstrap server + * + * The bootstrap server is the first user-mode task initiated by the Mach + * kernel at system boot time. The bootstrap server provides two services, + * it initiates other system tasks, and manages a table of name-port bindings + * for fundamental system services (e.g. lookupd, Window Manager, etc...). + * + * Name-port bindings can be established with the bootstrap server by either + * of two mechanisms: + * + * 1. The binding can be indicated, in advance of the service that backs it + * being available, via a "service create" request. In this case, bootstrap + * will immediately create a port and bind the indicated name with that port. + * At a later time, a service may "checkin" for the name-port + * binding and will be returned receive rights for the bound port. Lookup's + * on bindings created by this mechanism will return send rights to the port, + * even if no service has "checked-in". In this case, requests sent to the + * bound port will be queued until a server has checked-in and can satisfy the + * request. + * + * 2. Bindings can be established dynamically via a "register" request. In + * this case, the register request provides bootstrap with a name and send + * rights for a port. Bootstrap will provide send rights for the bound port + * to any requestor via the lookup request. + * + * Bootstrap provides its service port to descendant tasks via the Mach + * "bootstrap" special task port. All direct descendants of bootstrap receive + * a "privileged" bootstrap service port. System services that initiate + * untrusted tasks should replace the Mach bootstrap task special port with + * a subset bootstrap port to prevent them from infecting the namespace. + * + * The bootstrap server creates a "backup" port for each service that it + * creates. This is used to detect when a checked out service is no longer + * being served. The bootstrap server regains all rights to the port and + * it is marked available for check-out again. This allows crashed servers to + * resume service to previous clients. Lookup's on this named port will + * continue to be serviced by bootstrap while holding receive rights for the + * bound port. A client may detect that the service is inactive via the + * bootstrap status request. If an inactive service re-registers rather + * than "checking-in" the original bound port is destroyed. + * + * The status of a named service may be obtained via the "status" request. + * A service is "active" if a name-port binding exists and receive rights + * to the bound port are held by a task other than bootstrap. + * + * The bootstrap server may also (re)start server processes associated with + * with a set of services. The definition of the server process is done + * through the "create server" request. The server will be launched in the + * same bootstrap context in which it was registered. + */ +#include +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +#pragma GCC visibility push(default) + +#define BOOTSTRAP_MAX_NAME_LEN 128 +#define BOOTSTRAP_MAX_CMD_LEN 512 + +typedef char name_t[BOOTSTRAP_MAX_NAME_LEN]; +typedef char cmd_t[BOOTSTRAP_MAX_CMD_LEN]; +typedef name_t *name_array_t; +typedef int bootstrap_status_t; +typedef bootstrap_status_t *bootstrap_status_array_t; + +typedef boolean_t *bool_array_t; + +#define BOOTSTRAP_MAX_LOOKUP_COUNT 20 + +#define BOOTSTRAP_SUCCESS 0 +#define BOOTSTRAP_NOT_PRIVILEGED 1100 +#define BOOTSTRAP_NAME_IN_USE 1101 +#define BOOTSTRAP_UNKNOWN_SERVICE 1102 +#define BOOTSTRAP_SERVICE_ACTIVE 1103 +#define BOOTSTRAP_BAD_COUNT 1104 +#define BOOTSTRAP_NO_MEMORY 1105 + +#define BOOTSTRAP_STATUS_INACTIVE 0 +#define BOOTSTRAP_STATUS_ACTIVE 1 +#define BOOTSTRAP_STATUS_ON_DEMAND 2 + +/* + * After main() starts, it is safe to assume that this variable is always set. + */ +extern mach_port_t bootstrap_port; + +/* + * bootstrap_create_server() + * + * Declares a server that mach_init will re-spawn within the specified + * bootstrap context. The server is considered already "active" + * (i.e. will not be re-spawned) until the returned server_port is + * deallocated. + * + * In the meantime, services can be declared against the server, + * by using the server_port as the privileged bootstrap target of + * subsequent bootstrap_create_service() calls. + * + * When mach_init re-spawns the server, its task bootstrap port + * is set to the privileged sever_port. Through this special + * bootstrap port, it can access all of parent bootstrap's context + * (and all services are created in the parent's namespace). But + * all additional service declarations (and declaration removals) + * will be associated with this particular server. + * + * Only a holder of the server_port privilege bootstrap port can + * check in or register over those services. + * + * When all services associated with a server are deleted, and the server + * exits, it will automatically be deleted itself. + * + * If the server is declared "on_demand," then a non-running server + * will be re-launched on first use of one of the service ports + * registered against it. Otherwise, it will be re-launched + * immediately upon exiting (whether any client is actively using + * any of the service ports or not). + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_NOT_PRIVILEGED, bootstrap or uid invalid. + */ +kern_return_t bootstrap_create_server( + mach_port_t bp, + cmd_t server_cmd, + uid_t server_uid, + boolean_t on_demand, + mach_port_t *server_port); + +/* + * bootstrap_subset() + * + * Returns a new port to use as a bootstrap port. This port behaves + * exactly like the previous bootstrap_port, except that ports dynamically + * registered via bootstrap_register() are available only to users of this + * specific subset_port. Lookups on the subset_port will return ports + * registered with this port specifically, and ports registered with + * ancestors of this subset_port. Duplications of services already + * registered with an ancestor port may be registered with the subset port + * are allowed. Services already advertised may then be effectively removed + * by registering PORT_NULL for the service. + * When it is detected that the requestor_port is destroyed the subset + * port and all services advertized by it are destroyed as well. + * + * Errors: Returns appropriate kernel errors on rpc failure. + */ +kern_return_t bootstrap_subset( + mach_port_t bp, + mach_port_t requestor_port, + mach_port_t *subset_port); + +/* + * bootstrap_unprivileged() + * + * Given a bootstrap port, return its unprivileged equivalent. If + * the port is already unprivileged, another reference to the same + * port is returned. + * + * This is most often used by servers, which are launched with their + * bootstrap port set to the privileged port for the server, to get + * an unprivileged version of the same port for use by its unprivileged + * children (or any offspring that it does not want to count as part + * of the "server" for mach_init registration and re-launch purposes). + * + * Native launchd jobs are always started with an unprivileged port. + */ +kern_return_t bootstrap_unprivileged( + mach_port_t bp, + mach_port_t *unpriv_port) + AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; + +/* + * bootstrap_parent() + * + * Given a bootstrap subset port, return the parent bootstrap port. + * If the specified bootstrap port is already the root subset, + * the same port will be returned. Much like "." and ".." are the same + * in the file system name space for the root directory ("/"). + * + * Errors: + * Returns BOOTSTRAP_NOT_PRIVILEGED if the caller is not running + * with an effective user id of root (as determined by the security + * token in the message trailer). + */ +kern_return_t bootstrap_parent( + mach_port_t bp, + mach_port_t *parent_port); + +/* + * bootstrap_register() + * + * Registers a send right for service_port with the service identified by + * service_name. Attempts to register a service where an active binding + * already exists are rejected. + * + * If the service was previously declared with bootstrap_create_service(), + * but is not currently active, this call can be used to undeclare the + * service. The bootstrap port used must have sufficient privilege to + * do so. (Registering MACH_PORT_NULL is especially useful for shutting + * down declared services). + * + * This API is deprecated. Old scenarios and recommendations: + * + * 1) If the code was registering a well known name, please switch to launchd. + * + * 2) If the code was registering a dynamically generated string and passing + * the string to other applications, please rewrite the code to send a Mach + * send-right directly. + * + * 3) If the launchd job maintained an optional Mach service, please reserve + * the name with launchd and control the presense of the service through + * ownership of the Mach receive right like so. + * + * MachServices + * + * com.apple.windowserver + * + * com.apple.windowserver.active + * + * HideUntilCheckIn + * + * + * + * + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to + * bootstrap port without privilege. + * Returns BOOTSTRAP_NAME_IN_USE, if service has already been + * register or checked-in. + */ +kern_return_t bootstrap_register( + mach_port_t bp, + name_t service_name, + mach_port_t sp) + AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; + +/* + * bootstrap_create_service() + * + * Creates a service named "service_name" and returns send rights to that + * port in "service_port." The port may later be checked in as if this + * port were configured in the bootstrap configuration file. + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_SERVICE_ACTIVE, if service already exists. + */ +kern_return_t bootstrap_create_service( + mach_port_t bp, + name_t service_name, + mach_port_t *sp); + +/* + * bootstrap_check_in() + * + * Returns the receive right for the service named by service_name. The + * service must have previously been declared in this bootstrap context via + * a call to bootstrap_create_service(). Attempts to check_in a service + * which is already active are not allowed. + * + * If the service was declared as being associated with a server, the + * check_in must come from the server's privileged port (server_port). + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. + * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to + * bootstrap port without privilege. + * Returns BOOTSTRAP_SERVICE_ACTIVE, if service has already been + * registered or checked-in. + */ +kern_return_t bootstrap_check_in( + mach_port_t bp, + name_t service_name, + mach_port_t *sp); + +/* + * bootstrap_look_up() + * + * Returns a send right for the service port declared/registered under the + * name service_name. The service is not guaranteed to be active. Use the + * bootstrap_status call to determine the status of the service. + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. + */ +kern_return_t bootstrap_look_up( + mach_port_t bp, + name_t service_name, + mach_port_t *sp); + +/* + * bootstrap_status() + * + * In practice, this call was used to preflight whether the following two + * APIs would succeed. + * + * bootstrap_look_up() + * bootstrap_check_in() + * + * Please don't bother. Just call the above two APIs directly and check + * for failure. + */ +kern_return_t bootstrap_status( + mach_port_t bp, + name_t service_name, + bootstrap_status_t *service_active) + AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5; + +/* bootstrap_strerror() + * + * Translate a return value from the bootstrap_*() APIs to a string. + */ +const char *bootstrap_strerror(kern_return_t r) __attribute__((__nothrow__, __pure__, __warn_unused_result__)); + +#pragma GCC visibility pop + +__END_DECLS + +#endif Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/liblaunch.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -38,8 +38,8 @@ #include #include -#include "bootstrap_public.h" -#include "vproc_priv.h" +#include "libbootstrap_public.h" +#include "libvproc_internal.h" /* __OSBogusByteSwap__() must not really exist in the symbol namespace * in order for the following to generate an error at build time. Copied: trunk/launchd/src/liblaunch_private.h (from rev 22913, trunk/launchd/src/launch_priv.h) =================================================================== --- trunk/launchd/src/liblaunch_private.h (rev 0) +++ trunk/launchd/src/liblaunch_private.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ +#ifndef _LAUNCH_PRIV_H_ +#define _LAUNCH_PRIV_H_ + +#include +#include + +#pragma GCC visibility push(default) + +__BEGIN_DECLS + +#define LAUNCH_KEY_GETUSERENVIRONMENT "GetUserEnvironment" +#define LAUNCH_KEY_SETUSERENVIRONMENT "SetUserEnvironment" +#define LAUNCH_KEY_UNSETUSERENVIRONMENT "UnsetUserEnvironment" +#define LAUNCH_KEY_SETSTDOUT "SetStandardOut" +#define LAUNCH_KEY_SETSTDERR "SetStandardError" +#define LAUNCH_KEY_SHUTDOWN "Shutdown" +#define LAUNCH_KEY_SINGLEUSER "SingleUser" +#define LAUNCH_KEY_GETRESOURCELIMITS "GetResourceLimits" +#define LAUNCH_KEY_SETRESOURCELIMITS "SetResourceLimits" +#define LAUNCH_KEY_RELOADTTYS "ReloadTTYS" +#define LAUNCH_KEY_SETLOGMASK "SetLogMask" +#define LAUNCH_KEY_GETLOGMASK "GetLogMask" +#define LAUNCH_KEY_SETUMASK "SetUmask" +#define LAUNCH_KEY_GETUMASK "GetUmask" +#define LAUNCH_KEY_GETRUSAGESELF "GetResourceUsageSelf" +#define LAUNCH_KEY_GETRUSAGECHILDREN "GetResourceUsageChildren" + +#define LAUNCHD_SOCKET_ENV "LAUNCHD_SOCKET" +#define LAUNCHD_SOCK_PREFIX "/var/tmp/launchd" +#define LAUNCHD_TRUSTED_FD_ENV "__LAUNCHD_FD" +#define LAUNCHD_ASYNC_MSG_KEY "_AsyncMessage" +#define LAUNCH_KEY_BATCHCONTROL "BatchControl" +#define LAUNCH_KEY_BATCHQUERY "BatchQuery" + +#define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer" +#define LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER "ExceptionServer" +#define LAUNCH_JOBKEY_MACH_TASKSPECIALPORT "TaskSpecialPort" +#define LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT "HostSpecialPort" + +typedef struct _launch *launch_t; + +launch_t launchd_fdopen(int); +int launchd_getfd(launch_t); +void launchd_close(launch_t); + +launch_data_t launch_data_new_errno(int); +bool launch_data_set_errno(launch_data_t, int); + +int launchd_msg_send(launch_t, launch_data_t); +int launchd_msg_recv(launch_t, void (*)(launch_data_t, void *), void *); + +/* For LoginWindow. + * + * After this call, the task's bootstrap port is set to the per session launchd. + * + * This returns the PID on of the per session launchd, and -1 on failure. + * + * If launchd terminates, loginwindow should exit. + * If loginwindow terminates, launchd will exit. + */ +#define LOAD_ONLY_SAFEMODE_LAUNCHAGENTS 1 +pid_t create_and_switch_to_per_session_launchd(const char *login, int flags, ...); + +/* batch jobs will be implicity re-enabled when the last application who + * disabled them exits. + * + * This API is really a hack to work around the lack of real-time APIs + * at the VFS layer. + */ +void launchd_batch_enable(bool); +bool launchd_batch_query(void); + +/* For CoreProcesses + */ + +#define SPAWN_VIA_LAUNCHD_STOPPED 0x0001 +#define SPAWN_VIA_LAUNCHD_FORCE_PPC 0x0002 + +struct spawn_via_launchd_attr { + uint64_t spawn_flags; + const char * spawn_path; + const char * spawn_chdir; + const char *const * spawn_env; + const mode_t * spawn_umask; + mach_port_t * spawn_observer_port; +}; + +#define spawn_via_launchd(a, b, c) _spawn_via_launchd(a, b, c, 0) +pid_t _spawn_via_launchd( + const char *label, + const char *const *argv, + const struct spawn_via_launchd_attr *spawn_attrs, + int struct_version); + +kern_return_t mpm_wait(mach_port_t ajob, int *wstatus); + +kern_return_t mpm_uncork_fork(mach_port_t ajob); + + +__END_DECLS + +#pragma GCC visibility pop + + +#endif Copied: trunk/launchd/src/liblaunch_public.h (from rev 22913, trunk/launchd/src/launch.h) =================================================================== --- trunk/launchd/src/liblaunch_public.h (rev 0) +++ trunk/launchd/src/liblaunch_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ +#ifndef _LAUNCH_H_ +#define _LAUNCH_H_ + +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +__BEGIN_DECLS + +#ifdef __GNUC__ +#define __ld_normal __attribute__((__nothrow__)) +#define __ld_setter __attribute__((__nothrow__, __nonnull__)) +#define __ld_getter __attribute__((__nothrow__, __nonnull__, __pure__, __warn_unused_result__)) +#define __ld_iterator(x, y) __attribute__((__nonnull__(x, y))) +#define __ld_allocator __attribute__((__nothrow__, __malloc__, __nonnull__, __warn_unused_result__)) +#else +#define __ld_normal +#define __ld_setter +#define __ld_getter +#define __ld_iterator(x, y) +#define __ld_allocator +#endif + + +#define LAUNCH_KEY_SUBMITJOB "SubmitJob" +#define LAUNCH_KEY_REMOVEJOB "RemoveJob" +#define LAUNCH_KEY_STARTJOB "StartJob" +#define LAUNCH_KEY_STOPJOB "StopJob" +#define LAUNCH_KEY_GETJOB "GetJob" +#define LAUNCH_KEY_GETJOBWITHHANDLES "GetJobWithHandles" +#define LAUNCH_KEY_GETJOBS "GetJobs" +#define LAUNCH_KEY_CHECKIN "CheckIn" + +#define LAUNCH_JOBKEY_LABEL "Label" +#define LAUNCH_JOBKEY_DISABLED "Disabled" +#define LAUNCH_JOBKEY_USERNAME "UserName" +#define LAUNCH_JOBKEY_GROUPNAME "GroupName" +#define LAUNCH_JOBKEY_TIMEOUT "TimeOut" +#define LAUNCH_JOBKEY_INITGROUPS "InitGroups" +#define LAUNCH_JOBKEY_SOCKETS "Sockets" +#define LAUNCH_JOBKEY_MACHSERVICES "MachServices" +#define LAUNCH_JOBKEY_INETDCOMPATIBILITY "inetdCompatibility" +#define LAUNCH_JOBKEY_ENABLEGLOBBING "EnableGlobbing" +#define LAUNCH_JOBKEY_PROGRAMARGUMENTS "ProgramArguments" +#define LAUNCH_JOBKEY_PROGRAM "Program" +#define LAUNCH_JOBKEY_ONDEMAND "OnDemand" +#define LAUNCH_JOBKEY_KEEPALIVE "KeepAlive" +#define LAUNCH_JOBKEY_LIMITLOADTOHOSTS "LimitLoadToHosts" +#define LAUNCH_JOBKEY_LIMITLOADFROMHOSTS "LimitLoadFromHosts" +#define LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE "LimitLoadToSessionType" +#define LAUNCH_JOBKEY_RUNATLOAD "RunAtLoad" +#define LAUNCH_JOBKEY_ROOTDIRECTORY "RootDirectory" +#define LAUNCH_JOBKEY_WORKINGDIRECTORY "WorkingDirectory" +#define LAUNCH_JOBKEY_ENVIRONMENTVARIABLES "EnvironmentVariables" +#define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables" +#define LAUNCH_JOBKEY_FORCEPOWERPC "ForcePowerPC" +#define LAUNCH_JOBKEY_UMASK "Umask" +#define LAUNCH_JOBKEY_NICE "Nice" +#define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" +#define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" +#define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" +#define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" +#define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" +#define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath" +#define LAUNCH_JOBKEY_DEBUG "Debug" +#define LAUNCH_JOBKEY_WAITFORDEBUGGER "WaitForDebugger" +#define LAUNCH_JOBKEY_QUEUEDIRECTORIES "QueueDirectories" +#define LAUNCH_JOBKEY_WATCHPATHS "WatchPaths" +#define LAUNCH_JOBKEY_STARTINTERVAL "StartInterval" +#define LAUNCH_JOBKEY_STARTCALENDARINTERVAL "StartCalendarInterval" +#define LAUNCH_JOBKEY_BONJOURFDS "BonjourFDs" +#define LAUNCH_JOBKEY_LASTEXITSTATUS "LastExitStatus" +#define LAUNCH_JOBKEY_PID "PID" +#define LAUNCH_JOBKEY_SUBJOBS "SubJobs" +#define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" +#define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" + +#define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" + +#define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" +#define LAUNCH_JOBKEY_MACH_HIDEUNTILCHECKIN "HideUntilCheckIn" + +#define LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT "SuccessfulExit" +#define LAUNCH_JOBKEY_KEEPALIVE_NETWORKSTATE "NetworkState" +#define LAUNCH_JOBKEY_KEEPALIVE_PATHSTATE "PathState" + +#define LAUNCH_JOBKEY_CAL_MINUTE "Minute" +#define LAUNCH_JOBKEY_CAL_HOUR "Hour" +#define LAUNCH_JOBKEY_CAL_DAY "Day" +#define LAUNCH_JOBKEY_CAL_WEEKDAY "Weekday" +#define LAUNCH_JOBKEY_CAL_MONTH "Month" + +#define LAUNCH_JOBKEY_RESOURCELIMIT_CORE "Core" +#define LAUNCH_JOBKEY_RESOURCELIMIT_CPU "CPU" +#define LAUNCH_JOBKEY_RESOURCELIMIT_DATA "Data" +#define LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE "FileSize" +#define LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK "MemoryLock" +#define LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE "NumberOfFiles" +#define LAUNCH_JOBKEY_RESOURCELIMIT_NPROC "NumberOfProcesses" +#define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize" +#define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack" + +#define LAUNCH_JOBSOCKETKEY_TYPE "SockType" +#define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive" +#define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour" +#define LAUNCH_JOBSOCKETKEY_SECUREWITHKEY "SecureSocketWithKey" +#define LAUNCH_JOBSOCKETKEY_PATHNAME "SockPathName" +#define LAUNCH_JOBSOCKETKEY_PATHMODE "SockPathMode" +#define LAUNCH_JOBSOCKETKEY_NODENAME "SockNodeName" +#define LAUNCH_JOBSOCKETKEY_SERVICENAME "SockServiceName" +#define LAUNCH_JOBSOCKETKEY_FAMILY "SockFamily" +#define LAUNCH_JOBSOCKETKEY_PROTOCOL "SockProtocol" +#define LAUNCH_JOBSOCKETKEY_MULTICASTGROUP "MulticastGroup" + +typedef struct _launch_data *launch_data_t; + +typedef enum { + LAUNCH_DATA_DICTIONARY = 1, + LAUNCH_DATA_ARRAY, + LAUNCH_DATA_FD, + LAUNCH_DATA_INTEGER, + LAUNCH_DATA_REAL, + LAUNCH_DATA_BOOL, + LAUNCH_DATA_STRING, + LAUNCH_DATA_OPAQUE, + LAUNCH_DATA_ERRNO, + LAUNCH_DATA_MACHPORT, +} launch_data_type_t; + +launch_data_t launch_data_alloc(launch_data_type_t) __ld_allocator; +launch_data_t launch_data_copy(launch_data_t) __ld_allocator; +launch_data_type_t launch_data_get_type(const launch_data_t) __ld_getter; +void launch_data_free(launch_data_t) __ld_setter; + +/* Generic Dictionaries */ +/* the value should not be changed while iterating */ +bool launch_data_dict_insert(launch_data_t, const launch_data_t, const char *) __ld_setter; +launch_data_t launch_data_dict_lookup(const launch_data_t, const char *) __ld_getter; +bool launch_data_dict_remove(launch_data_t, const char *) __ld_setter; +void launch_data_dict_iterate(const launch_data_t, void (*)(const launch_data_t, const char *, void *), void *) __ld_iterator(1, 2); +size_t launch_data_dict_get_count(const launch_data_t) __ld_getter; + +/* Generic Arrays */ +bool launch_data_array_set_index(launch_data_t, const launch_data_t, size_t) __ld_setter; +launch_data_t launch_data_array_get_index(const launch_data_t, size_t) __ld_getter; +size_t launch_data_array_get_count(const launch_data_t) __ld_getter; + +launch_data_t launch_data_new_fd(int) __ld_allocator; +launch_data_t launch_data_new_machport(mach_port_t) __ld_allocator; +launch_data_t launch_data_new_integer(long long) __ld_allocator; +launch_data_t launch_data_new_bool(bool) __ld_allocator; +launch_data_t launch_data_new_real(double) __ld_allocator; +launch_data_t launch_data_new_string(const char *) __ld_allocator; +launch_data_t launch_data_new_opaque(const void *, size_t) __ld_allocator; + +bool launch_data_set_fd(launch_data_t, int) __ld_setter; +bool launch_data_set_machport(launch_data_t, mach_port_t) __ld_setter; +bool launch_data_set_integer(launch_data_t, long long) __ld_setter; +bool launch_data_set_bool(launch_data_t, bool) __ld_setter; +bool launch_data_set_real(launch_data_t, double) __ld_setter; +bool launch_data_set_string(launch_data_t, const char *) __ld_setter; +bool launch_data_set_opaque(launch_data_t, const void *, size_t) __ld_setter; + +int launch_data_get_fd(const launch_data_t) __ld_getter; +mach_port_t launch_data_get_machport(const launch_data_t) __ld_getter; +long long launch_data_get_integer(const launch_data_t) __ld_getter; +bool launch_data_get_bool(const launch_data_t) __ld_getter; +double launch_data_get_real(const launch_data_t) __ld_getter; +const char * launch_data_get_string(const launch_data_t) __ld_getter; +void * launch_data_get_opaque(const launch_data_t) __ld_getter; +size_t launch_data_get_opaque_size(const launch_data_t) __ld_getter; +int launch_data_get_errno(const launch_data_t) __ld_getter; + + +/* launch_get_fd() + * + * Use this to get the FD if you're doing asynchronous I/O with select(), + * poll() or kevent(). + */ +int launch_get_fd(void) __ld_normal; + +/* launch_msg() + * + * Use this API to send and receive messages. + * Calling launch_msg() with no message to send is a valid way to get + * asynchronously received messages. + * + * If a message was to be sent, it returns NULL and errno on failure. + * + * If no messages were to be sent, it returns NULL and errno is set to zero if + * no more asynchronous messages are available. + */ +launch_data_t launch_msg(const launch_data_t) __ld_normal; + +__END_DECLS + +#pragma GCC visibility pop + +#endif Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/libvproc.c 2006-10-23 21:32:53 UTC (rev 22914) @@ -19,19 +19,19 @@ */ #include "config.h" -#include "vproc.h" -#include "vproc_priv.h" +#include "libvproc_public.h" +#include "libvproc_internal.h" #include #include +#include +#include -#include "launch.h" -#include "launch_priv.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" #include "protocol_vproc.h" -#include -#include #include kern_return_t Copied: trunk/launchd/src/libvproc_internal.h (from rev 22913, trunk/launchd/src/vproc_priv.h) =================================================================== --- trunk/launchd/src/libvproc_internal.h (rev 0) +++ trunk/launchd/src/libvproc_internal.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,69 @@ +#ifndef _VPROC_PRIVATE_H_ +#define _VPROC_PRIVATE_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#include +#include "libbootstrap_public.h" + +typedef char * _internal_string_t; +typedef mach_port_t vproc_mig_t; + +#ifdef protocol_vproc_MSG_COUNT +/* HACK */ +#include "launchd_core_logic.h" +#endif + +#pragma GCC visibility push(default) + +#define SPAWN_HAS_PATH 0x0001 +#define SPAWN_HAS_WDIR 0x0002 +#define SPAWN_HAS_UMASK 0x0004 +#define SPAWN_WANTS_WAIT4DEBUGGER 0x0008 +#define SPAWN_WANTS_FORCE_PPC 0x0010 + +kern_return_t +_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, + name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, + mach_port_array_t *ports, mach_msg_type_number_t *portCnt); + +kern_return_t vprocmgr_getsocket(mach_port_t bp, name_t); + + +kern_return_t +bootstrap_look_up_array( + mach_port_t bp, + name_array_t service_names, + mach_msg_type_number_t service_namesCnt, + mach_port_array_t *sps, + mach_msg_type_number_t *service_portsCnt, + boolean_t *all_services_known); + +kern_return_t +bootstrap_info( + mach_port_t bp, + name_array_t *service_names, + mach_msg_type_number_t *service_namesCnt, + bootstrap_status_array_t *service_active, + mach_msg_type_number_t *service_activeCnt); + +#pragma GCC visibility pop + +#endif Copied: trunk/launchd/src/libvproc_public.h (from rev 22913, trunk/launchd/src/vproc.h) =================================================================== --- trunk/launchd/src/libvproc_public.h (rev 0) +++ trunk/launchd/src/libvproc_public.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -0,0 +1,84 @@ +#ifndef _VPROC_H_ +#define _VPROC_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#include + +__BEGIN_DECLS + +#if 0 + +typedef void * vproc_t; +typedef void * vprocmgr_t; +typedef void * vproc_err_t; + +/* By default, pass NULL for vprocmgr_t or vproc_t to get notions of self or "my manager" */ + +vproc_err_t vprocmgr_create_vproc(vprocmgr_t vpm, launch_data_t the_vproc, vproc_t *vp); + +/* If creating multiple jobs, it is wise to create them atomically with respect to each other */ +vproc_err_t vprocmgr_create_vprocs(vprocmgr_t vpm, launch_data_t *the_vprocs, vproc_t *vp, size_t cnt); + +vproc_err_t vprocmgr_delete_vproc(vprocmgr_t vpm, vproc_t vp); + +/* The virtual process managers are arranged in a hierarchy */ +vproc_err_t vprocmgr_get_parent(vprocmgr_t vpm, vprocmgr_t *vpm_parent); + +vproc_err_t vprocmgr_get_all_vprocs(vprocmgr_t vpm, vproc_t **vps, size_t *vp_cnt); + +vproc_err_t vprocmgr_lookup_vproc(vprocmgr_t vpm, const char *label, vproc_t *vp); + +vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm_out); + +vproc_err_t vprocmgr_lookup_mach_service(vprocmgr_t vpm, const char *service, mach_port_t *service_port); + +/* For controlling speculative and optimistical spawning of vprocs */ +vproc_err_t vprocmgr_set_force_on_demand(vproc_mgr_t vpm, bool force); +vproc_err_t vprocmgr_get_force_on_demand(vproc_mgr_t vpm, bool *force); + +/* Only release those vprocmgr_t objects that returned from APIs. */ +vproc_err_t vprocmgr_release(vprocmgr_t vpm); + + +/* Get meta-data and IPC handles from launchd */ +vproc_err_t vproc_checkin(launch_data_t *out); + +/* Get only meta-data from launchd */ +vproc_err_t vproc_get_info(vproc_t vp, launch_data_t *out); + +/* Lookup a Mach service amongst our peers and progenitors */ +vproc_err_t vproc_lookup_mach_service(vproc_t vp, const char *service, mach_port_t *service_port); + +/* Sending signals to a program that isn't running will return an error */ +vproc_err_t vproc_send_signal(vproc_t vp, int signum); + +/* Only release those vproc_t objects that returned from APIs. */ +vproc_err_t vproc_release(vproc_t vp); + + + +const char *vproc_strerror(vproc_err_t r); + +#endif + +__END_DECLS + +#endif Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/protocol_job.defs 2006-10-23 21:32:53 UTC (rev 22914) @@ -28,8 +28,8 @@ #include #include #include "launchd_mig_types.defs" -import "vproc.h"; -import "vproc_priv.h"; +import "libvproc_public.h"; +import "libvproc_internal.h"; userprefix vproc_mig_; serverprefix job_mig_; Modified: trunk/launchd/src/protocol_job_reply.defs =================================================================== --- trunk/launchd/src/protocol_job_reply.defs 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/protocol_job_reply.defs 2006-10-23 21:32:53 UTC (rev 22914) @@ -23,8 +23,8 @@ #include #include #include "launchd_mig_types.defs" -import "bootstrap_public.h"; -import "vproc_priv.h"; +import "libbootstrap_public.h"; +import "libvproc_internal.h"; skip; /* create_server */ Deleted: trunk/launchd/src/vproc.h =================================================================== --- trunk/launchd/src/vproc.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/vproc.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,84 +0,0 @@ -#ifndef _VPROC_H_ -#define _VPROC_H_ -/* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -#include - -__BEGIN_DECLS - -#if 0 - -typedef void * vproc_t; -typedef void * vprocmgr_t; -typedef void * vproc_err_t; - -/* By default, pass NULL for vprocmgr_t or vproc_t to get notions of self or "my manager" */ - -vproc_err_t vprocmgr_create_vproc(vprocmgr_t vpm, launch_data_t the_vproc, vproc_t *vp); - -/* If creating multiple jobs, it is wise to create them atomically with respect to each other */ -vproc_err_t vprocmgr_create_vprocs(vprocmgr_t vpm, launch_data_t *the_vprocs, vproc_t *vp, size_t cnt); - -vproc_err_t vprocmgr_delete_vproc(vprocmgr_t vpm, vproc_t vp); - -/* The virtual process managers are arranged in a hierarchy */ -vproc_err_t vprocmgr_get_parent(vprocmgr_t vpm, vprocmgr_t *vpm_parent); - -vproc_err_t vprocmgr_get_all_vprocs(vprocmgr_t vpm, vproc_t **vps, size_t *vp_cnt); - -vproc_err_t vprocmgr_lookup_vproc(vprocmgr_t vpm, const char *label, vproc_t *vp); - -vproc_err_t vprocmgr_lookup_vprocmgr_for_user(vprocmgr_t vpm, const char *user, vprocmgr_t *vpm_out); - -vproc_err_t vprocmgr_lookup_mach_service(vprocmgr_t vpm, const char *service, mach_port_t *service_port); - -/* For controlling speculative and optimistical spawning of vprocs */ -vproc_err_t vprocmgr_set_force_on_demand(vproc_mgr_t vpm, bool force); -vproc_err_t vprocmgr_get_force_on_demand(vproc_mgr_t vpm, bool *force); - -/* Only release those vprocmgr_t objects that returned from APIs. */ -vproc_err_t vprocmgr_release(vprocmgr_t vpm); - - -/* Get meta-data and IPC handles from launchd */ -vproc_err_t vproc_checkin(launch_data_t *out); - -/* Get only meta-data from launchd */ -vproc_err_t vproc_get_info(vproc_t vp, launch_data_t *out); - -/* Lookup a Mach service amongst our peers and progenitors */ -vproc_err_t vproc_lookup_mach_service(vproc_t vp, const char *service, mach_port_t *service_port); - -/* Sending signals to a program that isn't running will return an error */ -vproc_err_t vproc_send_signal(vproc_t vp, int signum); - -/* Only release those vproc_t objects that returned from APIs. */ -vproc_err_t vproc_release(vproc_t vp); - - - -const char *vproc_strerror(vproc_err_t r); - -#endif - -__END_DECLS - -#endif Deleted: trunk/launchd/src/vproc_priv.h =================================================================== --- trunk/launchd/src/vproc_priv.h 2006-10-23 21:04:26 UTC (rev 22913) +++ trunk/launchd/src/vproc_priv.h 2006-10-23 21:32:53 UTC (rev 22914) @@ -1,69 +0,0 @@ -#ifndef _VPROC_PRIVATE_H_ -#define _VPROC_PRIVATE_H_ -/* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -#include -#include "bootstrap_public.h" - -typedef char * _internal_string_t; -typedef mach_port_t vproc_mig_t; - -#ifdef protocol_vproc_MSG_COUNT -/* HACK */ -#include "launchd_core_logic.h" -#endif - -#pragma GCC visibility push(default) - -#define SPAWN_HAS_PATH 0x0001 -#define SPAWN_HAS_WDIR 0x0002 -#define SPAWN_HAS_UMASK 0x0004 -#define SPAWN_WANTS_WAIT4DEBUGGER 0x0008 -#define SPAWN_WANTS_FORCE_PPC 0x0010 - -kern_return_t -_launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, - name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, - mach_port_array_t *ports, mach_msg_type_number_t *portCnt); - -kern_return_t vprocmgr_getsocket(mach_port_t bp, name_t); - - -kern_return_t -bootstrap_look_up_array( - mach_port_t bp, - name_array_t service_names, - mach_msg_type_number_t service_namesCnt, - mach_port_array_t *sps, - mach_msg_type_number_t *service_portsCnt, - boolean_t *all_services_known); - -kern_return_t -bootstrap_info( - mach_port_t bp, - name_array_t *service_names, - mach_msg_type_number_t *service_namesCnt, - bootstrap_status_array_t *service_active, - mach_msg_type_number_t *service_activeCnt); - -#pragma GCC visibility pop - -#endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/953231fa/attachment.html From source_changes at macosforge.org Mon Oct 23 14:34:21 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22915] trunk/launchd/src/Makefile.am Message-ID: <20061023213421.552C024ADCD@cvs.opensource.apple.com> Revision: 22915 http://trac.macosforge.org/projects/launchd/changeset/22915 Author: zarzycki@apple.com Date: 2006-10-23 14:34:21 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Fix a old typo. Modified Paths: -------------- trunk/launchd/src/Makefile.am Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-23 21:32:53 UTC (rev 22914) +++ trunk/launchd/src/Makefile.am 2006-10-23 21:34:21 UTC (rev 22915) @@ -1,7 +1,7 @@ AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ - launchd_internal.h launchd_internalServer.h launchd_internalServer.h launchd_internalUser.c \ + launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h: $(srcdir)/protocol_job.defs -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/bbebd1ae/attachment.html From source_changes at macosforge.org Mon Oct 23 14:34:48 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22916] trunk/launchd/src/Makefile.in Message-ID: <20061023213448.40C9F24ADD5@cvs.opensource.apple.com> Revision: 22916 http://trac.macosforge.org/projects/launchd/changeset/22916 Author: zarzycki@apple.com Date: 2006-10-23 14:34:48 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Fix the old typo for real. Modified Paths: -------------- trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-23 21:34:21 UTC (rev 22915) +++ trunk/launchd/src/Makefile.in 2006-10-23 21:34:48 UTC (rev 22916) @@ -228,7 +228,7 @@ target_alias = @target_alias@ AM_CFLAGS = -no-cpp-precomp -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ - launchd_internal.h launchd_internalServer.h launchd_internalServer.h launchd_internalUser.c \ + launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061023/bc56b065/attachment.html From source_changes at macosforge.org Tue Oct 24 16:37:09 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22917] trunk/Makefile Message-ID: <20061024233709.07753253ACE@cvs.opensource.apple.com> Revision: 22917 http://trac.macosforge.org/projects/launchd/changeset/22917 Author: zarzycki@apple.com Date: 2006-10-24 16:37:09 -0700 (Tue, 24 Oct 2006) Log Message: ----------- dSYM files are the the new cool. Modified Paths: -------------- trunk/Makefile Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2006-10-23 21:34:48 UTC (rev 22916) +++ trunk/Makefile 2006-10-24 23:37:09 UTC (rev 22917) @@ -16,6 +16,9 @@ cp $(OBJROOT)/src/launchd $(SYMROOT) cp $(OBJROOT)/src/launchctl $(SYMROOT) cp $(OBJROOT)/src/launchproxy $(SYMROOT) + dsymutil $(SYMROOT)/launchd + dsymutil $(SYMROOT)/launchctl + dsymutil $(SYMROOT)/launchproxy endif launchd_libs:: install -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061024/c10d4242/attachment.html From source_changes at macosforge.org Wed Oct 25 09:36:58 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22918] trunk/launchd/src Message-ID: <20061025163658.CD50C258170@cvs.opensource.apple.com> Revision: 22918 http://trac.macosforge.org/projects/launchd/changeset/22918 Author: zarzycki@apple.com Date: 2006-10-25 09:36:57 -0700 (Wed, 25 Oct 2006) Log Message: ----------- Need a launchd force on demand API Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_mig_types.defs trunk/launchd/src/liblaunch.c trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_public.h trunk/launchd/src/protocol_job.defs Added Paths: ----------- trunk/launchd/src/libvproc_private.h Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/Makefile.am 2006-10-25 16:36:57 UTC (rev 22918) @@ -88,6 +88,7 @@ cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h mkdir -p $(DESTDIR)/usr/local/include cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h + cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d mkdir -p $(DESTDIR)/Library/LaunchDaemons Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/Makefile.in 2006-10-25 16:36:57 UTC (rev 22918) @@ -1093,6 +1093,7 @@ @LIBS_ONLY_FALSE@ cp $(srcdir)/libbootstrap_public.h $(DESTDIR)/usr/include/servers/bootstrap_defs.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/local/include @LIBS_ONLY_FALSE@ cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchDaemons Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-25 16:36:57 UTC (rev 22918) @@ -1,6 +1,4 @@ /* - * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. - * * @APPLE_APACHE_LICENSE_HEADER_START@ * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -237,7 +235,7 @@ anonymous:1; mode_t mask; unsigned int globargv:1, wait4debugger:1, transfer_bstrap:1, unload_at_exit:1, force_ppc:1, - stall_before_exec:1, only_once:1, currently_ignored:1; + stall_before_exec:1, only_once:1, currently_ignored:1, forced_peers_to_demand_mode:1; char label[0]; }; @@ -251,6 +249,8 @@ static void job_import_integer(job_t j, const char *key, long long value); static void job_import_dictionary(job_t j, const char *key, launch_data_t value); static void job_import_array(job_t j, const char *key, launch_data_t value); +static void job_dispatch_all(job_t j); +static bool job_set_global_on_demand(job_t j, bool val); static void job_watch(job_t j); static void job_ignore(job_t j); static void job_reap(job_t j); @@ -319,9 +319,10 @@ static int dir_has_files(job_t j, const char *path); static char **mach_cmd2argv(const char *string); -job_t root_job = NULL; -job_t gc_this_job = NULL; -size_t total_children = 0; +static size_t global_on_demand_cnt; +job_t root_job; +job_t gc_this_job; +size_t total_children; void simple_zombie_reaper(void *obj __attribute__((unused)), struct kevent *kev) @@ -655,6 +656,28 @@ } bool +job_set_global_on_demand(job_t j, bool val) +{ + if (j->forced_peers_to_demand_mode && val) { + return false; + } else if (!j->forced_peers_to_demand_mode && !val) { + return false; + } + + if ((j->forced_peers_to_demand_mode = val)) { + global_on_demand_cnt++; + } else { + global_on_demand_cnt--; + } + + if (global_on_demand_cnt == 0) { + job_dispatch_all(root_job); + } + + return true; +} + +bool job_setup_machport(job_t j) { mach_msg_size_t mxmsgsz; @@ -1547,6 +1570,18 @@ } void +job_dispatch_all(job_t j) +{ + job_t ji; + + SLIST_FOREACH(ji, &j->jobs, sle) { + job_dispatch_all(ji); + } + + job_dispatch(j, false); +} + +void job_dispatch(job_t j, bool kickstart) { /* @@ -1561,7 +1596,7 @@ return; } else if (job_useless(j)) { job_remove(j); - } else if (kickstart || job_keepalive(j)) { + } else if (global_on_demand_cnt == 0 && (kickstart || job_keepalive(j))) { job_start(j); } else { job_watch(j); @@ -2624,6 +2659,10 @@ { struct machservice *ms; + if (j->anonymous) { + return true; + } + if (j->req_port) { return true; } @@ -3535,6 +3574,40 @@ } kern_return_t +job_mig_get_integer(job_t j, get_set_int_key_t key, int64_t *val) +{ + kern_return_t kr = 0; + + switch (key) { + case LAST_EXIT_STATUS: + *val = j->last_exit_status; + break; + default: + kr = 1; + break; + } + + return kr; +} + +kern_return_t +job_mig_set_integer(job_t j, get_set_int_key_t key, int64_t val) +{ + kern_return_t kr = 0; + + switch (key) { + case GLOBAL_ON_DEMAND: + kr = job_set_global_on_demand(j, (bool)val) ? 0 : 1; + break; + default: + kr = 1; + break; + } + + return kr; +} + +kern_return_t job_mig_getsocket(job_t j, name_t spr) { if (!sockpath) { Modified: trunk/launchd/src/launchd_mig_types.defs =================================================================== --- trunk/launchd/src/launchd_mig_types.defs 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/launchd_mig_types.defs 2006-10-25 16:36:57 UTC (rev 22918) @@ -24,6 +24,7 @@ */ type pid_t = integer_t; +type get_set_int_key_t = integer_t; type cmd_t = c_string[512]; type cmd_array_t = ^array [] of cmd_t; type name_t = c_string[128]; Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/liblaunch.c 2006-10-25 16:36:57 UTC (rev 22918) @@ -19,8 +19,8 @@ */ #include "config.h" -#include "launch.h" -#include "launch_priv.h" +#include "liblaunch_public.h" +#include "liblaunch_private.h" #include #include @@ -1203,7 +1203,7 @@ if ((ldp = fexecv_as_user(login, u, g, ldargv)) == -1) return -1; - while (vprocmgr_getsocket(bootstrap_port, sp) != BOOTSTRAP_SUCCESS) + while (_vprocmgr_getsocket(bootstrap_port, sp) != BOOTSTRAP_SUCCESS) usleep(20000); setenv(LAUNCHD_SOCKET_ENV, sp, 1); Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/libvproc.c 2006-10-25 16:36:57 UTC (rev 22918) @@ -20,20 +20,20 @@ #include "config.h" #include "libvproc_public.h" +#include "libvproc_private.h" #include "libvproc_internal.h" #include #include #include #include +#include #include "liblaunch_public.h" #include "liblaunch_private.h" #include "protocol_vproc.h" -#include - kern_return_t _launchd_to_launchd(mach_port_t bp, mach_port_t *reqport, mach_port_t *rcvright, name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, @@ -146,7 +146,32 @@ } kern_return_t -vprocmgr_getsocket(mach_port_t bp, name_t sockpath) +_vprocmgr_getsocket(mach_port_t bp, name_t sockpath) { return vproc_mig_getsocket(bp, sockpath); } + +vproc_err_t +_vproc_get_last_exit_status(int *wstatus) +{ + int64_t val; + + if (vproc_mig_get_integer(bootstrap_port, LAST_EXIT_STATUS, &val) == 0) { + *wstatus = (int)val; + return NULL; + } + + return (vproc_err_t)_vproc_get_last_exit_status; +} + +vproc_err_t +_vproc_set_global_on_demand(bool state) +{ + int64_t val = state ? ~0 : 0; + + if (vproc_mig_set_integer(bootstrap_port, GLOBAL_ON_DEMAND, val) == 0) { + return NULL; + } + + return (vproc_err_t)_vproc_set_global_on_demand; +} Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/libvproc_internal.h 2006-10-25 16:36:57 UTC (rev 22918) @@ -1,5 +1,5 @@ -#ifndef _VPROC_PRIVATE_H_ -#define _VPROC_PRIVATE_H_ +#ifndef _VPROC_INTERNAL_H_ +#define _VPROC_INTERNAL_H_ /* * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. * @@ -25,6 +25,10 @@ typedef char * _internal_string_t; typedef mach_port_t vproc_mig_t; +typedef enum { + LAST_EXIT_STATUS = 1, + GLOBAL_ON_DEMAND, +} get_set_int_key_t; #ifdef protocol_vproc_MSG_COUNT /* HACK */ @@ -44,7 +48,7 @@ name_array_t *service_names, mach_msg_type_number_t *service_namesCnt, mach_port_array_t *ports, mach_msg_type_number_t *portCnt); -kern_return_t vprocmgr_getsocket(mach_port_t bp, name_t); +kern_return_t _vprocmgr_getsocket(mach_port_t bp, name_t); kern_return_t Added: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h (rev 0) +++ trunk/launchd/src/libvproc_private.h 2006-10-25 16:36:57 UTC (rev 22918) @@ -0,0 +1,37 @@ +#ifndef _VPROC_PRIVATE_H_ +#define _VPROC_PRIVATE_H_ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#include +#include + +__BEGIN_DECLS + +#pragma GCC visibility push(default) + +vproc_err_t _vproc_get_last_exit_status(int *wstatus); +vproc_err_t _vproc_set_global_on_demand(bool val); + +#pragma GCC visibility pop + +__END_DECLS + +#endif Modified: trunk/launchd/src/libvproc_public.h =================================================================== --- trunk/launchd/src/libvproc_public.h 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/libvproc_public.h 2006-10-25 16:36:57 UTC (rev 22918) @@ -24,11 +24,12 @@ __BEGIN_DECLS +typedef void * vproc_err_t; + #if 0 typedef void * vproc_t; typedef void * vprocmgr_t; -typedef void * vproc_err_t; /* By default, pass NULL for vprocmgr_t or vproc_t to get notions of self or "my manager" */ Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2006-10-24 23:37:09 UTC (rev 22917) +++ trunk/launchd/src/protocol_job.defs 2006-10-25 16:36:57 UTC (rev 22918) @@ -109,3 +109,13 @@ routine uncork_fork( __bs_port : job_t); + +routine get_integer( + __bs_port : job_t; + __key : get_set_int_key_t; + out __val : int64_t); + +routine set_integer( + __bs_port : job_t; + __key : get_set_int_key_t; + __val : int64_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061025/c1adf939/attachment.html From source_changes at macosforge.org Wed Oct 25 18:18:09 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22919] trunk/launchd/src Message-ID: <20061026011809.596C42594E2@cvs.opensource.apple.com> Revision: 22919 http://trac.macosforge.org/projects/launchd/changeset/22919 Author: zarzycki@apple.com Date: 2006-10-25 18:18:08 -0700 (Wed, 25 Oct 2006) Log Message: ----------- Make the internal logging code accessible to jobs as private API. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_mig_types.defs trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_private.h trunk/launchd/src/protocol_job.defs Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-25 16:36:57 UTC (rev 22918) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-26 01:18:08 UTC (rev 22919) @@ -3622,6 +3622,18 @@ } kern_return_t +job_mig_log(job_t j, int pri, int err, logmsg_t msg) +{ + if ((errno = err)) { + job_log_error(j, pri, "%s", msg); + } else { + job_log(j, pri, "%s", msg); + } + + return 0; +} + +kern_return_t job_mig_check_in(job_t j, name_t servicename, mach_port_t *serviceportp) { static pid_t last_warned_pid = 0; Modified: trunk/launchd/src/launchd_mig_types.defs =================================================================== --- trunk/launchd/src/launchd_mig_types.defs 2006-10-25 16:36:57 UTC (rev 22918) +++ trunk/launchd/src/launchd_mig_types.defs 2006-10-26 01:18:08 UTC (rev 22919) @@ -25,6 +25,7 @@ type pid_t = integer_t; type get_set_int_key_t = integer_t; +type logmsg_t = c_string[*:2048]; type cmd_t = c_string[512]; type cmd_array_t = ^array [] of cmd_t; type name_t = c_string[128]; Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-25 16:36:57 UTC (rev 22918) +++ trunk/launchd/src/libvproc.c 2006-10-26 01:18:08 UTC (rev 22919) @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "liblaunch_public.h" @@ -175,3 +176,34 @@ return (vproc_err_t)_vproc_set_global_on_demand; } + +static void +_vproc_logv(int pri, int err, const char *msg, va_list ap) +{ + char flat_msg[3000]; + + snprintf(flat_msg, sizeof(flat_msg) - 1, msg, ap); + flat_msg[sizeof(flat_msg) - 1] = '\0'; + + vproc_mig_log(bootstrap_port, pri, err, flat_msg); +} + +void +_vproc_log(int pri, const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + _vproc_logv(pri, 0, msg, ap); + va_end(ap); +} + +void +_vproc_log_error(int pri, const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + _vproc_logv(pri, errno, msg, ap); + va_end(ap); +} Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2006-10-25 16:36:57 UTC (rev 22918) +++ trunk/launchd/src/libvproc_internal.h 2006-10-26 01:18:08 UTC (rev 22919) @@ -24,6 +24,7 @@ #include "libbootstrap_public.h" typedef char * _internal_string_t; +typedef char * logmsg_t; typedef mach_port_t vproc_mig_t; typedef enum { LAST_EXIT_STATUS = 1, Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2006-10-25 16:36:57 UTC (rev 22918) +++ trunk/launchd/src/libvproc_private.h 2006-10-26 01:18:08 UTC (rev 22919) @@ -30,6 +30,9 @@ vproc_err_t _vproc_get_last_exit_status(int *wstatus); vproc_err_t _vproc_set_global_on_demand(bool val); +void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); +void _vproc_log_error(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); + #pragma GCC visibility pop __END_DECLS Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2006-10-25 16:36:57 UTC (rev 22918) +++ trunk/launchd/src/protocol_job.defs 2006-10-26 01:18:08 UTC (rev 22919) @@ -119,3 +119,9 @@ __bs_port : job_t; __key : get_set_int_key_t; __val : int64_t); + +simpleroutine log( + __bs_port : job_t; + __pri : integer_t; + __err : integer_t; + __msg : logmsg_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061025/db99f7ca/attachment.html From source_changes at macosforge.org Thu Oct 26 11:00:56 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22920] trunk/launchd/src Message-ID: <20061026180056.2FC7E25ACA9@cvs.opensource.apple.com> Revision: 22920 http://trac.macosforge.org/projects/launchd/changeset/22920 Author: zarzycki@apple.com Date: 2006-10-26 11:00:55 -0700 (Thu, 26 Oct 2006) Log Message: ----------- It was always dubious that job_log*() could be called on the child side of the fork() but before the exec*(). This provides a cleaner solution that is less likely to confuse launchd itself or any logging API it uses (syslog or asl_log). As a side effect, jobs _could_ now log indirectly via launchd, but I'm not sure we'll make that public API yet... Maybe someday when we have a somewhat more compelling story over syslog() or asl_log(), but that day isn't today, nor do I intend to put much effort to acheiving that goal in the foreseeable future. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-26 01:18:08 UTC (rev 22919) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-26 18:00:55 UTC (rev 22920) @@ -283,7 +283,7 @@ static void job_uncork_fork(job_t j); static struct machservice *job_lookup_service(job_t jbs, const char *name, bool check_parent); static void job_foreach_service(job_t jbs, void (*bs_iter)(struct machservice *, void *), void *context, bool only_anonymous); -static void job_logv(job_t j, int pri, const char *msg, va_list ap); +static void job_logv(job_t j, int pri, int err, const char *msg, va_list ap); static void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); static void job_log_error(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); static void job_log_bug(job_t j, const char *rcs_rev, const char *path, unsigned int line, const char *test); @@ -2115,15 +2115,28 @@ } void -job_logv(job_t j, int pri, const char *msg, va_list ap) +job_logv(job_t j, int pri, int err, const char *msg, va_list ap) { char newmsg[10000]; int oldmask = 0; size_t o; + /* + * Hack: If bootstrap_port is set, we must be on the child side of a + * fork(), but before the exec*(). Let's route the log message back to + * launchd proper. + */ + if (bootstrap_port) { + return _vproc_logv(pri, err, msg, ap); + } + o = job_prep_log_preface(j, newmsg); - sprintf(newmsg + o, ": %s", msg); + if (err) { + sprintf(newmsg + o, ": %s: %s", msg, strerror(err)); + } else { + sprintf(newmsg + o, ": %s", msg); + } if (j->debug) { oldmask = setlogmask(LOG_UPTO(LOG_DEBUG)); @@ -2139,13 +2152,10 @@ void job_log_error(job_t j, int pri, const char *msg, ...) { - char newmsg[10000]; va_list ap; - sprintf(newmsg, "%s: %s", msg, strerror(errno)); - va_start(ap, msg); - job_logv(j, pri, newmsg, ap); + job_logv(j, pri, errno, msg, ap); va_end(ap); } @@ -2155,7 +2165,7 @@ va_list ap; va_start(ap, msg); - job_logv(j, pri, msg, ap); + job_logv(j, pri, 0, msg, ap); va_end(ap); } Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-26 01:18:08 UTC (rev 22919) +++ trunk/launchd/src/libvproc.c 2006-10-26 18:00:55 UTC (rev 22920) @@ -177,7 +177,7 @@ return (vproc_err_t)_vproc_set_global_on_demand; } -static void +void _vproc_logv(int pri, int err, const char *msg, va_list ap) { char flat_msg[3000]; Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2006-10-26 01:18:08 UTC (rev 22919) +++ trunk/launchd/src/libvproc_internal.h 2006-10-26 18:00:55 UTC (rev 22920) @@ -21,6 +21,7 @@ */ #include +#include #include "libbootstrap_public.h" typedef char * _internal_string_t; @@ -51,7 +52,9 @@ kern_return_t _vprocmgr_getsocket(mach_port_t bp, name_t); +void _vproc_logv(int pri, int err, const char *msg, va_list ap); + kern_return_t bootstrap_look_up_array( mach_port_t bp, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061026/3e22e069/attachment.html From source_changes at macosforge.org Thu Oct 26 11:42:00 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22921] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061026184200.993FF25AE6A@cvs.opensource.apple.com> Revision: 22921 http://trac.macosforge.org/projects/launchd/changeset/22921 Author: zarzycki@apple.com Date: 2006-10-26 11:42:00 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Applications 'open'ed in 'ssh' session belong to 'root' Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-26 18:00:55 UTC (rev 22920) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-26 18:42:00 UTC (rev 22921) @@ -4054,6 +4054,8 @@ return BOOTSTRAP_NO_MEMORY; } + jr->mach_uid = ldc.uid; + if (!job_setup_machport(jr)) { job_remove(jr); return BOOTSTRAP_NO_MEMORY; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061026/be4cb716/attachment.html From source_changes at macosforge.org Thu Oct 26 11:56:26 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22922] trunk/launchd/src/libvproc.c Message-ID: <20061026185626.098C325AEB1@cvs.opensource.apple.com> Revision: 22922 http://trac.macosforge.org/projects/launchd/changeset/22922 Author: zarzycki@apple.com Date: 2006-10-26 11:56:25 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Workaround 4802454 for now by stubbing out the API Modified Paths: -------------- trunk/launchd/src/libvproc.c Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2006-10-26 18:42:00 UTC (rev 22921) +++ trunk/launchd/src/libvproc.c 2006-10-26 18:56:25 UTC (rev 22922) @@ -134,11 +134,22 @@ return -1; } +#if 0 kern_return_t -mpm_wait(mach_port_t ajob, int *wstatus) +mpm_wait(mach_port_t ajob __attribute__((unused)), int *wstatus) { + /* Stubbed out for now... + * CAS: WindowServer hangs in CGXProcessHIDEvent/.../CGXPseudoActivateWindow/.../_LSDoSetFrontProcess + */ return vproc_mig_wait(ajob, wstatus); } +#else +kern_return_t +mpm_wait(mach_port_t ajob __attribute__((unused)), int *wstatus __attribute__((unused))) +{ + return MIG_BAD_ID; +} +#endif kern_return_t mpm_uncork_fork(mach_port_t ajob) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061026/e5d6627c/attachment.html From source_changes at macosforge.org Thu Oct 26 11:57:29 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22923] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061026185729.3AF8C25AEB9@cvs.opensource.apple.com> Revision: 22923 http://trac.macosforge.org/projects/launchd/changeset/22923 Author: zarzycki@apple.com Date: 2006-10-26 11:57:29 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Let's not pay the getpwuid() hit unless we have to... Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-26 18:56:25 UTC (rev 22922) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-26 18:57:29 UTC (rev 22923) @@ -4054,7 +4054,9 @@ return BOOTSTRAP_NO_MEMORY; } - jr->mach_uid = ldc.uid; + if (getuid() == 0) { + jr->mach_uid = ldc.uid; + } if (!job_setup_machport(jr)) { job_remove(jr); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061026/692a44e0/attachment.html From source_changes at macosforge.org Thu Oct 26 14:50:06 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22924] tags/launchd-166/ Message-ID: <20061026215006.4CBDA25B2CD@cvs.opensource.apple.com> Revision: 22924 http://trac.macosforge.org/projects/launchd/changeset/22924 Author: zarzycki@apple.com Date: 2006-10-26 14:50:06 -0700 (Thu, 26 Oct 2006) Log Message: ----------- "Tagging launchd-166 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-166/ Copied: tags/launchd-166 (from rev 22923, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061026/725c89c8/attachment.html From source_changes at macosforge.org Fri Oct 27 10:52:51 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22925] trunk/launchd/src/launchd_core_logic.c Message-ID: <20061027175251.3D94625C069@cvs.opensource.apple.com> Revision: 22925 http://trac.macosforge.org/projects/launchd/changeset/22925 Author: zarzycki@apple.com Date: 2006-10-27 10:52:50 -0700 (Fri, 27 Oct 2006) Log Message: ----------- Since Mach service lookups are O(n) right now, let's keep the popular (MRU) services at the head of the list. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2006-10-26 21:50:06 UTC (rev 22924) +++ trunk/launchd/src/launchd_core_logic.c 2006-10-27 17:52:50 UTC (rev 22925) @@ -3040,6 +3040,10 @@ SLIST_FOREACH(ms, &ji->machservices, sle) { if (strcmp(name, ms->name) == 0) { + if (ji->parent) { + SLIST_REMOVE(&ji->parent->jobs, ji, job_s, sle); + SLIST_INSERT_HEAD(&ji->parent->jobs, ji, sle); + } return ms; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061027/46f798b4/attachment.html From source_changes at macosforge.org Mon Oct 30 08:16:10 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:34 2007 Subject: [launchd-changes] [22926] trunk/launchd/src/launchctl.c Message-ID: <20061030161610.C462926E151@cvs.opensource.apple.com> Revision: 22926 http://trac.macosforge.org/projects/launchd/changeset/22926 Author: zarzycki@apple.com Date: 2006-10-30 08:16:10 -0800 (Mon, 30 Oct 2006) Log Message: ----------- Just an experiment. The code is disabled for now... Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-27 17:52:50 UTC (rev 22925) +++ trunk/launchd/src/launchctl.c 2006-10-30 16:16:10 UTC (rev 22926) @@ -132,6 +132,7 @@ static void do_sysversion_sysctl(void); static void workaround4465949(void); static void do_application_firewall_magic(int sfd, launch_data_t thejob); +static void preheat_page_cache_hack(void); static int bootstrap_cmd(int argc, char *const argv[]); static int load_and_unload_cmd(int argc, char *const argv[]); @@ -1240,6 +1241,8 @@ const char *bcc_tool[] = { "BootCacheControl", "start", NULL }; assumes(fwexec(bcc_tool, true) != -1); + preheat_page_cache_hack(); + char *load_launchd_items[] = { "load", "-D", "all", "/etc/mach_init.d", NULL }; if (is_safeboot()) load_launchd_items[2] = "system"; @@ -2724,3 +2727,43 @@ assumes(setsockopt(sfd, SOL_SOCKET, SO_EXECPATH, prog, strlen(prog) + 1) != -1); } } + + +void +preheat_page_cache_hack(void) +{ + struct dirent *de; + DIR *thedir; + + /* Disable this hack for now */ + return; + + if ((thedir = opendir("/etc/preheat_at_boot")) == NULL) { + return; + } + + while ((de = readdir(thedir))) { + struct stat sb; + void *junkbuf; + int fd; + + if (de->d_name[0] == '.') { + continue; + } + + if ((fd = open(de->d_name, O_RDONLY)) == -1) { + continue; + } + + if (fstat(fd, &sb) != -1) { + if ((junkbuf = malloc(sb.st_size)) != NULL) { + assumes(read(fd, junkbuf, sb.st_size) == sb.st_size); + free(junkbuf); + } + } + + close(fd); + } + + closedir(thedir); +} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061030/bf7380a7/attachment.html From source_changes at macosforge.org Mon Oct 30 16:11:51 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:35 2007 Subject: [launchd-changes] [22927] trunk/launchd/src/launchctl.c Message-ID: <20061031001151.7BEB026FCF8@cvs.opensource.apple.com> Revision: 22927 http://trac.macosforge.org/projects/launchd/changeset/22927 Author: zarzycki@apple.com Date: 2006-10-30 16:11:51 -0800 (Mon, 30 Oct 2006) Log Message: ----------- do not load the Firewall tool during startup Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2006-10-30 16:16:10 UTC (rev 22926) +++ trunk/launchd/src/launchctl.c 2006-10-31 00:11:51 UTC (rev 22927) @@ -1233,11 +1233,6 @@ assumes(fwexec(audit_tool, true) != -1); } - if (path_check("/Library/Preferences/com.apple.sharing.firewall.plist")) { - const char *fw_tool[] = { "/usr/libexec/FirewallTool", NULL }; - assumes(fwexec(fw_tool, true) != -1); - } - const char *bcc_tool[] = { "BootCacheControl", "start", NULL }; assumes(fwexec(bcc_tool, true) != -1); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061030/e77cbd92/attachment.html From source_changes at macosforge.org Tue Oct 31 14:00:53 2006 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:35 2007 Subject: [launchd-changes] [22928] tags/launchd-167/ Message-ID: <20061031220053.69B5727557D@cvs.opensource.apple.com> Revision: 22928 http://trac.macosforge.org/projects/launchd/changeset/22928 Author: zarzycki@apple.com Date: 2006-10-31 14:00:53 -0800 (Tue, 31 Oct 2006) Log Message: ----------- "Tagging launchd-167 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-167/ Copied: tags/launchd-167 (from rev 22927, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061031/363a808a/attachment.html