Revision
23271
Author
zarzycki@apple.com
Date
2007-06-01 10:54:46 -0700 (Fri, 01 Jun 2007)

Log Message

<rdar://problem/5225292> WWDC: launchd (per-user version) not created for root logins?

Modified Paths

Diff

Modified: trunk/launchd/src/launchd_core_logic.c (23270 => 23271)


--- trunk/launchd/src/launchd_core_logic.c	2007-05-31 20:38:11 UTC (rev 23270)
+++ trunk/launchd/src/launchd_core_logic.c	2007-06-01 17:54:46 UTC (rev 23271)
@@ -5327,9 +5327,27 @@
 		job_t j2;
 
 		if (j->mgr->session_initialized) {
-			job_log(j, LOG_ERR, "Tried to initialize an already setup session!");
-			kr = BOOTSTRAP_NOT_PRIVILEGED;
-			goto out;
+			if (ldc.uid == 0 && getpid() == 1) {
+				if (strcmp(j->mgr->name, VPROCMGR_SESSION_LOGINWINDOW) == 0) {
+					job_t ji, jn;
+
+					LIST_FOREACH_SAFE(ji, &j->mgr->jobs, sle, jn) {
+						if (!ji->anonymous) {
+							job_remove(ji);
+						}
+					}
+				} else if (strcmp(j->mgr->name, VPROCMGR_SESSION_AQUA) == 0) {
+					return 0;
+				} else {
+					job_log(j, LOG_ERR, "Tried to initialize an already setup session!");
+					kr = BOOTSTRAP_NOT_PRIVILEGED;
+					goto out;
+				}
+			} else {
+				job_log(j, LOG_ERR, "Tried to initialize an already setup session!");
+				kr = BOOTSTRAP_NOT_PRIVILEGED;
+				goto out;
+			}
 		}
 
 		jobmgr_log(j->mgr, LOG_DEBUG, "Renaming to: %s", session_type);