From source_changes at macosforge.org Wed Jan 9 09:30:05 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 9 09:30:07 2008 Subject: [launchd-changes] [23477] trunk/launchd/src Message-ID: <20080109173005.0A0C5D8FEB08@lists.macosforge.org> Revision: 23477 http://trac.macosforge.org/projects/launchd/changeset/23477 Author: zarzycki@apple.com Date: 2008-01-09 09:30:02 -0800 (Wed, 09 Jan 2008) Log Message: ----------- Misc branch hints. Modified Paths: -------------- trunk/launchd/src/launchctl.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-12-21 21:53:37 UTC (rev 23476) +++ trunk/launchd/src/launchctl.c 2008-01-09 17:30:02 UTC (rev 23477) @@ -1475,6 +1475,7 @@ assumes(load_and_unload_cmd(4, load_launchd_items) == 0); +#ifdef __ppc__ /* * 5066316 * @@ -1483,7 +1484,7 @@ * I want a plist defined knob for jobs to give advisory hints that * will "hopefully" serialize bootstrap. Reasons for doing so include * pragmatic performance optimizations and attempts to workaround bugs - * in jobs. My current thought is something like what follows. + * in jobs. Something like what follows might work: * * The BootCache would switch to launchd and add this to the plist: * @@ -1519,6 +1520,7 @@ */ mach_timespec_t w = { 5, 0 }; IOKitWaitQuiet(kIOMasterPortDefault, &w); +#endif do_BootCache_magic(BOOTCACHE_TAG); Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-12-21 21:53:37 UTC (rev 23476) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-09 17:30:02 UTC (rev 23477) @@ -275,7 +275,7 @@ }; #define jobmgr_assumes(jm, e) \ - (__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) + (likely(e) ? true : jobmgr_log_bug(jm, __LINE__), false) static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); static job_t jobmgr_import2(jobmgr_t jm, launch_data_t pload); @@ -296,7 +296,7 @@ static void jobmgr_logv(jobmgr_t jm, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0))); static void jobmgr_log(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); /* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */ -static void jobmgr_log_bug(jobmgr_t jm, const char *rcs_rev, const char *path, unsigned int line, const char *test); +static void jobmgr_log_bug(jobmgr_t jm, unsigned int line); #define DO_RUSAGE_SUMMATION 0 @@ -373,7 +373,7 @@ #define job_assumes(j, e) \ - (__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) + (likely(e) ? true : job_log_bug(j, __LINE__), false) static void job_import_keys(launch_data_t obj, const char *key, void *context); static void job_import_bool(job_t j, const char *key, bool value); @@ -415,7 +415,7 @@ static void job_log_stdouterr(job_t j); 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_bug(job_t j, unsigned int line); 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); @@ -1266,7 +1266,7 @@ { job_t j = jobmgr_import2(root_jobmgr, pload); - if (j == NULL) { + if (unlikely(j == NULL)) { return NULL; } @@ -1283,17 +1283,16 @@ ja = alloca(c * sizeof(job_t )); for (i = 0; i < c; i++) { - if ((ja[i] = jobmgr_import2(root_jobmgr, launch_data_array_get_index(pload, i)))) { + if (likely(ja[i] = jobmgr_import2(root_jobmgr, launch_data_array_get_index(pload, i)))) { errno = 0; } launch_data_array_set_index(resp, launch_data_new_errno(errno), i); } for (i = 0; i < c; i++) { - if (ja[i] == NULL) { - continue; + if (likely(ja[i])) { + job_dispatch(ja[i], false); } - job_dispatch(ja[i], false); } return resp; @@ -1804,22 +1803,22 @@ return NULL; } - if (launch_data_get_type(pload) != LAUNCH_DATA_DICTIONARY) { + if (unlikely(launch_data_get_type(pload) != LAUNCH_DATA_DICTIONARY)) { errno = EINVAL; return NULL; } - if (!(tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_LABEL))) { + if (unlikely(!(tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_LABEL)))) { errno = EINVAL; return NULL; } - if (launch_data_get_type(tmp) != LAUNCH_DATA_STRING) { + if (unlikely(launch_data_get_type(tmp) != LAUNCH_DATA_STRING)) { errno = EINVAL; return NULL; } - if (!(label = launch_data_get_string(tmp))) { + if (unlikely(!(label = launch_data_get_string(tmp)))) { errno = EINVAL; return NULL; } @@ -1858,15 +1857,15 @@ if (unlikely((j = job_find(label)) != NULL)) { errno = EEXIST; return NULL; - } else if (label[0] == '\0' || (strncasecmp(label, "", strlen("com.apple.launchd")) == 0) || - (strtol(label, NULL, 10) != 0)) { + } else if (unlikely(label[0] == '\0' || (strncasecmp(label, "", strlen("com.apple.launchd")) == 0) || + (strtol(label, NULL, 10) != 0))) { jobmgr_log(jm, LOG_ERR, "Somebody attempted to use a reserved prefix for a label: %s", label); /* the empty string, com.apple.launchd and number prefixes for labels are reserved */ errno = EINVAL; return NULL; } - if ((j = job_new(jm, label, prog, argv))) { + if (likely(j = job_new(jm, label, prog, argv))) { launch_data_dict_iterate(pload, job_import_keys, j); } @@ -1959,7 +1958,8 @@ mib[3] = ldc.pid; - if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && jobmgr_assumes(root_jobmgr, len == sizeof(kp))) { + if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) + && jobmgr_assumes(root_jobmgr, len == sizeof(kp))) { jobmgr_log(root_jobmgr, LOG_ERR, "%s() was confused by PID %u UID %u EUID %u Mach Port 0x%x: %s", __func__, ldc.pid, ldc.uid, ldc.euid, p, kp.kp_proc.p_comm); } } @@ -2074,7 +2074,7 @@ job_log(j, LOG_DEBUG, "Reaping"); - if (j->weird_bootstrap) { + if (unlikely(j->weird_bootstrap)) { mach_msg_size_t mxmsgsz = sizeof(union __RequestUnion__job_mig_protocol_vproc_subsystem); if (job_mig_protocol_vproc_subsystem.maxsize > mxmsgsz) { @@ -2295,7 +2295,7 @@ rsz = read(j->log_redirect_fd, buf, BIG_PIPE_SIZE); - if (rsz == 0) { + if (unlikely(rsz == 0)) { job_log(j, LOG_DEBUG, "Standard out/error pipe closed"); close_log_redir = true; } else if (!job_assumes(j, rsz != -1)) { @@ -2312,7 +2312,7 @@ free(buf); - if (close_log_redir) { + if (unlikely(close_log_redir)) { job_assumes(j, runtime_close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; job_dispatch(j, false); @@ -2383,7 +2383,8 @@ struct kinfo_proc kp; size_t len = sizeof(kp); - if (job_assumes(j, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && job_assumes(j, len == sizeof(kp))) { + if (job_assumes(j, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) + && job_assumes(j, len == sizeof(kp))) { char newlabel[1000]; snprintf(newlabel, sizeof(newlabel), "%p.%s", j, kp.kp_proc.p_comm); @@ -3209,39 +3210,55 @@ } void -jobmgr_log_bug(jobmgr_t jm, const char *rcs_rev, const char *path, unsigned int line, const char *test) +jobmgr_log_bug(jobmgr_t jm, unsigned int line) { + static const char *file; int saved_errno = errno; - const char *file = strrchr(path, '/'); char buf[100]; - extract_rcsid_substr(rcs_rev, buf, sizeof(buf)); + extract_rcsid_substr(__rcs_file_version__, buf, sizeof(buf)); if (!file) { - file = path; + file = strrchr(__FILE__, '/'); + if (!file) { + file = __FILE__; + } else { + file += 1; + } + } + + /* the only time 'jm' should not be set is if setting up the first bootstrap fails for some reason */ + if (likely(jm)) { + jobmgr_log(jm, LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } else { - file += 1; + runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } - - jobmgr_log(jm, LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test); } void -job_log_bug(job_t j, const char *rcs_rev, const char *path, unsigned int line, const char *test) +job_log_bug(job_t j, unsigned int line) { + static const char *file; int saved_errno = errno; - const char *file = strrchr(path, '/'); char buf[100]; - extract_rcsid_substr(rcs_rev, buf, sizeof(buf)); + extract_rcsid_substr(__rcs_file_version__, buf, sizeof(buf)); if (!file) { - file = path; + file = strrchr(__FILE__, '/'); + if (!file) { + file = __FILE__; + } else { + file += 1; + } + } + + /* I cannot think of any reason why 'j' should ever be NULL, nor have I ever seen the case in the wild */ + if (likely(j)) { + job_log(j, LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } else { - file += 1; + runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } - - job_log(j, LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test); } void @@ -3417,7 +3434,7 @@ job_assumes(j, runtime_close(si->fd) == 0); si->fd = -1; } - } while ((si->fd == -1) && (saved_errno == ENOENT)); + } while (unlikely((si->fd == -1) && (saved_errno == ENOENT))); if (saved_errno == ENOTSUP) { /* @@ -3501,7 +3518,7 @@ struct tm *tmptm = context; int64_t val; - if (LAUNCH_DATA_INTEGER != launch_data_get_type(obj)) { + if (unlikely(LAUNCH_DATA_INTEGER != launch_data_get_type(obj))) { /* hack to let caller know something went wrong */ tmptm->tm_sec = -1; return; @@ -3540,13 +3557,13 @@ return false; } - if (LAUNCH_DATA_DICTIONARY != launch_data_get_type(obj)) { + if (unlikely(LAUNCH_DATA_DICTIONARY != launch_data_get_type(obj))) { return false; } launch_data_dict_iterate(obj, calendarinterval_new_from_obj_dict_walk, &tmptm); - if (tmptm.tm_sec == -1) { + if (unlikely(tmptm.tm_sec == -1)) { return false; } @@ -3591,7 +3608,7 @@ struct calendarinterval *ci = LIST_FIRST(&sorted_calendar_events); time_t now = time(NULL); - if (ci && (ci->when_next < now)) { + if (unlikely(ci && (ci->when_next < now))) { jobmgr_assumes(root_jobmgr, raise(SIGUSR1) != -1); } } @@ -3681,7 +3698,7 @@ char buf[10000]; unsigned int i, buf_off = 0; - if (sg->junkfds) { + if (unlikely(sg->junkfds)) { return; } @@ -3892,6 +3909,7 @@ struct stat sb; bool good_exit = (WIFEXITED(j->last_exit_status) && WEXITSTATUS(j->last_exit_status) == 0); +#ifdef __ppc__ /* * 5066316 * @@ -3901,6 +3919,11 @@ if (j->mgr->global_on_demand_cnt > 0 && strcmp(j->label, "com.apple.kextd") != 0) { return false; } +#else + if (j->mgr->global_on_demand_cnt > 0) { + return false; + } +#endif if (j->start_pending) { job_log(j, LOG_DEBUG, "KeepAlive check: Pent-up non-IPC launch criteria."); @@ -4071,9 +4094,9 @@ struct machservice * machservice_new(job_t j, const char *name, mach_port_t *serviceport, bool pid_local) { - struct machservice *ms; + struct machservice *ms = calloc(1, sizeof(struct machservice) + strlen(name) + 1); - if ((ms = calloc(1, sizeof(struct machservice) + strlen(name) + 1)) == NULL) { + if (!job_assumes(j, ms != NULL)) { return NULL; } @@ -4411,8 +4434,8 @@ } jmr = calloc(1, sizeof(struct jobmgr_s) + (name ? (strlen(name) + 1) : 128)); - - if (jmr == NULL) { + + if (!jobmgr_assumes(jm, jmr != NULL)) { return NULL; } @@ -6677,7 +6700,9 @@ } } - if ((msp = calloc(1, sizeof(struct mspolicy) + strlen(name) + 1)) == NULL) { + msp = calloc(1, sizeof(struct mspolicy) + strlen(name) + 1); + + if (!job_assumes(j, msp != NULL)) { return false; } Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-12-21 21:53:37 UTC (rev 23476) +++ trunk/launchd/src/launchd_runtime.c 2008-01-09 17:30:02 UTC (rev 23477) @@ -186,7 +186,7 @@ for (;;) { kr = mach_msg(&dummy.header, MACH_RCV_MSG|MACH_RCV_LARGE, 0, 0, demand_port_set, 0, MACH_PORT_NULL); - if (kr == MACH_RCV_PORT_CHANGED) { + if (unlikely(kr == MACH_RCV_PORT_CHANGED)) { break; } else if (!launchd_assumes(kr == MACH_RCV_TOO_LARGE)) { continue; @@ -357,7 +357,7 @@ unsigned short flags = kev->flags; unsigned int fflags = kev->fflags; - if (!(LOG_MASK(level) & internal_mask_pri)) { + if (likely(!(LOG_MASK(level) & internal_mask_pri))) { return; } @@ -592,9 +592,7 @@ bulk_kev = kev; - launchd_assumes((bulk_kev_cnt = kevent(fd, NULL, 0, kev, BULK_KEV_MAX, &ts)) != -1); - - if (bulk_kev_cnt > 0) { + if (launchd_assumes((bulk_kev_cnt = kevent(fd, NULL, 0, kev, BULK_KEV_MAX, &ts)) != -1)) { #if 0 Dl_info dli; @@ -631,11 +629,11 @@ int flags = VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE; for (;;) { - if (req) { + if (likely(req)) { launchd_assumes(vm_deallocate(mach_task_self(), (vm_address_t)req, mz) == KERN_SUCCESS); req = NULL; } - if (resp) { + if (likely(resp)) { launchd_assumes(vm_deallocate(mach_task_self(), (vm_address_t)resp, mz) == KERN_SUCCESS); resp = NULL; } @@ -676,7 +674,7 @@ if (which == MACH_NOTIFY_NO_SENDERS) { /* Always make sure the send count is zero, in case a receive right is reused */ errno = mach_port_set_mscount(mach_task_self(), name, 0); - if (errno != KERN_SUCCESS) { + if (unlikely(errno != KERN_SUCCESS)) { return errno; } } @@ -684,7 +682,7 @@ errno = mach_port_request_notification(mach_task_self(), name, which, msgc, where, MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous); - if (errno == 0 && previous != MACH_PORT_NULL) { + if (likely(errno == 0) && previous != MACH_PORT_NULL) { launchd_assumes(launchd_mport_deallocate(previous) == KERN_SUCCESS); } @@ -749,7 +747,7 @@ msg_size = round_page(msg_size + MAX_TRAILER_SIZE); - if (needed_table_sz > mig_cb_table_sz) { + if (unlikely(needed_table_sz > mig_cb_table_sz)) { needed_table_sz *= 2; /* Let's try and avoid realloc'ing for a while */ mig_callback *new_table = malloc(needed_table_sz); @@ -757,7 +755,7 @@ return KERN_RESOURCE_SHORTAGE; } - if (mig_cb_table) { + if (likely(mig_cb_table)) { memcpy(new_table, mig_cb_table, mig_cb_table_sz); free(mig_cb_table); } @@ -960,7 +958,7 @@ 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)) { + if (unlikely(trailer_size < (mach_msg_size_t)sizeof(audit_token_t))) { au_tok = NULL; return; } @@ -971,7 +969,7 @@ bool runtime_get_caller_creds(struct ldcred *ldc) { - if (!au_tok) { + if (unlikely(!au_tok)) { return false; } @@ -999,7 +997,7 @@ for (;;) { to = MACH_MSG_TIMEOUT_NONE; - if (msg_size != max_msg_size) { + if (unlikely(msg_size != max_msg_size)) { /* The buffer isn't big enougth to receive messages anymore... */ tmp_options &= ~MACH_RCV_MSG; options &= ~MACH_RCV_MSG; @@ -1023,13 +1021,13 @@ tmp_options = options; - if (mr == MACH_SEND_INVALID_DEST || mr == MACH_SEND_TIMED_OUT) { + if (unlikely(mr == MACH_SEND_INVALID_DEST || mr == MACH_SEND_TIMED_OUT)) { /* We need to clean up and start over. */ if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) { mach_msg_destroy(&bufReply->Head); } continue; - } else if (mr == MACH_RCV_TIMED_OUT) { + } else if (unlikely(mr == MACH_RCV_TIMED_OUT)) { if (to != MACH_MSG_TIMEOUT_NONE) { if (runtime_busy_cnt == 0) { launchd_shutdown(); @@ -1046,7 +1044,7 @@ bufRequest = bufReply; bufReply = bufTemp; - if (!(tmp_options & MACH_RCV_MSG)) { + if (unlikely(!(tmp_options & MACH_RCV_MSG))) { continue; } @@ -1069,7 +1067,7 @@ * struct to declare our intent. */ static int no_hang_fd = -1; - if (no_hang_fd == -1) { + if (unlikely(no_hang_fd == -1)) { no_hang_fd = _fd(open("/dev/autofs_nowait", 0)); } @@ -1207,7 +1205,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))) { + if (unlikely((lm = calloc(1, lm_sz)) == NULL)) { return false; } @@ -1255,7 +1253,7 @@ mig_allocate(outval, *outvalCnt); - if (*outval == 0) { + if (unlikely(*outval == 0)) { return 1; } @@ -1299,7 +1297,7 @@ tmp_port = drain_reply_port; drain_reply_port = MACH_PORT_NULL; - if ((errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt))) { + if (unlikely(errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt))) { launchd_assumes(errno == MACH_SEND_INVALID_DEST); launchd_assumes(launchd_mport_deallocate(tmp_port) == KERN_SUCCESS); } @@ -1307,7 +1305,16 @@ mig_deallocate(outval, outvalCnt); } +#if 0 void +runtime_kernel_trace(void *code, void *a, void *b, void *c, void *d) +{ + /* Request codes from Joe S. */ + syscall(180 , code, a, b, c, d); +} +#endif + +void runtime_log_push(void) { static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER; @@ -1332,7 +1339,7 @@ return; } - if (shutdown_start == 0) { + if (unlikely(shutdown_start == 0)) { shutdown_start = runtime_get_wall_time(); launchd_log_vm_stats(); } @@ -1340,14 +1347,14 @@ pthread_mutex_lock(&ourlock); - if (ourlogfile == NULL) { + if (unlikely(ourlogfile == NULL)) { rename("/var/log/launchd-shutdown.log", "/var/log/launchd-shutdown.log.1"); ourlogfile = fopen("/var/log/launchd-shutdown.log", "a"); } pthread_mutex_unlock(&ourlock); - if (!ourlogfile) { + if (unlikely(!ourlogfile)) { return; } @@ -1541,7 +1548,7 @@ static int apple_internal_logging = 1; struct stat sb; - if (apple_internal_logging == 1) { + if (unlikely(apple_internal_logging == 1)) { apple_internal_logging = stat("/AppleInternal", &sb); } @@ -1599,4 +1606,3 @@ tbi_float_val = tbi.numer; tbi_float_val /= tbi.denom; } - -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080109/79e086d8/attachment-0001.html From source_changes at macosforge.org Wed Jan 9 09:35:13 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 9 09:35:14 2008 Subject: [launchd-changes] [23478] trunk/launchd/src Message-ID: <20080109173513.8802BD9037E5@lists.macosforge.org> Revision: 23478 http://trac.macosforge.org/projects/launchd/changeset/23478 Author: zarzycki@apple.com Date: 2008-01-09 09:35:12 -0800 (Wed, 09 Jan 2008) Log Message: ----------- More misc. branch hints, plus basic (and untested) "StandardInPath" support. Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2008-01-09 17:30:02 UTC (rev 23477) +++ trunk/launchd/src/launchd.plist.5 2008-01-09 17:35:12 UTC (rev 23478) @@ -226,6 +226,9 @@ .It Sy Month The month on which this job will be run. .El +.It Sy StandardInPath +This optional key specifies what file should be used for data being supplied to stdin when using +.Xr stdio 3 . .It Sy StandardOutPath This optional key specifies what file should be used for data being sent to stdout when using .Xr stdio 3 . Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-09 17:30:02 UTC (rev 23477) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-09 17:35:12 UTC (rev 23478) @@ -331,6 +331,7 @@ char *workingdir; char *username; char *groupname; + char *stdinpath; char *stdoutpath; char *stderrpath; char *alt_exc_handler; @@ -343,7 +344,8 @@ pid_t p; int argc; int last_exit_status; - int forkfd; + int stdin_fd; + int fork_fd; int log_redirect_fd; int nice; unsigned int timeout; @@ -458,7 +460,7 @@ static size_t total_anon_children; static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; -#define JOB_BOOTCACHE_HACK_CHECK(j) (j->per_user && !did_first_per_user_launchd_BootCache_hack && (j->mach_uid >= 500) && (j->mach_uid != (uid_t)-2)) +#define JOB_BOOTCACHE_HACK_CHECK(j) (unlikely(j->per_user && !did_first_per_user_launchd_BootCache_hack && (j->mach_uid >= 500) && (j->mach_uid != (uid_t)-2))) static jobmgr_t background_jobmgr; static job_t workaround_5477111; @@ -576,6 +578,9 @@ if (j->prog && (tmp = launch_data_new_string(j->prog))) { launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_PROGRAM); } + if (j->stdinpath && (tmp = launch_data_new_string(j->stdinpath))) { + launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_STANDARDINPATH); + } if (j->stdoutpath && (tmp = launch_data_new_string(j->stdoutpath))) { launch_data_dict_insert(r, tmp, LAUNCH_JOBKEY_STANDARDOUTPATH); } @@ -810,10 +815,14 @@ job_set_global_on_demand(j, false); } - if (!job_assumes(j, j->forkfd == 0)) { - job_assumes(j, runtime_close(j->forkfd) != -1); + if (!job_assumes(j, j->fork_fd == 0)) { + job_assumes(j, runtime_close(j->fork_fd) != -1); } + if (j->stdin_fd) { + job_assumes(j, runtime_close(j->stdin_fd) != -1); + } + if (!job_assumes(j, j->log_redirect_fd == 0)) { job_assumes(j, runtime_close(j->log_redirect_fd) != -1); } @@ -872,6 +881,9 @@ if (j->groupname) { free(j->groupname); } + if (j->stdinpath) { + free(j->stdinpath); + } if (j->stdoutpath) { free(j->stdoutpath); } @@ -1499,6 +1511,17 @@ where2put = &j->stdoutpath; } else if (strcasecmp(key, LAUNCH_JOBKEY_STANDARDERRORPATH) == 0) { where2put = &j->stderrpath; + } else if (strcasecmp(key, LAUNCH_JOBKEY_STANDARDINPATH) == 0) { + where2put = &j->stdinpath; + j->stdin_fd = _fd(open(value, O_RDONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, DEFFILEMODE)); + if (job_assumes(j, j->stdin_fd != -1)) { + /* open() should not block, but regular IO by the job should */ + job_assumes(j, fcntl(j->stdin_fd, F_SETFL, 0) != -1); + /* XXX -- EV_CLEAR should make named pipes happy? */ + job_assumes(j, kevent_mod(j->stdin_fd, EVFILT_READ, EV_ADD|EV_CLEAR, 0, 0, j) != -1); + } else { + j->stdin_fd = 0; + } } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXPROFILE) == 0) { where2put = &j->seatbelt_profile; } @@ -2094,9 +2117,9 @@ } } - if (j->forkfd) { - job_assumes(j, runtime_close(j->forkfd) != -1); - j->forkfd = 0; + if (j->fork_fd) { + job_assumes(j, runtime_close(j->fork_fd) != -1); + j->fork_fd = 0; } if (j->anonymous) { @@ -2460,6 +2483,8 @@ { if (ident == j->log_redirect_fd) { job_log_stdouterr(j); + } else if (ident == j->stdin_fd) { + job_dispatch(j, true); } else { socketgroup_callback(j); } @@ -2580,7 +2605,7 @@ return; } - if (job_active(j)) { + if (unlikely(job_active(j))) { job_log(j, LOG_DEBUG, "Already started"); return; } @@ -2611,7 +2636,7 @@ j->sent_sigterm_time = 0; - if (!j->legacy_mach_job) { + if (likely(!j->legacy_mach_job)) { sipc = (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices)); } @@ -2623,7 +2648,7 @@ job_assumes(j, socketpair(AF_UNIX, SOCK_STREAM, 0, execspair) != -1); - if (!j->legacy_mach_job && job_assumes(j, pipe(oepair) != -1)) { + if (likely(!j->legacy_mach_job) && job_assumes(j, pipe(oepair) != -1)) { j->log_redirect_fd = _fd(oepair[0]); job_assumes(j, fcntl(j->log_redirect_fd, F_SETFL, O_NONBLOCK) != -1); job_assumes(j, kevent_mod(j->log_redirect_fd, EVFILT_READ, EV_ADD, 0, 0, j) != -1); @@ -2640,14 +2665,14 @@ job_assumes(j, runtime_close(spair[0]) == 0); job_assumes(j, runtime_close(spair[1]) == 0); } - if (!j->legacy_mach_job) { + if (likely(!j->legacy_mach_job)) { job_assumes(j, runtime_close(oepair[0]) != -1); job_assumes(j, runtime_close(oepair[1]) != -1); j->log_redirect_fd = 0; } break; case 0: - if (_vproc_post_fork_ping()) { + if (unlikely(_vproc_post_fork_ping())) { _exit(EXIT_FAILURE); } if (!j->legacy_mach_job) { @@ -2679,16 +2704,16 @@ did_first_per_user_launchd_BootCache_hack = true; } - if (!j->legacy_mach_job) { + if (likely(!j->legacy_mach_job)) { job_assumes(j, runtime_close(oepair[1]) != -1); } j->p = c; - if (j->hopefully_exits_first) { + if (unlikely(j->hopefully_exits_first)) { j->mgr->hopefully_first_cnt++; - } else if (!j->hopefully_exits_last) { + } else if (likely(!j->hopefully_exits_last)) { j->mgr->normal_active_cnt++; } - j->forkfd = _fd(execspair[0]); + j->fork_fd = _fd(execspair[0]); job_assumes(j, runtime_close(execspair[1]) == 0); if (sipc) { job_assumes(j, runtime_close(spair[1]) == 0); @@ -2700,7 +2725,7 @@ job_reap(j); } - if (!j->stall_before_exec) { + if (likely(!j->stall_before_exec)) { job_uncork_fork(j); } break; @@ -2745,7 +2770,7 @@ job_setup_attributes(j); - if (j->argv && j->globargv) { + if (unlikely(j->argv && j->globargv)) { g.gl_offs = 1; for (i = 0; i < j->argc; i++) { if (i > 0) { @@ -2772,18 +2797,18 @@ argv[2] = NULL; } - if (!j->inetcompat) { + if (likely(!j->inetcompat)) { argv++; } - if (j->wait4debugger) { + if (unlikely(j->wait4debugger)) { job_log(j, LOG_WARNING, "Spawned and waiting for the debugger to attach before continuing..."); spflags |= POSIX_SPAWN_START_SUSPENDED; } job_assumes(j, posix_spawnattr_setflags(&spattr, spflags) == 0); - if (j->j_binpref_cnt) { + if (unlikely(j->j_binpref_cnt)) { job_assumes(j, posix_spawnattr_setbinpref_np(&spattr, j->j_binpref_cnt, j->j_binpref, &binpref_out_cnt) == 0); job_assumes(j, binpref_out_cnt == j->j_binpref_cnt); } @@ -2811,7 +2836,7 @@ psf = j->prog ? posix_spawn : posix_spawnp; - if (!j->inetcompat) { + if (likely(!j->inetcompat)) { file2exec = j->prog ? j->prog : argv[0]; } @@ -2964,22 +2989,22 @@ strlcpy(loginname, pwe->pw_name, sizeof(loginname)); strlcpy(homedir, pwe->pw_dir, sizeof(homedir)); - if (pwe->pw_expire && time(NULL) >= pwe->pw_expire) { + if (unlikely(pwe->pw_expire && time(NULL) >= pwe->pw_expire)) { job_log(j, LOG_ERR, "Expired account"); _exit(EXIT_FAILURE); } - if (j->username && strcmp(j->username, loginname) != 0) { + if (unlikely(j->username && strcmp(j->username, loginname) != 0)) { job_log(j, LOG_WARNING, "Suspicious setup: User \"%s\" maps to user: %s", j->username, loginname); - } else if (j->mach_uid && (j->mach_uid != desired_uid)) { + } else if (unlikely(j->mach_uid && (j->mach_uid != desired_uid))) { job_log(j, LOG_WARNING, "Suspicious setup: UID %u maps to UID %u", j->mach_uid, desired_uid); } if (j->groupname) { struct group *gre; - if ((gre = getgrnam(j->groupname)) == NULL) { + if (unlikely((gre = getgrnam(j->groupname)) == NULL)) { job_log(j, LOG_ERR, "getgrnam(\"%s\") failed", j->groupname); _exit(EXIT_FAILURE); } @@ -3000,7 +3025,7 @@ * called after setgid(). See 4616864 for more information. */ - if (!j->no_init_groups) { + if (likely(!j->no_init_groups)) { if (!job_assumes(j, initgroups(loginname, desired_gid) != -1)) { _exit(EXIT_FAILURE); } @@ -3012,7 +3037,7 @@ r = confstr(_CS_DARWIN_USER_TEMP_DIR, tmpdirpath, sizeof(tmpdirpath)); - if (r > 0 && r < sizeof(tmpdirpath)) { + if (likely(r > 0 && r < sizeof(tmpdirpath))) { setenv("TMPDIR", tmpdirpath, 0); } @@ -3028,7 +3053,7 @@ struct limititem *li; struct envitem *ei; - if (j->setnice) { + if (unlikely(j->setnice)) { job_assumes(j, setpriority(PRIO_PROCESS, 0, j->nice) != -1); } @@ -3051,30 +3076,35 @@ } } - if (!j->inetcompat && j->session_create) { + if (unlikely(!j->inetcompat && j->session_create)) { launchd_SessionCreate(); } - if (j->low_pri_io) { + if (unlikely(j->low_pri_io)) { job_assumes(j, setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_THROTTLE) != -1); } - if (j->rootdir) { + if (unlikely(j->rootdir)) { job_assumes(j, chroot(j->rootdir) != -1); job_assumes(j, chdir(".") != -1); } job_postfork_become_user(j); - if (j->workingdir) { + if (unlikely(j->workingdir)) { job_assumes(j, chdir(j->workingdir) != -1); } - if (j->setmask) { + if (unlikely(j->setmask)) { umask(j->mask); } - job_setup_fd(j, STDOUT_FILENO, j->stdoutpath, O_WRONLY|O_APPEND|O_CREAT); - job_setup_fd(j, STDERR_FILENO, j->stderrpath, O_WRONLY|O_APPEND|O_CREAT); + if (j->stdin_fd) { + job_assumes(j, dup2(j->stdin_fd, STDIN_FILENO) != -1); + } else { + job_setup_fd(j, STDIN_FILENO, j->stdinpath, O_RDONLY|O_CREAT); + } + job_setup_fd(j, STDOUT_FILENO, j->stdoutpath, O_WRONLY|O_CREAT|O_APPEND); + job_setup_fd(j, STDERR_FILENO, j->stderrpath, O_WRONLY|O_CREAT|O_APPEND); jobmgr_setup_env_from_other_jobs(j->mgr); @@ -3119,7 +3149,7 @@ struct dirent *de; bool r = 0; - if (!dd) { + if (unlikely(!dd)) { return -1; } @@ -3185,7 +3215,7 @@ ctime_r(&later, time_string); time_string_len = strlen(time_string); - if (time_string_len && time_string[time_string_len - 1] == '\n') { + if (likely(time_string_len && time_string[time_string_len - 1] == '\n')) { time_string[time_string_len - 1] = '\0'; } @@ -3287,13 +3317,13 @@ snprintf(newmsg, newmsgsz, "%s", msg); } - if (j->debug) { + if (unlikely(j->debug)) { oldmask = setlogmask(LOG_UPTO(LOG_DEBUG)); } runtime_vsyslog(&attr, newmsg, ap); - if (j->debug) { + if (unlikely(j->debug)) { setlogmask(oldmask); } } @@ -4414,9 +4444,9 @@ job_log(j, LOG_DEBUG, "Uncorking the fork()."); /* this unblocks the child and avoids a race * between the above fork() and the kevent_mod() */ - job_assumes(j, write(j->forkfd, &c, sizeof(c)) == sizeof(c)); - job_assumes(j, runtime_close(j->forkfd) != -1); - j->forkfd = 0; + job_assumes(j, write(j->fork_fd, &c, sizeof(c)) == sizeof(c)); + job_assumes(j, runtime_close(j->fork_fd) != -1); + j->fork_fd = 0; } jobmgr_t Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2008-01-09 17:30:02 UTC (rev 23477) +++ trunk/launchd/src/liblaunch_public.h 2008-01-09 17:35:12 UTC (rev 23478) @@ -85,6 +85,7 @@ #define LAUNCH_JOBKEY_STARTONMOUNT "StartOnMount" #define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" #define LAUNCH_JOBKEY_HARDRESOURCELIMITS "HardResourceLimits" +#define LAUNCH_JOBKEY_STANDARDINPATH "StandardInPath" #define LAUNCH_JOBKEY_STANDARDOUTPATH "StandardOutPath" #define LAUNCH_JOBKEY_STANDARDERRORPATH "StandardErrorPath" #define LAUNCH_JOBKEY_DEBUG "Debug" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080109/1b82a5f4/attachment-0001.html From source_changes at macosforge.org Wed Jan 9 14:18:12 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 9 14:18:15 2008 Subject: [launchd-changes] [23479] trunk/launchd/src Message-ID: <20080109221812.14526D93AEA1@lists.macosforge.org> Revision: 23479 http://trac.macosforge.org/projects/launchd/changeset/23479 Author: zarzycki@apple.com Date: 2008-01-09 14:18:09 -0800 (Wed, 09 Jan 2008) Log Message: ----------- We should use a better internal ABI when we can. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in 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/launchd_runtime.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/launchd_unix_ipc.c Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/Makefile.am 2008-01-09 22:18:09 UTC (rev 23479) @@ -1,4 +1,4 @@ -AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__ +AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -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.c launchd_internalUser.c \ @@ -46,7 +46,7 @@ SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c -launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing +launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing launchd_LDFLAGS = -lbsm launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/Makefile.in 2008-01-09 22:18:09 UTC (rev 23479) @@ -238,7 +238,7 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__ +AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -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.c launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h @@ -254,7 +254,7 @@ @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 -@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing +@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd.c 2008-01-09 22:18:09 UTC (rev 23479) @@ -227,7 +227,7 @@ } -int +INTERNAL_ABI int _fd(int fd) { if (fd >= 0) { @@ -242,7 +242,7 @@ launchd_assumes(mkdir(SHUTDOWN_LOG_DIR, S_IRWXU) != -1 || errno == EEXIST); } -void +INTERNAL_ABI void launchd_shutdown(void) { int64_t now; @@ -271,7 +271,7 @@ launchd_assert(jobmgr_shutdown(root_jobmgr) != NULL); } -void +INTERNAL_ABI void launchd_single_user(void) { runtime_syslog(LOG_NOTICE, "Going to single-user mode"); @@ -285,7 +285,7 @@ runtime_kill(-1, SIGKILL); } -void +INTERNAL_ABI void launchd_SessionCreate(void) { OSStatus (*sescr)(SessionCreationFlags flags, SessionAttributeBits attributes); @@ -392,7 +392,7 @@ } } -void +INTERNAL_ABI bool _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test) { int saved_errno = errno; @@ -417,4 +417,6 @@ } runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test); + + return false; } Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd.h 2008-01-09 22:18:09 UTC (rev 23479) @@ -35,16 +35,16 @@ extern bool fake_shutdown_in_progress; extern bool network_up; -bool init_check_pid(pid_t); +INTERNAL_ABI bool init_check_pid(pid_t); -launch_data_t launchd_setstdio(int d, launch_data_t o); -void launchd_SessionCreate(void); -void launchd_shutdown(void); -void launchd_single_user(void); +INTERNAL_ABI launch_data_t launchd_setstdio(int d, launch_data_t o); +INTERNAL_ABI void launchd_SessionCreate(void); +INTERNAL_ABI void launchd_shutdown(void); +INTERNAL_ABI void launchd_single_user(void); boolean_t launchd_mach_ipc_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); -void mach_start_shutdown(void); +INTERNAL_ABI void mach_start_shutdown(void); -int _fd(int fd); +INTERNAL_ABI int _fd(int fd); #endif Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-09 22:18:09 UTC (rev 23479) @@ -275,7 +275,7 @@ }; #define jobmgr_assumes(jm, e) \ - (likely(e) ? true : jobmgr_log_bug(jm, __LINE__), false) + (likely(e) ? true : jobmgr_log_bug(jm, __LINE__)) static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); static job_t jobmgr_import2(jobmgr_t jm, launch_data_t pload); @@ -296,7 +296,7 @@ static void jobmgr_logv(jobmgr_t jm, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0))); static void jobmgr_log(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); /* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */ -static void jobmgr_log_bug(jobmgr_t jm, unsigned int line); +static bool jobmgr_log_bug(jobmgr_t jm, unsigned int line); #define DO_RUSAGE_SUMMATION 0 @@ -375,7 +375,7 @@ #define job_assumes(j, e) \ - (likely(e) ? true : job_log_bug(j, __LINE__), false) + (likely(e) ? true : job_log_bug(j, __LINE__)) static void job_import_keys(launch_data_t obj, const char *key, void *context); static void job_import_bool(job_t j, const char *key, bool value); @@ -417,7 +417,7 @@ static void job_log_stdouterr(job_t j); 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, unsigned int line); +static bool job_log_bug(job_t j, unsigned int line); 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); @@ -530,7 +530,7 @@ } } -void +INTERNAL_ABI void job_stop(job_t j) { if (!j->p || j->anonymous) { @@ -548,7 +548,7 @@ job_log(j, LOG_DEBUG, "Sent SIGTERM signal"); } -launch_data_t +INTERNAL_ABI launch_data_t job_export(job_t j) { launch_data_t tmp, tmp2, tmp3, r = launch_data_alloc(LAUNCH_DATA_DICTIONARY); @@ -690,7 +690,7 @@ runtime_closelog(); /* hack to flush logs */ } -jobmgr_t +INTERNAL_ABI jobmgr_t jobmgr_shutdown(jobmgr_t jm) { jobmgr_t jmi, jmn; @@ -773,7 +773,7 @@ free(jm); } -void +INTERNAL_ABI void job_remove(job_t j) { struct waiting_for_removal *w4r; @@ -1273,7 +1273,7 @@ return NULL; } -job_t +INTERNAL_ABI job_t job_import(launch_data_t pload) { job_t j = jobmgr_import2(root_jobmgr, pload); @@ -1285,7 +1285,7 @@ return job_dispatch(j, false); } -launch_data_t +INTERNAL_ABI launch_data_t job_import_bulk(launch_data_t pload) { launch_data_t resp = launch_data_alloc(LAUNCH_DATA_ARRAY); @@ -1895,7 +1895,7 @@ return j; } -job_t +INTERNAL_ABI job_t job_find(const char *label) { job_t ji; @@ -1964,7 +1964,7 @@ return NULL; } -job_t +INTERNAL_ABI job_t job_mig_intran(mach_port_t p) { struct ldcred ldc; @@ -1990,7 +1990,7 @@ return jr; } -job_t +INTERNAL_ABI job_t job_find_by_service_port(mach_port_t p) { struct machservice *ms; @@ -2004,7 +2004,7 @@ return NULL; } -void +INTERNAL_ABI void job_mig_destructor(job_t j) { /* @@ -2042,7 +2042,7 @@ } } -launch_data_t +INTERNAL_ABI launch_data_t job_export_all(void) { launch_data_t resp = launch_data_alloc(LAUNCH_DATA_DICTIONARY); @@ -2255,7 +2255,7 @@ } } -job_t +INTERNAL_ABI job_t job_dispatch(job_t j, bool kickstart) { /* @@ -3239,7 +3239,7 @@ } } -void +bool jobmgr_log_bug(jobmgr_t jm, unsigned int line) { static const char *file; @@ -3263,9 +3263,11 @@ } else { runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } + + return false; } -void +bool job_log_bug(job_t j, unsigned int line) { static const char *file; @@ -3289,6 +3291,8 @@ } else { runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } + + return false; } void @@ -3338,7 +3342,7 @@ va_end(ap); } -void +INTERNAL_ABI void job_log(job_t j, int pri, const char *msg, ...) { va_list ap; @@ -4587,7 +4591,7 @@ return bootstrapper; } -jobmgr_t +INTERNAL_ABI jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port) { struct machservice *ms, *next_ms; @@ -4787,13 +4791,13 @@ return argv_ret; } -void +INTERNAL_ABI void job_checkin(job_t j) { j->checkedin = true; } -bool +INTERNAL_ABI bool job_ack_port_destruction(mach_port_t p) { struct machservice *ms; @@ -4822,7 +4826,7 @@ return true; } -void +INTERNAL_ABI void job_ack_no_senders(job_t j) { j->priv_port_has_senders = false; @@ -4845,7 +4849,7 @@ return NULL; } -bool +INTERNAL_ABI bool job_is_anonymous(job_t j) { return j->anonymous; @@ -5064,7 +5068,7 @@ } } -void +INTERNAL_ABI void jobmgr_dispatch_all_semaphores(jobmgr_t jm) { jobmgr_t jmi, jmn; @@ -6666,7 +6670,7 @@ return BOOTSTRAP_SUCCESS; } -void +INTERNAL_ABI void jobmgr_init(bool sflag) { const char *root_session_type = getpid() == 1 ? VPROCMGR_SESSION_SYSTEM : VPROCMGR_SESSION_BACKGROUND; Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd_core_logic.h 2008-01-09 22:18:09 UTC (rev 23479) @@ -20,6 +20,7 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include #include "libbootstrap_public.h" #include "liblaunch_public.h" @@ -29,27 +30,27 @@ extern jobmgr_t root_jobmgr; extern mach_port_t inherited_bootstrap_port; -void jobmgr_init(bool); -jobmgr_t jobmgr_shutdown(jobmgr_t jm); -void jobmgr_dispatch_all_semaphores(jobmgr_t jm); -jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); +INTERNAL_ABI void jobmgr_init(bool); +INTERNAL_ABI jobmgr_t jobmgr_shutdown(jobmgr_t jm); +INTERNAL_ABI void jobmgr_dispatch_all_semaphores(jobmgr_t jm); +INTERNAL_ABI jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); -launch_data_t job_export_all(void); +INTERNAL_ABI launch_data_t job_export_all(void); -job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ -job_t job_find(const char *label); -job_t job_find_by_service_port(mach_port_t p); -bool job_ack_port_destruction(mach_port_t p); -bool job_is_anonymous(job_t j); -launch_data_t job_export(job_t j); -void job_stop(job_t j); -void job_checkin(job_t j); -void job_remove(job_t j); -job_t job_import(launch_data_t pload); -launch_data_t job_import_bulk(launch_data_t pload); -job_t job_mig_intran(mach_port_t mp); -void job_mig_destructor(job_t j); -void job_ack_no_senders(job_t j); -void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); +INTERNAL_ABI job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ +INTERNAL_ABI job_t job_find(const char *label); +INTERNAL_ABI job_t job_find_by_service_port(mach_port_t p); +INTERNAL_ABI bool job_ack_port_destruction(mach_port_t p); +INTERNAL_ABI bool job_is_anonymous(job_t j); +INTERNAL_ABI launch_data_t job_export(job_t j); +INTERNAL_ABI void job_stop(job_t j); +INTERNAL_ABI void job_checkin(job_t j); +INTERNAL_ABI void job_remove(job_t j); +INTERNAL_ABI job_t job_import(launch_data_t pload); +INTERNAL_ABI launch_data_t job_import_bulk(launch_data_t pload); +INTERNAL_ABI job_t job_mig_intran(mach_port_t mp); +INTERNAL_ABI void job_mig_destructor(job_t j); +INTERNAL_ABI void job_ack_no_senders(job_t j); +INTERNAL_ABI void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); #endif Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd_runtime.c 2008-01-09 22:18:09 UTC (rev 23479) @@ -122,7 +122,7 @@ static FILE *ourlogfile; -mach_port_t +INTERNAL_ABI mach_port_t runtime_get_kernel_port(void) { return launchd_internal_port; @@ -132,7 +132,7 @@ //static int internal_mask_pri = LOG_UPTO(LOG_DEBUG); -void +INTERNAL_ABI void launchd_runtime_init(void) { mach_msg_size_t mxmsgsz; @@ -167,7 +167,7 @@ pthread_attr_destroy(&attr); } -void +INTERNAL_ABI void launchd_runtime_init2(void) { size_t i; @@ -197,7 +197,7 @@ return NULL; } -const char * +INTERNAL_ABI const char * proc_flags_to_C_names(unsigned int flags) { #define MAX_PFLAG_STR "P_ADVLOCK|P_CONTROLT|P_LP64|P_NOCLDSTOP|P_PPWAIT|P_PROFIL|P_SELECT|P_CONTINUED|P_SUGID|P_SYSTEM|P_TIMEOUT|P_TRACED|P_RESV3|P_WEXIT|P_EXEC|P_OWEUPC|P_AFFINITY|P_TRANSLATED|P_RESV5|P_CHECKOPENEVT|P_DEPENDENCY_CAPABLE|P_REBOOT|P_TBE|P_RESV7|P_THCWD|P_RESV9|P_RESV10|P_RESV11|P_NOSHLIB|P_FORCEQUOTA|P_NOCLDWAIT|P_NOREMOTEHANG|0xdeadbeeffeedface" @@ -261,7 +261,7 @@ return flags_buf; } -const char * +INTERNAL_ABI const char * reboot_flags_to_C_names(unsigned int flags) { #define MAX_RB_STR "RB_ASKNAME|RB_SINGLE|RB_NOSYNC|RB_HALT|RB_INITNAME|RB_DFLTROOT|RB_ALTBOOT|RB_UNIPROC|RB_SAFEBOOT|RB_UPSDELAY|0xdeadbeeffeedface" @@ -300,7 +300,7 @@ return flags_buf; } -const char * +INTERNAL_ABI const char * signal_to_C_name(unsigned int sig) { static char unknown[25]; @@ -621,7 +621,7 @@ -void +INTERNAL_ABI void launchd_runtime(void) { mig_reply_error_t *req = NULL, *resp = NULL; @@ -653,19 +653,19 @@ } } -kern_return_t +INTERNAL_ABI kern_return_t launchd_set_bport(mach_port_t name) { return errno = task_set_bootstrap_port(mach_task_self(), name); } -kern_return_t +INTERNAL_ABI kern_return_t launchd_get_bport(mach_port_t *name) { return errno = task_get_bootstrap_port(mach_task_self(), name); } -kern_return_t +INTERNAL_ABI kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which) { mach_port_mscount_t msgc = (which == MACH_NOTIFY_PORT_DESTROYED) ? 0 : 1; @@ -689,7 +689,7 @@ return errno; } -pid_t +INTERNAL_ABI pid_t runtime_fork(mach_port_t bsport) { sigset_t emptyset, oset; @@ -727,7 +727,7 @@ } -void +INTERNAL_ABI void runtime_set_timeout(timeout_callback to_cb, unsigned int sec) { if (sec == 0 || to_cb == NULL) { @@ -739,7 +739,7 @@ runtime_idle_timeout = sec * 1000; } -kern_return_t +INTERNAL_ABI kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size) { size_t needed_table_sz = (MACH_PORT_INDEX(name) + 1) * sizeof(mig_callback); @@ -773,7 +773,7 @@ return errno = mach_port_move_member(mach_task_self(), name, target_set); } -kern_return_t +INTERNAL_ABI kern_return_t runtime_remove_mport(mach_port_t name) { mig_cb_table[MACH_PORT_INDEX(name)] = NULL; @@ -781,31 +781,31 @@ return errno = mach_port_move_member(mach_task_self(), name, MACH_PORT_NULL); } -kern_return_t +INTERNAL_ABI kern_return_t launchd_mport_make_send(mach_port_t name) { return errno = mach_port_insert_right(mach_task_self(), name, name, MACH_MSG_TYPE_MAKE_SEND); } -kern_return_t +INTERNAL_ABI kern_return_t launchd_mport_close_recv(mach_port_t name) { return errno = mach_port_mod_refs(mach_task_self(), name, MACH_PORT_RIGHT_RECEIVE, -1); } -kern_return_t +INTERNAL_ABI kern_return_t launchd_mport_create_recv(mach_port_t *name) { return errno = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, name); } -kern_return_t +INTERNAL_ABI kern_return_t launchd_mport_deallocate(mach_port_t name) { return errno = mach_port_deallocate(mach_task_self(), name); } -int +INTERNAL_ABI int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt) { size_t i; @@ -817,7 +817,7 @@ return kevent(mainkq, kev, kev_cnt, kev, kev_cnt, NULL); } -int +INTERNAL_ABI int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata) { struct kevent kev; @@ -966,7 +966,7 @@ au_tok = &tp->msgh_audit; } -bool +INTERNAL_ABI bool runtime_get_caller_creds(struct ldcred *ldc) { if (unlikely(!au_tok)) { @@ -1098,7 +1098,7 @@ } } -int +INTERNAL_ABI int runtime_close(int fd) { int i; @@ -1108,7 +1108,7 @@ case EVFILT_VNODE: case EVFILT_WRITE: case EVFILT_READ: - if ((int)bulk_kev[i].ident == fd) { + if (unlikely((int)bulk_kev[i].ident == fd)) { runtime_syslog(LOG_DEBUG, "Skipping kevent index: %d", i); bulk_kev[i].filter = 0; } @@ -1120,7 +1120,7 @@ return close(fd); } -void +INTERNAL_ABI void runtime_closelog(void) { runtime_log_push(); @@ -1131,7 +1131,7 @@ } } -int +INTERNAL_ABI int runtime_fsync(int fd) { #if 0 @@ -1145,7 +1145,7 @@ #endif } -int +INTERNAL_ABI int runtime_setlogmask(int maskpri) { internal_mask_pri = maskpri; @@ -1153,7 +1153,7 @@ return internal_mask_pri; } -void +INTERNAL_ABI void runtime_syslog(int pri, const char *message, ...) { struct runtime_syslog_attr attr = { @@ -1170,7 +1170,7 @@ va_end(ap); } -void +INTERNAL_ABI void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) { int saved_errno = errno; @@ -1314,7 +1314,7 @@ } #endif -void +INTERNAL_ABI void runtime_log_push(void) { static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER; @@ -1368,7 +1368,7 @@ } } -kern_return_t +INTERNAL_ABI 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; @@ -1404,7 +1404,7 @@ return 0; } -kern_return_t +INTERNAL_ABI kern_return_t runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt) { launchd_assumes(drain_reply_port == 0); @@ -1428,13 +1428,13 @@ * In the long run, reference counting should completely automate when a * process can and should exit. */ -void +INTERNAL_ABI void runtime_add_ref(void) { runtime_busy_cnt++; } -void +INTERNAL_ABI void runtime_del_ref(void) { runtime_busy_cnt--; @@ -1494,7 +1494,7 @@ return 0; } -void +INTERNAL_ABI void launchd_log_vm_stats(void) { static struct vm_statistics orig_stats; @@ -1542,7 +1542,7 @@ launchd_mport_deallocate(mhs); } -bool +INTERNAL_ABI bool do_apple_internal_logging(void) { static int apple_internal_logging = 1; @@ -1555,7 +1555,7 @@ return (apple_internal_logging == 0); } -int64_t +INTERNAL_ABI int64_t runtime_get_wall_time(void) { struct timeval tv; @@ -1570,13 +1570,13 @@ return r; } -uint64_t +INTERNAL_ABI uint64_t runtime_get_opaque_time(void) { return mach_absolute_time(); } -uint64_t +INTERNAL_ABI uint64_t runtime_opaque_time_to_nano(uint64_t o) { #if defined(__i386__) Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd_runtime.h 2008-01-09 22:18:09 UTC (rev 23479) @@ -70,6 +70,12 @@ #endif +#ifdef __i386__ +#define INTERNAL_ABI __attribute__((regparm(3))) +#else +#define INTERNAL_ABI +#endif + #define likely(x) __builtin_expect((bool)(x), true) #define unlikely(x) __builtin_expect((bool)(x), false) @@ -87,53 +93,50 @@ * Use launchd_assert() for core initialization routines. */ #define launchd_assumes(e) \ - (__builtin_expect(!(e), 0) ? _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true) + (likely(e) ? true : _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e)) -#define launchd_blame(e, b) \ - (__builtin_expect(!(e), 0) ? syslog(LOG_DEBUG, "Encountered bug: %d", b), false : true) - #define launchd_assert(e) if (__builtin_constant_p(e)) { char __compile_time_assert__[e ? 1 : -1] __attribute__((unused)); } else if (!launchd_assumes(e)) { abort(); } -void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test); +INTERNAL_ABI bool _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test); typedef void (*kq_callback)(void *, struct kevent *); typedef boolean_t (*mig_callback)(mach_msg_header_t *, mach_msg_header_t *); typedef void (*timeout_callback)(void); -mach_port_t runtime_get_kernel_port(void); +INTERNAL_ABI mach_port_t runtime_get_kernel_port(void); -void runtime_add_ref(void); -void runtime_del_ref(void); +INTERNAL_ABI void runtime_add_ref(void); +INTERNAL_ABI void runtime_del_ref(void); -void launchd_runtime_init(void); -void launchd_runtime_init2(void); -void launchd_runtime(void) __attribute__((noreturn)); +INTERNAL_ABI void launchd_runtime_init(void); +INTERNAL_ABI void launchd_runtime_init2(void); +INTERNAL_ABI void launchd_runtime(void) __attribute__((noreturn)); -void launchd_log_vm_stats(void); +INTERNAL_ABI void launchd_log_vm_stats(void); -int runtime_close(int fd); -int runtime_fsync(int fd); +INTERNAL_ABI int runtime_close(int fd); +INTERNAL_ABI int runtime_fsync(int fd); #define RUNTIME_ADVISABLE_IDLE_TIMEOUT 30 -void runtime_set_timeout(timeout_callback to_cb, unsigned int sec); -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); +INTERNAL_ABI void runtime_set_timeout(timeout_callback to_cb, unsigned int sec); +INTERNAL_ABI kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); +INTERNAL_ABI kern_return_t runtime_remove_mport(mach_port_t name); +INTERNAL_ABI bool runtime_get_caller_creds(struct ldcred *ldc); -const char *signal_to_C_name(unsigned int sig); -const char *reboot_flags_to_C_names(unsigned int flags); -const char *proc_flags_to_C_names(unsigned int flags); +INTERNAL_ABI const char *signal_to_C_name(unsigned int sig); +INTERNAL_ABI const char *reboot_flags_to_C_names(unsigned int flags); +INTERNAL_ABI const char *proc_flags_to_C_names(unsigned int flags); -bool do_apple_internal_logging(void); +INTERNAL_ABI bool do_apple_internal_logging(void); -int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt); -int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata); +INTERNAL_ABI int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt); +INTERNAL_ABI int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata); -pid_t runtime_fork(mach_port_t bsport); +INTERNAL_ABI pid_t runtime_fork(mach_port_t bsport); -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); +INTERNAL_ABI kern_return_t runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt); +INTERNAL_ABI 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 */ @@ -147,24 +150,23 @@ pid_t about_pid; }; -int runtime_setlogmask(int maskpri); -void runtime_closelog(void); -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))); -void runtime_log_push(void); +INTERNAL_ABI int runtime_setlogmask(int maskpri); +INTERNAL_ABI void runtime_closelog(void); +INTERNAL_ABI void runtime_syslog(int pri, const char *message, ...) __attribute__((format(printf, 2, 3))); +INTERNAL_ABI void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) __attribute__((format(printf, 2, 0))); +INTERNAL_ABI void runtime_log_push(void); -int64_t runtime_get_wall_time(void); -uint64_t runtime_get_opaque_time(void); -uint64_t runtime_opaque_time_to_nano(uint64_t o); +INTERNAL_ABI int64_t runtime_get_wall_time(void); +INTERNAL_ABI uint64_t runtime_get_opaque_time(void); +INTERNAL_ABI uint64_t runtime_opaque_time_to_nano(uint64_t o); +INTERNAL_ABI kern_return_t launchd_set_bport(mach_port_t name); +INTERNAL_ABI kern_return_t launchd_get_bport(mach_port_t *name); +INTERNAL_ABI kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which); +INTERNAL_ABI kern_return_t launchd_mport_notify_cancel(mach_port_t name, mach_msg_id_t which); +INTERNAL_ABI kern_return_t launchd_mport_create_recv(mach_port_t *name); +INTERNAL_ABI kern_return_t launchd_mport_deallocate(mach_port_t name); +INTERNAL_ABI kern_return_t launchd_mport_make_send(mach_port_t name); +INTERNAL_ABI kern_return_t launchd_mport_close_recv(mach_port_t name); -kern_return_t launchd_set_bport(mach_port_t name); -kern_return_t launchd_get_bport(mach_port_t *name); -kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which); -kern_return_t launchd_mport_notify_cancel(mach_port_t name, mach_msg_id_t which); -kern_return_t launchd_mport_create_recv(mach_port_t *name); -kern_return_t launchd_mport_deallocate(mach_port_t name); -kern_return_t launchd_mport_make_send(mach_port_t name); -kern_return_t launchd_mport_close_recv(mach_port_t name); - #endif Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2008-01-09 17:35:12 UTC (rev 23478) +++ trunk/launchd/src/launchd_unix_ipc.c 2008-01-09 22:18:09 UTC (rev 23479) @@ -418,11 +418,17 @@ rmc->resp = resp; } +static int +close_abi_fixup(int fd) +{ + return runtime_close(fd); +} + void ipc_close(struct conncb *c) { LIST_REMOVE(c, sle); - launchd_close(c->conn, runtime_close); + launchd_close(c->conn, close_abi_fixup); free(c); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080109/6de5b36c/attachment-0001.html From source_changes at macosforge.org Fri Jan 11 07:17:19 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 11 07:18:48 2008 Subject: [launchd-changes] [23480] trunk/launchd/src Message-ID: <20080111151719.67805891AE0@beta.macosforge.org> Revision: 23480 http://trac.macosforge.org/projects/launchd/changeset/23480 Author: zarzycki@apple.com Date: 2008-01-11 07:17:14 -0800 (Fri, 11 Jan 2008) Log Message: ----------- Misc updates. Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/launchd_unix_ipc.c trunk/launchd/src/launchd_unix_ipc.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-01-09 22:18:09 UTC (rev 23479) +++ trunk/launchd/src/launchd.c 2008-01-11 15:17:14 UTC (rev 23480) @@ -82,7 +82,7 @@ extern char **environ; -static void pfsystem_callback(void *, struct kevent *); +INTERNAL_ABI static void pfsystem_callback(void *, struct kevent *); static kq_callback kqpfsystem_callback = pfsystem_callback; @@ -376,7 +376,7 @@ launchd_assumes(kevent_mod(pfs, EVFILT_READ, EV_ADD, 0, 0, &kqpfsystem_callback) != -1); } -void +INTERNAL_ABI void pfsystem_callback(void *obj __attribute__((unused)), struct kevent *kev) { bool new_networking_state; @@ -392,7 +392,7 @@ } } -INTERNAL_ABI bool +INTERNAL_ABI void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test) { int saved_errno = errno; @@ -417,6 +417,4 @@ } runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test); - - return false; } Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-09 22:18:09 UTC (rev 23479) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-11 15:17:14 UTC (rev 23480) @@ -263,6 +263,7 @@ LIST_HEAD(, job_s) jobs; LIST_HEAD(, job_s) active_jobs[ACTIVE_JOB_HASH_SIZE]; LIST_HEAD(, machservice) ms_hash[MACHSERVICE_HASH_SIZE]; + LIST_HEAD(, job_s) global_env_jobs; mach_port_t jm_port; mach_port_t req_port; jobmgr_t parentmgr; @@ -275,7 +276,7 @@ }; #define jobmgr_assumes(jm, e) \ - (likely(e) ? true : jobmgr_log_bug(jm, __LINE__)) + (unlikely(!(e)) ? jobmgr_log_bug(jm, __LINE__), false : true) static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); static job_t jobmgr_import2(jobmgr_t jm, launch_data_t pload); @@ -289,14 +290,14 @@ static job_t jobmgr_find_by_pid(jobmgr_t jm, pid_t p, bool create_anon); static job_t job_mig_intran2(jobmgr_t jm, mach_port_t mport, pid_t upid); static void job_export_all2(jobmgr_t jm, launch_data_t where); -static void jobmgr_callback(void *obj, struct kevent *kev); +INTERNAL_ABI static void jobmgr_callback(void *obj, struct kevent *kev); static void jobmgr_setup_env_from_other_jobs(jobmgr_t jm); static void jobmgr_export_env_from_other_jobs(jobmgr_t jm, launch_data_t dict); static struct machservice *jobmgr_lookup_service(jobmgr_t jm, const char *name, bool check_parent, pid_t target_pid); static void jobmgr_logv(jobmgr_t jm, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0))); static void jobmgr_log(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); /* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */ -static bool jobmgr_log_bug(jobmgr_t jm, unsigned int line); +static void jobmgr_log_bug(jobmgr_t jm, unsigned int line); #define DO_RUSAGE_SUMMATION 0 @@ -307,6 +308,7 @@ LIST_ENTRY(job_s) sle; LIST_ENTRY(job_s) pid_hash_sle; LIST_ENTRY(job_s) label_hash_sle; + LIST_ENTRY(job_s) global_env_sle; SLIST_HEAD(, socketgroup) sockets; SLIST_HEAD(, calendarinterval) cal_intervals; SLIST_HEAD(, envitem) global_env; @@ -375,7 +377,7 @@ #define job_assumes(j, e) \ - (likely(e) ? true : job_log_bug(j, __LINE__)) + (unlikely(!(e)) ? job_log_bug(j, __LINE__), false : true) static void job_import_keys(launch_data_t obj, const char *key, void *context); static void job_import_bool(job_t j, const char *key, bool value); @@ -401,7 +403,7 @@ static void job_force_sampletool(job_t j); static void job_setup_exception_port(job_t j, task_t target_task); static void job_reparent_hack(job_t j, const char *where); -static void job_callback(void *obj, struct kevent *kev); +INTERNAL_ABI static void job_callback(void *obj, struct kevent *kev); static void job_callback_proc(job_t j, int fflags); static void job_callback_timer(job_t j, void *ident); static void job_callback_read(job_t j, int ident); @@ -417,7 +419,7 @@ static void job_log_stdouterr(job_t j); 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 bool job_log_bug(job_t j, unsigned int line); +static void job_log_bug(job_t j, unsigned int line); 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); @@ -680,7 +682,7 @@ } -static void +INTERNAL_ABI static void still_alive_with_check(void) { jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %lu/%lu children", total_children, total_anon_children); @@ -785,17 +787,18 @@ struct mspolicy *msp; struct envitem *ei; - if (j->p && j->anonymous) { - job_reap(j); - } else if (j->p) { - job_log(j, LOG_DEBUG, "Removal pended until the job exits"); + if (unlikely(j->p)) { + if (j->anonymous) { + job_reap(j); + } else { + job_log(j, LOG_DEBUG, "Removal pended until the job exits"); - if (!j->removal_pending) { - j->removal_pending = true; - job_stop(j); + if (!j->removal_pending) { + j->removal_pending = true; + job_stop(j); + } + return; } - - return; } ipc_close_all_with_job(j); @@ -866,7 +869,7 @@ if (j->prog) { free(j->prog); } - if (likely(j->argv)) { + if (j->argv) { free(j->argv); } if (j->rootdir) { @@ -1017,7 +1020,7 @@ free(argv); /* jobs can easily be denied creation during shutdown */ - if (!jr) { + if (unlikely(jr == NULL)) { goto out_bad; } @@ -1081,7 +1084,7 @@ return NULL; } - if (len != sizeof(kp)) { + if (unlikely(len != sizeof(kp))) { jobmgr_log(jm, LOG_DEBUG, "Tried to create an anonymous job for nonexistent PID: %u", anonpid); errno = ESRCH; return NULL; @@ -1096,7 +1099,7 @@ jobmgr_log(jm, LOG_DEBUG, "Tried to create an anonymous job for zombie PID %u: %s", anonpid, kp.kp_proc.p_comm); } - if (kp.kp_proc.p_flag & P_SUGID) { + if (unlikely(kp.kp_proc.p_flag & P_SUGID)) { jobmgr_log(jm, LOG_APPLEONLY, "Inconsistency: P_SUGID is set on PID %u: %s", anonpid, kp.kp_proc.p_comm); } @@ -1107,7 +1110,7 @@ kp_gid = kp.kp_eproc.e_pcred.p_rgid; kp_svgid = kp.kp_eproc.e_pcred.p_svgid; - if (kp_euid != kp_uid || kp_euid != kp_svuid || kp_uid != kp_svuid || kp_egid != kp_gid || kp_egid != kp_svgid || kp_gid != kp_svgid) { + if (unlikely(kp_euid != kp_uid || kp_euid != kp_svuid || kp_uid != kp_svuid || kp_egid != kp_gid || kp_egid != kp_svgid || kp_gid != kp_svgid)) { jobmgr_log(jm, LOG_APPLEONLY, "Inconsistency: Mixed credentials (e/r/s UID %u/%u/%u GID %u/%u/%u) detected on PID %u: %s", kp_euid, kp_uid, kp_svuid, kp_egid, kp_gid, kp_svgid, anonpid, kp.kp_proc.p_comm); } @@ -1128,13 +1131,13 @@ break; } - if (jp && !jp->anonymous && !(kp.kp_proc.p_flag & P_EXEC)) { + if (jp && !jp->anonymous && unlikely(!(kp.kp_proc.p_flag & P_EXEC))) { job_log(jp, LOG_APPLEONLY, "Performance and sanity: fork() without exec*(). Please switch to posix_spawn()"); } /* A total hack: Normally, job_new() returns an error during shutdown, but anonymous jobs are special. */ - if ((shutdown_state = jm->shutting_down)) { + if (unlikely(shutdown_state = jm->shutting_down)) { jm->shutting_down = false; } @@ -1158,14 +1161,14 @@ job_assumes(jr, mspolicy_copy(jr, jp)); } - if (shutdown_state && jm->hopefully_first_cnt == 0) { + if (unlikely(shutdown_state && jm->hopefully_first_cnt == 0)) { job_log(jr, LOG_APPLEONLY, "This process showed up to the party while all the guests were leaving. Odds are that it will have a miserable time."); } job_log(jr, LOG_DEBUG, "Created PID %u anonymously by PPID %u%s%s", anonpid, kp.kp_eproc.e_ppid, jp ? ": " : "", jp ? jp->label : ""); } - if (shutdown_state) { + if (unlikely(shutdown_state)) { jm->shutting_down = true; } @@ -1195,7 +1198,7 @@ return NULL; } - if (label == AUTO_PICK_LEGACY_LABEL) { + if (unlikely(label == AUTO_PICK_LEGACY_LABEL)) { bn = prog ? prog : basename((char *)argv[0]); /* prog for auto labels is kp.kp_kproc.p_comm */ snprintf(auto_label, sizeof(auto_label), "%s.%s", sizeof(void *) == 8 ? "0xdeadbeeffeedface" : "0xbabecafe", bn); label = auto_label; @@ -1211,7 +1214,7 @@ return NULL; } - if (label == auto_label) { + if (unlikely(label == auto_label)) { snprintf((char *)j->label, strlen(label) + 1, "%p.%s", j, bn); } else { strcpy((char *)j->label, label); @@ -1429,7 +1432,7 @@ break; } - if (!found_key) { + if (unlikely(!found_key)) { job_log(j, LOG_WARNING, "Unknown key for boolean: %s", key); } } @@ -1531,7 +1534,7 @@ break; } - if (where2put) { + if (likely(where2put)) { job_assumes(j, (*where2put = strdup(value)) != NULL); } else { job_log(j, LOG_WARNING, "Unknown key: %s", key); @@ -1821,7 +1824,7 @@ const char **argv = NULL; job_t j; - if (!launchd_assumes(pload != NULL)) { + if (!jobmgr_assumes(jm, pload != NULL)) { errno = EINVAL; return NULL; } @@ -1901,10 +1904,8 @@ job_t ji; LIST_FOREACH(ji, &label_hash[hash_label(label)], label_hash_sle) { - if (ji->removal_pending) { - continue; /* 5351245 */ - } else if (ji->mgr->shutting_down) { - continue; /* 5488633 */ + if (unlikely(ji->removal_pending || ji->mgr->shutting_down)) { + continue; /* 5351245 and 5488633 respectively */ } if (strcmp(ji->label, label) == 0) { @@ -1919,21 +1920,15 @@ job_t jobmgr_find_by_pid(jobmgr_t jm, pid_t p, bool create_anon) { - job_t ji = NULL; + job_t ji; LIST_FOREACH(ji, &jm->active_jobs[ACTIVE_JOB_HASH(p)], pid_hash_sle) { if (ji->p == p) { - break; + return ji; } } - if (ji) { - return ji; - } else if (create_anon) { - return job_new_anonymous(jm, p); - } else { - return NULL; - } + return create_anon ? job_new_anonymous(jm, p) : NULL; } job_t @@ -2013,7 +2008,7 @@ * 'j' can be invalid at this point. We should fix this up after Leopard ships. */ - if (j && j != workaround_5477111 && j->unload_at_mig_return) { + if (unlikely(j && (j != workaround_5477111) && j->unload_at_mig_return)) { job_log(j, LOG_NOTICE, "Unloading PID %u at MIG return.", j->p); job_remove(j); } @@ -2466,7 +2461,7 @@ job_log(j, LOG_ERR, "Did not die after sending SIGKILL %llu seconds ago...", td); } else { job_force_sampletool(j); - if (j->debug_before_kill) { + if (unlikely(j->debug_before_kill)) { job_log(j, LOG_NOTICE, "Exit timeout elapsed. Entering the kernel debugger."); job_assumes(j, host_reboot(mach_host_self(), HOST_REBOOT_DEBUGGER) == KERN_SUCCESS); } @@ -2506,7 +2501,7 @@ } } -void +INTERNAL_ABI void jobmgr_callback(void *obj, struct kevent *kev) { jobmgr_t jm = obj; @@ -2515,9 +2510,7 @@ switch (kev->filter) { case EVFILT_PROC: jobmgr_reap_bulk(jm, kev); - if (launchd_assumes(root_jobmgr != NULL)) { - root_jobmgr = jobmgr_do_garbage_collection(root_jobmgr); - } + root_jobmgr = jobmgr_do_garbage_collection(root_jobmgr); break; case EVFILT_SIGNAL: switch (kev->ident) { @@ -2566,7 +2559,7 @@ } } -void +INTERNAL_ABI void job_callback(void *obj, struct kevent *kev) { job_t j = obj; @@ -2887,7 +2880,7 @@ jobmgr_setup_env_from_other_jobs(jm->parentmgr); } - LIST_FOREACH(ji, &jm->jobs, sle) { + LIST_FOREACH(ji, &jm->global_env_jobs, global_env_sle) { SLIST_FOREACH(ei, &ji->global_env, sle) { setenv(ei->key, ei->value, 1); } @@ -3239,7 +3232,7 @@ } } -bool +void jobmgr_log_bug(jobmgr_t jm, unsigned int line) { static const char *file; @@ -3263,11 +3256,9 @@ } else { runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } - - return false; } -bool +void job_log_bug(job_t j, unsigned int line) { static const char *file; @@ -3291,8 +3282,6 @@ } else { runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno); } - - return false; } void @@ -3784,6 +3773,9 @@ strcpy(ei->value, v); if (global) { + if (SLIST_EMPTY(&j->global_env)) { + LIST_INSERT_HEAD(&j->mgr->global_env_jobs, j, global_env_sle); + } SLIST_INSERT_HEAD(&j->global_env, ei, sle); } else { SLIST_INSERT_HEAD(&j->env, ei, sle); @@ -3799,6 +3791,9 @@ { if (global) { SLIST_REMOVE(&j->global_env, ei, envitem, sle); + if (SLIST_EMPTY(&j->global_env)) { + LIST_REMOVE(j, global_env_sle); + } } else { SLIST_REMOVE(&j->env, ei, envitem, sle); } @@ -3950,11 +3945,11 @@ * We definitely need to revisit this after Leopard ships. Please see * launchctl.c for the other half of this hack. */ - if (j->mgr->global_on_demand_cnt > 0 && strcmp(j->label, "com.apple.kextd") != 0) { + if (unlikely(j->mgr->global_on_demand_cnt > 0 && strcmp(j->label, "com.apple.kextd") != 0)) { return false; } #else - if (j->mgr->global_on_demand_cnt > 0) { + if (unlikely(j->mgr->global_on_demand_cnt > 0)) { return false; } #endif @@ -3976,7 +3971,7 @@ continue; } if (status.mps_msgcount) { - job_log(j, LOG_DEBUG, "KeepAlive check: job restarted due to %d queued Mach messages on service: %s", + job_log(j, LOG_DEBUG, "KeepAlive check: %d queued Mach messages on service: %s", status.mps_msgcount, ms->name); return true; } @@ -4139,7 +4134,7 @@ ms->gen_num = 1; ms->per_pid = pid_local; - if (*serviceport == MACH_PORT_NULL) { + if (likely(*serviceport == MACH_PORT_NULL)) { if (!job_assumes(j, launchd_mport_create_recv(&ms->port) == KERN_SUCCESS)) { goto out_bad; } @@ -4187,16 +4182,16 @@ thread_state_flavor_t f = 0; mach_port_t exc_port = the_exception_server; - if (j->alt_exc_handler) { + if (unlikely(j->alt_exc_handler)) { ms = jobmgr_lookup_service(j->mgr, j->alt_exc_handler, true, 0); - if (ms) { + if (likely(ms)) { exc_port = machservice_port(ms); } else { job_log(j, LOG_WARNING, "Falling back to default Mach exception handler. Could not find: %s", j->alt_exc_handler); } - } else if (j->internal_exc_handler) { + } else if (unlikely(j->internal_exc_handler)) { exc_port = runtime_get_kernel_port(); - } else if (!exc_port) { + } else if (unlikely(!exc_port)) { return; } @@ -4206,7 +4201,7 @@ f = x86_THREAD_STATE; #endif - if (target_task) { + if (likely(target_task)) { job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, exc_port, EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); } else if (getpid() == 1 && the_exception_server) { @@ -4221,7 +4216,7 @@ void job_set_exeception_port(job_t j, mach_port_t port) { - if (!the_exception_server) { + if (unlikely(!the_exception_server)) { the_exception_server = port; job_setup_exception_port(j, 0); } else { @@ -4298,13 +4293,12 @@ struct machservice *ms; mach_port_t p = MACH_PORT_NULL; - if ((ms = jobmgr_lookup_service(j->mgr, key, false, 0))) { + if (unlikely(ms = jobmgr_lookup_service(j->mgr, key, false, 0))) { job_log(j, LOG_WARNING, "Conflict with job: %s over Mach service: %s", ms->job->label, key); return; } - if ((ms = machservice_new(j, key, &p, false)) == NULL) { - job_log_error(j, LOG_WARNING, "Cannot add service: %s", key); + if (!job_assumes(j, (ms = machservice_new(j, key, &p, false)) != NULL)) { return; } @@ -4325,7 +4319,7 @@ jobmgr_do_garbage_collection(jmi); } - if (!jm->shutting_down) { + if (likely(!jm->shutting_down)) { return jm; } @@ -4393,7 +4387,7 @@ size_t i, kp_cnt = 0, kp_skipped = 0, len = 10*1024*1024; struct kinfo_proc *kp; - if (jm->parentmgr || getpid() != 1) { + if (likely(jm->parentmgr || getpid() != 1)) { return; } @@ -4413,7 +4407,7 @@ const char *z = (kp[i].kp_proc.p_stat == SZOMB) ? "zombie " : ""; const char *n = kp[i].kp_proc.p_comm; - if (p_i == 0 || p_i == 1) { + if (unlikely(p_i == 0 || p_i == 1)) { kp_skipped++; continue; } @@ -4462,7 +4456,7 @@ launchd_assert(offsetof(struct jobmgr_s, kqjobmgr_callback) == 0); - if (jm && requestorport == MACH_PORT_NULL) { + if (unlikely(jm && requestorport == MACH_PORT_NULL)) { jobmgr_log(jm, LOG_ERR, "Mach sub-bootstrap create request requires a requester port"); return NULL; } @@ -4609,7 +4603,7 @@ if (jm == root_jobmgr) { if (port == inherited_bootstrap_port) { - launchd_assumes(launchd_mport_deallocate(port) == KERN_SUCCESS); + jobmgr_assumes(jm, launchd_mport_deallocate(port) == KERN_SUCCESS); inherited_bootstrap_port = MACH_PORT_NULL; return jobmgr_shutdown(jm); @@ -4638,24 +4632,31 @@ jobmgr_lookup_service(jobmgr_t jm, const char *name, bool check_parent, pid_t target_pid) { struct machservice *ms; + job_t target_j; if (target_pid) { - jobmgr_assumes(jm, !check_parent); - } + //jobmgr_assumes(jm, !check_parent); - LIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], name_hash_sle) { - if ((target_pid && ms->per_pid && ms->job->p == target_pid) || (!target_pid && !ms->per_pid)) { - if (strcmp(name, ms->name) == 0) { + if (unlikely((target_j = jobmgr_find_by_pid(jm, target_pid, false)) == NULL)) { + return NULL; + } + + SLIST_FOREACH(ms, &target_j->machservices, sle) { + if (ms->per_pid && strcmp(name, ms->name) == 0) { return ms; } } - } - if (jm->parentmgr == NULL) { return NULL; } - if (!check_parent) { + LIST_FOREACH(ms, &jm->ms_hash[hash_ms(name)], name_hash_sle) { + if (!ms->per_pid && strcmp(name, ms->name) == 0) { + return ms; + } + } + + if (jm->parentmgr == NULL || !check_parent) { return NULL; } @@ -4695,7 +4696,7 @@ void machservice_delete(job_t j, struct machservice *ms, bool port_died) { - if (ms->debug_on_close) { + if (unlikely(ms->debug_on_close)) { job_log(j, LOG_NOTICE, "About to enter kernel debugger because of Mach port: 0x%x", ms->port); job_assumes(j, host_reboot(mach_host_self(), HOST_REBOOT_DEBUGGER) == KERN_SUCCESS); } @@ -4706,7 +4707,7 @@ job_assumes(j, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); - if (ms->port == the_exception_server) { + if (unlikely(ms->port == the_exception_server)) { the_exception_server = 0; } @@ -5276,7 +5277,7 @@ /* XXX - This code should go away once the per session launchd is integrated with the rest of the system */ #ifdef LET_MERE_MORTALS_ADD_SERVERS_TO_PID1 if (getpid() == 1) { - if (ldc.euid && server_uid && (ldc.euid != server_uid)) { + if (unlikely(ldc.euid && server_uid && (ldc.euid != server_uid))) { job_log(j, LOG_WARNING, "Server create: \"%s\": Will run as UID %d, not UID %d as they told us to", server_cmd, ldc.euid, server_uid); server_uid = ldc.euid; @@ -5284,7 +5285,7 @@ } else #endif if (getuid()) { - if (server_uid != getuid()) { + if (unlikely(server_uid != getuid())) { job_log(j, LOG_WARNING, "Server create: \"%s\": As UID %d, we will not be able to switch to UID %d", server_cmd, getuid(), server_uid); } @@ -5293,7 +5294,7 @@ js = job_new_via_mach_init(j, server_cmd, server_uid, on_demand); - if (js == NULL) { + if (unlikely(js == NULL)) { return BOOTSTRAP_NO_MEMORY; } @@ -5313,11 +5314,11 @@ runtime_get_caller_creds(&ldc); - if (ldc.euid != 0 && ldc.euid != getuid()) { + if (unlikely(ldc.euid != 0 && ldc.euid != getuid())) { return BOOTSTRAP_NOT_PRIVILEGED; } - if (!(otherj = job_find(targetlabel))) { + if (unlikely(!(otherj = job_find(targetlabel)))) { return BOOTSTRAP_UNKNOWN_SERVICE; } @@ -5374,7 +5375,7 @@ runtime_get_caller_creds(&ldc); - if (ldc.euid) { + if (unlikely(ldc.euid)) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5398,11 +5399,11 @@ return BOOTSTRAP_NO_MEMORY; } - if (inkey && ldc.euid && ldc.euid != getuid()) { + if (unlikely(inkey && ldc.euid && ldc.euid != getuid())) { return BOOTSTRAP_NOT_PRIVILEGED; } - if (inkey && outkey && !job_assumes(j, inkey == outkey)) { + if (unlikely(inkey && outkey && !job_assumes(j, inkey == outkey))) { return 1; } @@ -5422,7 +5423,7 @@ return 1; } - if (invalCnt && !job_assumes(j, (input_obj = launch_data_unpack((void *)inval, invalCnt, NULL, 0, &data_offset, NULL)) != NULL)) { + if (unlikely(invalCnt && !job_assumes(j, (input_obj = launch_data_unpack((void *)inval, invalCnt, NULL, 0, &data_offset, NULL)) != NULL))) { goto out_bad; } @@ -5492,11 +5493,11 @@ return BOOTSTRAP_NO_MEMORY; } - if (inkey && ldc.euid && ldc.euid != getuid()) { + if (unlikely(inkey && ldc.euid && ldc.euid != getuid())) { return BOOTSTRAP_NOT_PRIVILEGED; } - if (inkey && outkey && !job_assumes(j, inkey == outkey)) { + if (unlikely(inkey && outkey && !job_assumes(j, inkey == outkey))) { return 1; } @@ -5627,7 +5628,7 @@ errno = task_set_special_port(child_task, ms->special_port_num, ms->port); - if (errno) { + if (unlikely(errno)) { int desired_log_level = LOG_ERR; if (j->anonymous) { @@ -5661,13 +5662,13 @@ return BOOTSTRAP_NO_MEMORY; } - if (getpid() != 1) { + if (unlikely(getpid() != 1)) { return BOOTSTRAP_NOT_PRIVILEGED; } runtime_get_caller_creds(&ldc); - if (ldc.euid) { + if (unlikely(ldc.euid)) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5702,7 +5703,7 @@ ipc_server_init(); - if (!sockpath) { + if (unlikely(!sockpath)) { return BOOTSTRAP_NO_MEMORY; } @@ -5730,7 +5731,7 @@ void ensure_root_bkgd_setup(void) { - if (background_jobmgr || getpid() != 1) { + if (likely(background_jobmgr) || getpid() != 1) { return; } @@ -5756,7 +5757,7 @@ runtime_get_caller_creds(&ldc); - if (getpid() != 1) { + if (unlikely(getpid() != 1)) { job_log(j, LOG_ERR, "Only PID 1 supports per user launchd lookups."); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5791,7 +5792,7 @@ break; } - if (ji == NULL) { + if (unlikely(ji == NULL)) { struct machservice *ms; char lbuf[1024]; @@ -5843,12 +5844,12 @@ ms = jobmgr_lookup_service(j->mgr, servicename, true, 0); - if (ms == NULL) { + if (unlikely(ms == NULL)) { job_log(j, LOG_DEBUG, "Check-in of Mach service failed. Unknown: %s", servicename); return BOOTSTRAP_UNKNOWN_SERVICE; } - if ((jo = machservice_job(ms)) != j) { + if (unlikely((jo = machservice_job(ms)) != j)) { static pid_t last_warned_pid; if (last_warned_pid != ldc.pid) { @@ -5858,7 +5859,7 @@ return BOOTSTRAP_NOT_PRIVILEGED; } - if (machservice_active(ms)) { + if (unlikely(machservice_active(ms))) { job_log(j, LOG_WARNING, "Check-in of Mach service failed. Already active: %s", servicename); return BOOTSTRAP_SERVICE_ACTIVE; } @@ -5894,7 +5895,7 @@ * 92) is a rogue application (not our UID, not root and not a child of * us). We'll have to reconcile this design friction at a later date. */ - if (j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.uid != getuid() && ldc.uid != 92) { + if (unlikely(j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.uid != getuid() && ldc.uid != 92)) { if (getpid() == 1) { return VPROC_ERR_TRY_PER_USER; } else { @@ -5904,7 +5905,7 @@ ms = jobmgr_lookup_service(j->mgr, servicename, false, flags & BOOTSTRAP_PER_PID_SERVICE ? ldc.pid : 0); - if (ms) { + if (unlikely(ms)) { if (machservice_job(ms) != j) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5916,8 +5917,8 @@ machservice_delete(j, ms, false); } - if (serviceport != MACH_PORT_NULL) { - if ((ms = machservice_new(j, servicename, &serviceport, flags & BOOTSTRAP_PER_PID_SERVICE ? true : false))) { + if (likely(serviceport != MACH_PORT_NULL)) { + if (likely(ms = machservice_new(j, servicename, &serviceport, flags & BOOTSTRAP_PER_PID_SERVICE ? true : false))) { machservice_request_notifications(ms); } else { return BOOTSTRAP_NO_MEMORY; @@ -5940,11 +5941,11 @@ runtime_get_caller_creds(&ldc); - if (getpid() == 1 && j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.euid != 0) { + if (unlikely(getpid() == 1 && j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.euid != 0)) { return VPROC_ERR_TRY_PER_USER; } - if (!mspolicy_check(j, servicename, flags & BOOTSTRAP_PER_PID_SERVICE)) { + if (unlikely(!mspolicy_check(j, servicename, flags & BOOTSTRAP_PER_PID_SERVICE))) { job_log(j, LOG_NOTICE, "Policy denied Mach service lookup: %s", servicename); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5957,15 +5958,15 @@ if (ms && machservice_hidden(ms) && !job_active(machservice_job(ms))) { ms = NULL; - } else if (ms && ms->per_user_hack) { + } else if (ms && unlikely(ms->per_user_hack)) { ms = NULL; } if (ms) { - launchd_assumes(machservice_port(ms) != MACH_PORT_NULL); + job_assumes(j, machservice_port(ms) != MACH_PORT_NULL); job_log(j, LOG_DEBUG, "%sMach service lookup: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); - if (j->lastlookup == ms && j->lastlookup_gennum == ms->gen_num && !j->per_user) { + if (unlikely(j->lastlookup == ms && j->lastlookup_gennum == ms->gen_num && !j->per_user)) { job_log(ms->job, LOG_APPLEONLY, "Performance: Please fix the framework to cache the Mach port for service: %s", servicename); } @@ -6048,12 +6049,12 @@ } mig_allocate((vm_address_t *)&service_names, cnt * sizeof(service_names[0])); - if (!launchd_assumes(service_names != NULL)) { + if (!job_assumes(j, service_names != NULL)) { goto out_bad; } mig_allocate((vm_address_t *)&service_actives, cnt * sizeof(service_actives[0])); - if (!launchd_assumes(service_actives != NULL)) { + if (!job_assumes(j, service_actives != NULL)) { goto out_bad; } @@ -6067,7 +6068,7 @@ } } - launchd_assumes(cnt == cnt2); + job_assumes(j, cnt == cnt2); out: *servicenamesp = service_names; @@ -6108,7 +6109,7 @@ } SLIST_FOREACH(jmi, &root_jobmgr->submgrs, sle) { - if (jmi->shutting_down) { + if (unlikely(jmi->shutting_down)) { continue; } else if (strcasecmp(jmi->name, where) == 0) { goto jm_found; @@ -6223,7 +6224,7 @@ */ SLIST_FOREACH(jmi, &root_jobmgr->submgrs, sle) { - if (jmi->shutting_down) { + if (unlikely(jmi->shutting_down)) { continue; } else if (strcasecmp(jmi->name, session_type) == 0) { jobmgr_shutdown(jmi); @@ -6281,13 +6282,13 @@ j_for_service = jobmgr_find_by_pid(jmr, target_pid, true); - if (!j_for_service) { + if (unlikely(!j_for_service)) { /* The PID probably exited */ job_assumes(j, launchd_mport_deallocate(l2l_ports[l2l_i]) == KERN_SUCCESS); continue; } - if ((ms = machservice_new(j_for_service, serv_name, &l2l_ports[l2l_i], serv_perpid))) { + if (likely(ms = machservice_new(j_for_service, serv_name, &l2l_ports[l2l_i], serv_perpid))) { machservice_request_notifications(ms); } } @@ -6333,16 +6334,19 @@ jm = j->mgr; - if (getpid() != 1) { + if (unlikely(getpid() != 1)) { job_log(j, LOG_ERR, "Only the system launchd will transfer Mach sub-bootstraps."); return BOOTSTRAP_NOT_PRIVILEGED; - } else if (jobmgr_parent(jm) == NULL) { + } + if (unlikely(jobmgr_parent(jm) == NULL)) { job_log(j, LOG_ERR, "Root Mach bootstrap cannot be transferred."); return BOOTSTRAP_NOT_PRIVILEGED; - } else if (strcasecmp(jm->name, VPROCMGR_SESSION_AQUA) == 0) { + } + if (unlikely(strcasecmp(jm->name, VPROCMGR_SESSION_AQUA) == 0)) { job_log(j, LOG_ERR, "Cannot transfer a setup GUI session."); return BOOTSTRAP_NOT_PRIVILEGED; - } else if (!j->anonymous) { + } + if (unlikely(!j->anonymous)) { job_log(j, LOG_ERR, "Only the anonymous job can transfer Mach sub-bootstraps."); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -6370,7 +6374,7 @@ } mig_allocate((vm_address_t *)&ports, cnt * sizeof(ports[0])); - if (!launchd_assumes(ports != NULL)) { + if (!job_assumes(j, ports != NULL)) { goto out_bad; } @@ -6412,7 +6416,7 @@ } } - launchd_assumes(cnt == cnt2); + job_assumes(j, cnt == cnt2); packed_size = launch_data_pack(outdata_obj_array, (void *)*outdata, *outdataCnt, NULL, NULL); if (!job_assumes(j, packed_size != 0)) { @@ -6467,13 +6471,13 @@ } /* Since we use recursion, we need an artificial depth for subsets */ - if (bsdepth > 100) { + if (unlikely(bsdepth > 100)) { job_log(j, LOG_ERR, "Mach sub-bootstrap create request failed. Depth greater than: %d", bsdepth); return BOOTSTRAP_NO_MEMORY; } - if ((jmr = jobmgr_new(j->mgr, requestorport, MACH_PORT_NULL, false, NULL)) == NULL) { - if (requestorport == MACH_PORT_NULL) { + if (!job_assumes(j, (jmr = jobmgr_new(j->mgr, requestorport, MACH_PORT_NULL, false, NULL)) != NULL)) { + if (unlikely(requestorport == MACH_PORT_NULL)) { return BOOTSTRAP_NOT_PRIVILEGED; } return BOOTSTRAP_NO_MEMORY; @@ -6492,18 +6496,18 @@ return BOOTSTRAP_NO_MEMORY; } - if (job_prog(j)[0] == '\0') { + if (unlikely(job_prog(j)[0] == '\0')) { job_log(j, LOG_ERR, "Mach service creation requires a target server: %s", servicename); return BOOTSTRAP_NOT_PRIVILEGED; } - if (!j->legacy_mach_job) { + if (unlikely(!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 = jobmgr_lookup_service(j->mgr, servicename, false, 0); - if (ms) { + if (unlikely(ms)) { job_log(j, LOG_DEBUG, "Mach service creation attempt for failed. Already exists: %s", servicename); return BOOTSTRAP_NAME_IN_USE; } @@ -6513,15 +6517,11 @@ *serviceportp = MACH_PORT_NULL; ms = machservice_new(j, servicename, serviceportp, false); - if (!launchd_assumes(ms != NULL)) { - goto out_bad; + if (!job_assumes(j, ms != NULL)) { + return BOOTSTRAP_NO_MEMORY; } return BOOTSTRAP_SUCCESS; - -out_bad: - launchd_assumes(launchd_mport_close_recv(*serviceportp) == KERN_SUCCESS); - return BOOTSTRAP_NO_MEMORY; } kern_return_t @@ -6544,7 +6544,7 @@ return BOOTSTRAP_NO_MEMORY; } - if (!j->stall_before_exec) { + if (unlikely(!j->stall_before_exec)) { job_log(j, LOG_WARNING, "Attempt to uncork a job that isn't in the middle of a fork()."); return 1; } @@ -6563,6 +6563,12 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(!SLIST_EMPTY(&j->mspolicies))) { + job_log(j, LOG_WARNING, "Jobs that have policies assigned to them may not set policies."); + return BOOTSTRAP_NOT_PRIVILEGED; + } + + target_j = jobmgr_find_by_pid(j->mgr, target_pid, true); if (unlikely(target_j == NULL)) { @@ -6572,24 +6578,15 @@ return BOOTSTRAP_NO_MEMORY; } - if (!job_assumes(j, (target_j = jobmgr_find_by_pid(j->mgr, target_pid, true)) != NULL)) { - return BOOTSTRAP_NO_MEMORY; - } + job_log(j, LOG_DEBUG, "Setting policy on job \"%s\" for Mach service: %s", target_j->label, target_service); + if (target_service[0]) { + bool r = mspolicy_new(target_j, target_service, flags & BOOTSTRAP_ALLOW_LOOKUP, flags & BOOTSTRAP_PER_PID_SERVICE, false); - if (SLIST_EMPTY(&j->mspolicies)) { - job_log(j, LOG_DEBUG, "Setting policy on job \"%s\" for Mach service: %s", target_j->label, target_service); - if (target_service[0]) { - bool r = mspolicy_new(target_j, target_service, flags & BOOTSTRAP_ALLOW_LOOKUP, flags & BOOTSTRAP_PER_PID_SERVICE, false); - - if (unlikely(!r) && job_assumes(j, errno == EEXIST)) { - job_log(j, LOG_ERR, "Tried to update a known policy on PID %u: %s", target_pid, target_service); - } - } else { - target_j->deny_unknown_mslookups = !(flags & BOOTSTRAP_ALLOW_LOOKUP); + if (unlikely(!r) && job_assumes(j, errno == EEXIST)) { + job_log(j, LOG_ERR, "Tried to update a known policy on PID %u: %s", target_pid, target_service); } } else { - job_log(j, LOG_WARNING, "Jobs that have policies assigned to them may not set policies."); - return BOOTSTRAP_NOT_PRIVILEGED; + target_j->deny_unknown_mslookups = !(flags & BOOTSTRAP_ALLOW_LOOKUP); } return 0; @@ -6609,7 +6606,7 @@ return BOOTSTRAP_NO_MEMORY; } - if (getpid() == 1 && ldc.euid && ldc.uid) { + if (unlikely(getpid() == 1 && ldc.euid && ldc.uid)) { job_log(j, LOG_DEBUG, "Punting spawn to per-user-context"); return VPROC_ERR_TRY_PER_USER; } Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2008-01-09 22:18:09 UTC (rev 23479) +++ trunk/launchd/src/launchd_runtime.h 2008-01-11 15:17:14 UTC (rev 23480) @@ -93,15 +93,15 @@ * Use launchd_assert() for core initialization routines. */ #define launchd_assumes(e) \ - (likely(e) ? true : _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e)) + (unlikely(!(e)) ? _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true) #define launchd_assert(e) if (__builtin_constant_p(e)) { char __compile_time_assert__[e ? 1 : -1] __attribute__((unused)); } else if (!launchd_assumes(e)) { abort(); } -INTERNAL_ABI bool _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test); +INTERNAL_ABI void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test); -typedef void (*kq_callback)(void *, struct kevent *); +typedef INTERNAL_ABI void (*kq_callback)(void *, struct kevent *); typedef boolean_t (*mig_callback)(mach_msg_header_t *, mach_msg_header_t *); -typedef void (*timeout_callback)(void); +typedef INTERNAL_ABI void (*timeout_callback)(void); INTERNAL_ABI mach_port_t runtime_get_kernel_port(void); Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2008-01-09 22:18:09 UTC (rev 23479) +++ trunk/launchd/src/launchd_unix_ipc.c 2008-01-11 15:17:14 UTC (rev 23480) @@ -60,8 +60,9 @@ static launch_data_t adjust_rlimits(launch_data_t in); static void ipc_readmsg2(launch_data_t data, const char *cmd, void *context); +static void ipc_readmsg(launch_data_t msg, void *context); -static void ipc_listen_callback(void *obj __attribute__((unused)), struct kevent *kev); +INTERNAL_ABI static void ipc_listen_callback(void *obj __attribute__((unused)), struct kevent *kev); static kq_callback kqipc_listen_callback = ipc_listen_callback; @@ -72,7 +73,7 @@ static bool ipc_inited = false; -void +static void ipc_clean_up(void) { if (ipc_self != getpid()) { @@ -86,7 +87,7 @@ } } -void +INTERNAL_ABI void ipc_server_init(void) { struct sockaddr_un sun; @@ -176,7 +177,7 @@ } } -void +INTERNAL_ABI void ipc_open(int fd, job_t j) { struct conncb *c = calloc(1, sizeof(struct conncb)); @@ -190,7 +191,7 @@ kevent_mod(fd, EVFILT_READ, EV_ADD, 0, 0, &c->kqconn_callback); } -void +INTERNAL_ABI void ipc_listen_callback(void *obj __attribute__((unused)), struct kevent *kev) { struct sockaddr_un sun; @@ -204,7 +205,7 @@ ipc_open(cfd, NULL); } -void +INTERNAL_ABI void ipc_callback(void *obj, struct kevent *kev) { struct conncb *c = obj; @@ -238,7 +239,7 @@ setenv(key, launch_data_get_string(obj), 1); } -void +INTERNAL_ABI void ipc_close_all_with_job(job_t j) { struct conncb *ci, *cin; @@ -250,7 +251,7 @@ } } -void +INTERNAL_ABI void ipc_close_fds(launch_data_t o) { size_t i; @@ -273,7 +274,7 @@ } } -void +INTERNAL_ABI void ipc_revoke_fds(launch_data_t o) { size_t i; @@ -424,7 +425,7 @@ return runtime_close(fd); } -void +INTERNAL_ABI void ipc_close(struct conncb *c) { LIST_REMOVE(c, sle); Modified: trunk/launchd/src/launchd_unix_ipc.h =================================================================== --- trunk/launchd/src/launchd_unix_ipc.h 2008-01-09 22:18:09 UTC (rev 23479) +++ trunk/launchd/src/launchd_unix_ipc.h 2008-01-11 15:17:14 UTC (rev 23480) @@ -35,14 +35,12 @@ extern char *sockpath; -void ipc_open(int fd, job_t j); -void ipc_close_all_with_job(job_t j); -void ipc_close(struct conncb *c); -void ipc_callback(void *, struct kevent *); -void ipc_readmsg(launch_data_t msg, void *context); -void ipc_revoke_fds(launch_data_t o); -void ipc_close_fds(launch_data_t o); -void ipc_clean_up(void); -void ipc_server_init(void); +INTERNAL_ABI void ipc_open(int fd, job_t j); +INTERNAL_ABI void ipc_close_all_with_job(job_t j); +INTERNAL_ABI void ipc_close(struct conncb *c); +INTERNAL_ABI void ipc_callback(void *, struct kevent *); +INTERNAL_ABI void ipc_revoke_fds(launch_data_t o); +INTERNAL_ABI void ipc_close_fds(launch_data_t o); +INTERNAL_ABI void ipc_server_init(void); #endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080111/d44ba0f8/attachment-0001.html From source_changes at macosforge.org Fri Jan 11 09:13:01 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 11 09:14:27 2008 Subject: [launchd-changes] [23481] trunk/launchd/src Message-ID: <20080111171301.DF1868971DD@beta.macosforge.org> Revision: 23481 http://trac.macosforge.org/projects/launchd/changeset/23481 Author: zarzycki@apple.com Date: 2008-01-11 09:12:59 -0800 (Fri, 11 Jan 2008) Log Message: ----------- Most of the time, when launchd calls getpid(), it simply wants to know whether it should do "PID 1 magic." This simplifies the code a bit. Modified Paths: -------------- 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 Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-01-11 15:17:14 UTC (rev 23480) +++ trunk/launchd/src/launchd.c 2008-01-11 17:12:59 UTC (rev 23481) @@ -134,7 +134,7 @@ setenv("PATH", _PATH_STDPATH, 1); } - if (getpid() == 1) { + if (pid1_magic) { pid1_magic_init(); } else { ipc_server_init(); @@ -142,7 +142,7 @@ monitor_networking_state(); - if (getpid() == 1) { + if (pid1_magic) { handle_pid1_crashes_separately(); } @@ -253,7 +253,7 @@ shutdown_in_progress = true; - if (getpid() == 1) { + if (pid1_magic) { /* * When this changes to a more sustainable API, update this: * http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-11 15:17:14 UTC (rev 23480) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-11 17:12:59 UTC (rev 23481) @@ -714,7 +714,7 @@ } } - if (do_apple_internal_logging() && jm->parentmgr == NULL && getpid() == 1) { + if (do_apple_internal_logging() && jm->parentmgr == NULL && pid1_magic) { runtime_set_timeout(still_alive_with_check, 5); } @@ -756,7 +756,7 @@ if (jm->parentmgr) { runtime_del_ref(); SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); - } else if (getpid() == 1) { + } else if (pid1_magic) { jobmgr_log(jm, LOG_DEBUG, "About to call: sync()"); sync(); /* We're are going to rely on log timestamps to benchmark this call */ jobmgr_log(jm, LOG_DEBUG, "Unmounting all filesystems except / and /dev"); @@ -1120,7 +1120,7 @@ /* the kernel */ break; case 1: - if (getpid() != 1) { + if (!pid1_magic) { /* we cannot possibly find a parent job_t that is useful in this function */ break; } @@ -2524,7 +2524,7 @@ runtime_closelog(); /* HACK -- force 'start' time to be set */ - if (getpid() == 1) { + if (pid1_magic) { int64_t now = runtime_get_wall_time(); jobmgr_log(jm, LOG_NOTICE, "Anticipatory shutdown began at: %lld.%06llu", now / USEC_PER_SEC, now % USEC_PER_SEC); @@ -4204,7 +4204,7 @@ if (likely(target_task)) { job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, exc_port, EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); - } else if (getpid() == 1 && the_exception_server) { + } else if (pid1_magic && the_exception_server) { mach_port_t mhp = mach_host_self(); job_assumes(j, host_set_exception_ports(mhp, EXC_MASK_CRASH, the_exception_server, EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); @@ -4254,7 +4254,7 @@ SLIST_INSERT_HEAD(&special_ports, ms, special_port_sle); break; } - } else if (strcasecmp(key, LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT) == 0 && getpid() == 1) { + } else if (strcasecmp(key, LAUNCH_JOBKEY_MACH_HOSTSPECIALPORT) == 0 && pid1_magic) { if (which_port > HOST_MAX_SPECIAL_KERNEL_PORT) { job_assumes(ms->job, (errno = host_set_special_port(mhp, which_port, ms->port)) == KERN_SUCCESS); } else { @@ -4387,7 +4387,7 @@ size_t i, kp_cnt = 0, kp_skipped = 0, len = 10*1024*1024; struct kinfo_proc *kp; - if (likely(jm->parentmgr || getpid() != 1)) { + if (likely(jm->parentmgr || !pid1_magic)) { return; } @@ -4483,7 +4483,7 @@ if (transfer_port != MACH_PORT_NULL) { jobmgr_assumes(jmr, jm != NULL); jmr->jm_port = transfer_port; - } else if (!jm && getpid() != 1) { + } else if (!jm && !pid1_magic) { char *trusted_fd = getenv(LAUNCHD_TRUSTED_FD_ENV); name_t service_buf; @@ -5276,7 +5276,7 @@ #define LET_MERE_MORTALS_ADD_SERVERS_TO_PID1 /* XXX - This code should go away once the per session launchd is integrated with the rest of the system */ #ifdef LET_MERE_MORTALS_ADD_SERVERS_TO_PID1 - if (getpid() == 1) { + if (pid1_magic) { if (unlikely(ldc.euid && server_uid && (ldc.euid != server_uid))) { job_log(j, LOG_WARNING, "Server create: \"%s\": Will run as UID %d, not UID %d as they told us to", server_cmd, ldc.euid, server_uid); @@ -5662,7 +5662,7 @@ return BOOTSTRAP_NO_MEMORY; } - if (unlikely(getpid() != 1)) { + if (unlikely(!pid1_magic)) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5731,7 +5731,7 @@ void ensure_root_bkgd_setup(void) { - if (likely(background_jobmgr) || getpid() != 1) { + if (likely(background_jobmgr) || !pid1_magic) { return; } @@ -5757,7 +5757,7 @@ runtime_get_caller_creds(&ldc); - if (unlikely(getpid() != 1)) { + if (unlikely(!pid1_magic)) { job_log(j, LOG_ERR, "Only PID 1 supports per user launchd lookups."); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5896,7 +5896,7 @@ * us). We'll have to reconcile this design friction at a later date. */ if (unlikely(j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.uid != getuid() && ldc.uid != 92)) { - if (getpid() == 1) { + if (pid1_magic) { return VPROC_ERR_TRY_PER_USER; } else { return BOOTSTRAP_NOT_PRIVILEGED; @@ -5941,7 +5941,7 @@ runtime_get_caller_creds(&ldc); - if (unlikely(getpid() == 1 && j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.euid != 0)) { + if (unlikely(pid1_magic && j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.euid != 0)) { return VPROC_ERR_TRY_PER_USER; } @@ -5981,7 +5981,7 @@ job_assumes(j, vproc_mig_look_up2_forward(inherited_bootstrap_port, srp, servicename, 0, 0) == 0); /* The previous routine moved the reply port, we're forced to return MIG_NO_REPLY now */ return MIG_NO_REPLY; - } else if (getpid() == 1 && j->anonymous && ldc.euid >= 500 && strcasecmp(job_get_bs(j)->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) { + } else if (pid1_magic && j->anonymous && ldc.euid >= 500 && strcasecmp(job_get_bs(j)->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) { /* * 5240036 Should start background session when a lookup of CCacheServer occurs * @@ -6113,7 +6113,7 @@ continue; } else if (strcasecmp(jmi->name, where) == 0) { goto jm_found; - } else if (strcasecmp(jmi->name, VPROCMGR_SESSION_BACKGROUND) == 0 && getpid() == 1) { + } else if (strcasecmp(jmi->name, VPROCMGR_SESSION_BACKGROUND) == 0 && pid1_magic) { SLIST_FOREACH(jmi2, &jmi->submgrs, sle) { if (strcasecmp(jmi2->name, where) == 0) { jmi = jmi2; @@ -6162,7 +6162,7 @@ job_t j2; if (j->mgr->session_initialized) { - if (ldc.uid == 0 && getpid() == 1) { + if (ldc.uid == 0 && pid1_magic) { if (strcmp(j->mgr->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) { job_t ji, jn; @@ -6200,7 +6200,7 @@ kr = BOOTSTRAP_NOT_PRIVILEGED; goto out; } - } else if (ldc.uid == 0 && getpid() == 1 && strcmp(session_type, VPROCMGR_SESSION_STANDARDIO) == 0) { + } else if (ldc.uid == 0 && pid1_magic && strcmp(session_type, VPROCMGR_SESSION_STANDARDIO) == 0) { ensure_root_bkgd_setup(); SLIST_REMOVE(&j->mgr->parentmgr->submgrs, j->mgr, jobmgr_s, sle); @@ -6334,7 +6334,7 @@ jm = j->mgr; - if (unlikely(getpid() != 1)) { + if (unlikely(!pid1_magic)) { job_log(j, LOG_ERR, "Only the system launchd will transfer Mach sub-bootstraps."); return BOOTSTRAP_NOT_PRIVILEGED; } @@ -6606,7 +6606,7 @@ return BOOTSTRAP_NO_MEMORY; } - if (unlikely(getpid() == 1 && ldc.euid && ldc.uid)) { + if (unlikely(pid1_magic && ldc.euid && ldc.uid)) { job_log(j, LOG_DEBUG, "Punting spawn to per-user-context"); return VPROC_ERR_TRY_PER_USER; } @@ -6632,7 +6632,7 @@ job_reparent_hack(jr, NULL); - if (getpid() == 1) { + if (pid1_magic) { jr->mach_uid = ldc.uid; } @@ -6670,7 +6670,7 @@ INTERNAL_ABI void jobmgr_init(bool sflag) { - const char *root_session_type = getpid() == 1 ? VPROCMGR_SESSION_SYSTEM : VPROCMGR_SESSION_BACKGROUND; + const char *root_session_type = pid1_magic ? VPROCMGR_SESSION_SYSTEM : VPROCMGR_SESSION_BACKGROUND; launchd_assert((root_jobmgr = jobmgr_new(NULL, MACH_PORT_NULL, MACH_PORT_NULL, sflag, root_session_type)) != NULL); } Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-11 15:17:14 UTC (rev 23480) +++ trunk/launchd/src/launchd_runtime.c 2008-01-11 17:12:59 UTC (rev 23481) @@ -120,8 +120,8 @@ }; static sigset_t sigign_set; static FILE *ourlogfile; +bool pid1_magic; - INTERNAL_ABI mach_port_t runtime_get_kernel_port(void) { @@ -1158,7 +1158,7 @@ { struct runtime_syslog_attr attr = { "com.apple.launchd", "com.apple.launchd", - getpid() == 1 ? "System" : "Background", + pid1_magic ? "System" : "Background", pri, getuid(), getpid(), getpid() }; va_list ap; @@ -1326,7 +1326,7 @@ if (logmsg_queue_cnt == 0) { launchd_assumes(STAILQ_EMPTY(&logmsg_queue)); return; - } else if (getpid() != 1) { + } else if (!pid1_magic) { if (runtime_log_pack(&outval, &outvalCnt) == 0) { launchd_assumes(_vprocmgr_log_forward(inherited_bootstrap_port, (void *)outval, outvalCnt) == NULL); mig_deallocate(outval, outvalCnt); @@ -1605,4 +1605,8 @@ launchd_assert(mach_timebase_info(&tbi) == 0); tbi_float_val = tbi.numer; tbi_float_val /= tbi.denom; + + if (getpid() == 1) { + pid1_magic = true; + } } Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2008-01-11 15:17:14 UTC (rev 23480) +++ trunk/launchd/src/launchd_runtime.h 2008-01-11 17:12:59 UTC (rev 23481) @@ -103,6 +103,8 @@ typedef boolean_t (*mig_callback)(mach_msg_header_t *, mach_msg_header_t *); typedef INTERNAL_ABI void (*timeout_callback)(void); +extern bool pid1_magic; + INTERNAL_ABI mach_port_t runtime_get_kernel_port(void); INTERNAL_ABI void runtime_add_ref(void); Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2008-01-11 15:17:14 UTC (rev 23480) +++ trunk/launchd/src/launchd_unix_ipc.c 2008-01-11 17:12:59 UTC (rev 23481) @@ -102,7 +102,7 @@ memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; - if (getpid() == 1) { + if (pid1_magic) { strcpy(ourdir, LAUNCHD_SOCK_PREFIX); strncpy(sun.sun_path, LAUNCHD_SOCK_PREFIX "/sock", sizeof(sun.sun_path)); @@ -458,7 +458,7 @@ continue; } - if (/* XXX readcfg_pid && */ getpid() == 1 && (i == RLIMIT_NOFILE || i == RLIMIT_NPROC)) { + if (/* XXX readcfg_pid && */ pid1_magic && (i == RLIMIT_NOFILE || i == RLIMIT_NPROC)) { int gmib[] = { CTL_KERN, KERN_MAXPROC }; int pmib[] = { CTL_KERN, KERN_MAXPROCPERUID }; const char *gstr = "kern.maxproc"; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080111/483f6910/attachment-0001.html From source_changes at macosforge.org Mon Jan 14 09:44:47 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 14 09:47:23 2008 Subject: [launchd-changes] [23482] trunk/launchd/src Message-ID: <20080114174447.25E3F9C94D7@beta.macosforge.org> Revision: 23482 http://trac.macosforge.org/projects/launchd/changeset/23482 Author: zarzycki@apple.com Date: 2008-01-14 09:44:45 -0800 (Mon, 14 Jan 2008) Log Message: ----------- Misc. changes Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-11 17:12:59 UTC (rev 23481) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-14 17:44:45 UTC (rev 23482) @@ -535,7 +535,7 @@ INTERNAL_ABI void job_stop(job_t j) { - if (!j->p || j->anonymous) { + if (unlikely(!j->p || j->anonymous)) { return; } @@ -1938,8 +1938,7 @@ job_t ji; if (jm->jm_port == mport) { - jobmgr_assumes(jm, (ji = jobmgr_find_by_pid(jm, upid, true)) != NULL); - return ji; + return jobmgr_find_by_pid(jm, upid, true); } SLIST_FOREACH(jmi, &jm->submgrs, sle) { @@ -2340,7 +2339,7 @@ void job_kill(job_t j) { - if (!j->p || j->anonymous) { + if (unlikely(!j->p || j->anonymous)) { return; } @@ -4850,12 +4849,6 @@ return NULL; } -INTERNAL_ABI bool -job_is_anonymous(job_t j) -{ - return j->anonymous; -} - void job_force_sampletool(job_t j) { @@ -5956,13 +5949,15 @@ ms = jobmgr_lookup_service(j->mgr, servicename, true, 0); } - if (ms && machservice_hidden(ms) && !job_active(machservice_job(ms))) { - ms = NULL; - } else if (ms && unlikely(ms->per_user_hack)) { - ms = NULL; + if (likely(ms)) { + if (machservice_hidden(ms) && !job_active(machservice_job(ms))) { + ms = NULL; + } else if (unlikely(ms->per_user_hack)) { + ms = NULL; + } } - if (ms) { + if (likely(ms)) { job_assumes(j, machservice_port(ms) != MACH_PORT_NULL); job_log(j, LOG_DEBUG, "%sMach service lookup: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-11 17:12:59 UTC (rev 23481) +++ trunk/launchd/src/launchd_runtime.c 2008-01-14 17:44:45 UTC (rev 23482) @@ -1049,16 +1049,19 @@ } /* we have another request message */ - +#if 0 if (!launchd_assumes(mig_cb_table != NULL)) { break; } +#endif the_demux = mig_cb_table[MACH_PORT_INDEX(bufRequest->Head.msgh_local_port)]; +#if 0 if (!launchd_assumes(the_demux != NULL)) { break; } +#endif record_caller_creds(&bufRequest->Head); @@ -1334,7 +1337,7 @@ return; } - if (!shutdown_in_progress && !fake_shutdown_in_progress) { + if (likely(!shutdown_in_progress && !fake_shutdown_in_progress)) { runtime_log_uncork_pending_drain(); return; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080114/a3cdf91e/attachment.html From source_changes at macosforge.org Mon Jan 14 16:51:22 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 14 16:52:16 2008 Subject: [launchd-changes] [23483] trunk/launchd/src/launchd_runtime.c Message-ID: <20080115005122.793FB9E65C6@beta.macosforge.org> Revision: 23483 http://trac.macosforge.org/projects/launchd/changeset/23483 Author: zarzycki@apple.com Date: 2008-01-14 16:51:21 -0800 (Mon, 14 Jan 2008) Log Message: ----------- More misc changes. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-14 17:44:45 UTC (rev 23482) +++ trunk/launchd/src/launchd_runtime.c 2008-01-15 00:51:21 UTC (rev 23483) @@ -1021,13 +1021,16 @@ tmp_options = options; - if (unlikely(mr == MACH_SEND_INVALID_DEST || mr == MACH_SEND_TIMED_OUT)) { + /* It looks like the compiler doesn't optimize switch(unlikely(...)) */ + if (unlikely(mr)) switch (mr) { + case MACH_SEND_INVALID_DEST: + case MACH_SEND_TIMED_OUT: /* We need to clean up and start over. */ if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) { mach_msg_destroy(&bufReply->Head); } continue; - } else if (unlikely(mr == MACH_RCV_TIMED_OUT)) { + case MACH_RCV_TIMED_OUT: if (to != MACH_MSG_TIMEOUT_NONE) { if (runtime_busy_cnt == 0) { launchd_shutdown(); @@ -1036,7 +1039,8 @@ } } continue; - } else if (!launchd_assumes(mr == MACH_MSG_SUCCESS)) { + default: + launchd_assumes(mr == MACH_MSG_SUCCESS); continue; } @@ -1076,25 +1080,28 @@ if (the_demux(&bufRequest->Head, &bufReply->Head) == FALSE) { /* XXX - also gross */ - if (bufRequest->Head.msgh_id == MACH_NOTIFY_NO_SENDERS) { + if (likely(bufRequest->Head.msgh_id == MACH_NOTIFY_NO_SENDERS)) { notify_server(&bufRequest->Head, &bufReply->Head); } } + /* bufReply is a union. If MACH_MSGH_BITS_COMPLEX is set, then bufReply->RetCode is assumed to be zero. */ if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { - if (bufReply->RetCode == MIG_NO_REPLY) { - bufReply->Head.msgh_remote_port = MACH_PORT_NULL; - } else if ((bufReply->RetCode != KERN_SUCCESS) && (bufRequest->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { - /* destroy the request - but not the reply port */ - bufRequest->Head.msgh_remote_port = MACH_PORT_NULL; - mach_msg_destroy(&bufRequest->Head); + if (unlikely(bufReply->RetCode != KERN_SUCCESS)) { + if (likely(bufReply->RetCode == MIG_NO_REPLY)) { + bufReply->Head.msgh_remote_port = MACH_PORT_NULL; + } else if (bufRequest->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) { + /* destroy the request - but not the reply port */ + bufRequest->Head.msgh_remote_port = MACH_PORT_NULL; + mach_msg_destroy(&bufRequest->Head); + } } } - if (bufReply->Head.msgh_remote_port != MACH_PORT_NULL) { + if (likely(bufReply->Head.msgh_remote_port != MACH_PORT_NULL)) { tmp_options |= MACH_SEND_MSG; - if (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) != MACH_MSG_TYPE_MOVE_SEND_ONCE) { + if (unlikely(MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) != MACH_MSG_TYPE_MOVE_SEND_ONCE)) { tmp_options |= MACH_SEND_TIMEOUT; } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080114/37a799fd/attachment.html From source_changes at macosforge.org Wed Jan 16 12:56:13 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 16 12:57:39 2008 Subject: [launchd-changes] [23484] trunk/launchd/src Message-ID: <20080116205613.E6EB3A4BA92@beta.macosforge.org> Revision: 23484 http://trac.macosforge.org/projects/launchd/changeset/23484 Author: zarzycki@apple.com Date: 2008-01-16 12:56:12 -0800 (Wed, 16 Jan 2008) Log Message: ----------- A simple change. Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-01-15 00:51:21 UTC (rev 23483) +++ trunk/launchd/src/launchd.c 2008-01-16 20:56:12 UTC (rev 23484) @@ -77,7 +77,6 @@ #define LAUNCHD_CONF ".launchd.conf" #define SECURITY_LIB "/System/Library/Frameworks/Security.framework/Versions/A/Security" -#define SHUTDOWN_LOG_DIR "/var/log/shutdown" extern char **environ; @@ -93,7 +92,6 @@ static void monitor_networking_state(void); static void fatal_signal_handler(int sig, siginfo_t *si, void *uap); static void handle_pid1_crashes_separately(void); -static void prep_shutdown_log_dir(void); static bool re_exec_in_single_user_mode; static void *crash_addr; @@ -236,12 +234,6 @@ return fd; } -void -prep_shutdown_log_dir(void) -{ - launchd_assumes(mkdir(SHUTDOWN_LOG_DIR, S_IRWXU) != -1 || errno == EEXIST); -} - INTERNAL_ABI void launchd_shutdown(void) { @@ -259,7 +251,6 @@ * http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown */ runtime_setlogmask(LOG_UPTO(LOG_DEBUG)); - prep_shutdown_log_dir(); } runtime_log_push(); Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2008-01-15 00:51:21 UTC (rev 23483) +++ trunk/launchd/src/launchd.h 2008-01-16 20:56:12 UTC (rev 23484) @@ -26,8 +26,6 @@ #include "libbootstrap_public.h" #include "launchd_runtime.h" -#define SHUTDOWN_LOG_DIR "/var/log/shutdown" - struct kevent; struct conncb; Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-15 00:51:21 UTC (rev 23483) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-16 20:56:12 UTC (rev 23484) @@ -96,6 +96,7 @@ #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 #define LAUNCHD_SIGKILL_TIMER 5 +#define SHUTDOWN_LOG_DIR "/var/log/shutdown" #define TAKE_SUBSET_NAME "TakeSubsetName" #define TAKE_SUBSET_PID "TakeSubsetPID" @@ -714,7 +715,7 @@ } } - if (do_apple_internal_logging() && jm->parentmgr == NULL && pid1_magic) { + if (do_apple_internal_logging && jm->parentmgr == NULL && pid1_magic) { runtime_set_timeout(still_alive_with_check, 5); } @@ -4862,10 +4863,14 @@ int wstatus; pid_t sp; - if (!do_apple_internal_logging()) { + if (!do_apple_internal_logging) { return; } + if (!job_assumes(j, mkdir(SHUTDOWN_LOG_DIR, S_IRWXU) != -1 || errno == EEXIST)) { + return; + } + snprintf(pidstr, sizeof(pidstr), "%u", j->p); snprintf(logfile, sizeof(logfile), SHUTDOWN_LOG_DIR "/%s-%u.sample.txt", j->label, j->p); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-15 00:51:21 UTC (rev 23483) +++ trunk/launchd/src/launchd_runtime.c 2008-01-16 20:56:12 UTC (rev 23484) @@ -121,7 +121,9 @@ static sigset_t sigign_set; static FILE *ourlogfile; bool pid1_magic; +bool do_apple_internal_logging; + INTERNAL_ABI mach_port_t runtime_get_kernel_port(void) { @@ -1145,7 +1147,7 @@ runtime_fsync(int fd) { #if 0 - if (do_apple_internal_logging()) { + if (do_apple_internal_logging) { return fcntl(fd, F_FULLFSYNC, NULL); } else { return fsync(fd); @@ -1187,7 +1189,7 @@ char newmsg[10000]; if (attr->priority == LOG_APPLEONLY) { - if (do_apple_internal_logging()) { + if (do_apple_internal_logging) { attr->priority = LOG_NOTICE; } else { return; @@ -1552,19 +1554,6 @@ launchd_mport_deallocate(mhs); } -INTERNAL_ABI bool -do_apple_internal_logging(void) -{ - static int apple_internal_logging = 1; - struct stat sb; - - if (unlikely(apple_internal_logging == 1)) { - apple_internal_logging = stat("/AppleInternal", &sb); - } - - return (apple_internal_logging == 0); -} - INTERNAL_ABI int64_t runtime_get_wall_time(void) { @@ -1612,6 +1601,8 @@ void do_file_init(void) { + struct stat sb; + launchd_assert(mach_timebase_info(&tbi) == 0); tbi_float_val = tbi.numer; tbi_float_val /= tbi.denom; @@ -1619,4 +1610,8 @@ if (getpid() == 1) { pid1_magic = true; } + + if (stat("/AppleInternal", &sb) != -1) { + do_apple_internal_logging = true; + } } Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2008-01-15 00:51:21 UTC (rev 23483) +++ trunk/launchd/src/launchd_runtime.h 2008-01-16 20:56:12 UTC (rev 23484) @@ -104,6 +104,7 @@ typedef INTERNAL_ABI void (*timeout_callback)(void); extern bool pid1_magic; +extern bool do_apple_internal_logging; INTERNAL_ABI mach_port_t runtime_get_kernel_port(void); @@ -130,8 +131,6 @@ INTERNAL_ABI const char *reboot_flags_to_C_names(unsigned int flags); INTERNAL_ABI const char *proc_flags_to_C_names(unsigned int flags); -INTERNAL_ABI bool do_apple_internal_logging(void); - INTERNAL_ABI int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt); INTERNAL_ABI int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080116/f295995e/attachment-0001.html From source_changes at macosforge.org Fri Jan 18 09:49:36 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 18 09:51:00 2008 Subject: [launchd-changes] [23485] branches/SULeopard/launchd/src Message-ID: <20080118174936.7D345AEA56B@beta.macosforge.org> Revision: 23485 http://trac.macosforge.org/projects/launchd/changeset/23485 Author: zarzycki@apple.com Date: 2008-01-18 09:49:34 -0800 (Fri, 18 Jan 2008) Log Message: ----------- SpringBoard needs custom launchd job management API Modified Paths: -------------- branches/SULeopard/launchd/src/launchd_core_logic.c branches/SULeopard/launchd/src/launchd_runtime.h branches/SULeopard/launchd/src/liblaunch_public.h branches/SULeopard/launchd/src/libvproc.c branches/SULeopard/launchd/src/libvproc_private.h branches/SULeopard/launchd/src/protocol_job.defs Modified: branches/SULeopard/launchd/src/launchd_core_logic.c =================================================================== --- branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-16 20:56:12 UTC (rev 23484) +++ branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-18 17:49:34 UTC (rev 23485) @@ -322,7 +322,7 @@ cpu_type_t *j_binpref; size_t j_binpref_cnt; mach_port_t j_port; - mach_port_t wait_reply_port; + mach_port_t wait_reply_port; /* we probably should switch to a list of waiters */ uid_t mach_uid; jobmgr_t mgr; char **argv; @@ -361,7 +361,7 @@ currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1, wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, - poll_for_vfs_changes:1, internal_exc_handler:1; + poll_for_vfs_changes:1, internal_exc_handler:1, can_kickstart:1; const char label[0]; }; @@ -1568,12 +1568,41 @@ } } +static void +policy_setup(launch_data_t obj, const char *key, void *context) +{ + job_t j = context; + bool found_key = false; + + switch (key[0]) { + case 'c': + case 'C': + if (strcasecmp(key, LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS) == 0) { + j->can_kickstart = launch_data_get_bool(obj); + found_key = true; + } + break; + default: + break; + } + + if (unlikely(!found_key)) { + job_log(j, LOG_WARNING, "Unknown policy: %s", key); + } +} + void job_import_dictionary(job_t j, const char *key, launch_data_t value) { launch_data_t tmp; switch (key[0]) { + case 'p': + case 'P': + if (strcasecmp(key, LAUNCH_JOBKEY_POLICIES) == 0) { + launch_data_dict_iterate(value, policy_setup, j); + } + break; case 'k': case 'K': if (strcasecmp(key, LAUNCH_JOBKEY_KEEPALIVE) == 0) { @@ -6367,6 +6396,61 @@ } kern_return_t +job_mig_embedded_wait(job_t j, name_t targetlabel, integer_t *waitstatus) +{ + job_t otherj; + + if (!launchd_assumes(j != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + + if (unlikely(!(otherj = job_find(targetlabel)))) { + return BOOTSTRAP_UNKNOWN_SERVICE; + } + + *waitstatus = j->last_exit_status; + + return 0; +} + +kern_return_t +job_mig_embedded_kickstart(job_t j, name_t targetlabel, pid_t *out_pid, mach_port_t *out_name_port) +{ + struct ldcred ldc; + kern_return_t kr; + job_t otherj; + + if (!launchd_assumes(j != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + + runtime_get_caller_creds(&ldc); + + if (!j->can_kickstart || (ldc.euid != 0 && ldc.euid != geteuid())) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + + if (unlikely(!(otherj = job_find(targetlabel)))) { + return BOOTSTRAP_UNKNOWN_SERVICE; + } + + otherj = job_dispatch(otherj, true); + + if (!job_assumes(j, otherj && otherj->p)) { + return BOOTSTRAP_NO_MEMORY; + } + + kr = task_name_for_pid(mach_task_self(), otherj->p, out_name_port); + if (!job_assumes(j, kr == 0)) { + return kr; + } + + *out_pid = otherj->p; + + return 0; +} + +kern_return_t job_mig_wait(job_t j, mach_port_t srp, integer_t *waitstatus) { if (!launchd_assumes(j != NULL)) { Modified: branches/SULeopard/launchd/src/launchd_runtime.h =================================================================== --- branches/SULeopard/launchd/src/launchd_runtime.h 2008-01-16 20:56:12 UTC (rev 23484) +++ branches/SULeopard/launchd/src/launchd_runtime.h 2008-01-18 17:49:34 UTC (rev 23485) @@ -50,6 +50,9 @@ #define launchd_assert(e) if (__builtin_constant_p(e)) { char __compile_time_assert__[e ? 1 : -1] __attribute__((unused)); } else if (!launchd_assumes(e)) { abort(); } +#define likely(x) __builtin_expect((bool)(x), true) +#define unlikely(x) __builtin_expect((bool)(x), false) + void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test); typedef void (*kq_callback)(void *, struct kevent *); Modified: branches/SULeopard/launchd/src/liblaunch_public.h =================================================================== --- branches/SULeopard/launchd/src/liblaunch_public.h 2008-01-16 20:56:12 UTC (rev 23484) +++ branches/SULeopard/launchd/src/liblaunch_public.h 2008-01-18 17:49:34 UTC (rev 23485) @@ -99,7 +99,10 @@ #define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" #define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" #define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup" +#define LAUNCH_JOBKEY_POLICIES "Policies" +#define LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS "CanKickStartOtherJobs" + #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" #define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" Modified: branches/SULeopard/launchd/src/libvproc.c =================================================================== --- branches/SULeopard/launchd/src/libvproc.c 2008-01-16 20:56:12 UTC (rev 23484) +++ branches/SULeopard/launchd/src/libvproc.c 2008-01-18 17:49:34 UTC (rev 23485) @@ -553,6 +553,26 @@ } vproc_err_t +_vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name) +{ + if (vproc_mig_embedded_kickstart(bootstrap_port, (char *)label, out_pid, out_port_name) == 0) { + return NULL; + } + + return (vproc_err_t)_vproc_kickstart_by_label; +} + +vproc_err_t +_vproc_wait_by_label(const char *label, int *out_wstatus) +{ + if (vproc_mig_embedded_wait(bootstrap_port, (char *)label, out_wstatus) == 0) { + return NULL; + } + + return (vproc_err_t)_vproc_wait_by_label; +} + +vproc_err_t _vproc_set_global_on_demand(bool state) { int64_t val = state ? ~0 : 0; Modified: branches/SULeopard/launchd/src/libvproc_private.h =================================================================== --- branches/SULeopard/launchd/src/libvproc_private.h 2008-01-16 20:56:12 UTC (rev 23484) +++ branches/SULeopard/launchd/src/libvproc_private.h 2008-01-18 17:49:34 UTC (rev 23485) @@ -61,6 +61,8 @@ 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); +vproc_err_t _vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name); +vproc_err_t _vproc_wait_by_label(const char *label, int *out_wstatus); 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))); Modified: branches/SULeopard/launchd/src/protocol_job.defs =================================================================== --- branches/SULeopard/launchd/src/protocol_job.defs 2008-01-16 20:56:12 UTC (rev 23484) +++ branches/SULeopard/launchd/src/protocol_job.defs 2008-01-18 17:49:34 UTC (rev 23485) @@ -166,3 +166,14 @@ routine log_forward( __bs_port : job_t; __inval : pointer_t); + +routine embedded_kickstart( + __bs_port : job_t; + __label : name_t; + out __pid : pid_t; + out __name_port : mach_port_t); + +routine embedded_wait( + __bs_port : job_t; + __label : name_t; + out __waitval : integer_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080118/5125729e/attachment.html From source_changes at macosforge.org Fri Jan 18 09:50:13 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 18 09:51:39 2008 Subject: [launchd-changes] [23486] trunk/launchd/src Message-ID: <20080118175013.D1DB3AEA62D@beta.macosforge.org> Revision: 23486 http://trac.macosforge.org/projects/launchd/changeset/23486 Author: zarzycki@apple.com Date: 2008-01-18 09:50:12 -0800 (Fri, 18 Jan 2008) Log Message: ----------- SpringBoard needs custom launchd job management API Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch_public.h trunk/launchd/src/libvproc.c 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 2008-01-18 17:49:34 UTC (rev 23485) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-18 17:50:12 UTC (rev 23486) @@ -325,7 +325,7 @@ cpu_type_t *j_binpref; size_t j_binpref_cnt; mach_port_t j_port; - mach_port_t wait_reply_port; + mach_port_t wait_reply_port; /* we probably should switch to a list of waiters */ uid_t mach_uid; jobmgr_t mgr; char **argv; @@ -365,7 +365,7 @@ currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1, legacy_LS_job:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, - poll_for_vfs_changes:1, __junk:12; + poll_for_vfs_changes:1, can_kickstart:1, __junk:11; mode_t mask; const char label[0]; }; @@ -1636,12 +1636,41 @@ } } +static void +policy_setup(launch_data_t obj, const char *key, void *context) +{ + job_t j = context; + bool found_key = false; + + switch (key[0]) { + case 'c': + case 'C': + if (strcasecmp(key, LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS) == 0) { + j->can_kickstart = launch_data_get_bool(obj); + found_key = true; + } + break; + default: + break; + } + + if (unlikely(!found_key)) { + job_log(j, LOG_WARNING, "Unknown policy: %s", key); + } +} + void job_import_dictionary(job_t j, const char *key, launch_data_t value) { launch_data_t tmp; switch (key[0]) { + case 'p': + case 'P': + if (strcasecmp(key, LAUNCH_JOBKEY_POLICIES) == 0) { + launch_data_dict_iterate(value, policy_setup, j); + } + break; case 'k': case 'K': if (strcasecmp(key, LAUNCH_JOBKEY_KEEPALIVE) == 0) { @@ -6525,6 +6554,61 @@ } kern_return_t +job_mig_embedded_wait(job_t j, name_t targetlabel, integer_t *waitstatus) +{ + job_t otherj; + + if (!launchd_assumes(j != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + + if (unlikely(!(otherj = job_find(targetlabel)))) { + return BOOTSTRAP_UNKNOWN_SERVICE; + } + + *waitstatus = j->last_exit_status; + + return 0; +} + +kern_return_t +job_mig_embedded_kickstart(job_t j, name_t targetlabel, pid_t *out_pid, mach_port_t *out_name_port) +{ + struct ldcred ldc; + kern_return_t kr; + job_t otherj; + + if (!launchd_assumes(j != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + + runtime_get_caller_creds(&ldc); + + if (!j->can_kickstart || (ldc.euid != 0 && ldc.euid != geteuid())) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + + if (unlikely(!(otherj = job_find(targetlabel)))) { + return BOOTSTRAP_UNKNOWN_SERVICE; + } + + otherj = job_dispatch(otherj, true); + + if (!job_assumes(j, otherj && otherj->p)) { + return BOOTSTRAP_NO_MEMORY; + } + + kr = task_name_for_pid(mach_task_self(), otherj->p, out_name_port); + if (!job_assumes(j, kr == 0)) { + return kr; + } + + *out_pid = otherj->p; + + return 0; +} + +kern_return_t job_mig_wait(job_t j, mach_port_t srp, integer_t *waitstatus) { if (!launchd_assumes(j != NULL)) { Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2008-01-18 17:49:34 UTC (rev 23485) +++ trunk/launchd/src/liblaunch_public.h 2008-01-18 17:50:12 UTC (rev 23486) @@ -100,7 +100,10 @@ #define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" #define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" #define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup" +#define LAUNCH_JOBKEY_POLICIES "Policies" +#define LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS "CanKickStartOtherJobs" + #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" #define LAUNCH_JOBKEY_MACH_RESETATCLOSE "ResetAtClose" Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2008-01-18 17:49:34 UTC (rev 23485) +++ trunk/launchd/src/libvproc.c 2008-01-18 17:50:12 UTC (rev 23486) @@ -389,6 +389,7 @@ { mach_msg_type_number_t outdata_cnt, tmp_cnt; vm_offset_t outdata = 0; + struct timeval tv; struct logmsg_s *lm; if (!func) { @@ -411,7 +412,10 @@ 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, + tv.tv_sec = lm->when / USEC_PER_SEC; + tv.tv_usec = lm->when % USEC_PER_SEC; + + func(&tv, 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; @@ -553,6 +557,26 @@ } vproc_err_t +_vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name) +{ + if (vproc_mig_embedded_kickstart(bootstrap_port, (char *)label, out_pid, out_port_name) == 0) { + return NULL; + } + + return (vproc_err_t)_vproc_kickstart_by_label; +} + +vproc_err_t +_vproc_wait_by_label(const char *label, int *out_wstatus) +{ + if (vproc_mig_embedded_wait(bootstrap_port, (char *)label, out_wstatus) == 0) { + return NULL; + } + + return (vproc_err_t)_vproc_wait_by_label; +} + +vproc_err_t _vproc_set_global_on_demand(bool state) { int64_t val = state ? ~0 : 0; Modified: trunk/launchd/src/libvproc_private.h =================================================================== --- trunk/launchd/src/libvproc_private.h 2008-01-18 17:49:34 UTC (rev 23485) +++ trunk/launchd/src/libvproc_private.h 2008-01-18 17:50:12 UTC (rev 23486) @@ -61,6 +61,8 @@ 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); +vproc_err_t _vproc_kickstart_by_label(const char *label, pid_t *out_pid, mach_port_t *out_port_name); +vproc_err_t _vproc_wait_by_label(const char *label, int *out_wstatus); 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))); Modified: trunk/launchd/src/protocol_job.defs =================================================================== --- trunk/launchd/src/protocol_job.defs 2008-01-18 17:49:34 UTC (rev 23485) +++ trunk/launchd/src/protocol_job.defs 2008-01-18 17:50:12 UTC (rev 23486) @@ -168,3 +168,14 @@ routine log_forward( __bs_port : job_t; __inval : pointer_t); + +routine embedded_kickstart( + __bs_port : job_t; + __label : name_t; + out __pid : pid_t; + out __name_port : mach_port_t); + +routine embedded_wait( + __bs_port : job_t; + __label : name_t; + out __waitval : integer_t); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080118/8727b2bf/attachment-0001.html From source_changes at macosforge.org Fri Jan 18 13:24:32 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 18 13:25:27 2008 Subject: [launchd-changes] [23487] branches/SULeopard/launchd/src Message-ID: <20080118212432.E5B5EAFD20B@beta.macosforge.org> Revision: 23487 http://trac.macosforge.org/projects/launchd/changeset/23487 Author: zarzycki@apple.com Date: 2008-01-18 13:24:30 -0800 (Fri, 18 Jan 2008) Log Message: ----------- work with Seatbelt to provide access control on spawn_via_launchd Modified Paths: -------------- branches/SULeopard/launchd/src/launchd_core_logic.c branches/SULeopard/launchd/src/liblaunch_public.h Modified: branches/SULeopard/launchd/src/launchd_core_logic.c =================================================================== --- branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-18 17:50:12 UTC (rev 23486) +++ branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-18 21:24:30 UTC (rev 23487) @@ -361,7 +361,7 @@ currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1, wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, - poll_for_vfs_changes:1, internal_exc_handler:1, can_kickstart:1; + poll_for_vfs_changes:1, internal_exc_handler:1, deny_job_creation:1; const char label[0]; }; @@ -1575,10 +1575,10 @@ bool found_key = false; switch (key[0]) { - case 'c': - case 'C': - if (strcasecmp(key, LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS) == 0) { - j->can_kickstart = launch_data_get_bool(obj); + case 'd': + case 'D': + if (strcasecmp(key, LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS) == 0) { + j->deny_job_creation = launch_data_get_bool(obj); found_key = true; } break; @@ -5140,6 +5140,10 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(j->deny_job_creation)) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + runtime_get_caller_creds(&ldc); job_log(j, LOG_DEBUG, "Server create attempt: %s", server_cmd); @@ -6424,16 +6428,21 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(!(otherj = job_find(targetlabel)))) { + return BOOTSTRAP_UNKNOWN_SERVICE; + } + runtime_get_caller_creds(&ldc); - if (!j->can_kickstart || (ldc.euid != 0 && ldc.euid != geteuid())) { + if (ldc.euid != 0 && ldc.euid != geteuid() +#if TARGET_OS_EMBEDDED + && j->username && otherj->username + && strcmp(j->username, otherj->username) != 0 +#endif + ) { return BOOTSTRAP_NOT_PRIVILEGED; } - if (unlikely(!(otherj = job_find(targetlabel)))) { - return BOOTSTRAP_UNKNOWN_SERVICE; - } - otherj = job_dispatch(otherj, true); if (!job_assumes(j, otherj && otherj->p)) { @@ -6522,6 +6531,10 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(j->deny_job_creation)) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + if (getpid() == 1 && ldc.euid && ldc.uid) { job_log(j, LOG_DEBUG, "Punting spawn to per-user-context"); return VPROC_ERR_TRY_PER_USER; Modified: branches/SULeopard/launchd/src/liblaunch_public.h =================================================================== --- branches/SULeopard/launchd/src/liblaunch_public.h 2008-01-18 17:50:12 UTC (rev 23486) +++ branches/SULeopard/launchd/src/liblaunch_public.h 2008-01-18 21:24:30 UTC (rev 23487) @@ -101,7 +101,7 @@ #define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup" #define LAUNCH_JOBKEY_POLICIES "Policies" -#define LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS "CanKickStartOtherJobs" +#define LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS "DenyCreatingOtherJobs" #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080118/ce7ca106/attachment.html From source_changes at macosforge.org Fri Jan 18 13:27:03 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 18 13:28:28 2008 Subject: [launchd-changes] [23488] trunk/launchd/src Message-ID: <20080118212703.40EABAFD53D@beta.macosforge.org> Revision: 23488 http://trac.macosforge.org/projects/launchd/changeset/23488 Author: zarzycki@apple.com Date: 2008-01-18 13:27:01 -0800 (Fri, 18 Jan 2008) Log Message: ----------- work with Seatbelt to provide access control on spawn_via_launchd Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-18 21:24:30 UTC (rev 23487) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-18 21:27:01 UTC (rev 23488) @@ -365,7 +365,7 @@ currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1, legacy_LS_job:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, - poll_for_vfs_changes:1, can_kickstart:1, __junk:11; + poll_for_vfs_changes:1, deny_job_creation:1, __junk:11; mode_t mask; const char label[0]; }; @@ -1643,10 +1643,10 @@ bool found_key = false; switch (key[0]) { - case 'c': - case 'C': - if (strcasecmp(key, LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS) == 0) { - j->can_kickstart = launch_data_get_bool(obj); + case 'd': + case 'D': + if (strcasecmp(key, LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS) == 0) { + j->deny_job_creation = launch_data_get_bool(obj); found_key = true; } break; @@ -5296,6 +5296,10 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(j->deny_job_creation)) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + runtime_get_caller_creds(&ldc); job_log(j, LOG_DEBUG, "Server create attempt: %s", server_cmd); @@ -6582,16 +6586,21 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(!(otherj = job_find(targetlabel)))) { + return BOOTSTRAP_UNKNOWN_SERVICE; + } + runtime_get_caller_creds(&ldc); - if (!j->can_kickstart || (ldc.euid != 0 && ldc.euid != geteuid())) { + if (ldc.euid != 0 && ldc.euid != geteuid() +#if TARGET_OS_EMBEDDED + && j->username && otherj->username + && strcmp(j->username, otherj->username) != 0 +#endif + ) { return BOOTSTRAP_NOT_PRIVILEGED; } - if (unlikely(!(otherj = job_find(targetlabel)))) { - return BOOTSTRAP_UNKNOWN_SERVICE; - } - otherj = job_dispatch(otherj, true); if (!job_assumes(j, otherj && otherj->p)) { @@ -6690,6 +6699,10 @@ return BOOTSTRAP_NO_MEMORY; } + if (unlikely(j->deny_job_creation)) { + return BOOTSTRAP_NOT_PRIVILEGED; + } + if (unlikely(pid1_magic && ldc.euid && ldc.uid)) { job_log(j, LOG_DEBUG, "Punting spawn to per-user-context"); return VPROC_ERR_TRY_PER_USER; Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2008-01-18 21:24:30 UTC (rev 23487) +++ trunk/launchd/src/liblaunch_public.h 2008-01-18 21:27:01 UTC (rev 23488) @@ -102,7 +102,7 @@ #define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup" #define LAUNCH_JOBKEY_POLICIES "Policies" -#define LAUNCH_JOBPOLICY_CANKICKSTARTOTHERJOBS "CanKickStartOtherJobs" +#define LAUNCH_JOBPOLICY_DENYCREATINGOTHERJOBS "DenyCreatingOtherJobs" #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080118/413189e2/attachment.html From source_changes at macosforge.org Fri Jan 18 16:53:25 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 18 16:54:20 2008 Subject: [launchd-changes] [23489] trunk/launchd/src Message-ID: <20080119005325.C7D2FB0CE60@beta.macosforge.org> Revision: 23489 http://trac.macosforge.org/projects/launchd/changeset/23489 Author: zarzycki@apple.com Date: 2008-01-18 16:53:23 -0800 (Fri, 18 Jan 2008) Log Message: ----------- Misc changes. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h trunk/launchd/src/libbootstrap_private.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-18 21:27:01 UTC (rev 23488) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-19 00:53:23 UTC (rev 23489) @@ -414,7 +414,6 @@ static job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv) __attribute__((malloc, nonnull(1,2), warn_unused_result)); static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond) __attribute__((malloc, nonnull, warn_unused_result)); static const char *job_prog(job_t j); -static jobmgr_t job_get_bs(job_t j); static void job_kill(job_t j); static void job_uncork_fork(job_t j); static void job_log_stdouterr(job_t j); @@ -1991,23 +1990,22 @@ INTERNAL_ABI job_t job_mig_intran(mach_port_t p) { - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); job_t jr; - runtime_get_caller_creds(&ldc); - jr = job_mig_intran2(root_jobmgr, p, ldc.pid); + jr = job_mig_intran2(root_jobmgr, p, ldc->pid); if (!jobmgr_assumes(root_jobmgr, jr != NULL)) { int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 }; struct kinfo_proc kp; size_t len = sizeof(kp); - mib[3] = ldc.pid; + mib[3] = ldc->pid; if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && jobmgr_assumes(root_jobmgr, len == sizeof(kp))) { - jobmgr_log(root_jobmgr, LOG_ERR, "%s() was confused by PID %u UID %u EUID %u Mach Port 0x%x: %s", __func__, ldc.pid, ldc.uid, ldc.euid, p, kp.kp_proc.p_comm); + jobmgr_log(root_jobmgr, LOG_ERR, "%s() was confused by PID %u UID %u EUID %u Mach Port 0x%x: %s", __func__, ldc->pid, ldc->uid, ldc->euid, p, kp.kp_proc.p_comm); } } @@ -4869,16 +4867,6 @@ job_dispatch(j, false); } -jobmgr_t -job_get_bs(job_t j) -{ - if (job_assumes(j, j->mgr != NULL)) { - return j->mgr; - } - - return NULL; -} - void job_force_sampletool(job_t j) { @@ -5289,7 +5277,7 @@ kern_return_t 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; + struct ldcred *ldc = runtime_get_caller_creds(); job_t js; if (!launchd_assumes(j != NULL)) { @@ -5300,18 +5288,16 @@ return BOOTSTRAP_NOT_PRIVILEGED; } - runtime_get_caller_creds(&ldc); - job_log(j, LOG_DEBUG, "Server create attempt: %s", server_cmd); #define LET_MERE_MORTALS_ADD_SERVERS_TO_PID1 /* XXX - This code should go away once the per session launchd is integrated with the rest of the system */ #ifdef LET_MERE_MORTALS_ADD_SERVERS_TO_PID1 if (pid1_magic) { - if (unlikely(ldc.euid && server_uid && (ldc.euid != server_uid))) { + if (unlikely(ldc->euid && server_uid && (ldc->euid != server_uid))) { job_log(j, LOG_WARNING, "Server create: \"%s\": Will run as UID %d, not UID %d as they told us to", - server_cmd, ldc.euid, server_uid); - server_uid = ldc.euid; + server_cmd, ldc->euid, server_uid); + server_uid = ldc->euid; } } else #endif @@ -5336,16 +5322,14 @@ kern_return_t job_mig_send_signal(job_t j, mach_port_t srp, name_t targetlabel, int sig) { - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); job_t otherj; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - runtime_get_caller_creds(&ldc); - - if (unlikely(ldc.euid != 0 && ldc.euid != getuid())) { + if (unlikely(ldc->euid != 0 && ldc->euid != getuid())) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5380,7 +5364,7 @@ kern_return_t job_mig_log_forward(job_t j, vm_offset_t inval, mach_msg_type_number_t invalCnt) { - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; @@ -5390,23 +5374,19 @@ return BOOTSTRAP_NOT_PRIVILEGED; } - runtime_get_caller_creds(&ldc); - - return runtime_log_forward(ldc.euid, ldc.egid, inval, invalCnt); + 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; + struct ldcred *ldc = runtime_get_caller_creds(); if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - runtime_get_caller_creds(&ldc); - - if (unlikely(ldc.euid)) { + if (unlikely(ldc->euid)) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5422,15 +5402,13 @@ launch_data_t input_obj, output_obj; size_t data_offset = 0; size_t packed_size; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); - runtime_get_caller_creds(&ldc); - if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - if (unlikely(inkey && ldc.euid && ldc.euid != getuid())) { + if (unlikely(inkey && ldc->euid && ldc->euid != getuid())) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5515,16 +5493,14 @@ { const char *action; kern_return_t kr = 0; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); int oldmask; - runtime_get_caller_creds(&ldc); - if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - if (unlikely(inkey && ldc.euid && ldc.euid != getuid())) { + if (unlikely(inkey && ldc->euid && ldc->euid != getuid())) { return BOOTSTRAP_NOT_PRIVILEGED; } @@ -5686,7 +5662,7 @@ { char who_started_the_reboot[2048] = ""; struct kinfo_proc kp; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); pid_t pid_to_log; if (!launchd_assumes(j != NULL)) { @@ -5697,13 +5673,11 @@ return BOOTSTRAP_NOT_PRIVILEGED; } - runtime_get_caller_creds(&ldc); - - if (unlikely(ldc.euid)) { + if (unlikely(ldc->euid)) { return BOOTSTRAP_NOT_PRIVILEGED; } - for (pid_to_log = ldc.pid; pid_to_log; pid_to_log = kp.kp_eproc.e_ppid) { + for (pid_to_log = ldc->pid; pid_to_log; pid_to_log = kp.kp_eproc.e_ppid) { int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid_to_log }; size_t who_offset, len = sizeof(kp); @@ -5777,7 +5751,7 @@ kern_return_t job_mig_lookup_per_user_context(job_t j, uid_t which_user, mach_port_t *up_cont) { - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); job_t ji; if (!launchd_assumes(j != NULL)) { @@ -5786,15 +5760,13 @@ job_log(j, LOG_DEBUG, "Looking up per user launchd for UID: %u", which_user); - runtime_get_caller_creds(&ldc); - if (unlikely(!pid1_magic)) { job_log(j, LOG_ERR, "Only PID 1 supports per user launchd lookups."); return BOOTSTRAP_NOT_PRIVILEGED; } - if (ldc.euid || ldc.uid) { - which_user = ldc.euid ? ldc.euid : ldc.uid; + if (ldc->euid || ldc->uid) { + which_user = ldc->euid ?: ldc->uid; } *up_cont = MACH_PORT_NULL; @@ -5864,15 +5836,13 @@ job_mig_check_in(job_t j, name_t servicename, mach_port_t *serviceportp) { struct machservice *ms; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); job_t jo; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - runtime_get_caller_creds(&ldc); - ms = jobmgr_lookup_service(j->mgr, servicename, true, 0); if (unlikely(ms == NULL)) { @@ -5883,9 +5853,9 @@ if (unlikely((jo = machservice_job(ms)) != j)) { static pid_t last_warned_pid; - if (last_warned_pid != ldc.pid) { + if (last_warned_pid != ldc->pid) { job_log(j, LOG_NOTICE, "Check-in of Mach service failed. The service \"%s\" is owned by: %s", servicename, jo->label); - last_warned_pid = ldc.pid; + last_warned_pid = ldc->pid; } return BOOTSTRAP_NOT_PRIVILEGED; @@ -5907,14 +5877,12 @@ job_mig_register2(job_t j, name_t servicename, mach_port_t serviceport, uint64_t flags) { struct machservice *ms; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - runtime_get_caller_creds(&ldc); - if (!(flags & BOOTSTRAP_PER_PID_SERVICE) && !j->legacy_LS_job) { job_log(j, LOG_APPLEONLY, "Performance: bootstrap_register() is deprecated. Service: %s", servicename); } @@ -5926,7 +5894,7 @@ * 92) is a rogue application (not our UID, not root and not a child of * us). We'll have to reconcile this design friction at a later date. */ - if (unlikely(j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.uid != getuid() && ldc.uid != 92)) { + if (unlikely(j->anonymous && j->mgr->parentmgr == NULL && ldc->uid != 0 && ldc->uid != getuid() && ldc->uid != 92)) { if (pid1_magic) { return VPROC_ERR_TRY_PER_USER; } else { @@ -5934,7 +5902,7 @@ } } - ms = jobmgr_lookup_service(j->mgr, servicename, false, flags & BOOTSTRAP_PER_PID_SERVICE ? ldc.pid : 0); + ms = jobmgr_lookup_service(j->mgr, servicename, false, flags & BOOTSTRAP_PER_PID_SERVICE ? ldc->pid : 0); if (unlikely(ms)) { if (machservice_job(ms) != j) { @@ -5963,16 +5931,14 @@ job_mig_look_up2(job_t j, mach_port_t srp, name_t servicename, mach_port_t *serviceportp, pid_t target_pid, uint64_t flags) { struct machservice *ms; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); kern_return_t kr; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - runtime_get_caller_creds(&ldc); - - if (unlikely(pid1_magic && j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.euid != 0)) { + if (unlikely(pid1_magic && j->anonymous && j->mgr->parentmgr == NULL && ldc->uid != 0 && ldc->euid != 0)) { return VPROC_ERR_TRY_PER_USER; } @@ -6014,7 +5980,7 @@ job_assumes(j, vproc_mig_look_up2_forward(inherited_bootstrap_port, srp, servicename, 0, 0) == 0); /* The previous routine moved the reply port, we're forced to return MIG_NO_REPLY now */ return MIG_NO_REPLY; - } else if (pid1_magic && j->anonymous && ldc.euid >= 500 && strcasecmp(job_get_bs(j)->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) { + } else if (pid1_magic && j->anonymous && ldc->euid >= 500 && strcasecmp(j->mgr->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) { /* * 5240036 Should start background session when a lookup of CCacheServer occurs * @@ -6182,20 +6148,18 @@ mach_port_t reqport, rcvright; kern_return_t kr = 1; launch_data_t out_obj_array = NULL; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); jobmgr_t jmr = NULL; if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } - runtime_get_caller_creds(&ldc); - if (target_subset == MACH_PORT_NULL) { job_t j2; if (j->mgr->session_initialized) { - if (ldc.uid == 0 && pid1_magic) { + if (ldc->uid == 0 && pid1_magic) { if (strcmp(j->mgr->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) { job_t ji, jn; @@ -6233,7 +6197,7 @@ kr = BOOTSTRAP_NOT_PRIVILEGED; goto out; } - } else if (ldc.uid == 0 && pid1_magic && strcmp(session_type, VPROCMGR_SESSION_STANDARDIO) == 0) { + } else if (ldc->uid == 0 && pid1_magic && strcmp(session_type, VPROCMGR_SESSION_STANDARDIO) == 0) { ensure_root_bkgd_setup(); SLIST_REMOVE(&j->mgr->parentmgr->submgrs, j->mgr, jobmgr_s, sle); @@ -6275,7 +6239,7 @@ kr = 0; goto out; - } else if (job_mig_intran2(root_jobmgr, target_subset, ldc.pid)) { + } else if (job_mig_intran2(root_jobmgr, target_subset, ldc->pid)) { job_log(j, LOG_ERR, "Moving a session to ourself is bogus."); kr = BOOTSTRAP_NOT_PRIVILEGED; @@ -6578,7 +6542,7 @@ kern_return_t job_mig_embedded_kickstart(job_t j, name_t targetlabel, pid_t *out_pid, mach_port_t *out_name_port) { - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); kern_return_t kr; job_t otherj; @@ -6590,9 +6554,7 @@ return BOOTSTRAP_UNKNOWN_SERVICE; } - runtime_get_caller_creds(&ldc); - - if (ldc.euid != 0 && ldc.euid != geteuid() + if (ldc->euid != 0 && ldc->euid != geteuid() #if TARGET_OS_EMBEDDED && j->username && otherj->username && strcmp(j->username, otherj->username) != 0 @@ -6624,8 +6586,7 @@ return BOOTSTRAP_NO_MEMORY; } #if 0 - struct ldcred ldc; - runtime_get_caller_creds(&ldc); + struct ldcred *ldc = runtime_get_caller_creds(); #endif return job_handle_mpm_wait(j, srp, waitstatus); } @@ -6661,7 +6622,6 @@ return BOOTSTRAP_NOT_PRIVILEGED; } - target_j = jobmgr_find_by_pid(j->mgr, target_pid, true); if (unlikely(target_j == NULL)) { @@ -6680,6 +6640,7 @@ } } else { target_j->deny_unknown_mslookups = !(flags & BOOTSTRAP_ALLOW_LOOKUP); + target_j->deny_job_creation = (bool)(flags & BOOTSTRAP_DENY_JOB_CREATION); } return 0; @@ -6690,11 +6651,9 @@ { launch_data_t input_obj = NULL; size_t data_offset = 0; - struct ldcred ldc; + struct ldcred *ldc = runtime_get_caller_creds(); job_t jr; - runtime_get_caller_creds(&ldc); - if (!launchd_assumes(j != NULL)) { return BOOTSTRAP_NO_MEMORY; } @@ -6703,7 +6662,7 @@ return BOOTSTRAP_NOT_PRIVILEGED; } - if (unlikely(pid1_magic && ldc.euid && ldc.uid)) { + if (unlikely(pid1_magic && ldc->euid && ldc->uid)) { job_log(j, LOG_DEBUG, "Punting spawn to per-user-context"); return VPROC_ERR_TRY_PER_USER; } @@ -6730,7 +6689,7 @@ job_reparent_hack(jr, NULL); if (pid1_magic) { - jr->mach_uid = ldc.uid; + jr->mach_uid = ldc->uid; } jr->legacy_LS_job = true; Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-18 21:27:01 UTC (rev 23488) +++ trunk/launchd/src/launchd_runtime.c 2008-01-19 00:53:23 UTC (rev 23489) @@ -96,7 +96,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; +static struct ldcred ldc; static size_t runtime_busy_cnt; @@ -960,26 +960,18 @@ trailer_size = tp->msgh_trailer_size - (mach_msg_size_t)(sizeof(mach_msg_trailer_type_t) - sizeof(mach_msg_trailer_size_t)); - if (unlikely(trailer_size < (mach_msg_size_t)sizeof(audit_token_t))) { - au_tok = NULL; - return; + if (launchd_assumes(trailer_size >= (mach_msg_size_t)sizeof(audit_token_t))) { + audit_token_to_au32(tp->msgh_audit, /* audit UID */ NULL, &ldc.euid, + &ldc.egid, &ldc.uid, &ldc.gid, &ldc.pid, + /* au_asid_t */ NULL, /* au_tid_t */ NULL); } - au_tok = &tp->msgh_audit; } -INTERNAL_ABI bool -runtime_get_caller_creds(struct ldcred *ldc) +INTERNAL_ABI struct ldcred * +runtime_get_caller_creds(void) { - if (unlikely(!au_tok)) { - return false; - } - - audit_token_to_au32(*au_tok, /* audit UID */ NULL, &ldc->euid, - &ldc->egid, &ldc->uid, &ldc->gid, &ldc->pid, - /* au_asid_t */ NULL, /* au_tid_t */ NULL); - - return true; + return &ldc; } void Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2008-01-18 21:27:01 UTC (rev 23488) +++ trunk/launchd/src/launchd_runtime.h 2008-01-19 00:53:23 UTC (rev 23489) @@ -125,7 +125,7 @@ INTERNAL_ABI void runtime_set_timeout(timeout_callback to_cb, unsigned int sec); INTERNAL_ABI kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); INTERNAL_ABI kern_return_t runtime_remove_mport(mach_port_t name); -INTERNAL_ABI bool runtime_get_caller_creds(struct ldcred *ldc); +INTERNAL_ABI struct ldcred *runtime_get_caller_creds(void); INTERNAL_ABI const char *signal_to_C_name(unsigned int sig); INTERNAL_ABI const char *reboot_flags_to_C_names(unsigned int flags); Modified: trunk/launchd/src/libbootstrap_private.h =================================================================== --- trunk/launchd/src/libbootstrap_private.h 2008-01-18 21:27:01 UTC (rev 23488) +++ trunk/launchd/src/libbootstrap_private.h 2008-01-19 00:53:23 UTC (rev 23489) @@ -29,6 +29,7 @@ #define BOOTSTRAP_PER_PID_SERVICE 0x1 #define BOOTSTRAP_ALLOW_LOOKUP 0x2 +#define BOOTSTRAP_DENY_JOB_CREATION 0x4 kern_return_t bootstrap_register2(mach_port_t bp, name_t service_name, mach_port_t sp, uint64_t flags); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080118/0c25d949/attachment-0001.html From source_changes at macosforge.org Mon Jan 21 14:14:29 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 21 14:15:55 2008 Subject: [launchd-changes] [23490] trunk/launchd/src Message-ID: <20080121221429.04CF6B9F5E6@beta.macosforge.org> Revision: 23490 http://trac.macosforge.org/projects/launchd/changeset/23490 Author: zarzycki@apple.com Date: 2008-01-21 14:14:27 -0800 (Mon, 21 Jan 2008) Log Message: ----------- Kernel trace logic support. Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-01-19 00:53:23 UTC (rev 23489) +++ trunk/launchd/src/launchd.c 2008-01-21 22:14:27 UTC (rev 23490) @@ -243,6 +243,8 @@ return; } + runtime_ktrace0(RTKT_LAUNCHD_EXITING); + shutdown_in_progress = true; if (pid1_magic) { @@ -391,6 +393,8 @@ const char *file = strrchr(path, '/'); char *rcs_rev_tmp = strchr(rcs_rev, ' '); + runtime_ktrace1(RTKT_LAUNCHD_BUG); + if (!file) { file = path; } else { Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-19 00:53:23 UTC (rev 23489) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-21 22:14:27 UTC (rev 23490) @@ -2083,6 +2083,8 @@ size_t i, kp_cnt, len = 10*1024*1024; struct kinfo_proc *kp; + runtime_ktrace(RTKT_LAUNCHD_FINDING_STRAY_PG, j->p, 0, 0); + if (!job_assumes(j, (kp = malloc(len)) != NULL)) { return; } @@ -2925,6 +2927,9 @@ if (!job_assumes(j, kp != NULL)) { return; } + + runtime_ktrace(RTKT_LAUNCHD_FINDING_WEIRD_UIDS, j->p, u, 0); + if (!job_assumes(j, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) { goto out; } @@ -3266,6 +3271,8 @@ int saved_errno = errno; char buf[100]; + runtime_ktrace1(RTKT_LAUNCHD_BUG); + extract_rcsid_substr(__rcs_file_version__, buf, sizeof(buf)); if (!file) { @@ -3292,6 +3299,8 @@ int saved_errno = errno; char buf[100]; + runtime_ktrace1(RTKT_LAUNCHD_BUG); + extract_rcsid_substr(__rcs_file_version__, buf, sizeof(buf)); if (!file) { @@ -4421,6 +4430,9 @@ if (!jobmgr_assumes(jm, (kp = malloc(len)) != NULL)) { return; } + + runtime_ktrace0(RTKT_LAUNCHD_FINDING_ALL_STRAYS); + if (!jobmgr_assumes(jm, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) { goto out; } @@ -5432,6 +5444,7 @@ return 1; } + runtime_ktrace0(RTKT_LAUNCHD_DATA_UNPACK); if (unlikely(invalCnt && !job_assumes(j, (input_obj = launch_data_unpack((void *)inval, invalCnt, NULL, 0, &data_offset, NULL)) != NULL))) { goto out_bad; } @@ -5442,6 +5455,7 @@ goto out_bad; } jobmgr_export_env_from_other_jobs(j->mgr, output_obj); + runtime_ktrace0(RTKT_LAUNCHD_DATA_PACK); if (!job_assumes(j, launch_data_pack(output_obj, (void *)*outval, *outvalCnt, NULL, NULL) != 0)) { goto out_bad; } @@ -5452,6 +5466,7 @@ goto out_bad; } ipc_revoke_fds(output_obj); + runtime_ktrace0(RTKT_LAUNCHD_DATA_PACK); packed_size = launch_data_pack(output_obj, (void *)*outval, *outvalCnt, NULL, NULL); if (!job_assumes(j, packed_size != 0)) { goto out_bad; @@ -6415,6 +6430,7 @@ job_assumes(j, cnt == cnt2); + runtime_ktrace0(RTKT_LAUNCHD_DATA_PACK); packed_size = launch_data_pack(outdata_obj_array, (void *)*outdata, *outdataCnt, NULL, NULL); if (!job_assumes(j, packed_size != 0)) { goto out_bad; @@ -6671,6 +6687,7 @@ return 1; } + runtime_ktrace0(RTKT_LAUNCHD_DATA_UNPACK); if (!job_assumes(j, (input_obj = launch_data_unpack((void *)indata, indataCnt, NULL, 0, &data_offset, NULL)) != NULL)) { return 1; } Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2008-01-19 00:53:23 UTC (rev 23489) +++ trunk/launchd/src/launchd_runtime.c 2008-01-21 22:14:27 UTC (rev 23490) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +87,7 @@ static void *mport_demand_loop(void *arg); static void *kqueue_demand_loop(void *arg); -static void log_kevent_struct(int level, struct kevent *kev, int indx); +static void log_kevent_struct(int level, struct kevent *kev_base, int indx); static boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); static void record_caller_creds(mach_msg_header_t *mh); @@ -347,8 +348,9 @@ } void -log_kevent_struct(int level, struct kevent *kev, int indx) +log_kevent_struct(int level, struct kevent *kev_base, int indx) { + struct kevent *kev = &kev_base[indx]; const char *filter_str; char ident_buf[100]; char filter_buf[100]; @@ -547,7 +549,7 @@ (*((kq_callback *)kev.udata))(kev.udata, &kev); #if 0 } else { - log_kevent_struct(LOG_ERR, &kev); + log_kevent_struct(LOG_ERR, &kev, 0); } #endif /* the callback may have tainted our ability to continue this for loop */ @@ -601,17 +603,19 @@ if (launchd_assumes(malloc_size(kev.udata) || dladdr(kev.udata, &dli))) { #endif for (i = 0; i < bulk_kev_cnt; i++) { - log_kevent_struct(LOG_DEBUG, &kev[i], i); + log_kevent_struct(LOG_DEBUG, kev, i); } for (i = 0; i < bulk_kev_cnt; i++) { bulk_kev_i = i; if (kev[i].filter) { + runtime_ktrace(RTKT_LAUNCHD_BSD_KEVENT|DBG_FUNC_START, kev[i].ident, kev[i].filter, kev[i].fflags); (*((kq_callback *)kev[i].udata))(kev[i].udata, &kev[i]); + runtime_ktrace0(RTKT_LAUNCHD_BSD_KEVENT|DBG_FUNC_END); } } #if 0 } else { - log_kevent_struct(LOG_ERR, &kev); + log_kevent_struct(LOG_ERR, &kev, 0); } #endif } @@ -1072,6 +1076,8 @@ no_hang_fd = _fd(open("/dev/autofs_nowait", 0)); } + runtime_ktrace(RTKT_LAUNCHD_MACH_IPC|DBG_FUNC_START, bufRequest->Head.msgh_local_port, bufRequest->Head.msgh_id, (int)the_demux); + if (the_demux(&bufRequest->Head, &bufReply->Head) == FALSE) { /* XXX - also gross */ if (likely(bufRequest->Head.msgh_id == MACH_NOTIFY_NO_SENDERS)) { @@ -1079,6 +1085,8 @@ } } + runtime_ktrace(RTKT_LAUNCHD_MACH_IPC|DBG_FUNC_END, bufReply->Head.msgh_remote_port, bufReply->Head.msgh_bits, bufReply->RetCode); + /* bufReply is a union. If MACH_MSGH_BITS_COMPLEX is set, then bufReply->RetCode is assumed to be zero. */ if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { if (unlikely(bufReply->RetCode != KERN_SUCCESS)) { @@ -1099,6 +1107,7 @@ tmp_options |= MACH_SEND_TIMEOUT; } } + } } @@ -1309,16 +1318,40 @@ mig_deallocate(outval, outvalCnt); } -#if 0 -void -runtime_kernel_trace(void *code, void *a, void *b, void *c, void *d) +INTERNAL_ABI void +runtime_ktrace1(runtime_ktrace_code_t code) { - /* Request codes from Joe S. */ - syscall(180 , code, a, b, c, d); + void *ra = __builtin_extract_return_addr(__builtin_return_address(1)); + + /* This syscall returns EINVAL when the trace isn't enabled. */ + if (do_apple_internal_logging) { + syscall(180, code, 0, 0, 0, (int)ra); + } } -#endif INTERNAL_ABI void +runtime_ktrace0(runtime_ktrace_code_t code) +{ + void *ra = __builtin_extract_return_addr(__builtin_return_address(0)); + + /* This syscall returns EINVAL when the trace isn't enabled. */ + if (do_apple_internal_logging) { + syscall(180, code, 0, 0, 0, (int)ra); + } +} + +INTERNAL_ABI void +runtime_ktrace(runtime_ktrace_code_t code, int a, int b, int c) +{ + void *ra = __builtin_extract_return_addr(__builtin_return_address(0)); + + /* This syscall returns EINVAL when the trace isn't enabled. */ + if (do_apple_internal_logging) { + syscall(180, code, a, b, c, (int)ra); + } +} + +INTERNAL_ABI void runtime_log_push(void) { static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER; Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2008-01-19 00:53:23 UTC (rev 23489) +++ trunk/launchd/src/launchd_runtime.h 2008-01-21 22:14:27 UTC (rev 23490) @@ -139,6 +139,33 @@ INTERNAL_ABI kern_return_t runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt); INTERNAL_ABI kern_return_t runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt); +#ifndef DBG_LAUNCHD +#define DBG_LAUNCHD 34 +#endif + +/* Class(8) | SubClass(8) | Code(14) | Qual(2) */ +#define RTKT_CODE(c) ((DBG_LAUNCHD << 24) | (((c) & 0x3fffff) << 2)) + +typedef enum { + RTKT_LAUNCHD_STARTING = RTKT_CODE(1), + RTKT_LAUNCHD_EXITING = RTKT_CODE(2), + RTKT_LAUNCHD_FINDING_STRAY_PG = RTKT_CODE(3), + RTKT_LAUNCHD_FINDING_ALL_STRAYS = RTKT_CODE(4), + RTKT_LAUNCHD_FINDING_EXECLESS = RTKT_CODE(5), + RTKT_LAUNCHD_FINDING_WEIRD_UIDS = RTKT_CODE(6), + RTKT_LAUNCHD_DATA_PACK = RTKT_CODE(7), + RTKT_LAUNCHD_DATA_UNPACK = RTKT_CODE(8), + RTKT_LAUNCHD_BUG = RTKT_CODE(9), + RTKT_LAUNCHD_MACH_IPC = RTKT_CODE(10), + RTKT_LAUNCHD_BSD_KEVENT = RTKT_CODE(11), +} runtime_ktrace_code_t; + +/* All of these log the return address as "arg4" */ +INTERNAL_ABI void runtime_ktrace1(runtime_ktrace_code_t code); +INTERNAL_ABI void runtime_ktrace0(runtime_ktrace_code_t code); +INTERNAL_ABI void runtime_ktrace(runtime_ktrace_code_t code, int a, int b, int c); + + #define LOG_APPLEONLY 0x4141504c /* AAPL in hex */ struct runtime_syslog_attr { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080121/8022ea1c/attachment.html From source_changes at macosforge.org Tue Jan 22 17:59:01 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Jan 22 18:01:26 2008 Subject: [launchd-changes] [23491] trunk/launchd/src/launchd_core_logic.c Message-ID: <20080123015901.33254BD8965@beta.macosforge.org> Revision: 23491 http://trac.macosforge.org/projects/launchd/changeset/23491 Author: zarzycki@apple.com Date: 2008-01-22 17:58:59 -0800 (Tue, 22 Jan 2008) Log Message: ----------- launchd exhibits a very high rate of zero fill page faults during shutdown Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-21 22:14:27 UTC (rev 23490) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-23 01:58:59 UTC (rev 23491) @@ -2390,7 +2390,7 @@ size_t i, kp_cnt, len = 10*1024*1024; struct kinfo_proc *kp; - if (j->anonymous || j->per_user) { + if (!do_apple_internal_logging || j->anonymous || j->per_user) { return; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080122/5f229488/attachment-0001.html From source_changes at macosforge.org Wed Jan 23 09:10:19 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 23 09:12:46 2008 Subject: [launchd-changes] [23492] branches/SULeopard Message-ID: <20080123171019.C2AF2C00D0A@beta.macosforge.org> Revision: 23492 http://trac.macosforge.org/projects/launchd/changeset/23492 Author: zarzycki@apple.com Date: 2008-01-23 09:09:49 -0800 (Wed, 23 Jan 2008) Log Message: ----------- Merge embedded changes into TOT SpringBoard needs custom launchd job management API Modified Paths: -------------- branches/SULeopard/Makefile branches/SULeopard/launchd/Makefile.in branches/SULeopard/launchd/aclocal.m4 branches/SULeopard/launchd/configure branches/SULeopard/launchd/configure.ac branches/SULeopard/launchd/src/Makefile.am branches/SULeopard/launchd/src/Makefile.in branches/SULeopard/launchd/src/config.h.in branches/SULeopard/launchd/src/launchctl.c branches/SULeopard/launchd/src/launchd.c branches/SULeopard/launchd/src/launchd_core_logic.c branches/SULeopard/launchd/src/launchd_runtime_kill.c branches/SULeopard/launchd/src/launchproxy.c branches/SULeopard/launchd/src/liblaunch_private.h branches/SULeopard/launchd/src/libvproc.c Modified: branches/SULeopard/Makefile =================================================================== --- branches/SULeopard/Makefile 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/Makefile 2008-01-23 17:09:49 UTC (rev 23492) @@ -4,6 +4,10 @@ include $(MAKEFILEPATH)/CoreOS/ReleaseControl/GNUSource.make Install_Flags = DESTDIR=$(DSTROOT) +ifeq ($(shell tconf --test TARGET_OS_EMBEDDED),YES) + Extra_Configure_Flags += --host=none-apple-darwin +endif + launchd_after_install:: ifeq ($(RC_ProjectName),launchd_libs) -find -d $(DSTROOT) -type f | grep -v /usr/local/lib/system | xargs rm @@ -18,9 +22,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 + -dsymutil $(SYMROOT)/launchd + -dsymutil $(SYMROOT)/launchctl + -dsymutil $(SYMROOT)/launchproxy endif launchd_libs:: install Modified: branches/SULeopard/launchd/Makefile.in =================================================================== --- branches/SULeopard/launchd/Makefile.in 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/Makefile.in 2008-01-23 17:09:49 UTC (rev 23492) @@ -97,6 +97,7 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBS_SECURITY = @LIBS_SECURITY@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ @@ -113,6 +114,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WEAKLIBS_SECURITY = @WEAKLIBS_SECURITY@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ Modified: branches/SULeopard/launchd/aclocal.m4 =================================================================== --- branches/SULeopard/launchd/aclocal.m4 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/aclocal.m4 2008-01-23 17:09:49 UTC (rev 23492) @@ -365,18 +365,6 @@ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 8 - -# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. -AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) - # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, Modified: branches/SULeopard/launchd/configure =================================================================== --- branches/SULeopard/launchd/configure 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/configure 2008-01-23 17:09:49 UTC (rev 23492) @@ -698,6 +698,8 @@ EGREP ALLOCA LIBOBJS +LIBS_SECURITY +WEAKLIBS_SECURITY LIBS_ONLY_TRUE LIBS_ONLY_FALSE LTLIBOBJS' @@ -6575,244 +6577,9 @@ fi -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------------------- ## -## Report this to launchd-bug-reports@group.apple.com ## -## -------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -{ echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 -echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_malloc_0_nonnull=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -return ! malloc (0); - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_malloc_0_nonnull=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 0 -_ACEOF - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - - -cat >>confdefs.h <<\_ACEOF -#define malloc rpl_malloc -_ACEOF - -fi - - - - - - - for ac_header in $ac_header_list do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -7324,7 +7091,7 @@ -for ac_header in stdlib.h unistd.h +for ac_header in sys/select.h sys/socket.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then @@ -7468,68 +7235,46 @@ done - -for ac_func in getpagesize -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then +{ echo "$as_me:$LINENO: checking types of arguments for select" >&5 +echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } +if test "${ac_cv_func_select_args+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + for ac_arg234 in 'fd_set *' 'int *' 'void *'; do + for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do + for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include +$ac_includes_default +#ifdef HAVE_SYS_SELECT_H +# include #endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#ifdef HAVE_SYS_SOCKET_H +# include #endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif int main () { -return $ac_func (); +extern int select ($ac_arg1, + $ac_arg234, $ac_arg234, $ac_arg234, + $ac_arg5); ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -7538,241 +7283,67 @@ (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" + } && test -s conftest.$ac_objext; then + ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_var=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF -fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done done +# Provide a safe default value. +: ${ac_cv_func_select_args='int,int *,struct timeval *'} -{ echo "$as_me:$LINENO: checking for working mmap" >&5 -echo $ECHO_N "checking for working mmap... $ECHO_C" >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_mmap_fixed_mapped=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 +echo "${ECHO_T}$ac_cv_func_select_args" >&6; } +ac_save_IFS=$IFS; IFS=',' +set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` +IFS=$ac_save_IFS +shift + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG1 $1 _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include -#include - -#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H -char *malloc (); -#endif - -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE -/* Assume that all systems that can run configure have sys/param.h. */ -# ifndef HAVE_SYS_PARAM_H -# define HAVE_SYS_PARAM_H 1 -# endif - -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ - -int -main () -{ - char *data, *data2, *data3; - int i, pagesize; - int fd; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - return 1; - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - return 1; - if (write (fd, data, pagesize) != pagesize) - return 1; - close (fd); - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - return 1; - data2 = (char *) malloc (2 * pagesize); - if (!data2) - return 1; - data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - return 1; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - return 1; - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - return 1; - if (read (fd, data3, pagesize) != pagesize) - return 1; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - return 1; - close (fd); - return 0; -} +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG234 ($2) _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_mmap_fixed_mapped=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 -echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6; } -if test $ac_cv_func_mmap_fixed_mapped = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MMAP 1 +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG5 ($3) _ACEOF -fi -rm -f conftest.mmap +rm -f conftest* - -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then +{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } +if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" @@ -7791,115 +7362,31 @@ test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_header_compiler=yes + ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no + ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6; } -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------------------- ## -## Report this to launchd-bug-reports@group.apple.com ## -## -------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal _ACEOF -fi -done - -{ echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 -echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6; } -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then +{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 +echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } +if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - ac_cv_func_realloc_0_nonnull=no + ac_cv_func_stat_empty_string_bug=yes else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -7907,16 +7394,12 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *realloc (); -#endif - +$ac_includes_default int main () { -return ! realloc (0, 0); +struct stat sbuf; + return stat ("", &sbuf) == 0; ; return 0; } @@ -7941,42 +7424,32 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_realloc_0_nonnull=yes + ac_cv_func_stat_empty_string_bug=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -ac_cv_func_realloc_0_nonnull=no +ac_cv_func_stat_empty_string_bug=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6; } -if test $ac_cv_func_realloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_REALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_REALLOC 0 -_ACEOF - - case " $LIBOBJS " in - *" realloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS realloc.$ac_objext" +{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 +echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } +if test $ac_cv_func_stat_empty_string_bug = yes; then + case " $LIBOBJS " in + *" stat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stat.$ac_objext" ;; esac -cat >>confdefs.h <<\_ACEOF -#define realloc rpl_realloc +cat >>confdefs.h <<_ACEOF +#define HAVE_STAT_EMPTY_STRING_BUG 1 _ACEOF fi @@ -7985,190 +7458,85 @@ -for ac_header in sys/select.h sys/socket.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------------------- ## -## Report this to launchd-bug-reports@group.apple.com ## -## -------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF -fi -done -{ echo "$as_me:$LINENO: checking types of arguments for select" >&5 -echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } -if test "${ac_cv_func_select_args+set}" = set; then + + + + + + + + +for ac_func in atexit dup2 gethostname gettimeofday malloc mmap memmove memset mkdir munmap realloc rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - for ac_arg234 in 'fd_set *' 'int *' 'void *'; do - for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do - for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#ifdef HAVE_SYS_SELECT_H -# include +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include #endif -#ifdef HAVE_SYS_SOCKET_H -# include + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" #endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif int main () { -extern int select ($ac_arg1, - $ac_arg234, $ac_arg234, $ac_arg234, - $ac_arg5); +return $ac_func (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -8177,49 +7545,37 @@ (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - + eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - done -done -# Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} - +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 -echo "${ECHO_T}$ac_cv_func_select_args" >&6; } -ac_save_IFS=$IFS; IFS=',' -set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` -IFS=$ac_save_IFS -shift - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG1 $1 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF +fi +done -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG234 ($2) -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG5 ($3) -_ACEOF - -rm -f conftest* - -{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 -echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } -if test "${ac_cv_type_signal+set}" = set; then +# check for a Security framework that includes session support +ac_func_search_save_LIBS=$LIBS +LIBS="-framework Security $ac_func_search_save_LIBS" +{ echo "$as_me:$LINENO: checking for SessionCreate" >&5 +echo $ECHO_N "checking for SessionCreate... $ECHO_C" >&6; } +if test "${ac_cv_func_SessionCreate+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -8228,25 +7584,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include +/* Define SessionCreate to an innocuous variant, in case declares SessionCreate. + For example, HP-UX 11i declares gettimeofday. */ +#define SessionCreate innocuous_SessionCreate +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char SessionCreate (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef SessionCreate + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char SessionCreate (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_SessionCreate || defined __stub___SessionCreate +choke me +#endif + int main () { -return *(signal (0, 0)) (0) == 1; +return SessionCreate (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -8255,124 +7639,130 @@ (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_type_signal=int + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_SessionCreate=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_type_signal=void + ac_cv_func_SessionCreate=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 -echo "${ECHO_T}$ac_cv_type_signal" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_func_SessionCreate" >&5 +echo "${ECHO_T}$ac_cv_func_SessionCreate" >&6; } +if test $ac_cv_func_SessionCreate = yes; then -cat >>confdefs.h <<_ACEOF -#define RETSIGTYPE $ac_cv_type_signal +cat >>confdefs.h <<\_ACEOF +#define HAVE_SECURITY 1 _ACEOF + LIBS_SECURITY="-framework Security" -{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 -echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } -if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then + WEAKLIBS_SECURITY="-weak_framework Security" + +fi + +LIBS=$ac_func_search_save_LIBS + +# check for seatbelt +{ echo "$as_me:$LINENO: checking for sandbox_init" >&5 +echo $ECHO_N "checking for sandbox_init... $ECHO_C" >&6; } +if test "${ac_cv_func_sandbox_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$cross_compiling" = yes; then - ac_cv_func_stat_empty_string_bug=yes -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +/* Define sandbox_init to an innocuous variant, in case declares sandbox_init. + For example, HP-UX 11i declares gettimeofday. */ +#define sandbox_init innocuous_sandbox_init + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char sandbox_init (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef sandbox_init + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sandbox_init (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_sandbox_init || defined __stub___sandbox_init +choke me +#endif + int main () { -struct stat sbuf; - return stat ("", &sbuf) == 0; +return sandbox_init (); ; return 0; } _ACEOF -rm -f conftest$ac_exeext +rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_stat_empty_string_bug=no + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_sandbox_init=yes else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_func_stat_empty_string_bug=yes + ac_cv_func_sandbox_init=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 -echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } -if test $ac_cv_func_stat_empty_string_bug = yes; then - case " $LIBOBJS " in - *" stat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS stat.$ac_objext" - ;; -esac +{ echo "$as_me:$LINENO: result: $ac_cv_func_sandbox_init" >&5 +echo "${ECHO_T}$ac_cv_func_sandbox_init" >&6; } +if test $ac_cv_func_sandbox_init = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_STAT_EMPTY_STRING_BUG 1 +cat >>confdefs.h <<\_ACEOF +#define HAVE_SANDBOX 1 _ACEOF fi - - - - - - - - - - - - - - - - - - -for ac_func in atexit dup2 gethostname gettimeofday memmove memset mkdir munmap rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then +# check for quarantine +{ echo "$as_me:$LINENO: checking for _qtn_proc_init_with_data" >&5 +echo $ECHO_N "checking for _qtn_proc_init_with_data... $ECHO_C" >&6; } +if test "${ac_cv_func__qtn_proc_init_with_data+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -8381,12 +7771,12 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. +/* Define _qtn_proc_init_with_data to an innocuous variant, in case declares _qtn_proc_init_with_data. For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func +#define _qtn_proc_init_with_data innocuous__qtn_proc_init_with_data /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. + which can conflict with char _qtn_proc_init_with_data (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -8396,7 +7786,7 @@ # include #endif -#undef $ac_func +#undef _qtn_proc_init_with_data /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC @@ -8404,18 +7794,18 @@ #ifdef __cplusplus extern "C" #endif -char $ac_func (); +char _qtn_proc_init_with_data (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func +#if defined __stub__qtn_proc_init_with_data || defined __stub____qtn_proc_init_with_data choke me #endif int main () { -return $ac_func (); +return _qtn_proc_init_with_data (); ; return 0; } @@ -8438,27 +7828,26 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" + ac_cv_func__qtn_proc_init_with_data=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_var=no" + ac_cv_func__qtn_proc_init_with_data=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +{ echo "$as_me:$LINENO: result: $ac_cv_func__qtn_proc_init_with_data" >&5 +echo "${ECHO_T}$ac_cv_func__qtn_proc_init_with_data" >&6; } +if test $ac_cv_func__qtn_proc_init_with_data = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_QUARANTINE 1 _ACEOF fi -done ac_config_files="$ac_config_files Makefile src/Makefile" @@ -9204,12 +8593,14 @@ EGREP!$EGREP$ac_delim ALLOCA!$ALLOCA$ac_delim LIBOBJS!$LIBOBJS$ac_delim +LIBS_SECURITY!$LIBS_SECURITY$ac_delim +WEAKLIBS_SECURITY!$WEAKLIBS_SECURITY$ac_delim LIBS_ONLY_TRUE!$LIBS_ONLY_TRUE$ac_delim LIBS_ONLY_FALSE!$LIBS_ONLY_FALSE$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: branches/SULeopard/launchd/configure.ac =================================================================== --- branches/SULeopard/launchd/configure.ac 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/configure.ac 2008-01-23 17:09:49 UTC (rev 23492) @@ -1,12 +1,12 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.59) +AC_PREREQ(2.61) AC_INIT([launchd],[1.0],[launchd-bug-reports@group.apple.com]) AC_CONFIG_SRCDIR([src/launchd.c]) AM_INIT_AUTOMAKE -AM_CONFIG_HEADER([src/config.h]) +AC_CONFIG_HEADERS([src/config.h]) # Checks for programs. AC_PROG_CC @@ -37,15 +37,27 @@ AC_PROG_GCC_TRADITIONAL AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK -AC_FUNC_MALLOC AC_FUNC_MKTIME -AC_FUNC_MMAP -AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_TYPE_SIGNAL AC_FUNC_STAT -AC_CHECK_FUNCS([atexit dup2 gethostname gettimeofday memmove memset mkdir munmap rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol]) +AC_CHECK_FUNCS([atexit dup2 gethostname gettimeofday malloc mmap memmove memset mkdir munmap realloc rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol]) +# check for a Security framework that includes session support +ac_func_search_save_LIBS=$LIBS +LIBS="-framework Security $ac_func_search_save_LIBS" +AC_CHECK_FUNC([SessionCreate], + [AC_DEFINE(HAVE_SECURITY, 1, [Define to 1 if you have the Security framework]) + AC_SUBST(LIBS_SECURITY,"-framework Security") + AC_SUBST(WEAKLIBS_SECURITY,"-weak_framework Security")]) +LIBS=$ac_func_search_save_LIBS + +# check for seatbelt +AC_CHECK_FUNC([sandbox_init],[AC_DEFINE(HAVE_SANDBOX, 1, [Define to 1 if you have the sandbox library])]) + +# check for quarantine +AC_CHECK_FUNC([_qtn_proc_init_with_data],[AC_DEFINE(HAVE_QUARANTINE, 1, [Define to 1 if you have the quarantine library])]) + AC_CONFIG_FILES([Makefile src/Makefile]) Modified: branches/SULeopard/launchd/src/Makefile.am =================================================================== --- branches/SULeopard/launchd/src/Makefile.am 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/Makefile.am 2008-01-23 17:09:49 UTC (rev 23492) @@ -39,8 +39,8 @@ sysconf_DATA = hostconfig rc.common rc.netboot -launchctl_CFLAGS = $(AM_CFLAGS) -I/System/Library/Frameworks/System.framework/PrivateHeaders -launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -framework Security -weak_library /usr/lib/libedit.dylib +launchctl_CFLAGS = $(AM_CFLAGS) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders +launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit @@ -53,7 +53,7 @@ launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h -launchproxy_LDFLAGS = -weak_framework Security +launchproxy_LDFLAGS = $(WEAKLIBS_SECURITY) notifyServer.c notifyServer.h: /usr/include/mach/notify.defs mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs Modified: branches/SULeopard/launchd/src/Makefile.in =================================================================== --- branches/SULeopard/launchd/src/Makefile.in 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/Makefile.in 2008-01-23 17:09:49 UTC (rev 23492) @@ -180,6 +180,7 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBS_SECURITY = @LIBS_SECURITY@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ @@ -196,6 +197,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WEAKLIBS_SECURITY = @WEAKLIBS_SECURITY@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -248,15 +250,15 @@ @LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS) @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 -framework Security -weak_library /usr/lib/libedit.dylib +@LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders +@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_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 @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 protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c -@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security +@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(WEAKLIBS_SECURITY) @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 @LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 Modified: branches/SULeopard/launchd/src/config.h.in =================================================================== --- branches/SULeopard/launchd/src/config.h.in 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/config.h.in 2008-01-23 17:09:49 UTC (rev 23492) @@ -3,30 +3,60 @@ /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H +/* Define to 1 if you have the `dup2' function. */ +#undef HAVE_DUP2 + /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE +/* Define to 1 if you have the `gethostname' function. */ +#undef HAVE_GETHOSTNAME +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_LSTAT_EMPTY_STRING_BUG + /* Define to 1 if you have the header file. */ #undef HAVE_MACH_MACH_H -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ +/* Define to 1 if you have the `malloc' function. */ #undef HAVE_MALLOC /* Define to 1 if you have the `memmove' function. */ @@ -35,7 +65,13 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define to 1 if you have a working `mmap' system call. */ +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `mkdir' function. */ +#undef HAVE_MKDIR + +/* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP /* Define to 1 if you have the `munmap' function. */ @@ -44,6 +80,39 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PATHS_H + +/* Define to 1 if you have the quarantine library */ +#undef HAVE_QUARANTINE + +/* Define to 1 if you have the `realloc' function. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the `rmdir' function. */ +#undef HAVE_RMDIR + +/* Define to 1 if you have the sandbox library */ +#undef HAVE_SANDBOX + +/* Define to 1 if you have the Security framework */ +#undef HAVE_SECURITY + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the `socket' function. */ +#undef HAVE_SOCKET + /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG @@ -51,12 +120,24 @@ /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR @@ -66,6 +147,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H @@ -73,19 +163,40 @@ */ #undef HAVE_SYS_DIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MOUNT_H + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -108,6 +219,9 @@ slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + /* Name of package */ #undef PACKAGE @@ -129,9 +243,32 @@ /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE +/* Define to the type of arg 1 for `select'. */ +#undef SELECT_TYPE_ARG1 + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#undef SELECT_TYPE_ARG234 + +/* Define to the type of arg 5 for `select'. */ +#undef SELECT_TYPE_ARG5 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + /* Version number of package */ #undef VERSION @@ -141,19 +278,16 @@ /* Define to `int' if doesn't define. */ #undef gid_t -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - /* Define to `int' if does not define. */ #undef mode_t -/* Define to `long' if does not define. */ +/* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t -/* Define to `unsigned' if does not define. */ +/* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ Modified: branches/SULeopard/launchd/src/launchctl.c =================================================================== --- branches/SULeopard/launchd/src/launchctl.c 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/launchctl.c 2008-01-23 17:09:49 UTC (rev 23492) @@ -30,7 +30,7 @@ #include #include #include -#if !TARGET_OS_EMBEDDED +#if HAVE_SECURITY #include #include #endif @@ -1431,10 +1431,12 @@ assumes(acct("/var/account/acct") != -1); } +#if !TARGET_OS_EMBEDDED if (path_check("/etc/fstab")) { const char *mount_tool[] = { "mount", "-vat", "nonfs", NULL }; assumes(fwexec(mount_tool, true) != -1); } +#endif if (path_check("/etc/rc.installer_cleanup")) { const char *rccleanup_tool[] = { _PATH_BSHELL, "/etc/rc.installer_cleanup", "multiuser", NULL }; @@ -1533,9 +1535,9 @@ void do_BootCache_magic(BootCache_action_t what) { - const char *bcc_tool[] = { "BootCacheControl", "-f", "/var/db/BootCache.playlist", NULL, NULL }; + const char *bcc_tool[] = { "/usr/sbin/BootCacheControl", "-f", "/var/db/BootCache.playlist", NULL, NULL }; - if (is_safeboot()) { + if (is_safeboot() || !path_check(bcc_tool[0])) { return; } @@ -1612,7 +1614,7 @@ the_argc += 1; } -#if !TARGET_OS_EMBEDDED +#if HAVE_SECURITY if (strcasecmp(session_type, VPROCMGR_SESSION_BACKGROUND) == 0) { assumes(SessionCreate(sessionKeepCurrentBootstrap, 0) == 0); } @@ -2768,7 +2770,13 @@ fprintf(stderr, "fsck failed!\n"); /* someday, we should keep booting read-only, but as of today, other sub-systems cannot handle that scenario */ +#if TARGET_OS_EMBEDDED + const char *nvram_tool[] = { "/usr/sbin/nvram", "auto-boot=false", NULL }; + assumes(fwexec(nvram_tool, true) != -1); + assumes(reboot(RB_AUTOBOOT) != -1); +#else assumes(reboot(RB_HALT) != -1); +#endif return; out: @@ -2782,7 +2790,15 @@ * assumes(mount(sfs.f_fstypename, "/", MNT_UPDATE, NULL) != -1); */ - assumes(fwexec(remount_tool, true) != -1); +#if TARGET_OS_EMBEDDED + if (path_check("/etc/fstab")) { + const char *mount_tool[] = { "mount", "-vat", "nonfs", NULL }; + assumes(fwexec(mount_tool, true) != -1); + } else +#endif + { + assumes(fwexec(remount_tool, true) != -1); + } fix_bogus_file_metadata(); } Modified: branches/SULeopard/launchd/src/launchd.c =================================================================== --- branches/SULeopard/launchd/src/launchd.c 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/launchd.c 2008-01-23 17:09:49 UTC (rev 23492) @@ -23,9 +23,11 @@ #include "config.h" #include "launchd.h" +#if HAVE_SECURITY_FRAMEWORK #include #include #include +#endif #include #include #include @@ -283,6 +285,7 @@ void launchd_SessionCreate(void) { +#if HAVE_SECURITY_FRAMEWORK OSStatus (*sescr)(SessionCreationFlags flags, SessionAttributeBits attributes); void *seclib; @@ -292,6 +295,7 @@ } launchd_assumes(dlclose(seclib) != -1); } +#endif } void Modified: branches/SULeopard/launchd/src/launchd_core_logic.c =================================================================== --- branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-23 17:09:49 UTC (rev 23492) @@ -21,6 +21,7 @@ #include "config.h" #include "launchd_core_logic.h" +#include #include #include #include @@ -73,7 +74,12 @@ #include #include #include +#if HAVE_SANDBOX #include +#endif +#if HAVE_QUARANTINE +#include +#endif #include "liblaunch_public.h" #include "liblaunch_private.h" @@ -212,7 +218,9 @@ static bool limititem_update(job_t j, int w, rlim_t r); static void limititem_delete(job_t j, struct limititem *li); static void limititem_setup(launch_data_t obj, const char *key, void *context); +#if HAVE_SANDBOX static void seatbelt_setup_flags(launch_data_t obj, const char *key, void *context); +#endif typedef enum { NETWORK_UP = 1, @@ -336,10 +344,14 @@ char *alt_exc_handler; struct machservice *lastlookup; unsigned int lastlookup_gennum; +#if HAVE_SANDBOX char *seatbelt_profile; uint64_t seatbelt_flags; +#endif +#if HAVE_QUARANTINE void *quarantine_data; size_t quarantine_data_sz; +#endif pid_t p; int argc; int last_exit_status; @@ -865,12 +877,16 @@ if (j->alt_exc_handler) { free(j->alt_exc_handler); } +#if HAVE_SANDBOX if (j->seatbelt_profile) { free(j->seatbelt_profile); } +#endif +#if HAVE_QUARANTINE if (j->quarantine_data) { free(j->quarantine_data); } +#endif if (j->j_binpref) { free(j->j_binpref); } @@ -1458,8 +1474,10 @@ where2put = &j->stdoutpath; } else if (strcasecmp(key, LAUNCH_JOBKEY_STANDARDERRORPATH) == 0) { where2put = &j->stderrpath; +#if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXPROFILE) == 0) { where2put = &j->seatbelt_profile; +#endif } break; default: @@ -1537,8 +1555,10 @@ job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, value, j) != -1); } +#if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXFLAGS) == 0) { j->seatbelt_flags = value; +#endif } break; @@ -1554,6 +1574,7 @@ switch (key[0]) { case 'q': case 'Q': +#if HAVE_QUARANTINE if (strcasecmp(key, LAUNCH_JOBKEY_QUARANTINEDATA) == 0) { size_t tmpsz = launch_data_get_opaque_size(value); @@ -1562,6 +1583,7 @@ j->quarantine_data_sz = tmpsz; } } +#endif break; default: break; @@ -1641,8 +1663,10 @@ calendarinterval_new_from_obj(j, value); } else if (strcasecmp(key, LAUNCH_JOBKEY_SOFTRESOURCELIMITS) == 0) { launch_data_dict_iterate(value, limititem_setup, j); +#if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXFLAGS) == 0) { launch_data_dict_iterate(value, seatbelt_setup_flags, j); +#endif } break; case 'h': @@ -2709,6 +2733,7 @@ job_assumes(j, binpref_out_cnt == j->j_binpref_cnt); } +#if HAVE_QUARANTINE if (j->quarantine_data) { qtn_proc_t qp; @@ -2718,7 +2743,9 @@ } } } +#endif +#if HAVE_SANDBOX if (j->seatbelt_profile) { char *seatbelt_err_buf = NULL; @@ -2729,6 +2756,7 @@ goto out_bad; } } +#endif if (j->prog) { errno = posix_spawn(&junk_pid, j->inetcompat ? file2exec : j->prog, NULL, &spattr, (char *const*)argv, environ); @@ -3730,6 +3758,7 @@ free(li); } +#if HAVE_SANDBOX void seatbelt_setup_flags(launch_data_t obj, const char *key, void *context) { @@ -3748,6 +3777,7 @@ j->seatbelt_flags |= SANDBOX_NAMED; } } +#endif void limititem_setup(launch_data_t obj, const char *key, void *context) @@ -4069,6 +4099,10 @@ f = PPC_THREAD_STATE64; #elif defined(__i386__) f = x86_THREAD_STATE; +#elif defined(__arm__) + f = ARM_THREAD_STATE; +#else +#error "unknown architecture" #endif if (target_task) { @@ -5762,6 +5796,8 @@ job_log(j, LOG_DEBUG, "%sMach service registration attempt: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); + /* 5641783 for the embedded hack */ +#if !TARGET_OS_EMBEDDED /* * From a per-user/session launchd's perspective, SecurityAgent (UID * 92) is a rogue application (not our UID, not root and not a child of @@ -5774,6 +5810,7 @@ return BOOTSTRAP_NOT_PRIVILEGED; } } +#endif ms = jobmgr_lookup_service(j->mgr, servicename, false, flags & BOOTSTRAP_PER_PID_SERVICE ? ldc.pid : 0); @@ -5813,9 +5850,12 @@ runtime_get_caller_creds(&ldc); + /* 5641783 for the embedded hack */ +#if !TARGET_OS_EMBEDDED if (getpid() == 1 && j->anonymous && job_get_bs(j)->parentmgr == NULL && ldc.uid != 0 && ldc.euid != 0) { return VPROC_ERR_TRY_PER_USER; } +#endif if (!mspolicy_check(j, servicename, flags & BOOTSTRAP_PER_PID_SERVICE)) { job_log(j, LOG_NOTICE, "Policy denied Mach service lookup: %s", servicename); Modified: branches/SULeopard/launchd/src/launchd_runtime_kill.c =================================================================== --- branches/SULeopard/launchd/src/launchd_runtime_kill.c 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/launchd_runtime_kill.c 2008-01-23 17:09:49 UTC (rev 23492) @@ -18,7 +18,16 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#if !defined(__LP64__) && !defined(__arm__) #define _NONSTD_SOURCE 1 +#define old_kill(x, y) kill(x, y) +#define old_killpg(x, y) killpg(x, y) +#else +/* ??? No blessed way to get the old behavior */ +extern int __kill(int, int, int); +#define old_kill(x, y) __kill(x, y, 0) +#define old_killpg(x, y) __kill(-(x), y, 0) +#endif #include #include "launchd_runtime_kill.h" @@ -34,11 +43,11 @@ int runtime_kill(pid_t pid, int sig) { - return kill(pid, sig); + return old_kill(pid, sig); } int runtime_killpg(pid_t pgrp, int sig) { - return killpg(pgrp, sig); + return old_killpg(pgrp, sig); } Modified: branches/SULeopard/launchd/src/launchproxy.c =================================================================== --- branches/SULeopard/launchd/src/launchproxy.c 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/launchproxy.c 2008-01-23 17:09:49 UTC (rev 23492) @@ -17,9 +17,11 @@ * * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#if HAVE_SECURITY #include #include #include +#endif #include #include #include @@ -40,7 +42,7 @@ #include "launch.h" -#if __GNUC__ >= 4 +#if __GNUC__ >= 4 && HAVE_SECURITY OSStatus SessionCreate(SessionCreationFlags flags, SessionAttributeBits attributes) __attribute__((weak)); #endif @@ -184,6 +186,7 @@ setpgid(0, 0); +#if HAVE_SECURITY if ((tmp = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SESSIONCREATE)) && launch_data_get_bool(tmp)) { if (SessionCreate) { OSStatus scr = SessionCreate(0, 0); @@ -193,6 +196,7 @@ syslog(LOG_NOTICE, "%s: SessionCreate == NULL!", prog); } } +#endif fcntl(r, F_SETFL, 0); fcntl(r, F_SETFD, 1); dup2(r, STDIN_FILENO); Modified: branches/SULeopard/launchd/src/liblaunch_private.h =================================================================== --- branches/SULeopard/launchd/src/liblaunch_private.h 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/liblaunch_private.h 2008-01-23 17:09:49 UTC (rev 23492) @@ -24,7 +24,6 @@ #include #include #include -#include #pragma GCC visibility push(default) @@ -114,7 +113,7 @@ mach_port_t * spawn_observer_port; const cpu_type_t * spawn_binpref; size_t spawn_binpref_cnt; - qtn_proc_t spawn_quarantine; + void * spawn_quarantine; const char * spawn_seatbelt_profile; const uint64_t * spawn_seatbelt_flags; }; Modified: branches/SULeopard/launchd/src/libvproc.c =================================================================== --- branches/SULeopard/launchd/src/libvproc.c 2008-01-23 01:58:59 UTC (rev 23491) +++ branches/SULeopard/launchd/src/libvproc.c 2008-01-23 17:09:49 UTC (rev 23492) @@ -201,6 +201,7 @@ if (spawn_attrs) switch (struct_version) { case 2: +#if HAVE_QUARANTINE if (spawn_attrs->spawn_quarantine) { char qbuf[QTN_SERIALIZED_DATA_MAX]; size_t qbuf_sz = QTN_SERIALIZED_DATA_MAX; @@ -210,6 +211,7 @@ launch_data_dict_insert(in_obj, tmp, LAUNCH_JOBKEY_QUARANTINEDATA); } } +#endif if (spawn_attrs->spawn_seatbelt_profile) { tmp = launch_data_new_string(spawn_attrs->spawn_seatbelt_profile); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080123/fcceaf77/attachment-0001.html From source_changes at macosforge.org Wed Jan 23 09:14:12 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 23 09:16:38 2008 Subject: [launchd-changes] [23493] tags/launchd-258.2/ Message-ID: <20080123171412.5A34BC00E9F@beta.macosforge.org> Revision: 23493 http://trac.macosforge.org/projects/launchd/changeset/23493 Author: zarzycki@apple.com Date: 2008-01-23 09:13:59 -0800 (Wed, 23 Jan 2008) Log Message: ----------- "Tagging launchd-258.2 from https://svn.macosforge.org/repository/launchd/branches/SULeopard" Added Paths: ----------- tags/launchd-258.2/ Copied: tags/launchd-258.2 (from rev 23492, branches/SULeopard) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080123/97456dd4/attachment.html From source_changes at macosforge.org Wed Jan 23 10:11:51 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 23 10:14:17 2008 Subject: [launchd-changes] [23494] trunk Message-ID: <20080123181151.D208BC02DF7@beta.macosforge.org> Revision: 23494 http://trac.macosforge.org/projects/launchd/changeset/23494 Author: zarzycki@apple.com Date: 2008-01-23 10:11:46 -0800 (Wed, 23 Jan 2008) Log Message: ----------- Merge embedded changes into TOT SpringBoard needs custom launchd job management API Modified Paths: -------------- trunk/Makefile trunk/launchd/Makefile.in trunk/launchd/aclocal.m4 trunk/launchd/configure trunk/launchd/configure.ac trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/config.h.in trunk/launchd/src/launchctl.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime_kill.c trunk/launchd/src/launchproxy.c trunk/launchd/src/liblaunch_private.h trunk/launchd/src/libvproc.c Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/Makefile 2008-01-23 18:11:46 UTC (rev 23494) @@ -4,6 +4,10 @@ include $(MAKEFILEPATH)/CoreOS/ReleaseControl/GNUSource.make Install_Flags = DESTDIR=$(DSTROOT) +ifeq ($(shell tconf --test TARGET_OS_EMBEDDED),YES) + Extra_Configure_Flags += --host=none-apple-darwin +endif + launchd_after_install:: ifeq ($(RC_ProjectName),launchd_libs) -find -d $(DSTROOT) -type f | grep -v /usr/local/lib/system | xargs rm @@ -18,9 +22,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 + -dsymutil $(SYMROOT)/launchd + -dsymutil $(SYMROOT)/launchctl + -dsymutil $(SYMROOT)/launchproxy endif launchd_libs:: install Modified: trunk/launchd/Makefile.in =================================================================== --- trunk/launchd/Makefile.in 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/Makefile.in 2008-01-23 18:11:46 UTC (rev 23494) @@ -97,6 +97,7 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBS_SECURITY = @LIBS_SECURITY@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ @@ -113,6 +114,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WEAKLIBS_SECURITY = @WEAKLIBS_SECURITY@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ Modified: trunk/launchd/aclocal.m4 =================================================================== --- trunk/launchd/aclocal.m4 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/aclocal.m4 2008-01-23 18:11:46 UTC (rev 23494) @@ -365,18 +365,6 @@ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 8 - -# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. -AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) - # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, Modified: trunk/launchd/configure =================================================================== --- trunk/launchd/configure 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/configure 2008-01-23 18:11:46 UTC (rev 23494) @@ -698,6 +698,8 @@ EGREP ALLOCA LIBOBJS +LIBS_SECURITY +WEAKLIBS_SECURITY LIBS_ONLY_TRUE LIBS_ONLY_FALSE LTLIBOBJS' @@ -6575,244 +6577,9 @@ fi -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------------------- ## -## Report this to launchd-bug-reports@group.apple.com ## -## -------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -{ echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 -echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_malloc_0_nonnull=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -return ! malloc (0); - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_malloc_0_nonnull=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 0 -_ACEOF - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - - -cat >>confdefs.h <<\_ACEOF -#define malloc rpl_malloc -_ACEOF - -fi - - - - - - - for ac_header in $ac_header_list do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -7324,7 +7091,7 @@ -for ac_header in stdlib.h unistd.h +for ac_header in sys/select.h sys/socket.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then @@ -7468,68 +7235,46 @@ done - -for ac_func in getpagesize -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then +{ echo "$as_me:$LINENO: checking types of arguments for select" >&5 +echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } +if test "${ac_cv_func_select_args+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + for ac_arg234 in 'fd_set *' 'int *' 'void *'; do + for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do + for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include +$ac_includes_default +#ifdef HAVE_SYS_SELECT_H +# include #endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#ifdef HAVE_SYS_SOCKET_H +# include #endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif int main () { -return $ac_func (); +extern int select ($ac_arg1, + $ac_arg234, $ac_arg234, $ac_arg234, + $ac_arg5); ; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -7538,241 +7283,67 @@ (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" + } && test -s conftest.$ac_objext; then + ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_var=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF -fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done done +# Provide a safe default value. +: ${ac_cv_func_select_args='int,int *,struct timeval *'} -{ echo "$as_me:$LINENO: checking for working mmap" >&5 -echo $ECHO_N "checking for working mmap... $ECHO_C" >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - ac_cv_func_mmap_fixed_mapped=no -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 +echo "${ECHO_T}$ac_cv_func_select_args" >&6; } +ac_save_IFS=$IFS; IFS=',' +set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` +IFS=$ac_save_IFS +shift + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG1 $1 _ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include -#include - -#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H -char *malloc (); -#endif - -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE -/* Assume that all systems that can run configure have sys/param.h. */ -# ifndef HAVE_SYS_PARAM_H -# define HAVE_SYS_PARAM_H 1 -# endif - -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ - -int -main () -{ - char *data, *data2, *data3; - int i, pagesize; - int fd; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - return 1; - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - return 1; - if (write (fd, data, pagesize) != pagesize) - return 1; - close (fd); - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - return 1; - data2 = (char *) malloc (2 * pagesize); - if (!data2) - return 1; - data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - return 1; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - return 1; - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - return 1; - if (read (fd, data3, pagesize) != pagesize) - return 1; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - return 1; - close (fd); - return 0; -} +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG234 ($2) _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_mmap_fixed_mapped=yes -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - -fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 -echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6; } -if test $ac_cv_func_mmap_fixed_mapped = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_MMAP 1 +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG5 ($3) _ACEOF -fi -rm -f conftest.mmap +rm -f conftest* - -for ac_header in stdlib.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then +{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } +if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" @@ -7791,115 +7362,31 @@ test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_header_compiler=yes + ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no + ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6; } -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------------------- ## -## Report this to launchd-bug-reports@group.apple.com ## -## -------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal _ACEOF -fi -done - -{ echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 -echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6; } -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then +{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 +echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } +if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - ac_cv_func_realloc_0_nonnull=no + ac_cv_func_stat_empty_string_bug=yes else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -7907,16 +7394,12 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *realloc (); -#endif - +$ac_includes_default int main () { -return ! realloc (0, 0); +struct stat sbuf; + return stat ("", &sbuf) == 0; ; return 0; } @@ -7941,42 +7424,32 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_realloc_0_nonnull=yes + ac_cv_func_stat_empty_string_bug=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -ac_cv_func_realloc_0_nonnull=no +ac_cv_func_stat_empty_string_bug=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 -echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6; } -if test $ac_cv_func_realloc_0_nonnull = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_REALLOC 1 -_ACEOF - -else - cat >>confdefs.h <<\_ACEOF -#define HAVE_REALLOC 0 -_ACEOF - - case " $LIBOBJS " in - *" realloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS realloc.$ac_objext" +{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 +echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } +if test $ac_cv_func_stat_empty_string_bug = yes; then + case " $LIBOBJS " in + *" stat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stat.$ac_objext" ;; esac -cat >>confdefs.h <<\_ACEOF -#define realloc rpl_realloc +cat >>confdefs.h <<_ACEOF +#define HAVE_STAT_EMPTY_STRING_BUG 1 _ACEOF fi @@ -7985,190 +7458,85 @@ -for ac_header in sys/select.h sys/socket.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## -------------------------------------------------- ## -## Report this to launchd-bug-reports@group.apple.com ## -## -------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF -fi -done -{ echo "$as_me:$LINENO: checking types of arguments for select" >&5 -echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } -if test "${ac_cv_func_select_args+set}" = set; then + + + + + + + + +for ac_func in atexit dup2 gethostname gettimeofday malloc mmap memmove memset mkdir munmap realloc rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - for ac_arg234 in 'fd_set *' 'int *' 'void *'; do - for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do - for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#ifdef HAVE_SYS_SELECT_H -# include +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include #endif -#ifdef HAVE_SYS_SOCKET_H -# include + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" #endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif int main () { -extern int select ($ac_arg1, - $ac_arg234, $ac_arg234, $ac_arg234, - $ac_arg5); +return $ac_func (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -8177,49 +7545,37 @@ (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - + eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - done -done -# Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} - +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 -echo "${ECHO_T}$ac_cv_func_select_args" >&6; } -ac_save_IFS=$IFS; IFS=',' -set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` -IFS=$ac_save_IFS -shift - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG1 $1 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF +fi +done -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG234 ($2) -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG5 ($3) -_ACEOF - -rm -f conftest* - -{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 -echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } -if test "${ac_cv_type_signal+set}" = set; then +# check for a Security framework that includes session support +ac_func_search_save_LIBS=$LIBS +LIBS="-framework Security $ac_func_search_save_LIBS" +{ echo "$as_me:$LINENO: checking for SessionCreate" >&5 +echo $ECHO_N "checking for SessionCreate... $ECHO_C" >&6; } +if test "${ac_cv_func_SessionCreate+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -8228,25 +7584,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#include +/* Define SessionCreate to an innocuous variant, in case declares SessionCreate. + For example, HP-UX 11i declares gettimeofday. */ +#define SessionCreate innocuous_SessionCreate +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char SessionCreate (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef SessionCreate + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char SessionCreate (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_SessionCreate || defined __stub___SessionCreate +choke me +#endif + int main () { -return *(signal (0, 0)) (0) == 1; +return SessionCreate (); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -8255,124 +7639,130 @@ (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_type_signal=int + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_SessionCreate=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_type_signal=void + ac_cv_func_SessionCreate=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 -echo "${ECHO_T}$ac_cv_type_signal" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_func_SessionCreate" >&5 +echo "${ECHO_T}$ac_cv_func_SessionCreate" >&6; } +if test $ac_cv_func_SessionCreate = yes; then -cat >>confdefs.h <<_ACEOF -#define RETSIGTYPE $ac_cv_type_signal +cat >>confdefs.h <<\_ACEOF +#define HAVE_SECURITY 1 _ACEOF + LIBS_SECURITY="-framework Security" -{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 -echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } -if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then + WEAKLIBS_SECURITY="-weak_framework Security" + +fi + +LIBS=$ac_func_search_save_LIBS + +# check for seatbelt +{ echo "$as_me:$LINENO: checking for sandbox_init" >&5 +echo $ECHO_N "checking for sandbox_init... $ECHO_C" >&6; } +if test "${ac_cv_func_sandbox_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$cross_compiling" = yes; then - ac_cv_func_stat_empty_string_bug=yes -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default +/* Define sandbox_init to an innocuous variant, in case declares sandbox_init. + For example, HP-UX 11i declares gettimeofday. */ +#define sandbox_init innocuous_sandbox_init + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char sandbox_init (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef sandbox_init + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sandbox_init (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_sandbox_init || defined __stub___sandbox_init +choke me +#endif + int main () { -struct stat sbuf; - return stat ("", &sbuf) == 0; +return sandbox_init (); ; return 0; } _ACEOF -rm -f conftest$ac_exeext +rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_stat_empty_string_bug=no + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_sandbox_init=yes else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ac_cv_func_stat_empty_string_bug=yes + ac_cv_func_sandbox_init=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 -echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } -if test $ac_cv_func_stat_empty_string_bug = yes; then - case " $LIBOBJS " in - *" stat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS stat.$ac_objext" - ;; -esac +{ echo "$as_me:$LINENO: result: $ac_cv_func_sandbox_init" >&5 +echo "${ECHO_T}$ac_cv_func_sandbox_init" >&6; } +if test $ac_cv_func_sandbox_init = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_STAT_EMPTY_STRING_BUG 1 +cat >>confdefs.h <<\_ACEOF +#define HAVE_SANDBOX 1 _ACEOF fi - - - - - - - - - - - - - - - - - - -for ac_func in atexit dup2 gethostname gettimeofday memmove memset mkdir munmap rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then +# check for quarantine +{ echo "$as_me:$LINENO: checking for _qtn_proc_init_with_data" >&5 +echo $ECHO_N "checking for _qtn_proc_init_with_data... $ECHO_C" >&6; } +if test "${ac_cv_func__qtn_proc_init_with_data+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -8381,12 +7771,12 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. +/* Define _qtn_proc_init_with_data to an innocuous variant, in case declares _qtn_proc_init_with_data. For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func +#define _qtn_proc_init_with_data innocuous__qtn_proc_init_with_data /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. + which can conflict with char _qtn_proc_init_with_data (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -8396,7 +7786,7 @@ # include #endif -#undef $ac_func +#undef _qtn_proc_init_with_data /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC @@ -8404,18 +7794,18 @@ #ifdef __cplusplus extern "C" #endif -char $ac_func (); +char _qtn_proc_init_with_data (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func +#if defined __stub__qtn_proc_init_with_data || defined __stub____qtn_proc_init_with_data choke me #endif int main () { -return $ac_func (); +return _qtn_proc_init_with_data (); ; return 0; } @@ -8438,27 +7828,26 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" + ac_cv_func__qtn_proc_init_with_data=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_var=no" + ac_cv_func__qtn_proc_init_with_data=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +{ echo "$as_me:$LINENO: result: $ac_cv_func__qtn_proc_init_with_data" >&5 +echo "${ECHO_T}$ac_cv_func__qtn_proc_init_with_data" >&6; } +if test $ac_cv_func__qtn_proc_init_with_data = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_QUARANTINE 1 _ACEOF fi -done ac_config_files="$ac_config_files Makefile src/Makefile" @@ -9204,12 +8593,14 @@ EGREP!$EGREP$ac_delim ALLOCA!$ALLOCA$ac_delim LIBOBJS!$LIBOBJS$ac_delim +LIBS_SECURITY!$LIBS_SECURITY$ac_delim +WEAKLIBS_SECURITY!$WEAKLIBS_SECURITY$ac_delim LIBS_ONLY_TRUE!$LIBS_ONLY_TRUE$ac_delim LIBS_ONLY_FALSE!$LIBS_ONLY_FALSE$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: trunk/launchd/configure.ac =================================================================== --- trunk/launchd/configure.ac 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/configure.ac 2008-01-23 18:11:46 UTC (rev 23494) @@ -1,12 +1,12 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.59) +AC_PREREQ(2.61) AC_INIT([launchd],[1.0],[launchd-bug-reports@group.apple.com]) AC_CONFIG_SRCDIR([src/launchd.c]) AM_INIT_AUTOMAKE -AM_CONFIG_HEADER([src/config.h]) +AC_CONFIG_HEADERS([src/config.h]) # Checks for programs. AC_PROG_CC @@ -37,15 +37,27 @@ AC_PROG_GCC_TRADITIONAL AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK -AC_FUNC_MALLOC AC_FUNC_MKTIME -AC_FUNC_MMAP -AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_TYPE_SIGNAL AC_FUNC_STAT -AC_CHECK_FUNCS([atexit dup2 gethostname gettimeofday memmove memset mkdir munmap rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol]) +AC_CHECK_FUNCS([atexit dup2 gethostname gettimeofday malloc mmap memmove memset mkdir munmap realloc rmdir select setenv socket strcasecmp strchr strdup strerror strrchr strstr strtol]) +# check for a Security framework that includes session support +ac_func_search_save_LIBS=$LIBS +LIBS="-framework Security $ac_func_search_save_LIBS" +AC_CHECK_FUNC([SessionCreate], + [AC_DEFINE(HAVE_SECURITY, 1, [Define to 1 if you have the Security framework]) + AC_SUBST(LIBS_SECURITY,"-framework Security") + AC_SUBST(WEAKLIBS_SECURITY,"-weak_framework Security")]) +LIBS=$ac_func_search_save_LIBS + +# check for seatbelt +AC_CHECK_FUNC([sandbox_init],[AC_DEFINE(HAVE_SANDBOX, 1, [Define to 1 if you have the sandbox library])]) + +# check for quarantine +AC_CHECK_FUNC([_qtn_proc_init_with_data],[AC_DEFINE(HAVE_QUARANTINE, 1, [Define to 1 if you have the quarantine library])]) + AC_CONFIG_FILES([Makefile src/Makefile]) Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/Makefile.am 2008-01-23 18:11:46 UTC (rev 23494) @@ -39,8 +39,8 @@ sysconf_DATA = hostconfig rc.common rc.netboot -launchctl_CFLAGS = $(AM_CFLAGS) -isystem /System/Library/Frameworks/System.framework/PrivateHeaders -launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -framework Security -weak_library /usr/lib/libedit.dylib +launchctl_CFLAGS = $(AM_CFLAGS) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders +launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit @@ -53,7 +53,7 @@ launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h job_forward.h -launchproxy_LDFLAGS = -weak_framework Security +launchproxy_LDFLAGS = $(LIBS_SECURITY) job_forwardUser.c job_forward.h: $(srcdir)/protocol_job_forward.defs mig $(MIGFLAGS) -sheader /dev/null -server /dev/null $(srcdir)/protocol_job_forward.defs Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/Makefile.in 2008-01-23 18:11:46 UTC (rev 23494) @@ -181,6 +181,7 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBS_SECURITY = @LIBS_SECURITY@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ @@ -197,6 +198,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ +WEAKLIBS_SECURITY = @WEAKLIBS_SECURITY@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -249,15 +251,15 @@ @LIBS_ONLY_TRUE@liblaunch_profile_a_CFLAGS = -pg -D__DARWIN_NON_CANCELABLE=1 $(AM_CFLAGS) @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) -isystem /System/Library/Frameworks/System.framework/PrivateHeaders -@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit -framework Security -weak_library /usr/lib/libedit.dylib +@LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders +@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_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 @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c -@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security +@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(LIBS_SECURITY) @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 @LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 Modified: trunk/launchd/src/config.h.in =================================================================== --- trunk/launchd/src/config.h.in 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/config.h.in 2008-01-23 18:11:46 UTC (rev 23494) @@ -3,30 +3,60 @@ /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H +/* Define to 1 if you have the `dup2' function. */ +#undef HAVE_DUP2 + /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE +/* Define to 1 if you have the `gethostname' function. */ +#undef HAVE_GETHOSTNAME +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_LSTAT_EMPTY_STRING_BUG + /* Define to 1 if you have the header file. */ #undef HAVE_MACH_MACH_H -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ +/* Define to 1 if you have the `malloc' function. */ #undef HAVE_MALLOC /* Define to 1 if you have the `memmove' function. */ @@ -35,7 +65,13 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define to 1 if you have a working `mmap' system call. */ +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `mkdir' function. */ +#undef HAVE_MKDIR + +/* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP /* Define to 1 if you have the `munmap' function. */ @@ -44,6 +80,39 @@ /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PATHS_H + +/* Define to 1 if you have the quarantine library */ +#undef HAVE_QUARANTINE + +/* Define to 1 if you have the `realloc' function. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the `rmdir' function. */ +#undef HAVE_RMDIR + +/* Define to 1 if you have the sandbox library */ +#undef HAVE_SANDBOX + +/* Define to 1 if you have the Security framework */ +#undef HAVE_SECURITY + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the `socket' function. */ +#undef HAVE_SOCKET + /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG @@ -51,12 +120,24 @@ /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR @@ -66,6 +147,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H @@ -73,19 +163,40 @@ */ #undef HAVE_SYS_DIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MOUNT_H + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -108,6 +219,9 @@ slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + /* Name of package */ #undef PACKAGE @@ -129,9 +243,32 @@ /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE +/* Define to the type of arg 1 for `select'. */ +#undef SELECT_TYPE_ARG1 + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#undef SELECT_TYPE_ARG234 + +/* Define to the type of arg 5 for `select'. */ +#undef SELECT_TYPE_ARG5 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + /* Version number of package */ #undef VERSION @@ -141,19 +278,16 @@ /* Define to `int' if doesn't define. */ #undef gid_t -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - /* Define to `int' if does not define. */ #undef mode_t -/* Define to `long' if does not define. */ +/* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t -/* Define to `unsigned' if does not define. */ +/* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if doesn't define. */ Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/launchctl.c 2008-01-23 18:11:46 UTC (rev 23494) @@ -30,7 +30,7 @@ #include #include #include -#if !TARGET_OS_EMBEDDED +#if HAVE_SECURITY #include #include #endif @@ -1434,10 +1434,12 @@ assumes(acct("/var/account/acct") != -1); } +#if !TARGET_OS_EMBEDDED if (path_check("/etc/fstab")) { const char *mount_tool[] = { "mount", "-vat", "nonfs", NULL }; assumes(fwexec(mount_tool, NULL) != -1); } +#endif if (path_check("/etc/rc.installer_cleanup")) { const char *rccleanup_tool[] = { _PATH_BSHELL, "/etc/rc.installer_cleanup", "multiuser", NULL }; @@ -1538,9 +1540,9 @@ void do_BootCache_magic(BootCache_action_t what) { - const char *bcc_tool[] = { "BootCacheControl", "-f", "/var/db/BootCache.playlist", NULL, NULL }; + const char *bcc_tool[] = { "/usr/sbin/BootCacheControl", "-f", "/var/db/BootCache.playlist", NULL, NULL }; - if (is_safeboot()) { + if (is_safeboot() || !path_check(bcc_tool[0])) { return; } @@ -1617,7 +1619,7 @@ the_argc += 1; } -#if !TARGET_OS_EMBEDDED +#if HAVE_SECURITY if (strcasecmp(session_type, VPROCMGR_SESSION_BACKGROUND) == 0) { assumes(SessionCreate(sessionKeepCurrentBootstrap, 0) == 0); } @@ -2782,9 +2784,16 @@ * * assumes(mount(sfs.f_fstypename, "/", MNT_UPDATE, NULL) != -1); */ +#if TARGET_OS_EMBEDDED + if (path_check("/etc/fstab")) { + const char *mount_tool[] = { "mount", "-vat", "nonfs", NULL }; + assumes(fwexec(mount_tool, true) != -1); + } else +#endif + { + assumes(fwexec(remount_tool, NULL) != -1); + } - assumes(fwexec(remount_tool, NULL) != -1); - fix_bogus_file_metadata(); } Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/launchd.c 2008-01-23 18:11:46 UTC (rev 23494) @@ -23,9 +23,11 @@ #include "config.h" #include "launchd.h" +#if HAVE_SECURITY_FRAMEWORK #include #include #include +#endif #include #include #include @@ -281,6 +283,7 @@ INTERNAL_ABI void launchd_SessionCreate(void) { +#if HAVE_SECURITY_FRAMEWORK OSStatus (*sescr)(SessionCreationFlags flags, SessionAttributeBits attributes); void *seclib; @@ -290,6 +293,7 @@ } launchd_assumes(dlclose(seclib) != -1); } +#endif } void Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-23 18:11:46 UTC (rev 23494) @@ -21,6 +21,7 @@ #include "config.h" #include "launchd_core_logic.h" +#include #include #include #include @@ -72,7 +73,12 @@ #include #include #include +#if HAVE_SANDBOX #include +#endif +#if HAVE_QUARANTINE +#include +#endif #include "liblaunch_public.h" #include "liblaunch_private.h" @@ -213,7 +219,9 @@ static bool limititem_update(job_t j, int w, rlim_t r); static void limititem_delete(job_t j, struct limititem *li); static void limititem_setup(launch_data_t obj, const char *key, void *context); +#if HAVE_SANDBOX static void seatbelt_setup_flags(launch_data_t obj, const char *key, void *context); +#endif typedef enum { NETWORK_UP = 1, @@ -340,10 +348,14 @@ char *alt_exc_handler; struct machservice *lastlookup; unsigned int lastlookup_gennum; +#if HAVE_SANDBOX char *seatbelt_profile; uint64_t seatbelt_flags; +#endif +#if HAVE_QUARANTINE void *quarantine_data; size_t quarantine_data_sz; +#endif pid_t p; int argc; int last_exit_status; @@ -896,12 +908,16 @@ if (j->alt_exc_handler) { free(j->alt_exc_handler); } +#if HAVE_SANDBOX if (j->seatbelt_profile) { free(j->seatbelt_profile); } +#endif +#if HAVE_QUARANTINE if (j->quarantine_data) { free(j->quarantine_data); } +#endif if (j->j_binpref) { free(j->j_binpref); } @@ -1525,8 +1541,10 @@ } else { j->stdin_fd = 0; } +#if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXPROFILE) == 0) { where2put = &j->seatbelt_profile; +#endif } break; default: @@ -1604,8 +1622,10 @@ job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, value, j) != -1); } +#if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXFLAGS) == 0) { j->seatbelt_flags = value; +#endif } break; @@ -1621,6 +1641,7 @@ switch (key[0]) { case 'q': case 'Q': +#if HAVE_QUARANTINE if (strcasecmp(key, LAUNCH_JOBKEY_QUARANTINEDATA) == 0) { size_t tmpsz = launch_data_get_opaque_size(value); @@ -1629,6 +1650,7 @@ j->quarantine_data_sz = tmpsz; } } +#endif break; default: break; @@ -1708,8 +1730,10 @@ calendarinterval_new_from_obj(j, value); } else if (strcasecmp(key, LAUNCH_JOBKEY_SOFTRESOURCELIMITS) == 0) { launch_data_dict_iterate(value, limititem_setup, j); +#if HAVE_SANDBOX } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXFLAGS) == 0) { launch_data_dict_iterate(value, seatbelt_setup_flags, j); +#endif } break; case 'h': @@ -2835,6 +2859,7 @@ job_assumes(j, binpref_out_cnt == j->j_binpref_cnt); } +#if HAVE_QUARANTINE if (j->quarantine_data) { qtn_proc_t qp; @@ -2844,7 +2869,9 @@ } } } +#endif +#if HAVE_SANDBOX if (j->seatbelt_profile) { char *seatbelt_err_buf = NULL; @@ -2855,6 +2882,7 @@ goto out_bad; } } +#endif psf = j->prog ? posix_spawn : posix_spawnp; @@ -3891,6 +3919,7 @@ free(li); } +#if HAVE_SANDBOX void seatbelt_setup_flags(launch_data_t obj, const char *key, void *context) { @@ -3909,6 +3938,7 @@ j->seatbelt_flags |= SANDBOX_NAMED; } } +#endif void limititem_setup(launch_data_t obj, const char *key, void *context) @@ -4235,6 +4265,10 @@ f = PPC_THREAD_STATE64; #elif defined(__i386__) f = x86_THREAD_STATE; +#elif defined(__arm__) + f = ARM_THREAD_STATE; +#else +#error "unknown architecture" #endif if (likely(target_task)) { @@ -5904,6 +5938,8 @@ job_log(j, LOG_DEBUG, "%sMach service registration attempt: %s", flags & BOOTSTRAP_PER_PID_SERVICE ? "Per PID " : "", servicename); + /* 5641783 for the embedded hack */ +#if !TARGET_OS_EMBEDDED /* * From a per-user/session launchd's perspective, SecurityAgent (UID * 92) is a rogue application (not our UID, not root and not a child of @@ -5916,6 +5952,7 @@ return BOOTSTRAP_NOT_PRIVILEGED; } } +#endif ms = jobmgr_lookup_service(j->mgr, servicename, false, flags & BOOTSTRAP_PER_PID_SERVICE ? ldc->pid : 0); @@ -5953,9 +5990,12 @@ return BOOTSTRAP_NO_MEMORY; } + /* 5641783 for the embedded hack */ +#if !TARGET_OS_EMBEDDED if (unlikely(pid1_magic && j->anonymous && j->mgr->parentmgr == NULL && ldc->uid != 0 && ldc->euid != 0)) { return VPROC_ERR_TRY_PER_USER; } +#endif if (unlikely(!mspolicy_check(j, servicename, flags & BOOTSTRAP_PER_PID_SERVICE))) { job_log(j, LOG_NOTICE, "Policy denied Mach service lookup: %s", servicename); Modified: trunk/launchd/src/launchd_runtime_kill.c =================================================================== --- trunk/launchd/src/launchd_runtime_kill.c 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/launchd_runtime_kill.c 2008-01-23 18:11:46 UTC (rev 23494) @@ -18,7 +18,16 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#if !defined(__LP64__) && !defined(__arm__) #define _NONSTD_SOURCE 1 +#define old_kill(x, y) kill(x, y) +#define old_killpg(x, y) killpg(x, y) +#else +/* ??? No blessed way to get the old behavior */ +extern int __kill(int, int, int); +#define old_kill(x, y) __kill(x, y, 0) +#define old_killpg(x, y) __kill(-(x), y, 0) +#endif #include #include "launchd_runtime_kill.h" @@ -34,11 +43,11 @@ int runtime_kill(pid_t pid, int sig) { - return kill(pid, sig); + return old_kill(pid, sig); } int runtime_killpg(pid_t pgrp, int sig) { - return killpg(pgrp, sig); + return old_killpg(pgrp, sig); } Modified: trunk/launchd/src/launchproxy.c =================================================================== --- trunk/launchd/src/launchproxy.c 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/launchproxy.c 2008-01-23 18:11:46 UTC (rev 23494) @@ -17,9 +17,11 @@ * * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#if HAVE_SECURITY #include #include #include +#endif #include #include #include @@ -40,7 +42,7 @@ #include "launch.h" -#if __GNUC__ >= 4 +#if __GNUC__ >= 4 && HAVE_SECURITY OSStatus SessionCreate(SessionCreationFlags flags, SessionAttributeBits attributes) __attribute__((weak)); #endif @@ -184,6 +186,7 @@ setpgid(0, 0); +#if HAVE_SECURITY if ((tmp = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SESSIONCREATE)) && launch_data_get_bool(tmp)) { if (SessionCreate) { OSStatus scr = SessionCreate(0, 0); @@ -193,6 +196,7 @@ syslog(LOG_NOTICE, "%s: SessionCreate == NULL!", prog); } } +#endif fcntl(r, F_SETFL, 0); fcntl(r, F_SETFD, 1); dup2(r, STDIN_FILENO); Modified: trunk/launchd/src/liblaunch_private.h =================================================================== --- trunk/launchd/src/liblaunch_private.h 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/liblaunch_private.h 2008-01-23 18:11:46 UTC (rev 23494) @@ -25,7 +25,6 @@ #include #include #include -#include #pragma GCC visibility push(default) @@ -115,7 +114,7 @@ mach_port_t * spawn_observer_port; const cpu_type_t * spawn_binpref; size_t spawn_binpref_cnt; - qtn_proc_t spawn_quarantine; + void * spawn_quarantine; const char * spawn_seatbelt_profile; const uint64_t * spawn_seatbelt_flags; }; Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2008-01-23 17:13:59 UTC (rev 23493) +++ trunk/launchd/src/libvproc.c 2008-01-23 18:11:46 UTC (rev 23494) @@ -201,6 +201,7 @@ if (spawn_attrs) switch (struct_version) { case 2: +#if HAVE_QUARANTINE if (spawn_attrs->spawn_quarantine) { char qbuf[QTN_SERIALIZED_DATA_MAX]; size_t qbuf_sz = QTN_SERIALIZED_DATA_MAX; @@ -210,6 +211,7 @@ launch_data_dict_insert(in_obj, tmp, LAUNCH_JOBKEY_QUARANTINEDATA); } } +#endif if (spawn_attrs->spawn_seatbelt_profile) { tmp = launch_data_new_string(spawn_attrs->spawn_seatbelt_profile); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080123/1a8f8095/attachment-0001.html From source_changes at macosforge.org Wed Jan 23 14:25:38 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Wed Jan 23 14:28:04 2008 Subject: [launchd-changes] [23495] trunk/launchd/src/launchd_core_logic.c Message-ID: <20080123222538.3A254C0F8C7@beta.macosforge.org> Revision: 23495 http://trac.macosforge.org/projects/launchd/changeset/23495 Author: zarzycki@apple.com Date: 2008-01-23 14:25:34 -0800 (Wed, 23 Jan 2008) Log Message: ----------- Speculative 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 2008-01-23 18:11:46 UTC (rev 23494) +++ trunk/launchd/src/launchd_core_logic.c 2008-01-23 22:25:34 UTC (rev 23495) @@ -2410,7 +2410,13 @@ void job_log_chidren_without_exec(job_t j) { + /* ER: Add a KERN_PROC_PPID sysctl */ +#ifdef KERN_PROC_PPID + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PPID, j->p }; +#else int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; +#endif + int mib_sz = sizeof(mib) / sizeof(mib[0]); size_t i, kp_cnt, len = 10*1024*1024; struct kinfo_proc *kp; @@ -2421,20 +2427,24 @@ if (!job_assumes(j, (kp = malloc(len)) != NULL)) { return; } - if (!job_assumes(j, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) { + if (!job_assumes(j, sysctl(mib, mib_sz, kp, &len, NULL, 0) != -1)) { goto out; } kp_cnt = len / sizeof(struct kinfo_proc); for (i = 0; i < kp_cnt; i++) { +#ifndef KERN_PROC_PPID if (kp[i].kp_eproc.e_ppid != j->p) { continue; - } else if (kp[i].kp_proc.p_flag & P_EXEC) { + } +#endif + if (kp[i].kp_proc.p_flag & P_EXEC) { continue; } job_log(j, LOG_APPLEONLY, "Performance and sanity: fork() without exec*(). Please switch to posix_spawn()"); + break; } out: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080123/b9b25858/attachment.html From source_changes at macosforge.org Fri Jan 25 14:08:17 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 25 14:10:43 2008 Subject: [launchd-changes] [23496] branches/SULeopard/launchd/src/launchproxy.c Message-ID: <20080125220817.27DBBC81AD2@beta.macosforge.org> Revision: 23496 http://trac.macosforge.org/projects/launchd/changeset/23496 Author: zarzycki@apple.com Date: 2008-01-25 14:08:13 -0800 (Fri, 25 Jan 2008) Log Message: ----------- Think-o. Modified Paths: -------------- branches/SULeopard/launchd/src/launchproxy.c Modified: branches/SULeopard/launchd/src/launchproxy.c =================================================================== --- branches/SULeopard/launchd/src/launchproxy.c 2008-01-23 22:25:34 UTC (rev 23495) +++ branches/SULeopard/launchd/src/launchproxy.c 2008-01-25 22:08:13 UTC (rev 23496) @@ -17,6 +17,7 @@ * * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include "config.h" #if HAVE_SECURITY #include #include -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080125/e1bacf3f/attachment.html From source_changes at macosforge.org Fri Jan 25 14:08:25 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Fri Jan 25 14:10:51 2008 Subject: [launchd-changes] [23497] tags/launchd-258.3/ Message-ID: <20080125220825.C8DEFC81AF6@beta.macosforge.org> Revision: 23497 http://trac.macosforge.org/projects/launchd/changeset/23497 Author: zarzycki@apple.com Date: 2008-01-25 14:08:25 -0800 (Fri, 25 Jan 2008) Log Message: ----------- "Tagging launchd-258.3 from https://svn.macosforge.org/repository/launchd/branches/SULeopard" Added Paths: ----------- tags/launchd-258.3/ Copied: tags/launchd-258.3 (from rev 23496, branches/SULeopard) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080125/7bc8de8b/attachment.html From source_changes at macosforge.org Mon Jan 28 10:20:29 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 10:21:58 2008 Subject: [launchd-changes] [23498] branches/SULeopard Message-ID: <20080128182029.0EE09D2B2AE@beta.macosforge.org> Revision: 23498 http://trac.macosforge.org/projects/launchd/changeset/23498 Author: zarzycki@apple.com Date: 2008-01-28 10:20:19 -0800 (Mon, 28 Jan 2008) Log Message: ----------- launchd uses distributed notifications, which aren't available launchd does not get -isysroot Modified Paths: -------------- branches/SULeopard/Makefile branches/SULeopard/launchd/configure branches/SULeopard/launchd/configure.ac branches/SULeopard/launchd/src/Makefile.am branches/SULeopard/launchd/src/Makefile.in branches/SULeopard/launchd/src/launchd_core_logic.c Modified: branches/SULeopard/Makefile =================================================================== --- branches/SULeopard/Makefile 2008-01-25 22:08:25 UTC (rev 23497) +++ branches/SULeopard/Makefile 2008-01-28 18:20:19 UTC (rev 23498) @@ -1,3 +1,7 @@ +ifndef SDKROOT +export SDKROOT = / +endif + Project = launchd Extra_Configure_Flags = --sbindir=/sbin --bindir=/bin --sysconfdir=/private/etc GnuAfterInstall = launchd_after_install @@ -5,7 +9,7 @@ Install_Flags = DESTDIR=$(DSTROOT) ifeq ($(shell tconf --test TARGET_OS_EMBEDDED),YES) - Extra_Configure_Flags += --host=none-apple-darwin +Extra_Configure_Flags += --host=none-apple-darwin endif launchd_after_install:: @@ -14,10 +18,12 @@ -find -d $(DSTROOT) -type l | grep -v /usr/local/lib/system | xargs rm -find -d $(DSTROOT) -type d | grep -v /usr/local/lib/system | xargs rmdir else +ifeq ($(shell tconf --test TARGET_OS_EMBEDDED),NO) mkdir -p $(DSTROOT)/Library/StartupItems chmod 755 $(DSTROOT)/Library/StartupItems mkdir -p $(DSTROOT)/System/Library/StartupItems chmod 755 $(DSTROOT)/System/Library/StartupItems +endif rm -rf $(DSTROOT)/usr/local/lib/system cp $(OBJROOT)/src/launchd $(SYMROOT) cp $(OBJROOT)/src/launchctl $(SYMROOT) Modified: branches/SULeopard/launchd/configure =================================================================== --- branches/SULeopard/launchd/configure 2008-01-25 22:08:25 UTC (rev 23497) +++ branches/SULeopard/launchd/configure 2008-01-28 18:20:19 UTC (rev 23498) @@ -702,6 +702,8 @@ WEAKLIBS_SECURITY LIBS_ONLY_TRUE LIBS_ONLY_FALSE +DO_EMBEDDED_MAGIC_TRUE +DO_EMBEDDED_MAGIC_FALSE LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias @@ -7861,7 +7863,16 @@ LIBS_ONLY_FALSE= fi + if test $(tconf --test TARGET_OS_EMBEDDED) = YES; then + DO_EMBEDDED_MAGIC_TRUE= + DO_EMBEDDED_MAGIC_FALSE='#' +else + DO_EMBEDDED_MAGIC_TRUE='#' + DO_EMBEDDED_MAGIC_FALSE= +fi + + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -7979,6 +7990,13 @@ Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${DO_EMBEDDED_MAGIC_TRUE}" && test -z "${DO_EMBEDDED_MAGIC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"DO_EMBEDDED_MAGIC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"DO_EMBEDDED_MAGIC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files @@ -8597,10 +8615,12 @@ WEAKLIBS_SECURITY!$WEAKLIBS_SECURITY$ac_delim LIBS_ONLY_TRUE!$LIBS_ONLY_TRUE$ac_delim LIBS_ONLY_FALSE!$LIBS_ONLY_FALSE$ac_delim +DO_EMBEDDED_MAGIC_TRUE!$DO_EMBEDDED_MAGIC_TRUE$ac_delim +DO_EMBEDDED_MAGIC_FALSE!$DO_EMBEDDED_MAGIC_FALSE$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: branches/SULeopard/launchd/configure.ac =================================================================== --- branches/SULeopard/launchd/configure.ac 2008-01-25 22:08:25 UTC (rev 23497) +++ branches/SULeopard/launchd/configure.ac 2008-01-28 18:20:19 UTC (rev 23498) @@ -62,5 +62,7 @@ src/Makefile]) AM_CONDITIONAL(LIBS_ONLY, test "$RC_ProjectName" = launchd_libs) +AM_CONDITIONAL(DO_EMBEDDED_MAGIC, test $(tconf --test TARGET_OS_EMBEDDED) = YES) + AC_OUTPUT Modified: branches/SULeopard/launchd/src/Makefile.am =================================================================== --- branches/SULeopard/launchd/src/Makefile.am 2008-01-25 22:08:25 UTC (rev 23497) +++ branches/SULeopard/launchd/src/Makefile.am 2008-01-28 18:20:19 UTC (rev 23498) @@ -1,5 +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__ +AM_CFLAGS = -no-cpp-precomp -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ +AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT) + CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h @@ -34,26 +36,33 @@ else bin_PROGRAMS = launchctl wait4path +if DO_EMBEDDED_MAGIC +sbin_PROGRAMS = launchd +else sbin_PROGRAMS = launchd SystemStarter +endif libexec_PROGRAMS = launchproxy sysconf_DATA = hostconfig rc.common rc.netboot launchctl_CFLAGS = $(AM_CFLAGS) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders -launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib +launchctl_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib +if DO_EMBEDDED_MAGIC +else SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit +SystemStarter_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c +endif launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter -launchd_LDFLAGS = -lbsm +launchd_LDFLAGS = $(AM_LDFLAGS) -lbsm launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h -launchproxy_LDFLAGS = $(WEAKLIBS_SECURITY) +launchproxy_LDFLAGS = $(AM_LDFLAGS) $(WEAKLIBS_SECURITY) notifyServer.c notifyServer.h: /usr/include/mach/notify.defs mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs @@ -72,7 +81,11 @@ man5_MANS = launchd.plist.5 launchd.conf.5 +if DO_EMBEDDED_MAGIC +man8_MANS = launchd.8 launchproxy.8 +else man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 +endif install-data-hook: mkdir -p $(DESTDIR)/usr/libexec @@ -85,7 +98,6 @@ mkdir -p $(DESTDIR)/Library/LaunchAgents mkdir -p $(DESTDIR)/System/Library/LaunchAgents mkdir -p $(DESTDIR)/System/Library/LaunchDaemons - cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec 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 @@ -94,6 +106,10 @@ cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h +if DO_EMBEDDED_MAGIC +else + cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons +endif endif Modified: branches/SULeopard/launchd/src/Makefile.in =================================================================== --- branches/SULeopard/launchd/src/Makefile.in 2008-01-25 22:08:25 UTC (rev 23497) +++ branches/SULeopard/launchd/src/Makefile.in 2008-01-28 18:20:19 UTC (rev 23498) @@ -33,8 +33,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : @LIBS_ONLY_FALSE@bin_PROGRAMS = launchctl$(EXEEXT) wait4path$(EXEEXT) -@LIBS_ONLY_FALSE@sbin_PROGRAMS = launchd$(EXEEXT) \ -@LIBS_ONLY_FALSE@ SystemStarter$(EXEEXT) +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@sbin_PROGRAMS = \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ launchd$(EXEEXT) \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ SystemStarter$(EXEEXT) +@DO_EMBEDDED_MAGIC_TRUE@@LIBS_ONLY_FALSE@sbin_PROGRAMS = \ +@DO_EMBEDDED_MAGIC_TRUE@@LIBS_ONLY_FALSE@ launchd$(EXEEXT) @LIBS_ONLY_FALSE@libexec_PROGRAMS = launchproxy$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ @@ -80,10 +83,9 @@ sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) $(sbin_PROGRAMS) am__SystemStarter_SOURCES_DIST = StartupItems.c IPC.c SystemStarter.c -@LIBS_ONLY_FALSE@am_SystemStarter_OBJECTS = \ -@LIBS_ONLY_FALSE@ SystemStarter-StartupItems.$(OBJEXT) \ -@LIBS_ONLY_FALSE@ SystemStarter-IPC.$(OBJEXT) \ -@LIBS_ONLY_FALSE@ SystemStarter-SystemStarter.$(OBJEXT) +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@am_SystemStarter_OBJECTS = SystemStarter-StartupItems.$(OBJEXT) \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ SystemStarter-IPC.$(OBJEXT) \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ SystemStarter-SystemStarter.$(OBJEXT) SystemStarter_OBJECTS = $(am_SystemStarter_OBJECTS) SystemStarter_LDADD = $(LDADD) SystemStarter_LINK = $(CCLD) $(SystemStarter_CFLAGS) $(CFLAGS) \ @@ -239,7 +241,8 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -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__ +AM_CFLAGS = -no-cpp-precomp -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ +AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT) CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h @@ -251,17 +254,18 @@ @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$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders -@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_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 +@LIBS_ONLY_FALSE@launchctl_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter -@LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm +@LIBS_ONLY_FALSE@launchd_LDFLAGS = $(AM_LDFLAGS) -lbsm @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c mach_excServer.c -@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(WEAKLIBS_SECURITY) +@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(AM_LDFLAGS) $(WEAKLIBS_SECURITY) @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 -@LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 +@DO_EMBEDDED_MAGIC_TRUE@@LIBS_ONLY_FALSE@man8_MANS = launchd.8 launchproxy.8 all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -1193,7 +1197,6 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchAgents @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchAgents @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchDaemons -@LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec @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 @@ -1202,7 +1205,8 @@ @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@ cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h -@LIBS_ONLY_FALSE@ cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Modified: branches/SULeopard/launchd/src/launchd_core_logic.c =================================================================== --- branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-25 22:08:25 UTC (rev 23497) +++ branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-28 18:20:19 UTC (rev 23498) @@ -6165,7 +6165,7 @@ job_log(j, LOG_DEBUG, "Move subset attempt: 0x%x", target_subset); - kr = _vproc_grab_subset(target_subset, &reqport, &rcvright, &out_obj_array, &l2l_ports, &l2l_port_cnt); + errno = kr = _vproc_grab_subset(target_subset, &reqport, &rcvright, &out_obj_array, &l2l_ports, &l2l_port_cnt); if (!job_assumes(j, kr == 0)) { goto out; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/bdcb2b50/attachment-0001.html From source_changes at macosforge.org Mon Jan 28 10:38:38 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 10:41:07 2008 Subject: [launchd-changes] [23499] branches/SULeopard/launchd/src Message-ID: <20080128183838.15626D2C0ED@beta.macosforge.org> Revision: 23499 http://trac.macosforge.org/projects/launchd/changeset/23499 Author: zarzycki@apple.com Date: 2008-01-28 10:38:20 -0800 (Mon, 28 Jan 2008) Log Message: ----------- work with Seatbelt to provide access control on spawn_via_launchd Modified Paths: -------------- branches/SULeopard/launchd/src/launchd_core_logic.c branches/SULeopard/launchd/src/libbootstrap_private.h Modified: branches/SULeopard/launchd/src/launchd_core_logic.c =================================================================== --- branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-28 18:20:19 UTC (rev 23498) +++ branches/SULeopard/launchd/src/launchd_core_logic.c 2008-01-28 18:38:20 UTC (rev 23499) @@ -6548,6 +6548,7 @@ job_assumes(j, mspolicy_new(target_j, target_service, flags & BOOTSTRAP_ALLOW_LOOKUP, flags & BOOTSTRAP_PER_PID_SERVICE, false)); } else { target_j->deny_unknown_mslookups = !(flags & BOOTSTRAP_ALLOW_LOOKUP); + target_j->deny_job_creation = (bool)(flags & BOOTSTRAP_DENY_JOB_CREATION); } } else { job_log(j, LOG_WARNING, "Jobs that have policies assigned to them may not set policies."); Modified: branches/SULeopard/launchd/src/libbootstrap_private.h =================================================================== --- branches/SULeopard/launchd/src/libbootstrap_private.h 2008-01-28 18:20:19 UTC (rev 23498) +++ branches/SULeopard/launchd/src/libbootstrap_private.h 2008-01-28 18:38:20 UTC (rev 23499) @@ -29,6 +29,7 @@ #define BOOTSTRAP_PER_PID_SERVICE 0x1 #define BOOTSTRAP_ALLOW_LOOKUP 0x2 +#define BOOTSTRAP_DENY_JOB_CREATION 0x4 kern_return_t bootstrap_register2(mach_port_t bp, name_t service_name, mach_port_t sp, uint64_t flags); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/f218e3b0/attachment.html From source_changes at macosforge.org Mon Jan 28 11:20:09 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 11:22:38 2008 Subject: [launchd-changes] [23500] trunk/launchd/src/launchproxy.c Message-ID: <20080128192009.8098DD2DEDB@beta.macosforge.org> Revision: 23500 http://trac.macosforge.org/projects/launchd/changeset/23500 Author: zarzycki@apple.com Date: 2008-01-28 11:20:02 -0800 (Mon, 28 Jan 2008) Log Message: ----------- Think-o. Modified Paths: -------------- trunk/launchd/src/launchproxy.c Modified: trunk/launchd/src/launchproxy.c =================================================================== --- trunk/launchd/src/launchproxy.c 2008-01-28 18:38:20 UTC (rev 23499) +++ trunk/launchd/src/launchproxy.c 2008-01-28 19:20:02 UTC (rev 23500) @@ -17,6 +17,7 @@ * * @APPLE_APACHE_LICENSE_HEADER_END@ */ +#include "config.h" #if HAVE_SECURITY #include #include -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/7f953119/attachment.html From source_changes at macosforge.org Mon Jan 28 11:26:33 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 11:28:30 2008 Subject: [launchd-changes] [23501] trunk Message-ID: <20080128192633.A3B86D2E5B8@beta.macosforge.org> Revision: 23501 http://trac.macosforge.org/projects/launchd/changeset/23501 Author: zarzycki@apple.com Date: 2008-01-28 11:26:29 -0800 (Mon, 28 Jan 2008) Log Message: ----------- SystemStarter links against distributed notifications, which aren't available Modified Paths: -------------- trunk/Makefile trunk/launchd/configure trunk/launchd/configure.ac trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-01-28 19:20:02 UTC (rev 23500) +++ trunk/Makefile 2008-01-28 19:26:29 UTC (rev 23501) @@ -1,3 +1,7 @@ +ifndef SDKROOT +export SDKROOT = / +endif + Project = launchd Extra_Configure_Flags = --sbindir=/sbin --bindir=/bin --sysconfdir=/private/etc GnuAfterInstall = launchd_after_install @@ -5,7 +9,7 @@ Install_Flags = DESTDIR=$(DSTROOT) ifeq ($(shell tconf --test TARGET_OS_EMBEDDED),YES) - Extra_Configure_Flags += --host=none-apple-darwin +Extra_Configure_Flags += --host=none-apple-darwin endif launchd_after_install:: @@ -14,10 +18,12 @@ -find -d $(DSTROOT) -type l | grep -v /usr/local/lib/system | xargs rm -find -d $(DSTROOT) -type d | grep -v /usr/local/lib/system | xargs rmdir else +ifeq ($(shell tconf --test TARGET_OS_EMBEDDED),NO) mkdir -p $(DSTROOT)/Library/StartupItems chmod 755 $(DSTROOT)/Library/StartupItems mkdir -p $(DSTROOT)/System/Library/StartupItems chmod 755 $(DSTROOT)/System/Library/StartupItems +endif rm -rf $(DSTROOT)/usr/local/lib/system cp $(OBJROOT)/src/launchd $(SYMROOT) cp $(OBJROOT)/src/launchctl $(SYMROOT) Modified: trunk/launchd/configure =================================================================== --- trunk/launchd/configure 2008-01-28 19:20:02 UTC (rev 23500) +++ trunk/launchd/configure 2008-01-28 19:26:29 UTC (rev 23501) @@ -702,6 +702,8 @@ WEAKLIBS_SECURITY LIBS_ONLY_TRUE LIBS_ONLY_FALSE +DO_EMBEDDED_MAGIC_TRUE +DO_EMBEDDED_MAGIC_FALSE LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias @@ -7861,7 +7863,16 @@ LIBS_ONLY_FALSE= fi + if test $(tconf --test TARGET_OS_EMBEDDED) = YES; then + DO_EMBEDDED_MAGIC_TRUE= + DO_EMBEDDED_MAGIC_FALSE='#' +else + DO_EMBEDDED_MAGIC_TRUE='#' + DO_EMBEDDED_MAGIC_FALSE= +fi + + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -7979,6 +7990,13 @@ Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${DO_EMBEDDED_MAGIC_TRUE}" && test -z "${DO_EMBEDDED_MAGIC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"DO_EMBEDDED_MAGIC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"DO_EMBEDDED_MAGIC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files @@ -8597,10 +8615,12 @@ WEAKLIBS_SECURITY!$WEAKLIBS_SECURITY$ac_delim LIBS_ONLY_TRUE!$LIBS_ONLY_TRUE$ac_delim LIBS_ONLY_FALSE!$LIBS_ONLY_FALSE$ac_delim +DO_EMBEDDED_MAGIC_TRUE!$DO_EMBEDDED_MAGIC_TRUE$ac_delim +DO_EMBEDDED_MAGIC_FALSE!$DO_EMBEDDED_MAGIC_FALSE$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: trunk/launchd/configure.ac =================================================================== --- trunk/launchd/configure.ac 2008-01-28 19:20:02 UTC (rev 23500) +++ trunk/launchd/configure.ac 2008-01-28 19:26:29 UTC (rev 23501) @@ -62,5 +62,7 @@ src/Makefile]) AM_CONDITIONAL(LIBS_ONLY, test "$RC_ProjectName" = launchd_libs) +AM_CONDITIONAL(DO_EMBEDDED_MAGIC, test $(tconf --test TARGET_OS_EMBEDDED) = YES) + AC_OUTPUT Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2008-01-28 19:20:02 UTC (rev 23500) +++ trunk/launchd/src/Makefile.am 2008-01-28 19:26:29 UTC (rev 23501) @@ -34,7 +34,11 @@ else bin_PROGRAMS = launchctl wait4path +if DO_EMBEDDED_MAGIC +sbin_PROGRAMS = launchd +else sbin_PROGRAMS = launchd SystemStarter +endif libexec_PROGRAMS = launchproxy sysconf_DATA = hostconfig rc.common rc.netboot @@ -42,9 +46,12 @@ launchctl_CFLAGS = $(AM_CFLAGS) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib +if DO_EMBEDDED_MAGIC +else SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c +endif launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing launchd_LDFLAGS = -lbsm @@ -75,7 +82,11 @@ man5_MANS = launchd.plist.5 launchd.conf.5 +if DO_EMBEDDED_MAGIC +man8_MANS = launchd.8 launchproxy.8 +else man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 +endif install-data-hook: mkdir -p $(DESTDIR)/usr/libexec @@ -88,7 +99,6 @@ mkdir -p $(DESTDIR)/Library/LaunchAgents mkdir -p $(DESTDIR)/System/Library/LaunchAgents mkdir -p $(DESTDIR)/System/Library/LaunchDaemons - cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec 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 @@ -97,6 +107,10 @@ cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h +if DO_EMBEDDED_MAGIC +else + cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons +endif endif Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2008-01-28 19:20:02 UTC (rev 23500) +++ trunk/launchd/src/Makefile.in 2008-01-28 19:26:29 UTC (rev 23501) @@ -33,8 +33,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : @LIBS_ONLY_FALSE@bin_PROGRAMS = launchctl$(EXEEXT) wait4path$(EXEEXT) -@LIBS_ONLY_FALSE@sbin_PROGRAMS = launchd$(EXEEXT) \ -@LIBS_ONLY_FALSE@ SystemStarter$(EXEEXT) +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@sbin_PROGRAMS = \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ launchd$(EXEEXT) \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ SystemStarter$(EXEEXT) +@DO_EMBEDDED_MAGIC_TRUE@@LIBS_ONLY_FALSE@sbin_PROGRAMS = \ +@DO_EMBEDDED_MAGIC_TRUE@@LIBS_ONLY_FALSE@ launchd$(EXEEXT) @LIBS_ONLY_FALSE@libexec_PROGRAMS = launchproxy$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ @@ -80,10 +83,9 @@ sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) $(sbin_PROGRAMS) am__SystemStarter_SOURCES_DIST = StartupItems.c IPC.c SystemStarter.c -@LIBS_ONLY_FALSE@am_SystemStarter_OBJECTS = \ -@LIBS_ONLY_FALSE@ SystemStarter-StartupItems.$(OBJEXT) \ -@LIBS_ONLY_FALSE@ SystemStarter-IPC.$(OBJEXT) \ -@LIBS_ONLY_FALSE@ SystemStarter-SystemStarter.$(OBJEXT) +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@am_SystemStarter_OBJECTS = SystemStarter-StartupItems.$(OBJEXT) \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ SystemStarter-IPC.$(OBJEXT) \ +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ SystemStarter-SystemStarter.$(OBJEXT) SystemStarter_OBJECTS = $(am_SystemStarter_OBJECTS) SystemStarter_LDADD = $(LDADD) SystemStarter_LINK = $(CCLD) $(SystemStarter_CFLAGS) $(CFLAGS) \ @@ -253,16 +255,17 @@ @LIBS_ONLY_FALSE@sysconf_DATA = hostconfig rc.common rc.netboot @LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders @LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_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 +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(LIBS_SECURITY) @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 -@LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 +@DO_EMBEDDED_MAGIC_TRUE@@LIBS_ONLY_FALSE@man8_MANS = launchd.8 launchproxy.8 all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -1212,7 +1215,6 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchAgents @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchAgents @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchDaemons -@LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec @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 @@ -1221,7 +1223,8 @@ @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@ cp $(srcdir)/reboot2.h $(DESTDIR)/usr/local/include/reboot2.h -@LIBS_ONLY_FALSE@ cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ cp $(srcdir)/StartupItemContext $(DESTDIR)/usr/libexec +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@ cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/e4a70a99/attachment-0001.html From source_changes at macosforge.org Mon Jan 28 14:17:05 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 14:19:44 2008 Subject: [launchd-changes] [23502] tags/launchd-258.4/ Message-ID: <20080128221705.11FADD3B40A@beta.macosforge.org> Revision: 23502 http://trac.macosforge.org/projects/launchd/changeset/23502 Author: zarzycki@apple.com Date: 2008-01-28 14:17:04 -0800 (Mon, 28 Jan 2008) Log Message: ----------- "Tagging launchd-258.4 from https://svn.macosforge.org/repository/launchd/branches/SULeopard" Added Paths: ----------- tags/launchd-258.4/ Copied: tags/launchd-258.4 (from rev 23501, branches/SULeopard) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/876b81ed/attachment.html From source_changes at macosforge.org Mon Jan 28 15:22:21 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 15:24:46 2008 Subject: [launchd-changes] [23503] trunk/launchd/src/liblaunch_private.h Message-ID: <20080128232221.23911D407EC@beta.macosforge.org> Revision: 23503 http://trac.macosforge.org/projects/launchd/changeset/23503 Author: zarzycki@apple.com Date: 2008-01-28 15:22:19 -0800 (Mon, 28 Jan 2008) Log Message: ----------- /usr/include/launch_priv.h not c99-safe Modified Paths: -------------- trunk/launchd/src/liblaunch_private.h Modified: trunk/launchd/src/liblaunch_private.h =================================================================== --- trunk/launchd/src/liblaunch_private.h 2008-01-28 22:17:04 UTC (rev 23502) +++ trunk/launchd/src/liblaunch_private.h 2008-01-28 23:22:19 UTC (rev 23503) @@ -67,7 +67,7 @@ launch_t launchd_fdopen(int); int launchd_getfd(launch_t); -void launchd_close(launch_t, typeof(close) closefunc); +void launchd_close(launch_t, __typeof__(close) closefunc); launch_data_t launch_data_new_errno(int); bool launch_data_set_errno(launch_data_t, int); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/c8f42ac7/attachment.html From source_changes at macosforge.org Mon Jan 28 15:24:01 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 15:25:56 2008 Subject: [launchd-changes] [23504] branches/SULeopard/launchd/src/liblaunch_private.h Message-ID: <20080128232401.C0199D40A09@beta.macosforge.org> Revision: 23504 http://trac.macosforge.org/projects/launchd/changeset/23504 Author: zarzycki@apple.com Date: 2008-01-28 15:24:00 -0800 (Mon, 28 Jan 2008) Log Message: ----------- /usr/include/launch_priv.h not c99-safe Modified Paths: -------------- branches/SULeopard/launchd/src/liblaunch_private.h Modified: branches/SULeopard/launchd/src/liblaunch_private.h =================================================================== --- branches/SULeopard/launchd/src/liblaunch_private.h 2008-01-28 23:22:19 UTC (rev 23503) +++ branches/SULeopard/launchd/src/liblaunch_private.h 2008-01-28 23:24:00 UTC (rev 23504) @@ -66,7 +66,7 @@ launch_t launchd_fdopen(int); int launchd_getfd(launch_t); -void launchd_close(launch_t, typeof(close) closefunc); +void launchd_close(launch_t, __typeof__(close) closefunc); launch_data_t launch_data_new_errno(int); bool launch_data_set_errno(launch_data_t, int); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/09db9dd8/attachment.html From source_changes at macosforge.org Mon Jan 28 16:31:37 2008 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Mon Jan 28 16:34:06 2008 Subject: [launchd-changes] [23505] trunk/launchd/src Message-ID: <20080129003137.746D0D43370@beta.macosforge.org> Revision: 23505 http://trac.macosforge.org/projects/launchd/changeset/23505 Author: zarzycki@apple.com Date: 2008-01-28 16:31:31 -0800 (Mon, 28 Jan 2008) Log Message: ----------- Misc. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2008-01-28 23:24:00 UTC (rev 23504) +++ trunk/launchd/src/Makefile.am 2008-01-29 00:31:31 UTC (rev 23505) @@ -1,4 +1,8 @@ -AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ +CWARN = -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror # -Wconversion -Wstrict-aliasing=2 +CTUNE = -fvisibility=hidden -fdiagnostics-show-option # -fstrict-aliasing +CMISC = -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -D__MigTypeCheck=1 -Dmig_external=__private_extern__ +AM_CFLAGS = $(CTUNE) $(CMISC) $(CWARN) +AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT) CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ @@ -44,23 +48,23 @@ sysconf_DATA = hostconfig rc.common rc.netboot launchctl_CFLAGS = $(AM_CFLAGS) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders -launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib +launchctl_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib if DO_EMBEDDED_MAGIC else SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit +SystemStarter_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c endif -launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing -launchd_LDFLAGS = -lbsm +launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks +launchd_LDFLAGS = $(AM_LDFLAGS) -lbsm launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h job_forward.h -launchproxy_LDFLAGS = $(LIBS_SECURITY) +launchproxy_LDFLAGS = $(AM_LDFLAGS) $(LIBS_SECURITY) job_forwardUser.c job_forward.h: $(srcdir)/protocol_job_forward.defs mig $(MIGFLAGS) -sheader /dev/null -server /dev/null $(srcdir)/protocol_job_forward.defs Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2008-01-28 23:24:00 UTC (rev 23504) +++ trunk/launchd/src/Makefile.in 2008-01-29 00:31:31 UTC (rev 23505) @@ -242,7 +242,11 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__ +CWARN = -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror # -Wconversion -Wstrict-aliasing=2 +CTUNE = -fvisibility=hidden -fdiagnostics-show-option # -fstrict-aliasing +CMISC = -isysroot $(SDKROOT) -F$(SDKROOT)/System/Library/PrivateFrameworks -D__MigTypeCheck=1 -Dmig_external=__private_extern__ +AM_CFLAGS = $(CTUNE) $(CMISC) $(CWARN) +AM_LDFLAGS = -Wl,-syslibroot,$(SDKROOT) CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h @@ -254,14 +258,14 @@ @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) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders -@LIBS_ONLY_FALSE@launchctl_LDFLAGS = -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib +@LIBS_ONLY_FALSE@launchctl_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit $(LIBS_SECURITY) -weak_library /usr/lib/libedit.dylib @DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit +@DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_LDFLAGS = $(AM_LDFLAGS) -framework CoreFoundation -framework IOKit @DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c -@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing -@LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm +@LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks +@LIBS_ONLY_FALSE@launchd_LDFLAGS = $(AM_LDFLAGS) -lbsm @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c -@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(LIBS_SECURITY) +@LIBS_ONLY_FALSE@launchproxy_LDFLAGS = $(AM_LDFLAGS) $(LIBS_SECURITY) @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 @DO_EMBEDDED_MAGIC_FALSE@@LIBS_ONLY_FALSE@man8_MANS = StartupItemContext.8 SystemStarter.8 rc.8 launchd.8 launchproxy.8 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080128/610632f3/attachment-0001.html