Modified: trunk/launchd/src/launchd_core_logic.c (23600 => 23601)
--- trunk/launchd/src/launchd_core_logic.c 2008-04-18 21:41:05 UTC (rev 23600)
+++ trunk/launchd/src/launchd_core_logic.c 2008-04-21 20:33:29 UTC (rev 23601)
@@ -5650,18 +5650,12 @@
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))) {
- 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;
+ if (ldc->euid || ldc->uid) {
+ job_log(j, LOG_WARNING, "Server create attempt moved to per-user launchd: %s", server_cmd);
+ return VPROC_ERR_TRY_PER_USER;
}
- } else
-#endif
- if (getuid()) {
+ } else {
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);
Modified: trunk/launchd/src/libbootstrap.c (23600 => 23601)
--- trunk/launchd/src/libbootstrap.c 2008-04-18 21:41:05 UTC (rev 23600)
+++ trunk/launchd/src/libbootstrap.c 2008-04-21 20:33:29 UTC (rev 23601)
@@ -37,7 +37,20 @@
kern_return_t
bootstrap_create_server(mach_port_t bp, cmd_t server_cmd, uid_t server_uid, boolean_t on_demand, mach_port_t *server_port)
{
- return vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port);
+ kern_return_t kr;
+
+ kr = vproc_mig_create_server(bp, server_cmd, server_uid, on_demand, server_port);
+
+ if (kr == VPROC_ERR_TRY_PER_USER) {
+ mach_port_t puc;
+
+ if (vproc_mig_lookup_per_user_context(bp, 0, &puc) == 0) {
+ kr = vproc_mig_create_server(puc, server_cmd, server_uid, on_demand, server_port);
+ mach_port_deallocate(mach_task_self(), puc);
+ }
+ }
+
+ return kr;
}
kern_return_t