[launchd-changes] [23839] branches/PR-6564965/launchd/src

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 26 16:28:06 PST 2009


Revision: 23839
          http://trac.macosforge.org/projects/launchd/changeset/23839
Author:   dsorresso at apple.com
Date:     2009-02-26 16:28:06 -0800 (Thu, 26 Feb 2009)
Log Message:
-----------
More progress.

Modified Paths:
--------------
    branches/PR-6564965/launchd/src/launch_internal.h
    branches/PR-6564965/launchd/src/launchctl.c
    branches/PR-6564965/launchd/src/launchd.c
    branches/PR-6564965/launchd/src/launchd.h
    branches/PR-6564965/launchd/src/launchd_core_logic.c
    branches/PR-6564965/launchd/src/libvproc.c

Modified: branches/PR-6564965/launchd/src/launch_internal.h
===================================================================
--- branches/PR-6564965/launchd/src/launch_internal.h	2009-02-26 23:58:22 UTC (rev 23838)
+++ branches/PR-6564965/launchd/src/launch_internal.h	2009-02-27 00:28:06 UTC (rev 23839)
@@ -22,6 +22,8 @@
 
 #pragma GCC visibility push(default)
 
+#define LAUNCHD_JOB_OVERRIDES_DB_PREFIX	"/var/db/launchd_job_overrides"
+
 size_t launch_data_pack(launch_data_t d, void *where, size_t len, int *fd_where, size_t *fdslotsleft);
 launch_data_t launch_data_unpack(void *data, size_t data_size, int *fds, size_t fd_cnt, size_t *data_offset, size_t *fdoffset);
 

Modified: branches/PR-6564965/launchd/src/launchctl.c
===================================================================
--- branches/PR-6564965/launchd/src/launchctl.c	2009-02-26 23:58:22 UTC (rev 23838)
+++ branches/PR-6564965/launchd/src/launchctl.c	2009-02-27 00:28:06 UTC (rev 23839)
@@ -28,6 +28,7 @@
 #include "vproc_priv.h"
 #include "vproc_internal.h"
 #include "bootstrap_priv.h"
+#include "launch_internal.h"
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <CoreFoundation/CFPriv.h>
@@ -2979,7 +2980,7 @@
 	CFTypeRef value = NULL;	
 	do {
 		io_registry_entry_t entry = IORegistryEntryFromPath(kIOMasterPortDefault, "IODeviceTree:/options");
-		if( assumes(entry == IO_OBJECT_NULL) ) {
+		if( assumes(entry != IO_OBJECT_NULL) ) {
 			break;
 		}
 		
@@ -3581,6 +3582,7 @@
 		{ _PATH_TMP, 0, 0, S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO, S_ISUID|S_ISGID, true },
 		{ _PATH_VARTMP, 0, 0, S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO, S_ISUID|S_ISGID, true },
 		{ "/var/folders", 0, 0, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH, S_ISUID | S_ISGID, true },
+		{ LAUNCHD_JOB_OVERRIDES_DB_PREFIX, 0, 0, S_IRWXO, S_IRWXG | S_IRWXU, true }
 	};
 	struct stat sb;
 	size_t i;

Modified: branches/PR-6564965/launchd/src/launchd.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd.c	2009-02-26 23:58:22 UTC (rev 23838)
+++ branches/PR-6564965/launchd/src/launchd.c	2009-02-27 00:28:06 UTC (rev 23839)
@@ -80,6 +80,7 @@
 #include "vproc_priv.h"
 #include "vproc_internal.h"
 #include "launch.h"
+#include "launch_internal.h"
 
 #include "launchd_runtime.h"
 #include "launchd_core_logic.h"
@@ -188,7 +189,7 @@
 			strlcpy(g_username, pwent->pw_name, sizeof(g_username) - 1);
 		}
 		
