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

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 26 19:28:49 PST 2009


Revision: 23846
          http://trac.macosforge.org/projects/launchd/changeset/23846
Author:   dsorresso at apple.com
Date:     2009-02-26 19:28:49 -0800 (Thu, 26 Feb 2009)
Log Message:
-----------
Settled on a directory hierarchy of databases for future expandability. We now have /var/db/launchd.db, with subdirectories for the system and per-user launchd's. In those directories are the override databases, and future databases we might wish to add.

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_core_logic.c

Modified: branches/PR-6564965/launchd/src/launch_internal.h
===================================================================
--- branches/PR-6564965/launchd/src/launch_internal.h	2009-02-27 03:04:10 UTC (rev 23845)
+++ branches/PR-6564965/launchd/src/launch_internal.h	2009-02-27 03:28:49 UTC (rev 23846)
@@ -22,7 +22,7 @@
 
 #pragma GCC visibility push(default)
 
-#define LAUNCHD_JOB_OVERRIDES_DB_PREFIX	"/var/db/launchd_job_overrides"
+#define LAUNCHD_DB_PREFIX "/var/db/launchd.db"
 
 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-27 03:04:10 UTC (rev 23845)
+++ branches/PR-6564965/launchd/src/launchctl.c	2009-02-27 03:28:49 UTC (rev 23846)
@@ -261,7 +261,7 @@
 static bool g_shutdown_debugging = false;
 
 static bool g_job_overrides_db_has_changed = false;
-static CFDictionaryRef g_job_overrides_db = NULL;
+static CFMutableDictionaryRef g_job_overrides_db = NULL;
 char g_job_overrides_db_path[PATH_MAX];
 
 int
@@ -350,7 +350,10 @@
 		strncpy(g_job_overrides_db_path, db, strlen(db));
 		free(db);
 		
-		g_job_overrides_db = (CFDictionaryRef)CreateMyPropertyListFromFile(g_job_overrides_db_path);
+		g_job_overrides_db = (CFMutableDictionaryRef)CreateMyPropertyListFromFile(g_job_overrides_db_path);
+		if( !g_job_overrides_db ) {
+			g_job_overrides_db = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+		}
 	}
 	
 	if (NULL == readline) {
@@ -744,11 +747,15 @@
 	if (editondisk) {
 		if( g_job_overrides_db ) {
 			CFMutableDictionaryRef job = (CFMutableDictionaryRef)CFDictionaryGetValue(g_job_overrides_db, label);
-			if( job && CFTypeCheck(job, CFDictionary) ) {
-				CFDictionarySetValue(job, CFSTR(LAUNCH_JOBKEY_DISABLED), load ? kCFBooleanFalse : kCFBooleanTrue);
-				CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED), load ? kCFBooleanFalse : kCFBooleanTrue);
-				g_job_overrides_db_has_changed = true;
+			if( !job || !CFTypeCheck(job, CFDictionary) ) {
+				job = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+				CFDictionarySetValue(g_job_overrides_db, label, job);
+				CFRelease(job);
 			}
+			
+			CFDictionarySetValue(job, CFSTR(LAUNCH_JOBKEY_DISABLED), load ? kCFBooleanFalse : kCFBooleanTrue);
+			CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED), load ? kCFBooleanFalse : kCFBooleanTrue);
+			g_job_overrides_db_has_changed = true;
 		} else {
 			if (load) {
 				CFDictionaryRemoveValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED));
@@ -3594,7 +3601,8 @@
 		{ _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_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH, S_IWGRP | S_IWOTH, true }
+		{ LAUNCHD_DB_PREFIX, 0, 0, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH, S_IWGRP | S_IWOTH, true },
+		{ LAUNCHD_DB_PREFIX "/com.apple.launchd", 0, 0, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH, S_IWGRP | S_IWOTH, true }
 	};
 	struct stat sb;
 	size_t i;

Modified: branches/PR-6564965/launchd/src/launchd.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd.c	2009-02-27 03:04:10 UTC (rev 23845)
+++ branches/PR-6564965/launchd/src/launchd.c	2009-02-27 03:28:49 UTC (rev 23846)
@@ -189,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_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);
 	}
 
@@ -404,7 +404,7 @@
 	launchd_assumes(chdir("/") != -1);
 	launchd_assumes(setlogin("root") != -1);
 	
-	strcpy(g_job_overrides_db_path, LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/com.apple.launchd.overrides.plist");
+	strcpy(g_job_overrides_db_path, LAUNCHD_DB_PREFIX "/com.apple.launchd/overrides.plist");
 }
 
 

Modified: branches/PR-6564965/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd_core_logic.c	2009-02-27 03:04:10 UTC (rev 23845)
+++ branches/PR-6564965/launchd/src/launchd_core_logic.c	2009-02-27 03:28:49 UTC (rev 23846)
@@ -7284,12 +7284,18 @@
 			
 			struct stat sb;
 			char pu_db[PATH_MAX];
-			snprintf(pu_db, sizeof(pu_db), LAUNCHD_JOB_OVERRIDES_DB_PREFIX "/%s.overrides.plist", lbuf);
+			snprintf(pu_db, sizeof(pu_db), LAUNCHD_DB_PREFIX "/%s", lbuf);
 			
 			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( !job_assumes(ji, sb.st_uid == which_user) ) {
+					job_assumes(ji, chown(pu_db, which_user, 0) != -1);
 				}
+				if( !job_assumes(ji, sb.st_gid == 0) ) {
+					job_assumes(ji, chown(pu_db, which_user, 0) != -1);
+				}
+				if( !job_assumes(ji, sb.st_mode == S_IRWXU) ) {
+					job_assumes(ji, chmod(pu_db, S_IRWXU) != -1);
+				}
 			}
 			
 			if ((ms = machservice_new(ji, lbuf, mp, false)) == NULL) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090226/dd0ff8a0/attachment-0001.html>


More information about the launchd-changes mailing list