[launchd-changes] [23312] trunk/launchd/src/launchctl.c

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 16 09:54:29 PDT 2007


Revision: 23312
          http://trac.macosforge.org/projects/launchd/changeset/23312
Author:   zarzycki at apple.com
Date:     2007-07-16 09:54:29 -0700 (Mon, 16 Jul 2007)

Log Message:
-----------
<rdar://problem/5334775> launchctl needs to target root boostrap when run as root

Modified Paths:
--------------
    trunk/launchd/src/launchctl.c

Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c	2007-07-16 16:46:32 UTC (rev 23311)
+++ trunk/launchd/src/launchctl.c	2007-07-16 16:54:29 UTC (rev 23312)
@@ -216,8 +216,16 @@
 int
 main(int argc, char *const argv[])
 {
+	int64_t is_managed = 0;
 	char *l;
 
+	if ((getuid() == 0) && (vproc_swap_integer(NULL, VPROC_GSK_IS_MANAGED, NULL, &is_managed) == NULL) && (is_managed == 0)) {
+		mach_port_t root_bs = str2bsport("/");
+		task_set_bootstrap_port(mach_task_self(), root_bs);
+		mach_port_deallocate(mach_task_self(), bootstrap_port);
+		bootstrap_port = root_bs;
+	}
+
 	istty = isatty(STDIN_FILENO);
 
 	argc--, argv++;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070716/ce426401/attachment.html


More information about the launchd-changes mailing list