-		snprintf(g_job_overrides_db_path, sizeof(g_job_overrides_db_path), LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/com.apple.launchd.peruser.%u/overrides.plist", getuid());
+		snprintf(g_job_overrides_db_path, sizeof(g_job_overrides_db_path), LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/com.apple.launchd.peruser.%u.overrides.plist", getuid());
 		runtime_syslog(LOG_DEBUG, "Per-user launchd for UID %u (%s) has begun.", getuid(), g_username);
 	}
 
@@ -403,15 +404,7 @@
 	launchd_assumes(chdir("/") != -1);
 	launchd_assumes(setlogin("root") != -1);
 	
-	struct stat sb;
-	if( stat(LAUNCHD_JOB_OVERRIDES_DB_PREFIX, &sb) == -1 && launchd_assumes(errno == ENOENT) ) {
-		launchd_assumes(mkdir(LAUNCHD_JOB_OVERRIDES_DB_PREFIX, S_IRWXO) != -1);
-	}
-	
-	strcpy(g_job_overrides_db_path, LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/com.apple.launchd/overrides.plist");
-	if( stat(dirname(g_job_overrides_db_path), &sb) == -1 && launchd_assumes(errno == ENOENT) ) {
-		launchd_assumes(mkdir(dirname(g_job_overrides_db_path), S_IRWXO) != -1);
-	}
+	strcpy(g_job_overrides_db_path, LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/com.apple.launchd.overrides.plist");
 }
 
 

Modified: branches/PR-6564965/launchd/src/launchd.h
===================================================================
--- branches/PR-6564965/launchd/src/launchd.h	2009-02-26 23:58:22 UTC (rev 23838)
+++ branches/PR-6564965/launchd/src/launchd.h	2009-02-27 00:28:06 UTC (rev 23839)
@@ -26,8 +26,6 @@
 #include "bootstrap.h"
 #include "launchd_runtime.h"
 
-#define LAUNCHD_JOB_OVERRIDES_DB_PREFIX	"/var/db/launchd_job_overrides"
-
 struct kevent;
 struct conncb;
 

Modified: branches/PR-6564965/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd_core_logic.c	2009-02-26 23:58:22 UTC (rev 23838)
+++ branches/PR-6564965/launchd/src/launchd_core_logic.c	2009-02-27 00:28:06 UTC (rev 23839)
@@ -7283,11 +7283,12 @@
 			
 			struct stat sb;
 			char pu_db[PATH_MAX];
-			snprintf(pu_db, sizeof(pu_db), LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/%s", lbuf);
+			snprintf(pu_db, sizeof(pu_db), LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/%s.overrides.plist", lbuf);
 			
-			if( stat(pu_db, &sb) == -1 && job_assumes(ji, errno == ENOENT) ) {
-				job_assumes(ji, mkdir(pu_db, S_IRWXO) != -1);
-				job_assumes(ji, chown(pu_db, which_user, 0) != -1);
+			if( stat(pu_db, &sb) != -1 ) {
+				if( !job_assumes(ji, sb.st_uid == which_user) || !job_assumes(ji, sb.st_uid == 0) || !job_assumes(ji, sb.st_mode == S_IRWXU) ) {
+					job_assumes(ji, remove(pu_db) != -1);
+				}
 			}
 			
 			if ((ms = machservice_new(ji, lbuf, mp, false)) == NULL) {

Modified: branches/PR-6564965/launchd/src/libvproc.c
===================================================================
--- branches/PR-6564965/launchd/src/libvproc.c	2009-02-26 23:58:22 UTC (rev 23838)
+++ branches/PR-6564965/launchd/src/libvproc.c	2009-02-27 00:28:06 UTC (rev 23839)
@@ -823,21 +823,20 @@
 			/* Once you're in the transaction model, you're in for good. Like the Mafia. */
 			s_cached_transactions_enabled = 1;
 			break;
-		case VPROC_GSK_PERUSER_SUSPEND:
-			{
-				char peruser_label[NAME_MAX];
-				snprintf(peruser_label, NAME_MAX - 1, "com.apple.launchd.peruser.%u", (uid_t)*inval);
+		case VPROC_GSK_PERUSER_SUSPEND: {
+			char peruser_label[NAME_MAX];
+			snprintf(peruser_label, NAME_MAX - 1, "com.apple.launchd.peruser.%u", (uid_t)*inval);
+			
+			vproc_t pu_vp = vprocmgr_lookup_vproc(peruser_label);
+			if( pu_vp ) {
+				int status = 0;
+				kern_return_t kr = vproc_mig_wait2(bootstrap_port, pu_vp->j_port, &status);
+				vproc_release(pu_vp);
 				
-				vproc_t pu_vp = vprocmgr_lookup_vproc(peruser_label);
-				if( pu_vp ) {
-					int status = 0;
-					kern_return_t kr = vproc_mig_wait2(bootstrap_port, pu_vp->j_port, &status);
-					vproc_release(pu_vp);
-					
-					syslog(LOG_DEBUG, "%u's suspended launchd exited with status %i (kr = 0x%x).", (uid_t)*inval, status, kr);
-				}
+				syslog(LOG_DEBUG, "%u's suspended launchd exited with status %i (kr = 0x%x).", (uid_t)*inval, status, kr);
 			}
 			break;
+		}
 		default:
 			break;
 		}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090226/3b3ca8ab/attachment-0001.html>


More information about the launchd-changes mailing list