From f70834ee277faaa833845b86850fa6a18afa634f Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 17 May 2012 20:31:20 +0000 Subject: [PATCH] launchd-392.38.tar.gz --- launchd/src/launchctl.c | 23 +++++++++++++++++++++-- launchd/src/launchd_core_logic.c | 13 +++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/launchd/src/launchctl.c b/launchd/src/launchctl.c index 25b3b3f..8510c9f 100644 --- a/launchd/src/launchctl.c +++ b/launchd/src/launchctl.c @@ -18,7 +18,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ -static const char *const __rcs_file_version__ = "$Revision: 25182 $"; +static const char *const __rcs_file_version__ = "$Revision: 25957 $"; #include "config.h" #include "launch.h" @@ -479,6 +479,16 @@ CFPropertyListRef CFPropertyListCreateFromFile(CFURLRef plistURL) return plist; } +static void +sanitize_environment_dot_plist(const launch_data_t val, const char *key, void *ctx) +{ + launch_data_t copy = (launch_data_t)ctx; + if (strncmp("DYLD_", key, sizeof("DYLD_") - 1) != 0) { + launch_data_t copyi = launch_data_copy(val); + launch_data_dict_insert(copy, copyi, key); + } +} + #define CFReleaseIfNotNULL(cf) if (cf) CFRelease(cf); void read_environment_dot_plist(void) @@ -516,13 +526,22 @@ read_environment_dot_plist(void) if (!assumes(launch_env_dict != NULL)) { goto out; } + + launch_data_t sanitized = launch_data_alloc(LAUNCH_DATA_DICTIONARY); + if (!assumes(sanitized != NULL)) { + goto out; + } + + launch_data_dict_iterate(launch_env_dict, sanitize_environment_dot_plist, sanitized); + launch_data_free(launch_env_dict); req = launch_data_alloc(LAUNCH_DATA_DICTIONARY); if (!assumes(req != NULL)) { goto out; } - launch_data_dict_insert(req, launch_env_dict, LAUNCH_KEY_SETUSERENVIRONMENT); + launch_data_dict_insert(req, sanitized, LAUNCH_KEY_SETUSERENVIRONMENT); + resp = launch_msg(req); if (!assumes(resp != NULL)) { goto out; diff --git a/launchd/src/launchd_core_logic.c b/launchd/src/launchd_core_logic.c index d1023a7..3b86e0f 100644 --- a/launchd/src/launchd_core_logic.c +++ b/launchd/src/launchd_core_logic.c @@ -16,7 +16,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ -static const char *const __rcs_file_version__ = "$Revision: 25397 $"; +static const char *const __rcs_file_version__ = "$Revision: 25693 $"; #include "config.h" #include "launchd_core_logic.h" @@ -10061,7 +10061,16 @@ xpc_events_find_channel(job_t j, event_name_t stream, mach_port_t *p) msi->event_channel = true; *p = sp; - (void)job_dispatch(j, false); + /* If we call job_dispatch() here before the audit session for the + * job has been set, we'll end up not watching this service. But we + * also have to take care not to watch the port if the job is + * active. + * + * See . + */ + if (!j->currently_ignored) { + machservice_watch(j, msi); + } } else { errno = BOOTSTRAP_NO_MEMORY; } -- 2.45.2