From source_changes at macosforge.org Mon Jul 2 09:29:12 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:49 2007 Subject: [launchd-changes] [23288] trunk/launchd/src Message-ID: <20070702162912.EB4C569D62E@cvs.opensource.apple.com> Revision: 23288 http://trac.macosforge.org/projects/launchd/changeset/23288 Author: zarzycki@apple.com Date: 2007-07-02 09:29:12 -0700 (Mon, 02 Jul 2007) Log Message: ----------- Per-user agents run in root security context 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 2007-06-29 20:24:46 UTC (rev 23287) +++ trunk/launchd/src/Makefile.am 2007-07-02 16:29:12 UTC (rev 23288) @@ -40,7 +40,7 @@ sysconf_DATA = hostconfig rc.common rc.netboot launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders -launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -weak_library /usr/lib/libedit.dylib +launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -framework Security -weak_library /usr/lib/libedit.dylib SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-06-29 20:24:46 UTC (rev 23287) +++ trunk/launchd/src/Makefile.in 2007-07-02 16:29:12 UTC (rev 23288) @@ -246,7 +246,7 @@ @LIBS_ONLY_TRUE@liblaunch_profile_a_SOURCES = liblaunch.c libvproc.c libbootstrap.c protocol_vprocUser.c __version.c @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot @LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders -@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -weak_library /usr/lib/libedit.dylib +@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -framework Security -weak_library /usr/lib/libedit.dylib @LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) @LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit @LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-06-29 20:24:46 UTC (rev 23287) +++ trunk/launchd/src/launchctl.c 2007-07-02 16:29:12 UTC (rev 23288) @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -1553,6 +1555,10 @@ the_argc += 1; } + if (strcasecmp(session_type, "Background") == 0) { + assumes(SessionCreate(sessionKeepCurrentBootstrap, 0) == 0); + } + assumes(load_and_unload_cmd(the_argc, load_launchd_items) == 0); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070702/fa584ec7/attachment.html From source_changes at macosforge.org Mon Jul 2 13:21:32 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:49 2007 Subject: [launchd-changes] [23289] trunk/launchd/src/launchctl.c Message-ID: <20070702202132.ED97869DA2B@cvs.opensource.apple.com> Revision: 23289 http://trac.macosforge.org/projects/launchd/changeset/23289 Author: zarzycki@apple.com Date: 2007-07-02 13:21:25 -0700 (Mon, 02 Jul 2007) Log Message: ----------- Bug: launchctl.c:1556 (23257):2: load_and_unload_cmd(the_argc, load_launchd_items) == 0 Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-07-02 16:29:12 UTC (rev 23288) +++ trunk/launchd/src/launchctl.c 2007-07-02 20:21:25 UTC (rev 23289) @@ -1559,7 +1559,7 @@ assumes(SessionCreate(sessionKeepCurrentBootstrap, 0) == 0); } - assumes(load_and_unload_cmd(the_argc, load_launchd_items) == 0); + return load_and_unload_cmd(the_argc, load_launchd_items); } return 0; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070702/4fc284cd/attachment.html From source_changes at macosforge.org Mon Jul 2 14:30:55 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23290] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070702213055.15AB369DC5A@cvs.opensource.apple.com> Revision: 23290 http://trac.macosforge.org/projects/launchd/changeset/23290 Author: zarzycki@apple.com Date: 2007-07-02 14:30:55 -0700 (Mon, 02 Jul 2007) Log Message: ----------- Extra 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 2007-07-02 20:21:25 UTC (rev 23289) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-02 21:30:55 UTC (rev 23290) @@ -1003,6 +1003,7 @@ if (kevent_mod(jr->p, EVFILT_PROC, EV_ADD, proc_fflags, 0, root_jobmgr) == -1 && job_assumes(jr, errno == ESRCH)) { /* zombies are weird */ + job_log(jr, LOG_ERR, "Failed to add kevent for PID %u. Will unload at MIG return.", jr->p); jr->unload_at_mig_return = true; } @@ -1805,6 +1806,7 @@ job_mig_destructor(job_t j) { if (j->unload_at_mig_return) { + job_log(j, LOG_NOTICE, "Unloading PID %u at MIG return.", j->p); job_remove(j); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070702/301ec7cd/attachment.html From source_changes at macosforge.org Mon Jul 2 14:31:19 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23291] tags/launchd-224/ Message-ID: <20070702213119.7674169DC5E@cvs.opensource.apple.com> Revision: 23291 http://trac.macosforge.org/projects/launchd/changeset/23291 Author: zarzycki@apple.com Date: 2007-07-02 14:31:19 -0700 (Mon, 02 Jul 2007) Log Message: ----------- "Tagging launchd-224 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-224/ Copied: tags/launchd-224 (from rev 23290, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070702/0b51555f/attachment.html From source_changes at macosforge.org Tue Jul 3 10:31:03 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23292] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070703173103.6C90369F34E@cvs.opensource.apple.com> Revision: 23292 http://trac.macosforge.org/projects/launchd/changeset/23292 Author: zarzycki@apple.com Date: 2007-07-03 10:31:02 -0700 (Tue, 03 Jul 2007) Log Message: ----------- Aqua session launch agent jobs not loaded for root user session Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-02 21:31:19 UTC (rev 23291) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-03 17:31:02 UTC (rev 23292) @@ -5422,7 +5422,7 @@ void job_reparent_hack(job_t j, const char *where) { - jobmgr_t jmi = NULL; + jobmgr_t jmi, jmi2; ensure_root_bkgd_setup(); @@ -5445,10 +5445,18 @@ SLIST_FOREACH(jmi, &root_jobmgr->submgrs, sle) { if (strcasecmp(jmi->name, where) == 0) { - break; + goto jm_found; + } else if (strcasecmp(jmi->name, VPROCMGR_SESSION_BACKGROUND) == 0 && getpid() == 1) { + SLIST_FOREACH(jmi2, &jmi->submgrs, sle) { + if (strcasecmp(jmi2->name, where) == 0) { + jmi = jmi2; + goto jm_found; + } + } } } +jm_found: if (job_assumes(j, jmi != NULL)) { struct machservice *msi; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070703/e44f87f2/attachment.html From source_changes at macosforge.org Tue Jul 3 12:53:19 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23293] trunk/launchd/src/libvproc.c Message-ID: <20070703195319.D72AC69F7C6@cvs.opensource.apple.com> Revision: 23293 http://trac.macosforge.org/projects/launchd/changeset/23293 Author: zarzycki@apple.com Date: 2007-07-03 12:53:19 -0700 (Tue, 03 Jul 2007) Log Message: ----------- STD:VSC nohup tests failing Modified Paths: -------------- trunk/launchd/src/libvproc.c Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-07-03 17:31:02 UTC (rev 23292) +++ trunk/launchd/src/libvproc.c 2007-07-03 19:53:19 UTC (rev 23293) @@ -158,10 +158,13 @@ return (vproc_err_t)_vprocmgr_move_subset_to_user; } - if (vproc_swap_complex(NULL, VPROC_GSK_ENVIRONMENT, NULL, &output_obj) == NULL) { - if (launch_data_get_type(output_obj) == LAUNCH_DATA_DICTIONARY) { - launch_data_dict_iterate(output_obj, setup_env_hack, NULL); - launch_data_free(output_obj); + /* XXX We need to give 'nohup' a better API after Leopard ships */ + if (getprogname() && strcmp(getprogname(), "nohup") != 0) { + if (vproc_swap_complex(NULL, VPROC_GSK_ENVIRONMENT, NULL, &output_obj) == NULL) { + if (launch_data_get_type(output_obj) == LAUNCH_DATA_DICTIONARY) { + launch_data_dict_iterate(output_obj, setup_env_hack, NULL); + launch_data_free(output_obj); + } } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070703/3d620cd0/attachment.html From source_changes at macosforge.org Tue Jul 3 13:01:01 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23294] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070703200101.0700669F813@cvs.opensource.apple.com> Revision: 23294 http://trac.macosforge.org/projects/launchd/changeset/23294 Author: zarzycki@apple.com Date: 2007-07-03 13:01:00 -0700 (Tue, 03 Jul 2007) Log Message: ----------- StandardIO agent launched in Background context Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-03 19:53:19 UTC (rev 23293) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-03 20:01:00 UTC (rev 23294) @@ -5433,10 +5433,6 @@ } else { where = VPROCMGR_SESSION_AQUA; } - } else if (strcasecmp(where, VPROCMGR_SESSION_AQUA) != 0 - && strcasecmp(where, VPROCMGR_SESSION_LOGINWINDOW) != 0 - && strcasecmp(where, VPROCMGR_SESSION_BACKGROUND) != 0) { - return; } if (strcasecmp(j->mgr->name, where) == 0) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070703/e1e9d680/attachment.html From source_changes at macosforge.org Tue Jul 3 14:49:43 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23295] tags/launchd-225/ Message-ID: <20070703214943.BC45F69FBA7@cvs.opensource.apple.com> Revision: 23295 http://trac.macosforge.org/projects/launchd/changeset/23295 Author: zarzycki@apple.com Date: 2007-07-03 14:49:43 -0700 (Tue, 03 Jul 2007) Log Message: ----------- "Tagging launchd-225 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-225/ Copied: tags/launchd-225 (from rev 23294, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070703/04843fbb/attachment.html From source_changes at macosforge.org Fri Jul 6 09:44:55 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23296] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070706164455.87BA06A6FD6@cvs.opensource.apple.com> Revision: 23296 http://trac.macosforge.org/projects/launchd/changeset/23296 Author: zarzycki@apple.com Date: 2007-07-06 09:44:54 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Let's force flush the debug logs. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-03 21:49:43 UTC (rev 23295) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-06 16:44:54 UTC (rev 23296) @@ -2179,6 +2179,7 @@ calendarinterval_callback(); } else { jobmgr_log(jm, LOG_NOTICE, "Still alive with %u children.", total_children); + runtime_closelog(); /* hack to flush logs */ } break; default: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070706/f3546a27/attachment.html From source_changes at macosforge.org Fri Jul 6 14:38:28 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23297] trunk/launchd/src Message-ID: <20070706213828.30E656A8583@cvs.opensource.apple.com> Revision: 23297 http://trac.macosforge.org/projects/launchd/changeset/23297 Author: zarzycki@apple.com Date: 2007-07-06 14:38:27 -0700 (Fri, 06 Jul 2007) Log Message: ----------- A lot of startup messages are not written to the system.log file Modified Paths: -------------- trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/libvproc.c trunk/launchd/src/libvproc_internal.h trunk/launchd/src/libvproc_private.h trunk/launchd/src/protocol_job.defs trunk/launchd/src/protocol_job_reply.defs Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/launchd.h 2007-07-06 21:38:27 UTC (rev 23297) @@ -33,7 +33,6 @@ extern bool debug_shutdown_hangs; extern bool network_up; -extern mach_port_t inherited_bootstrap_port; bool init_check_pid(pid_t); Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-06 21:38:27 UTC (rev 23297) @@ -1927,7 +1927,7 @@ #endif if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { - job_log(j, LOG_WARNING, "exited with exit code: %d", WEXITSTATUS(status)); + job_log(j, LOG_WARNING, "Exited with exit code: %d", WEXITSTATUS(status)); } if (WIFSIGNALED(status)) { @@ -1999,6 +1999,17 @@ return j; } +static void +job_log_stdouterr2(job_t j, const char *msg, ...) +{ + struct runtime_syslog_attr attr = { j->label, j->label, j->mgr->name, LOG_NOTICE, getuid(), j->p, j->p }; + va_list ap; + + va_start(ap, msg); + runtime_vsyslog(&attr, msg, ap); + va_end(ap); +} + void job_log_stdouterr(job_t j) { @@ -2023,7 +2034,7 @@ while ((msg = strsep(&bufindex, "\n\r"))) { if (msg[0]) { - job_log(j, LOG_NOTICE, "Standard out/error: %s", msg); + job_log_stdouterr2(j, "%s", msg); } } } @@ -2850,10 +2861,10 @@ void job_logv(job_t j, int pri, int err, const char *msg, va_list ap) { + struct runtime_syslog_attr attr = { "com.apple.launchd", j->label, j->mgr->name, pri, getuid(), getpid(), j->p }; char *newmsg; - char *newlabel; int oldmask = 0; - size_t i, o, jlabel_len = strlen(j->label), newmsgsz; + size_t newmsgsz; /* * Hack: If bootstrap_port is set, we must be on the child side of a @@ -2864,30 +2875,20 @@ return _vproc_logv(pri, err, msg, ap); } - newlabel = alloca((jlabel_len + 1) * 2); - newmsgsz = (jlabel_len + 1) * 2 + strlen(msg) + 100; + newmsgsz = strlen(msg) + 200; newmsg = alloca(newmsgsz); - for (i = 0, o = 0; i < jlabel_len; i++, o++) { - if (j->label[i] == '%') { - newlabel[o] = '%'; - o++; - } - newlabel[o] = j->label[i]; - } - newlabel[o] = '\0'; - if (err) { - snprintf(newmsg, newmsgsz, "%s: %s: %s", newlabel, msg, strerror(err)); + snprintf(newmsg, newmsgsz, "%s: %s", msg, strerror(err)); } else { - snprintf(newmsg, newmsgsz, "%s: %s", newlabel, msg); + snprintf(newmsg, newmsgsz, "%s", msg); } if (j->debug) { oldmask = setlogmask(LOG_UPTO(LOG_DEBUG)); } - jobmgr_logv(j->mgr, pri, 0, newmsg, ap); + runtime_vsyslog(&attr, newmsg, ap); if (j->debug) { setlogmask(oldmask); @@ -2965,7 +2966,9 @@ if (jm->parentmgr) { jobmgr_logv(jm->parentmgr, pri, 0, newmsg, ap); } else { - runtime_vsyslog(pri, newmsg, ap); + struct runtime_syslog_attr attr = { "com.apple.launchd", "com.apple.launchd", jm->name, pri, getuid(), getpid(), getpid() }; + + runtime_vsyslog(&attr, newmsg, ap); } } @@ -3985,9 +3988,11 @@ unsetenv(LAUNCHD_TRUSTED_FD_ENV); } + /* cut off the Libc cache, we don't want to deadlock against ourself */ inherited_bootstrap_port = bootstrap_port; - /* cut off the Libc cache, we don't want to deadlock against ourself */ bootstrap_port = MACH_PORT_NULL; + launchd_assert(launchd_mport_notify_req(inherited_bootstrap_port, MACH_NOTIFY_DEAD_NAME) == KERN_SUCCESS); + /* We set this explicitly as we start each child */ launchd_assert(launchd_set_bport(MACH_PORT_NULL) == KERN_SUCCESS); } else if (!jobmgr_assumes(jmr, launchd_mport_create_recv(&jmr->jm_port) == KERN_SUCCESS)) { @@ -4076,6 +4081,13 @@ */ if (jm == root_jobmgr) { + if (port == inherited_bootstrap_port) { + launchd_assumes(launchd_mport_deallocate(port) == KERN_SUCCESS); + inherited_bootstrap_port = MACH_PORT_NULL; + + return jobmgr_shutdown(jm); + } + LIST_FOREACH_SAFE(ms, &port_hash[HASH_PORT(port)], port_hash_sle, next_ms) { if (ms->port == port) { machservice_delete(ms->job, ms, true); @@ -4758,6 +4770,42 @@ } kern_return_t +job_mig_log_forward(job_t j, vm_offset_t inval, mach_msg_type_number_t invalCnt) +{ + struct ldcred ldc; + + if (!launchd_assumes(j != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + + if (!job_assumes(j, j->per_user)) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + + runtime_get_caller_creds(&ldc); + + return runtime_log_forward(ldc.euid, ldc.egid, inval, invalCnt); +} + +kern_return_t +job_mig_log_drain(job_t j, mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt) +{ + struct ldcred ldc; + + if (!launchd_assumes(j != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + + runtime_get_caller_creds(&ldc); + + if (ldc.euid) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + + return runtime_log_drain(srp, outval, outvalCnt); +} + +kern_return_t job_mig_swap_complex(job_t j, vproc_gsk_t inkey, vproc_gsk_t outkey, vm_offset_t inval, mach_msg_type_number_t invalCnt, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt) Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/launchd_core_logic.h 2007-07-06 21:38:27 UTC (rev 23297) @@ -27,6 +27,7 @@ typedef struct jobmgr_s *jobmgr_t; extern jobmgr_t root_jobmgr; +extern mach_port_t inherited_bootstrap_port; void jobmgr_init(bool); jobmgr_t jobmgr_shutdown(jobmgr_t jm); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/launchd_runtime.c 2007-07-06 21:38:27 UTC (rev 23297) @@ -64,6 +64,8 @@ #include "launch.h" #include "launchd.h" #include "launchd_core_logic.h" +#include "libvproc_internal.h" +#include "job_reply.h" static mach_port_t ipc_port_set; static mach_port_t demand_port_set; @@ -91,6 +93,18 @@ static mach_msg_timeout_t runtime_idle_timeout; static audit_token_t *au_tok; + +static STAILQ_HEAD(, logmsg_s) logmsg_queue = STAILQ_HEAD_INITIALIZER(logmsg_queue); +static size_t logmsg_queue_sz; +static size_t logmsg_queue_cnt; +static mach_port_t drain_reply_port; +static void runtime_log_uncork_pending_drain(void); +static kern_return_t runtime_log_pack(vm_offset_t *outval, mach_msg_type_number_t *outvalCnt); +static void runtime_log_push(void); + +static bool logmsg_add(struct runtime_syslog_attr *attr, int err_num, const char *msg); +static void logmsg_remove(struct logmsg_s *lm); + void launchd_runtime_init(void) { @@ -773,9 +787,9 @@ * a receiver somewhere else on the system. */ - if (name == inherited_bootstrap_port) { + if (name == drain_reply_port) { launchd_assumes(launchd_mport_deallocate(name) == KERN_SUCCESS); - inherited_bootstrap_port = MACH_PORT_NULL; + drain_reply_port = MACH_PORT_NULL; } if (launchd_assumes(root_jobmgr != NULL)) { @@ -857,6 +871,8 @@ } } + runtime_log_push(); + mr = mach_msg(&bufReply->Head, tmp_options, bufReply->Head.msgh_size, msg_size, ipc_port_set, to, MACH_PORT_NULL); @@ -973,26 +989,35 @@ } } +static int internal_mask_pri; + int runtime_setlogmask(int maskpri) { - return setlogmask(maskpri); + internal_mask_pri = maskpri; + + return internal_mask_pri; } void -runtime_syslog(int priority, const char *message, ...) +runtime_syslog(int pri, const char *message, ...) { + struct runtime_syslog_attr attr = { + "com.apple.launchd", "com.apple.launchd", + getpid() == 1 ? "System" : "Background", + pri, getuid(), getpid(), getpid() + }; va_list ap; va_start(ap, message); - runtime_vsyslog(priority, message, ap); + runtime_vsyslog(&attr, message, ap); va_end(ap); } void -runtime_vsyslog(int priority, const char *message, va_list args) +runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) { static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER; static struct timeval shutdown_start; @@ -1004,19 +1029,25 @@ char newmsg[10000]; size_t i, j; + if (!(LOG_MASK(attr->priority) & internal_mask_pri)) { + goto out; + } + if (apple_internal_logging == 1) { apple_internal_logging = stat("/AppleInternal", &sb); } + if (!(debug_shutdown_hangs && getpid() == 1)) { - if (priority == LOG_APPLEONLY) { + if (attr->priority == LOG_APPLEONLY) { if (apple_internal_logging == -1) { - return; + goto out; } - priority = LOG_NOTICE; + attr->priority = LOG_NOTICE; } - vsyslog(priority, message, args); - return closelog(); + vsnprintf(newmsg, sizeof(newmsg), message, args); + logmsg_add(attr, saved_errno, newmsg); + goto out; } if (shutdown_start.tv_sec == 0) { @@ -1038,12 +1069,11 @@ pthread_mutex_unlock(&ourlock); if (ourlogfile == NULL) { - syslog(LOG_ERR, "Couldn't open alternate log file!"); - return vsyslog(priority, message, args); + goto out; } if (message == NULL) { - return; + goto out; } timersub(&tvnow, &shutdown_start, &tvd_total); @@ -1074,4 +1104,190 @@ strcpy(newmsg + j, "\n"); vfprintf(ourlogfile, newmsg, args); + +out: + runtime_log_uncork_pending_drain(); } + +bool +logmsg_add(struct runtime_syslog_attr *attr, int err_num, const char *msg) +{ + size_t lm_sz = sizeof(struct logmsg_s) + strlen(msg) + strlen(attr->from_name) + strlen(attr->about_name) + strlen(attr->session_name) + 4; + char *data_off; + struct logmsg_s *lm; + +#define ROUND_TO_64BIT_WORD_SIZE(x) ((x + 7) & ~7) + + /* we do this to make the unpacking for the log_drain cause unalignment faults */ + lm_sz = ROUND_TO_64BIT_WORD_SIZE(lm_sz); + + if (!(lm = calloc(1, lm_sz))) { + return false; + } + + data_off = lm->data; + + launchd_assumes(gettimeofday(&lm->when, NULL) != -1); + lm->from_pid = attr->from_pid; + lm->about_pid = attr->about_pid; + lm->err_num = err_num; + lm->pri = attr->priority; + lm->obj_sz = lm_sz; + lm->msg = data_off; + data_off += sprintf(data_off, "%s", msg) + 1; + lm->from_name = data_off; + data_off += sprintf(data_off, "%s", attr->from_name) + 1; + lm->about_name = data_off; + data_off += sprintf(data_off, "%s", attr->about_name) + 1; + lm->session_name = data_off; + data_off += sprintf(data_off, "%s", attr->session_name) + 1; + + STAILQ_INSERT_TAIL(&logmsg_queue, lm, sqe); + logmsg_queue_sz += lm_sz; + logmsg_queue_cnt++; + + return true; +} + +void +logmsg_remove(struct logmsg_s *lm) +{ + STAILQ_REMOVE(&logmsg_queue, lm, logmsg_s, sqe); + logmsg_queue_sz -= lm->obj_sz; + logmsg_queue_cnt--; + + free(lm); +} + +kern_return_t +runtime_log_pack(vm_offset_t *outval, mach_msg_type_number_t *outvalCnt) +{ + struct logmsg_s *lm; + void *offset; + + *outvalCnt = logmsg_queue_sz; + + mig_allocate(outval, *outvalCnt); + + if (*outval == 0) { + return 1; + } + + offset = (void *)*outval; + + while ((lm = STAILQ_FIRST(&logmsg_queue))) { + lm->from_name -= (size_t)lm; + lm->about_name -= (size_t)lm; + lm->msg -= (size_t)lm; + lm->session_name -= (size_t)lm; + + memcpy(offset, lm, lm->obj_sz); + + offset += lm->obj_sz; + + logmsg_remove(lm); + } + + return 0; +} + +void +runtime_log_uncork_pending_drain(void) +{ + mach_msg_type_number_t outvalCnt; + vm_offset_t outval; + + if (!drain_reply_port) { + return; + } + + if (logmsg_queue_cnt == 0) { + return; + } + + if (runtime_log_pack(&outval, &outvalCnt) != 0) { + return; + } + + if (!launchd_assumes(job_mig_log_drain_reply(drain_reply_port, 0, outval, outvalCnt) == 0)) { + launchd_assumes(launchd_mport_deallocate(drain_reply_port) == KERN_SUCCESS); + } + + drain_reply_port = MACH_PORT_NULL; + + mig_deallocate(outval, outvalCnt); +} + +void +runtime_log_push(void) +{ + mach_msg_type_number_t outvalCnt; + vm_offset_t outval; + + if (logmsg_queue_cnt == 0) { + launchd_assumes(STAILQ_EMPTY(&logmsg_queue)); + return; + } else if (getpid() == 1) { + return; + } + + if (runtime_log_pack(&outval, &outvalCnt) != 0) { + return; + } + + launchd_assumes(_vprocmgr_log_forward(inherited_bootstrap_port, (void *)outval, outvalCnt) == NULL); + + mig_deallocate(outval, outvalCnt); +} + +kern_return_t +runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt) +{ + struct logmsg_s *lm, *lm_walk; + mach_msg_type_number_t data_left = invalCnt; + + if (inval == 0) { + return 0; + } + + for (lm_walk = (struct logmsg_s *)inval; (data_left > 0) && (lm_walk->obj_sz <= data_left); lm_walk = ((void *)lm_walk + lm_walk->obj_sz)) { + if (!launchd_assumes(lm = malloc(lm_walk->obj_sz))) { + continue; + } + + memcpy(lm, lm_walk, lm_walk->obj_sz); + lm->sender_uid = forward_uid; + lm->sender_gid = forward_gid; + + lm->from_name += (size_t)lm; + lm->about_name += (size_t)lm; + lm->msg += (size_t)lm; + lm->session_name += (size_t)lm; + + STAILQ_INSERT_TAIL(&logmsg_queue, lm, sqe); + logmsg_queue_sz += lm->obj_sz; + logmsg_queue_cnt++; + + data_left -= lm->obj_sz; + } + + mig_deallocate(inval, invalCnt); + + return 0; +} + +kern_return_t +runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt) +{ + if (logmsg_queue_cnt == 0) { + launchd_assumes(STAILQ_EMPTY(&logmsg_queue)); + launchd_assumes(drain_reply_port == 0); + + drain_reply_port = srp; + launchd_assumes(launchd_mport_notify_req(drain_reply_port, MACH_NOTIFY_DEAD_NAME) == KERN_SUCCESS); + + return MIG_NO_REPLY; + } + + return runtime_log_pack(outval, outvalCnt); +} Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/launchd_runtime.h 2007-07-06 21:38:27 UTC (rev 23297) @@ -77,12 +77,24 @@ void runtime_openlog(const char *ident, int logopt, int facility); void runtime_closelog(void); +kern_return_t runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt); +kern_return_t runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt); #define LOG_APPLEONLY 0x4141504c /* AAPL in hex */ +struct runtime_syslog_attr { + const char *from_name; + const char *about_name; + const char *session_name; + int priority; + uid_t from_uid; + pid_t from_pid; + pid_t about_pid; +}; + int runtime_setlogmask(int maskpri); -void runtime_syslog(int priority, const char *message, ...) __attribute__((format(printf, 2, 3))); -void runtime_vsyslog(int priority, const char *message, va_list args) __attribute__((format(printf, 2, 0))); +void runtime_syslog(int pri, const char *message, ...) __attribute__((format(printf, 2, 3))); +void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) __attribute__((format(printf, 2, 0))); kern_return_t launchd_set_bport(mach_port_t name); Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/libvproc.c 2007-07-06 21:38:27 UTC (rev 23297) @@ -31,6 +31,7 @@ #include #include #include +#include #include "liblaunch_public.h" #include "liblaunch_private.h" @@ -382,6 +383,55 @@ } vproc_err_t +_vprocmgr_log_forward(mach_port_t mp, void *data, size_t len) +{ + if (vproc_mig_log_forward(mp, (vm_offset_t)data, len) == 0) { + return NULL; + } + + return _vprocmgr_log_forward; +} + +vproc_err_t +_vprocmgr_log_drain(vproc_t vp __attribute__((unused)), pthread_mutex_t *mutex, _vprocmgr_log_drain_callback_t func) +{ + mach_msg_type_number_t outdata_cnt; + vm_offset_t outdata = 0; + struct logmsg_s *lm; + + if (!func) { + return _vprocmgr_log_drain; + } + + if (vproc_mig_log_drain(bootstrap_port, &outdata, &outdata_cnt) != 0) { + return _vprocmgr_log_drain; + } + + if (mutex) { + pthread_mutex_lock(mutex); + } + + for (lm = (struct logmsg_s *)outdata; lm->obj_sz; lm = ((void *)lm + lm->obj_sz)) { + lm->from_name += (size_t)lm; + lm->about_name += (size_t)lm; + lm->msg += (size_t)lm; + lm->session_name += (size_t)lm; + + func(&lm->when, lm->from_pid, lm->about_pid, lm->sender_uid, lm->sender_gid, lm->pri, lm->from_name, lm->about_name, lm->session_name, lm->msg); + } + + if (mutex) { + pthread_mutex_unlock(mutex); + } + + if (outdata) { + mig_deallocate(outdata, outdata_cnt); + } + + return NULL; +} + +vproc_err_t vproc_swap_integer(vproc_t vp __attribute__((unused)), vproc_gsk_t key, int64_t *inval, int64_t *outval) { static int64_t cached_is_managed = -1; Modified: trunk/launchd/src/libvproc_internal.h =================================================================== --- trunk/launchd/src/libvproc_internal.h 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/libvproc_internal.h 2007-07-06 21:38:27 UTC (rev 23297) @@ -1,7 +1,7 @@ #ifndef _VPROC_INTERNAL_H_ #define _VPROC_INTERNAL_H_ /* - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2006-2007 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * @@ -21,9 +21,12 @@ */ #include +#include +#include #include #include "liblaunch_public.h" #include "libbootstrap_public.h" +#include "libvproc_public.h" typedef char * _internal_string_t; typedef char * logmsg_t; @@ -53,8 +56,29 @@ kern_return_t _vprocmgr_getsocket(name_t); + +struct logmsg_s { + STAILQ_ENTRY(logmsg_s) sqe; + struct timeval when; + pid_t from_pid; + pid_t about_pid; + uid_t sender_uid; + gid_t sender_gid; + int err_num; + int pri; + const char *from_name; + const char *about_name; + const char *session_name; + const char *msg; + size_t obj_sz; + char data[0]; +}; + + void _vproc_logv(int pri, int err, const char *msg, va_list ap); +vproc_err_t _vprocmgr_log_forward(mach_port_t mp, void *data, size_t len); + kern_return_t bootstrap_info( mach_port_t bp, Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/libvproc_private.h 2007-07-06 21:38:27 UTC (rev 23297) @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,10 @@ vproc_err_t _vproc_get_last_exit_status(int *wstatus); vproc_err_t _vproc_set_global_on_demand(bool val); +typedef void (*_vprocmgr_log_drain_callback_t)(struct timeval *when, pid_t from_pid, pid_t about_pid, uid_t sender_uid, gid_t sender_gid, int priority, const char *from_name, const char *about_name, const char *session_name, const char *msg); + +vproc_err_t _vprocmgr_log_drain(vproc_t vp, pthread_mutex_t *optional_mutex_around_callback, _vprocmgr_log_drain_callback_t func); + vproc_err_t _vproc_send_signal_by_label(const char *label, int sig); void _vproc_log(int pri, const char *msg, ...) __attribute__((format(printf, 2, 3))); Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/protocol_job.defs 2007-07-06 21:38:27 UTC (rev 23297) @@ -115,7 +115,7 @@ routine wait( __bs_port : job_t; - sreplyport __rport : mach_port_make_send_once_t; + sreplyport __rport : mach_port_make_send_once_t; out __waitval : integer_t); routine uncork_fork( @@ -156,3 +156,12 @@ __outkey : vproc_gsk_t; __inval : pointer_t; out __outval : pointer_t, dealloc); + +routine log_drain( + __bs_port : job_t; + sreplyport __rport : mach_port_make_send_once_t; + out __outval : pointer_t, dealloc); + +routine log_forward( + __bs_port : job_t; + __inval : pointer_t); Modified: trunk/launchd/src/protocol_job_reply.defs =================================================================== --- trunk/launchd/src/protocol_job_reply.defs 2007-07-06 16:44:54 UTC (rev 23296) +++ trunk/launchd/src/protocol_job_reply.defs 2007-07-06 21:38:27 UTC (rev 23297) @@ -37,7 +37,7 @@ skip; /* look_up */ -skip; +skip; /* send_signal */ skip; /* parent */ @@ -59,3 +59,22 @@ __r_port : mach_port_move_send_once_t; __result : kern_return_t, RetCode; __wait : integer_t); + +skip; /* uncork_fork */ + +skip; /* swap_integer */ + +skip; /* set_service_policy */ + +skip; /* log */ + +skip; /* lookup_per_user_context */ + +skip; /* move_subset */ + +skip; /* swap_complex */ + +simpleroutine job_mig_log_drain_reply( + __r_port : mach_port_move_send_once_t; + __result : kern_return_t, RetCode; + __outval : pointer_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070706/b23d36f7/attachment.html From source_changes at macosforge.org Fri Jul 6 14:38:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23298] tags/launchd-226/ Message-ID: <20070706213858.008886A8592@cvs.opensource.apple.com> Revision: 23298 http://trac.macosforge.org/projects/launchd/changeset/23298 Author: zarzycki@apple.com Date: 2007-07-06 14:38:57 -0700 (Fri, 06 Jul 2007) Log Message: ----------- "Tagging launchd-226 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-226/ Copied: tags/launchd-226 (from rev 23297, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070706/1dfae707/attachment.html From source_changes at macosforge.org Tue Jul 10 13:24:40 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23299] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070710202440.3E3486C4FFE@cvs.opensource.apple.com> Revision: 23299 http://trac.macosforge.org/projects/launchd/changeset/23299 Author: zarzycki@apple.com Date: 2007-07-10 13:24:39 -0700 (Tue, 10 Jul 2007) Log Message: ----------- Bug: launchd_core_logic.c:3739 (23294):8: (errno = task_set_special_port(mach_task_self(), which_port, ms->port)) == KERN_SUCCESS Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-06 21:38:57 UTC (rev 23298) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-10 20:24:39 UTC (rev 23299) @@ -121,16 +121,19 @@ struct machservice { SLIST_ENTRY(machservice) sle; + SLIST_ENTRY(machservice) special_port_sle; LIST_ENTRY(machservice) name_hash_sle; LIST_ENTRY(machservice) port_hash_sle; job_t job; uint64_t bad_perf_cnt; unsigned int gen_num; mach_port_name_t port; - unsigned int isActive:1, reset:1, recv:1, hide:1, kUNCServer:1, per_user_hack:1, debug_on_close:1, per_pid:1; + unsigned int isActive:1, reset:1, recv:1, hide:1, kUNCServer:1, per_user_hack:1, debug_on_close:1, per_pid:1, special_port_num:10; const char name[0]; }; +static SLIST_HEAD(, machservice) special_ports; /* hack, this should be per jobmgr_t */ + #define PORT_HASH_SIZE 32 #define HASH_PORT(x) (IS_POWER_OF_TWO(PORT_HASH_SIZE) ? (MACH_PORT_INDEX(x) & (PORT_HASH_SIZE - 1)) : (MACH_PORT_INDEX(x) % PORT_HASH_SIZE)) @@ -3740,7 +3743,8 @@ job_log(ms->job, LOG_WARNING, "Tried to set a reserved task special port: %d", which_port); break; default: - job_assumes(ms->job, (errno = task_set_special_port(mach_task_self(), which_port, ms->port)) == KERN_SUCCESS); + ms->special_port_num = which_port; + SLIST_INSERT_HEAD(&special_ports, ms, special_port_sle); break; } } else if (strcasecmp(key, LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT) == 0 && getpid() == 1) { @@ -4185,6 +4189,10 @@ job_log(j, LOG_INFO, "Mach service deleted%s: %s", port_died ? " (port died)" : "", ms->name); + if (ms->special_port_num) { + SLIST_REMOVE(&special_ports, ms, machservice, special_port_sle); + } + SLIST_REMOVE(&j->machservices, ms, machservice, sle); LIST_REMOVE(ms, name_hash_sle); LIST_REMOVE(ms, port_hash_sle); @@ -5022,6 +5030,8 @@ kern_return_t job_mig_post_fork_ping(job_t j, task_t child_task) { + struct machservice *ms; + if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } @@ -5030,6 +5040,14 @@ job_setup_exception_port(j, child_task); + SLIST_FOREACH(ms, &special_ports, special_port_sle) { + if (j->per_user && (ms->special_port_num != TASK_ACCESS_PORT)) { + /* The TASK_ACCESS_PORT funny business is to workaround 5325399. */ + continue; + } + job_assumes(j, (errno = task_set_special_port(child_task, ms->special_port_num, ms->port)) == KERN_SUCCESS); + } + job_assumes(j, launchd_mport_deallocate(child_task) == KERN_SUCCESS); return 0; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070710/d94aa4b2/attachment.html From source_changes at macosforge.org Tue Jul 10 13:31:35 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23300] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070710203135.9E8E56C5034@cvs.opensource.apple.com> Revision: 23300 http://trac.macosforge.org/projects/launchd/changeset/23300 Author: zarzycki@apple.com Date: 2007-07-10 13:31:35 -0700 (Tue, 10 Jul 2007) Log Message: ----------- Extra logging due to 5321044. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-10 20:24:39 UTC (rev 23299) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-10 20:31:35 UTC (rev 23300) @@ -3016,7 +3016,10 @@ } job_log(j, LOG_DEBUG, "Watching Vnode: %d", si->fd); - job_assumes(j, kevent_mod(si->fd, EVFILT_VNODE, EV_ADD, fflags, 0, j) != -1); + if (!job_assumes(j, kevent_mod(si->fd, EVFILT_VNODE, EV_ADD, fflags, 0, j) != -1)) { + /* Extra logging for 5321044 */ + job_log(j, LOG_ERR, "Bug (5321044): si->fd == %d fflags = 0x%x j == %p", si->fd, fflags, j); + } } void -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070710/a1c3508f/attachment.html From source_changes at macosforge.org Tue Jul 10 14:41:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23301] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070710214136.D6CB16C515D@cvs.opensource.apple.com> Revision: 23301 http://trac.macosforge.org/projects/launchd/changeset/23301 Author: zarzycki@apple.com Date: 2007-07-10 14:41:36 -0700 (Tue, 10 Jul 2007) Log Message: ----------- Disable NOTE_REAP while we investigate 5289559. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-10 20:31:35 UTC (rev 23300) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-10 21:41:36 UTC (rev 23301) @@ -995,7 +995,7 @@ } if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_LEGACY_LABEL, zombie ? zombie : kp.kp_proc.p_comm, NULL)) != NULL)) { - u_int proc_fflags = NOTE_EXEC|NOTE_EXIT|NOTE_REAP; + u_int proc_fflags = NOTE_EXEC|NOTE_EXIT /* |NOTE_REAP */; total_children++; jr->anonymous = true; @@ -2096,12 +2096,15 @@ } } + /* NOTE_REAP sanity checking is disabled for now while we try and diagnose 5289559 */ +#if 0 if (j && (fflags & NOTE_REAP)) { job_assumes(j, flags & EV_ONESHOT); job_assumes(j, flags & EV_EOF); job_assumes(j, j->p == 0); } +#endif } void @@ -2234,7 +2237,7 @@ pid_t c; bool sipc = false; time_t td; - u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT|NOTE_REAP; + u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT /* |NOTE_REAP */; if (!job_assumes(j, j->mgr != NULL)) { return; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070710/89fac81a/attachment.html From source_changes at macosforge.org Tue Jul 10 14:42:01 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23302] tags/launchd-227/ Message-ID: <20070710214201.AD32A6C5161@cvs.opensource.apple.com> Revision: 23302 http://trac.macosforge.org/projects/launchd/changeset/23302 Author: zarzycki@apple.com Date: 2007-07-10 14:42:01 -0700 (Tue, 10 Jul 2007) Log Message: ----------- "Tagging launchd-227 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-227/ Copied: tags/launchd-227 (from rev 23301, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070710/253bfb57/attachment.html From source_changes at macosforge.org Wed Jul 11 11:10:33 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23303] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070711181033.093C96C7A12@cvs.opensource.apple.com> Revision: 23303 http://trac.macosforge.org/projects/launchd/changeset/23303 Author: zarzycki@apple.com Date: 2007-07-11 11:10:33 -0700 (Wed, 11 Jul 2007) Log Message: ----------- Misc fixes. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-10 21:42:01 UTC (rev 23302) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-11 18:10:33 UTC (rev 23303) @@ -167,6 +167,7 @@ static void socketgroup_ignore(job_t j, struct socketgroup *sg); static void socketgroup_callback(job_t j); static void socketgroup_setup(launch_data_t obj, const char *key, void *context); +static void socketgroup_kevent_mod(job_t j, struct socketgroup *sg, bool do_add); struct calendarinterval { LIST_ENTRY(calendarinterval) global_sle; @@ -180,6 +181,7 @@ static bool calendarinterval_new(job_t j, struct tm *w); static bool calendarinterval_new_from_obj(job_t j, launch_data_t obj); +static void calendarinterval_new_from_obj_dict_walk(launch_data_t obj, const char *key, void *context); static void calendarinterval_delete(job_t j, struct calendarinterval *ci); static void calendarinterval_setalarm(job_t j, struct calendarinterval *ci); static void calendarinterval_callback(void); @@ -402,6 +404,7 @@ static void job_logv(job_t j, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0))); 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); +static void job_log_stdouterr2(job_t j, const char *msg, ...); static void job_set_exeception_port(job_t j, mach_port_t port); static kern_return_t job_handle_mpm_wait(job_t j, mach_port_t srp, int *waitstatus); @@ -429,16 +432,22 @@ static bool cronemu_hour(struct tm *wtm, int hour, int min); static bool cronemu_min(struct tm *wtm, int min); -static unsigned int total_children; +/* miscellaneous file local functions */ static void ensure_root_bkgd_setup(void); static int dir_has_files(job_t j, const char *path); static char **mach_cmd2argv(const char *string); static size_t our_strhash(const char *s) __attribute__((pure)); +static void extract_rcsid_substr(const char *i, char *o, size_t osz); +static void do_first_per_user_launchd_hack(void); + +/* file local globals */ +static unsigned int total_children; static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; +static jobmgr_t background_jobmgr; +/* process wide globals */ jobmgr_t root_jobmgr; -static jobmgr_t background_jobmgr; void job_ignore(job_t j) @@ -2002,7 +2011,7 @@ return j; } -static void +void job_log_stdouterr2(job_t j, const char *msg, ...) { struct runtime_syslog_attr attr = { j->label, j->label, j->mgr->name, LOG_NOTICE, getuid(), j->p, j->p }; @@ -2352,7 +2361,7 @@ } } -static void +void do_first_per_user_launchd_hack(void) { char *bcct_tool[] = { "/usr/sbin/BootCacheControl", "tag", NULL }; @@ -2812,7 +2821,7 @@ } } -static void +void extract_rcsid_substr(const char *i, char *o, size_t osz) { char *rcs_rev_tmp = strchr(i, ' '); @@ -2993,11 +3002,11 @@ char parentdir_path[PATH_MAX], *which_path = si->what; int fflags = 0; + strlcpy(parentdir_path, dirname(si->what), sizeof(parentdir_path)); + switch (si->why) { case PATH_EXISTS: fflags = NOTE_DELETE|NOTE_RENAME|NOTE_REVOKE|NOTE_EXTEND|NOTE_WRITE; - strlcpy(parentdir_path, dirname(si->what), sizeof(parentdir_path)); - which_path = parentdir_path; break; case PATH_MISSING: fflags = NOTE_DELETE|NOTE_RENAME; @@ -3011,7 +3020,10 @@ } if (si->fd == -1) { - si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY)); + if ((si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY))) == -1) { + which_path = parentdir_path; + si->fd = _fd(open(which_path, O_EVTONLY|O_NOCTTY)); + } } if (si->fd == -1) { @@ -3086,7 +3098,7 @@ job_dispatch(j, false); } -static void +void calendarinterval_new_from_obj_dict_walk(launch_data_t obj, const char *key, void *context) { struct tm *tmptm = context; @@ -3245,7 +3257,7 @@ free(sg); } -static void +void socketgroup_kevent_mod(job_t j, struct socketgroup *sg, bool do_add) { struct kevent kev[sg->fd_cnt]; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070711/4b78b53a/attachment.html From source_changes at macosforge.org Wed Jul 11 15:11:37 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23304] trunk/launchd/src Message-ID: <20070711221137.E46D86C807E@cvs.opensource.apple.com> Revision: 23304 http://trac.macosforge.org/projects/launchd/changeset/23304 Author: zarzycki@apple.com Date: 2007-07-11 15:11:37 -0700 (Wed, 11 Jul 2007) Log Message: ----------- launchctl unload should block until unload is complete Modified Paths: -------------- trunk/launchd/src/launchctl.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc_private.h trunk/launchd/src/protocol_job.defs trunk/launchd/src/protocol_job_reply.defs Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-07-11 18:10:33 UTC (rev 23303) +++ trunk/launchd/src/launchctl.c 2007-07-11 22:11:37 UTC (rev 23304) @@ -440,11 +440,8 @@ void unloadjob(launch_data_t job) { - launch_data_t resp, tmp, tmps, msg; - int e; + launch_data_t tmps; - msg = launch_data_alloc(LAUNCH_DATA_DICTIONARY); - tmp = launch_data_alloc(LAUNCH_DATA_STRING); tmps = launch_data_dict_lookup(job, LAUNCH_JOBKEY_LABEL); if (!tmps) { @@ -452,20 +449,7 @@ return; } - launch_data_set_string(tmp, launch_data_get_string(tmps)); - launch_data_dict_insert(msg, tmp, LAUNCH_KEY_REMOVEJOB); - resp = launch_msg(msg); - launch_data_free(msg); - if (!resp) { - fprintf(stderr, "%s: Error: launch_msg(): %s\n", getprogname(), strerror(errno)); - return; - } - if (LAUNCH_DATA_ERRNO == launch_data_get_type(resp)) { - if ((e = launch_data_get_errno(resp))) { - fprintf(stderr, "%s\n", strerror(e)); - } - } - launch_data_free(resp); + assumes(_vproc_send_signal_by_label(launch_data_get_string(tmps), VPROC_MAGIC_UNLOAD_SIGNAL) == NULL); } launch_data_t Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-11 18:10:33 UTC (rev 23303) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-11 22:11:37 UTC (rev 23304) @@ -105,8 +105,14 @@ extern char **environ; -mach_port_t inherited_bootstrap_port; +struct waiting_for_removal { + SLIST_ENTRY(waiting_for_removal) sle; + mach_port_t reply_port; +}; +static bool waiting4removal_new(job_t j, mach_port_t rp); +static void waiting4removal_delete(job_t j, struct waiting_for_removal *w4r); + struct mspolicy { SLIST_ENTRY(mspolicy) sle; unsigned int allow:1, per_pid:1; @@ -308,6 +314,7 @@ SLIST_HEAD(, mspolicy) mspolicies; SLIST_HEAD(, machservice) machservices; SLIST_HEAD(, semaphoreitem) semaphores; + SLIST_HEAD(, waiting_for_removal) removal_watchers; #if DO_RUSAGE_SUMMATION struct rusage ru; #endif @@ -447,6 +454,7 @@ static jobmgr_t background_jobmgr; /* process wide globals */ +mach_port_t inherited_bootstrap_port; jobmgr_t root_jobmgr; void @@ -711,6 +719,7 @@ void job_remove(job_t j) { + struct waiting_for_removal *w4r; struct calendarinterval *ci; struct semaphoreitem *si; struct socketgroup *sg; @@ -778,6 +787,9 @@ while ((si = SLIST_FIRST(&j->semaphores))) { semaphoreitem_delete(j, si); } + while ((w4r = SLIST_FIRST(&j->removal_watchers))) { + waiting4removal_delete(j, w4r); + } if (j->prog) { free(j->prog); @@ -4769,7 +4781,7 @@ } kern_return_t -job_mig_send_signal(job_t j, name_t targetlabel, int sig) +job_mig_send_signal(job_t j, mach_port_t srp, name_t targetlabel, int sig) { struct ldcred ldc; job_t otherj; @@ -4788,7 +4800,24 @@ return BOOTSTRAP_UNKNOWN_SERVICE; } - if (otherj->p) { + if (sig == VPROC_MAGIC_UNLOAD_SIGNAL) { + bool do_block = otherj->p; + + if (otherj->anonymous) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + + job_remove(otherj); + + if (do_block) { + job_log(j, LOG_DEBUG, "Blocking MIG return of job_remove(): %s", otherj->label); + /* this is messy. We shouldn't access 'otherj' after job_remove(), but we check otherj->p first... */ + job_assumes(otherj, waiting4removal_new(otherj, srp)); + return MIG_NO_REPLY; + } else { + return 0; + } + } else if (otherj->p) { job_assumes(j, kill(otherj->p, sig) != -1); } @@ -6134,3 +6163,29 @@ free(msp); } + +bool +waiting4removal_new(job_t j, mach_port_t rp) +{ + struct waiting_for_removal *w4r; + + if (!job_assumes(j, (w4r = malloc(sizeof(struct waiting_for_removal))) != NULL)) { + return false; + } + + w4r->reply_port = rp; + + SLIST_INSERT_HEAD(&j->removal_watchers, w4r, sle); + + return true; +} + +void +waiting4removal_delete(job_t j, struct waiting_for_removal *w4r) +{ + job_assumes(j, job_mig_send_signal_reply(w4r->reply_port, 0) == 0); + + SLIST_REMOVE(&j->removal_watchers, w4r, waiting_for_removal, sle); + + free(w4r); +} Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2007-07-11 18:10:33 UTC (rev 23303) +++ trunk/launchd/src/libvproc_private.h 2007-07-11 22:11:37 UTC (rev 23304) @@ -31,6 +31,9 @@ #pragma GCC visibility push(default) +/* DO NOT use this. This is a hack for launchctl */ +#define VPROC_MAGIC_UNLOAD_SIGNAL 0x4141504C + typedef enum { VPROC_GSK_LAST_EXIT_STATUS = 1, VPROC_GSK_GLOBAL_ON_DEMAND, Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2007-07-11 18:10:33 UTC (rev 23303) +++ trunk/launchd/src/protocol_job.defs 2007-07-11 22:11:37 UTC (rev 23304) @@ -70,6 +70,7 @@ routine send_signal( __bs_port : job_t; + sreplyport __rport : mach_port_make_send_once_t; __label : name_t; __signal : integer_t); Modified: trunk/launchd/src/protocol_job_reply.defs =================================================================== --- trunk/launchd/src/protocol_job_reply.defs 2007-07-11 18:10:33 UTC (rev 23303) +++ trunk/launchd/src/protocol_job_reply.defs 2007-07-11 22:11:37 UTC (rev 23304) @@ -37,7 +37,9 @@ skip; /* look_up */ -skip; /* send_signal */ +simpleroutine job_mig_send_signal_reply( + __r_port : mach_port_move_send_once_t; + __result : kern_return_t, RetCode); skip; /* parent */ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070711/f0bd95db/attachment.html From source_changes at macosforge.org Wed Jul 11 15:29:16 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23305] trunk/launchd/src/launchd_runtime.c Message-ID: <20070711222916.C489A6C80B0@cvs.opensource.apple.com> Revision: 23305 http://trac.macosforge.org/projects/launchd/changeset/23305 Author: zarzycki@apple.com Date: 2007-07-11 15:29:16 -0700 (Wed, 11 Jul 2007) Log Message: ----------- Leopard9A491: After Installing 9A491 the system froze at restart in the installer. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-07-11 22:11:37 UTC (rev 23304) +++ trunk/launchd/src/launchd_runtime.c 2007-07-11 22:29:16 UTC (rev 23305) @@ -1195,6 +1195,7 @@ runtime_log_uncork_pending_drain(void) { mach_msg_type_number_t outvalCnt; + mach_port_t tmp_port; vm_offset_t outval; if (!drain_reply_port) { @@ -1209,12 +1210,13 @@ return; } - if (!launchd_assumes(job_mig_log_drain_reply(drain_reply_port, 0, outval, outvalCnt) == 0)) { - launchd_assumes(launchd_mport_deallocate(drain_reply_port) == KERN_SUCCESS); + tmp_port = drain_reply_port; + drain_reply_port = MACH_PORT_NULL; + + if (!launchd_assumes(job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt) == 0)) { + launchd_assumes(launchd_mport_deallocate(tmp_port) == KERN_SUCCESS); } - drain_reply_port = MACH_PORT_NULL; - mig_deallocate(outval, outvalCnt); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070711/81c11796/attachment.html From source_changes at macosforge.org Wed Jul 11 16:16:02 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23306] tags/launchd-228/ Message-ID: <20070711231602.B8CCD6C81A8@cvs.opensource.apple.com> Revision: 23306 http://trac.macosforge.org/projects/launchd/changeset/23306 Author: zarzycki@apple.com Date: 2007-07-11 16:16:02 -0700 (Wed, 11 Jul 2007) Log Message: ----------- "Tagging launchd-228 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-228/ Copied: tags/launchd-228 (from rev 23305, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070711/96c0e3b2/attachment.html From source_changes at macosforge.org Thu Jul 12 13:05:48 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23307] trunk/launchd/src/libvproc.c Message-ID: <20070712200548.0C3406CA13B@cvs.opensource.apple.com> Revision: 23307 http://trac.macosforge.org/projects/launchd/changeset/23307 Author: zarzycki@apple.com Date: 2007-07-12 13:05:47 -0700 (Thu, 12 Jul 2007) Log Message: ----------- 9A491: syslogd crashed 12 times in _vprocmgr_log_drain Modified Paths: -------------- trunk/launchd/src/libvproc.c Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-07-11 23:16:02 UTC (rev 23306) +++ trunk/launchd/src/libvproc.c 2007-07-12 20:05:47 UTC (rev 23307) @@ -395,7 +395,7 @@ vproc_err_t _vprocmgr_log_drain(vproc_t vp __attribute__((unused)), pthread_mutex_t *mutex, _vprocmgr_log_drain_callback_t func) { - mach_msg_type_number_t outdata_cnt; + mach_msg_type_number_t outdata_cnt, tmp_cnt; vm_offset_t outdata = 0; struct logmsg_s *lm; @@ -407,17 +407,22 @@ return _vprocmgr_log_drain; } + tmp_cnt = outdata_cnt; + if (mutex) { pthread_mutex_lock(mutex); } - for (lm = (struct logmsg_s *)outdata; lm->obj_sz; lm = ((void *)lm + lm->obj_sz)) { + for (lm = (struct logmsg_s *)outdata; tmp_cnt > 0; lm = ((void *)lm + lm->obj_sz)) { lm->from_name += (size_t)lm; lm->about_name += (size_t)lm; lm->msg += (size_t)lm; lm->session_name += (size_t)lm; - func(&lm->when, lm->from_pid, lm->about_pid, lm->sender_uid, lm->sender_gid, lm->pri, lm->from_name, lm->about_name, lm->session_name, lm->msg); + func(&lm->when, lm->from_pid, lm->about_pid, lm->sender_uid, lm->sender_gid, lm->pri, + lm->from_name, lm->about_name, lm->session_name, lm->msg); + + tmp_cnt -= lm->obj_sz; } if (mutex) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070712/f84d7f8e/attachment.html From source_changes at macosforge.org Thu Jul 12 13:43:09 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23308] trunk/launchd/src Message-ID: <20070712204309.082F66CA206@cvs.opensource.apple.com> Revision: 23308 http://trac.macosforge.org/projects/launchd/changeset/23308 Author: zarzycki@apple.com Date: 2007-07-12 13:43:08 -0700 (Thu, 12 Jul 2007) Log Message: ----------- launchd dynamic enable/disable of services based on machine Modified Paths: -------------- trunk/launchd/src/launchctl.c trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-07-12 20:05:47 UTC (rev 23307) +++ trunk/launchd/src/launchctl.c 2007-07-12 20:43:08 UTC (rev 23308) @@ -20,6 +20,13 @@ static const char *const __rcs_file_version__ = "$Revision$"; +#include "liblaunch_public.h" +#include "liblaunch_private.h" +#include "libbootstrap_public.h" +#include "libvproc_public.h" +#include "libvproc_private.h" +#include "libvproc_internal.h" + #include #include #include @@ -65,12 +72,6 @@ #include #include -#include "libbootstrap_public.h" -#include "libvproc_public.h" -#include "libvproc_private.h" -#include "libvproc_internal.h" -#include "liblaunch_public.h" -#include "liblaunch_private.h" #define LAUNCH_SECDIR "/tmp/launch-XXXXXX" @@ -143,6 +144,7 @@ static void do_single_user_mode(bool); static bool do_single_user_mode2(void); static void read_launchd_conf(void); +static bool job_disabled_logic(launch_data_t obj); typedef enum { BOOTCACHE_START = 1, @@ -612,7 +614,7 @@ } if ((tmpd = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_DISABLED))) { - job_disabled = launch_data_get_bool(tmpd); + job_disabled = job_disabled_logic(tmpd); } if (lus->forceload) { @@ -641,7 +643,62 @@ launch_data_free(thejob); } +static bool +sysctl_hw_streq(int mib_slot, const char *str) +{ + char buf[1000]; + size_t bufsz = sizeof(buf); + int mib[] = { CTL_HW, mib_slot }; + + if (sysctl(mib, 2, buf, &bufsz, NULL, 0) != -1) { + if (strcmp(buf, str) == 0) { + return true; + } + } + + return false; +} + +static void +job_disabled_dict_logic(launch_data_t obj, const char *key, void *context) +{ + bool *r = context; + + if (launch_data_get_type(obj) != LAUNCH_DATA_STRING) { + return; + } + + if (strcasecmp(key, LAUNCH_JOBKEY_DISABLED_MACHINETYPE) == 0) { + if (sysctl_hw_streq(HW_MACHINE, launch_data_get_string(obj))) { + *r = true; + } + } else if (strcasecmp(key, LAUNCH_JOBKEY_DISABLED_MODELNAME) == 0) { + if (sysctl_hw_streq(HW_MODEL, launch_data_get_string(obj))) { + *r = true; + } + } +} + bool +job_disabled_logic(launch_data_t obj) +{ + bool r = false; + + switch (launch_data_get_type(obj)) { + case LAUNCH_DATA_DICTIONARY: + launch_data_dict_iterate(obj, job_disabled_dict_logic, &r); + break; + case LAUNCH_DATA_BOOL: + r = launch_data_get_bool(obj); + break; + default: + break; + } + + return r; +} + +bool path_goodness_check(const char *path, bool forceload) { struct stat sb; Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2007-07-12 20:05:47 UTC (rev 23307) +++ trunk/launchd/src/liblaunch_public.h 2007-07-12 20:43:08 UTC (rev 23308) @@ -126,6 +126,9 @@ #define LAUNCH_JOBKEY_RESOURCELIMIT_RSS "ResidentSetSize" #define LAUNCH_JOBKEY_RESOURCELIMIT_STACK "Stack" +#define LAUNCH_JOBKEY_DISABLED_MACHINETYPE "MachineType" +#define LAUNCH_JOBKEY_DISABLED_MODELNAME "ModelName" + #define LAUNCH_JOBSOCKETKEY_TYPE "SockType" #define LAUNCH_JOBSOCKETKEY_PASSIVE "SockPassive" #define LAUNCH_JOBSOCKETKEY_BONJOUR "Bonjour" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070712/b4db26ff/attachment.html From source_changes at macosforge.org Thu Jul 12 16:00:50 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23309] tags/launchd-229/ Message-ID: <20070712230050.5F89F6CA498@cvs.opensource.apple.com> Revision: 23309 http://trac.macosforge.org/projects/launchd/changeset/23309 Author: zarzycki@apple.com Date: 2007-07-12 16:00:49 -0700 (Thu, 12 Jul 2007) Log Message: ----------- "Tagging launchd-229 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-229/ Copied: tags/launchd-229 (from rev 23308, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070712/63e21018/attachment.html From source_changes at macosforge.org Mon Jul 16 08:47:32 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23310] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070716154732.45FAA6D142C@cvs.opensource.apple.com> Revision: 23310 http://trac.macosforge.org/projects/launchd/changeset/23310 Author: zarzycki@apple.com Date: 2007-07-16 08:47:31 -0700 (Mon, 16 Jul 2007) Log Message: ----------- clarity++ Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-12 23:00:49 UTC (rev 23309) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-16 15:47:31 UTC (rev 23310) @@ -2607,6 +2607,17 @@ return; } + /* + * We must copy the results of getpw*(). + * + * Why? Because subsequent API calls may call getpw*() as a part of + * their implementation. Since getpw*() returns a [now thread scoped] + * global, we must therefore cache the results before continuing. + */ + + desired_uid = pwe->pw_uid; + desired_gid = pwe->pw_gid; + strlcpy(shellpath, pwe->pw_shell, sizeof(shellpath)); strlcpy(loginname, pwe->pw_name, sizeof(loginname)); strlcpy(homedir, pwe->pw_dir, sizeof(homedir)); @@ -2616,8 +2627,6 @@ _exit(EXIT_FAILURE); } - desired_uid = pwe->pw_uid; - desired_gid = pwe->pw_gid; if (j->username && strcmp(j->username, loginname) != 0) { job_log(j, LOG_WARNING, "Suspicious setup: User \"%s\" maps to user: %s", j->username, loginname); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/9e8e104c/attachment.html From source_changes at macosforge.org Mon Jul 16 09:46:33 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23311] trunk/launchd/src/launchctl.c Message-ID: <20070716164633.731016D15CA@cvs.opensource.apple.com> Revision: 23311 http://trac.macosforge.org/projects/launchd/changeset/23311 Author: zarzycki@apple.com Date: 2007-07-16 09:46:32 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Bug: launchctl.c:452 (23304):25: _vproc_send_signal_by_label(launch_data_get_string(tmps), VPROC_MAGIC_UNLOAD_SIGNAL) == NULL Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-07-16 15:47:31 UTC (rev 23310) +++ trunk/launchd/src/launchctl.c 2007-07-16 16:46:32 UTC (rev 23311) @@ -451,7 +451,9 @@ return; } - assumes(_vproc_send_signal_by_label(launch_data_get_string(tmps), VPROC_MAGIC_UNLOAD_SIGNAL) == NULL); + if (_vproc_send_signal_by_label(launch_data_get_string(tmps), VPROC_MAGIC_UNLOAD_SIGNAL) != NULL) { + fprintf(stderr, "%s: Error unloading: %s\n", getprogname(), launch_data_get_string(tmps)); + } } launch_data_t -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/4e4e34f6/attachment.html From source_changes at macosforge.org Mon Jul 16 09:54:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23312] trunk/launchd/src/launchctl.c Message-ID: <20070716165429.D7BD96D16FB@cvs.opensource.apple.com> Revision: 23312 http://trac.macosforge.org/projects/launchd/changeset/23312 Author: zarzycki@apple.com Date: 2007-07-16 09:54:29 -0700 (Mon, 16 Jul 2007) Log Message: ----------- launchctl needs to target root boostrap when run as root Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-07-16 16:46:32 UTC (rev 23311) +++ trunk/launchd/src/launchctl.c 2007-07-16 16:54:29 UTC (rev 23312) @@ -216,8 +216,16 @@ int main(int argc, char *const argv[]) { + int64_t is_managed = 0; char *l; + if ((getuid() == 0) && (vproc_swap_integer(NULL, VPROC_GSK_IS_MANAGED, NULL, &is_managed) == NULL) && (is_managed == 0)) { + mach_port_t root_bs = str2bsport("/"); + task_set_bootstrap_port(mach_task_self(), root_bs); + mach_port_deallocate(mach_task_self(), bootstrap_port); + bootstrap_port = root_bs; + } + istty = isatty(STDIN_FILENO); argc--, argv++; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/ce426401/attachment.html From source_changes at macosforge.org Mon Jul 16 10:21:16 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23313] trunk/launchd/src Message-ID: <20070716172116.C6CBB6D1980@cvs.opensource.apple.com> Revision: 23313 http://trac.macosforge.org/projects/launchd/changeset/23313 Author: zarzycki@apple.com Date: 2007-07-16 10:21:16 -0700 (Mon, 16 Jul 2007) Log Message: ----------- launchd-shutdown.log lost most of its informative value Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-07-16 16:54:29 UTC (rev 23312) +++ trunk/launchd/src/launchd.c 2007-07-16 17:21:16 UTC (rev 23313) @@ -262,6 +262,7 @@ * When this changes to a more sustainable API, update this: * http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown */ + runtime_setlogmask(LOG_UPTO(LOG_DEBUG)); prep_shutdown_log_dir(); debug_shutdown_hangs = true; } Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-07-16 16:54:29 UTC (rev 23312) +++ trunk/launchd/src/launchd_runtime.c 2007-07-16 17:21:16 UTC (rev 23313) @@ -1084,9 +1084,11 @@ prev_msg = tvnow; - snprintf(newmsg, sizeof(newmsg), "%3ld.%06d\t%ld.%06d\t", + snprintf(newmsg, sizeof(newmsg), "%3ld.%06d%4ld.%06d%6u %-40s%6u %-40s ", tvd_total.tv_sec, tvd_total.tv_usec, - tvd_msg_delta.tv_sec, tvd_msg_delta.tv_usec); + tvd_msg_delta.tv_sec, tvd_msg_delta.tv_usec, + attr->from_pid, attr->from_name, + attr->about_pid, attr->about_name); for (i = 0, j = strlen(newmsg); message[i];) { if (message[i] == '%' && message[i + 1] == 'm') { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/c55f2257/attachment.html From source_changes at macosforge.org Mon Jul 16 14:36:45 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23314] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070716213645.0672B6D232A@cvs.opensource.apple.com> Revision: 23314 http://trac.macosforge.org/projects/launchd/changeset/23314 Author: zarzycki@apple.com Date: 2007-07-16 14:36:44 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Bug: launchd_core_logic.c:5095 (23304):8: (errno = task_set_special_port(child_task, ms->special_port_num, ms->port)) == KERN_SUCCESS Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-16 17:21:16 UTC (rev 23313) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-16 21:36:44 UTC (rev 23314) @@ -5101,7 +5101,24 @@ /* The TASK_ACCESS_PORT funny business is to workaround 5325399. */ continue; } - job_assumes(j, (errno = task_set_special_port(child_task, ms->special_port_num, ms->port)) == KERN_SUCCESS); + + errno = task_set_special_port(child_task, ms->special_port_num, ms->port); + + if (errno) { + int desired_log_devel = LOG_ERR; + + if (j->anonymous) { + /* 5338127 */ + + desired_log_devel = LOG_WARNING; + + if (ms->special_port_num == TASK_SEATBELT_PORT) { + desired_log_devel = LOG_DEBUG; + } + } + + job_log(j, desired_log_devel, "Could not setup Mach task special port %u: %s", ms->special_port_num, mach_error_string(errno)); + } } job_assumes(j, launchd_mport_deallocate(child_task) == KERN_SUCCESS); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/eb6ee670/attachment.html From source_changes at macosforge.org Mon Jul 16 14:37:00 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23315] tags/launchd-230/ Message-ID: <20070716213700.0ED2F6D232E@cvs.opensource.apple.com> Revision: 23315 http://trac.macosforge.org/projects/launchd/changeset/23315 Author: zarzycki@apple.com Date: 2007-07-16 14:36:59 -0700 (Mon, 16 Jul 2007) Log Message: ----------- "Tagging launchd-230 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-230/ Copied: tags/launchd-230 (from rev 23314, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/8e82ea36/attachment.html From source_changes at macosforge.org Tue Jul 17 08:46:30 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:50 2007 Subject: [launchd-changes] [23316] trunk/launchd/src Message-ID: <20070717154630.1E9C36D8B86@cvs.opensource.apple.com> Revision: 23316 http://trac.macosforge.org/projects/launchd/changeset/23316 Author: zarzycki@apple.com Date: 2007-07-17 08:46:29 -0700 (Tue, 17 Jul 2007) Log Message: ----------- Possible Error Messages in System Log: Couldn't stat(/etc/mach_init_per_login_session.d) Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-07-16 21:36:59 UTC (rev 23315) +++ trunk/launchd/src/Makefile.am 2007-07-17 15:46:29 UTC (rev 23316) @@ -77,6 +77,7 @@ mkdir -p $(DESTDIR)/usr/local/include mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d + mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_login_session.d mkdir -p $(DESTDIR)/Library/LaunchDaemons mkdir -p $(DESTDIR)/Library/LaunchAgents mkdir -p $(DESTDIR)/System/Library/LaunchAgents Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-07-16 21:36:59 UTC (rev 23315) +++ trunk/launchd/src/Makefile.in 2007-07-17 15:46:29 UTC (rev 23316) @@ -1150,6 +1150,7 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/local/include @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)/$(sysconfdir)/mach_init_per_login_session.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchDaemons @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchAgents @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchAgents -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070717/24edb546/attachment.html From source_changes at macosforge.org Tue Jul 17 12:03:05 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23317] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070717190305.3A23B6D95D6@cvs.opensource.apple.com> Revision: 23317 http://trac.macosforge.org/projects/launchd/changeset/23317 Author: zarzycki@apple.com Date: 2007-07-17 12:03:04 -0700 (Tue, 17 Jul 2007) Log Message: ----------- Typo. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-17 15:46:29 UTC (rev 23316) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-17 19:03:04 UTC (rev 23317) @@ -5105,19 +5105,19 @@ errno = task_set_special_port(child_task, ms->special_port_num, ms->port); if (errno) { - int desired_log_devel = LOG_ERR; + int desired_log_level = LOG_ERR; if (j->anonymous) { /* 5338127 */ - desired_log_devel = LOG_WARNING; + desired_log_level = LOG_WARNING; if (ms->special_port_num == TASK_SEATBELT_PORT) { - desired_log_devel = LOG_DEBUG; + desired_log_level = LOG_DEBUG; } } - job_log(j, desired_log_devel, "Could not setup Mach task special port %u: %s", ms->special_port_num, mach_error_string(errno)); + job_log(j, desired_log_level, "Could not setup Mach task special port %u: %s", ms->special_port_num, mach_error_string(errno)); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070717/7cf4fdd0/attachment.html From source_changes at macosforge.org Tue Jul 17 14:55:52 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23318] tags/launchd-231/ Message-ID: <20070717215552.B29B46D9D2E@cvs.opensource.apple.com> Revision: 23318 http://trac.macosforge.org/projects/launchd/changeset/23318 Author: zarzycki@apple.com Date: 2007-07-17 14:55:52 -0700 (Tue, 17 Jul 2007) Log Message: ----------- "Tagging launchd-231 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-231/ Copied: tags/launchd-231 (from rev 23317, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070717/d3dce52e/attachment.html From source_changes at macosforge.org Fri Jul 27 10:59:56 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23319] trunk/launchd/src Message-ID: <20070727175956.DE5D3702BD0@cvs.opensource.apple.com> Revision: 23319 http://trac.macosforge.org/projects/launchd/changeset/23319 Author: zarzycki@apple.com Date: 2007-07-27 10:59:56 -0700 (Fri, 27 Jul 2007) Log Message: ----------- kinit fails with Internal credentials cache error when run by root user over ssh Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-07-17 21:55:52 UTC (rev 23318) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-27 17:59:56 UTC (rev 23319) @@ -5659,6 +5659,12 @@ kr = BOOTSTRAP_NOT_PRIVILEGED; goto out; } + } else if (ldc.uid == 0 && getpid() == 1 && strcmp(session_type, VPROCMGR_SESSION_STANDARDIO) == 0) { + ensure_root_bkgd_setup(); + + SLIST_REMOVE(&j->mgr->parentmgr->submgrs, j->mgr, jobmgr_s, sle); + j->mgr->parentmgr = background_jobmgr; + SLIST_INSERT_HEAD(&j->mgr->parentmgr->submgrs, j->mgr, sle); } jobmgr_log(j->mgr, LOG_DEBUG, "Renaming to: %s", session_type); Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-07-17 21:55:52 UTC (rev 23318) +++ trunk/launchd/src/libvproc.c 2007-07-27 17:59:56 UTC (rev 23319) @@ -99,8 +99,7 @@ _vprocmgr_move_subset_to_user(uid_t target_user, const char *session_type) { launch_data_t output_obj; - kern_return_t kr = 1; - mach_port_t puc = 0, rootbs = get_root_bootstrap_port(); + kern_return_t kr = 0; bool is_bkgd = (strcmp(session_type, VPROCMGR_SESSION_BACKGROUND) == 0); int64_t ldpid, lduid; @@ -112,18 +111,6 @@ return (vproc_err_t)_vprocmgr_move_subset_to_user; } - if (target_user == 0) { - if (ldpid == 1 && rootbs != bootstrap_port) { - return _vprocmgr_init(session_type); - } - - task_set_bootstrap_port(mach_task_self(), rootbs); - mach_port_deallocate(mach_task_self(), bootstrap_port); - bootstrap_port = rootbs; - - return NULL; - } - if (ldpid != 1) { if (lduid == getuid()) { return NULL; @@ -135,22 +122,23 @@ return (vproc_err_t)_vprocmgr_move_subset_to_user; } - if (vproc_mig_lookup_per_user_context(rootbs, target_user, &puc) != 0) { - return (vproc_err_t)_vprocmgr_move_subset_to_user; - } + if (is_bkgd || target_user) { + mach_port_t puc = 0, rootbs = get_root_bootstrap_port(); - if (is_bkgd) { - kr = 0; - } else { - kr = vproc_mig_move_subset(puc, bootstrap_port, (char *)session_type); - } + if (vproc_mig_lookup_per_user_context(rootbs, target_user, &puc) != 0) { + return (vproc_err_t)_vprocmgr_move_subset_to_user; + } - if (is_bkgd) { - task_set_bootstrap_port(mach_task_self(), puc); - mach_port_deallocate(mach_task_self(), bootstrap_port); - bootstrap_port = puc; + if (is_bkgd) { + task_set_bootstrap_port(mach_task_self(), puc); + mach_port_deallocate(mach_task_self(), bootstrap_port); + bootstrap_port = puc; + } else { + kr = vproc_mig_move_subset(puc, bootstrap_port, (char *)session_type); + mach_port_deallocate(mach_task_self(), puc); + } } else { - mach_port_deallocate(mach_task_self(), puc); + kr = _vprocmgr_init(session_type) ? 1 : 0; } cached_pid = -1; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070727/135c7247/attachment.html From source_changes at macosforge.org Fri Jul 27 15:25:56 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23320] tags/launchd-232/ Message-ID: <20070727222556.44ADD703BDA@cvs.opensource.apple.com> Revision: 23320 http://trac.macosforge.org/projects/launchd/changeset/23320 Author: zarzycki@apple.com Date: 2007-07-27 15:25:55 -0700 (Fri, 27 Jul 2007) Log Message: ----------- "Tagging launchd-232 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-232/ Copied: tags/launchd-232 (from rev 23319, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070727/b91e4206/attachment.html From source_changes at macosforge.org Mon Jul 30 08:15:13 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23321] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070730151513.740FB70FDBF@cvs.opensource.apple.com> Revision: 23321 http://trac.macosforge.org/projects/launchd/changeset/23321 Author: zarzycki@apple.com Date: 2007-07-30 08:15:12 -0700 (Mon, 30 Jul 2007) Log Message: ----------- ARD Agent not starting when logging in as 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 2007-07-27 22:25:55 UTC (rev 23320) +++ trunk/launchd/src/launchd_core_logic.c 2007-07-30 15:15:12 UTC (rev 23321) @@ -1730,6 +1730,10 @@ job_t ji; LIST_FOREACH(ji, &label_hash[hash_label(label)], label_hash_sle) { + if (ji->removal_pending) { + continue; /* 5351245 */ + } + if (strcmp(ji->label, label) == 0) { return ji; } @@ -5647,6 +5651,12 @@ j->mgr->parentmgr = background_jobmgr; SLIST_INSERT_HEAD(&j->mgr->parentmgr->submgrs, j->mgr, sle); + /* + * We really should wait for all the jobs to die before proceeding. See 5351245 for more info. + * + * We have hacked around this in job_find() by ignoring jobs that are pending removal. + */ + } else if (strcmp(j->mgr->name, VPROCMGR_SESSION_AQUA) == 0) { return 0; } else { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070730/adce1345/attachment.html From source_changes at macosforge.org Mon Jul 30 10:43:00 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23322] trunk/launchd/src/launchd.c Message-ID: <20070730174300.D3225710382@cvs.opensource.apple.com> Revision: 23322 http://trac.macosforge.org/projects/launchd/changeset/23322 Author: zarzycki@apple.com Date: 2007-07-30 10:43:00 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Force dyld to resolve certain symbols at launch rather than lazily. Modified Paths: -------------- trunk/launchd/src/launchd.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-07-30 15:15:12 UTC (rev 23321) +++ trunk/launchd/src/launchd.c 2007-07-30 17:43:00 UTC (rev 23322) @@ -179,6 +179,11 @@ #define PID1_CRASH_LOGFILE "/var/log/launchd-pid1.crash" +/* This hack forces the dynamic linker to resolve these symbols ASAP */ +static __attribute__((unused)) typeof(sync) *__junk_dyld_trick1 = sync; +static __attribute__((unused)) typeof(sleep) *__junk_dyld_trick2 = sleep; +static __attribute__((unused)) typeof(reboot) *__junk_dyld_trick3 = reboot; + void fatal_signal_handler(int sig, siginfo_t *si, void *uap) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070730/ebacc580/attachment.html From source_changes at macosforge.org Mon Jul 30 15:05:15 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:51 2007 Subject: [launchd-changes] [23323] tags/launchd-233/ Message-ID: <20070730220515.674DA711370@cvs.opensource.apple.com> Revision: 23323 http://trac.macosforge.org/projects/launchd/changeset/23323 Author: zarzycki@apple.com Date: 2007-07-30 15:05:14 -0700 (Mon, 30 Jul 2007) Log Message: ----------- "Tagging launchd-233 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-233/ Copied: tags/launchd-233 (from rev 23322, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070730/f874ca8b/attachment.html