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

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 26 11:09:11 PST 2009


Revision: 23833
          http://trac.macosforge.org/projects/launchd/changeset/23833
Author:   dsorresso at apple.com
Date:     2009-02-26 11:09:11 -0800 (Thu, 26 Feb 2009)
Log Message:
-----------
More incremental steps.

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

Modified: branches/PR-6564965/launchd/src/launchctl.c
===================================================================
--- branches/PR-6564965/launchd/src/launchctl.c	2009-02-26 04:09:33 UTC (rev 23832)
+++ branches/PR-6564965/launchd/src/launchctl.c	2009-02-26 19:09:11 UTC (rev 23833)
@@ -336,6 +336,16 @@
 		}
 	}
 
+	char *db = NULL;
+	vproc_err_t verr = vproc_swap_string(NULL, VPROC_GSK_JOB_ENABLED_DB, NULL, &db);
+	if( verr ) {
+		fprintf(stderr, "Could not get location of job state database.\n");
+		g_job_enabled_db[0] = 0;
+	} else {
+		strncpy(g_job_enabled_db, db, strlen(db));
+		free(db);
+	}
+	
 	if (NULL == readline) {
 		fprintf(stderr, "missing library: readline\n");
 		exit(EXIT_FAILURE);
@@ -926,12 +936,24 @@
 	case LAUNCH_DATA_DICTIONARY: {
 		launch_data_t label = NULL;
 		if( (label = launch_data_dict_lookup(obj, LAUNCH_JOBKEY_LABEL)) && launch_data_get_type(label) == LAUNCH_DATA_STRING ) {
-			char db_path[PATH_MAX];
+			bool disabled = false;
+			launch_data_t disabled_data = launch_data_dict_lookup(obj, LAUNCH_JOBKEY_DISABLED);
 			
+			if( disabled_data && launch_data_get_type(disabled_data) == LAUNCH_DATA_BOOL ) {
+				disabled = launch_data_get_bool(disabled_data);
+			}
+
+			if( disabled && g_job_enabled_db[0] != 0 ) {
+				char path[PATH_MAX];
+				snprintf(path, sizeof(path), "%s/%s", g_job_enabled_db, launch_data_get_string(label));
+				
+				struct stat sb;
+				r = stat(path, &sb) == -1;
+			}
 		} else {
 			launch_data_dict_iterate(obj, job_disabled_dict_logic, &r);
 		}
-
+				
 		break;
 	}
 	case LAUNCH_DATA_BOOL:

Modified: branches/PR-6564965/launchd/src/launchd.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd.c	2009-02-26 04:09:33 UTC (rev 23832)
+++ branches/PR-6564965/launchd/src/launchd.c	2009-02-26 19:09:11 UTC (rev 23833)
@@ -188,7 +188,7 @@
 			strlcpy(g_username, pwent->pw_name, sizeof(g_username) - 1);
 		}
 		
-		snprintf(g_job_enabled_db, sizeof(g_job_enabled_db), "/var/db/launch_job_state_db/com.apple.launchd.peruser.%u", getuid());
+		snprintf(g_job_enabled_db, sizeof(g_job_enabled_db), LAUNCHD_JOB_STATE_DB_PREFIX "/com.apple.launchd.peruser.%u", getuid());
 		runtime_syslog(LOG_DEBUG, "Per-user launchd for UID %u (%s) has begun.", getuid(), g_username);
 	}
 
@@ -403,7 +403,7 @@
 	launchd_assumes(chdir("/") != -1);
 	launchd_assumes(setlogin("root") != -1);
 	
-	strcpy(g_job_enabled_db, "/var/db/launchd_job_state_db/com.apple.launchd");
+	strcpy(g_job_enabled_db, LAUNCHD_JOB_STATE_DB_PREFIX "/com.apple.launchd");
 	struct stat sb;
 	if( stat(g_job_enabled_db, &sb) == -1 ) {
 		launchd_assumes(mkdir(g_job_enabled_db, S_IRWXO) != -1);

Modified: branches/PR-6564965/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd_core_logic.c	2009-02-26 04:09:33 UTC (rev 23832)
+++ branches/PR-6564965/launchd/src/launchd_core_logic.c	2009-02-26 19:09:11 UTC (rev 23833)
@@ -6860,6 +6860,16 @@
 			
 		launch_data_free(output_obj);
 		break;
+	case VPROC_GSK_JOB_ENABLED_DB:
+		if( !g_job_enabled_db || (g_job_enabled_db && !(output_obj = launch_data_new_string(g_job_enabled_db))) ) {
+			goto out_bad;
+		}
+		packed_size = launch_data_pack(output_obj, (void *)*outval, *outvalCnt, NULL, NULL);
+		if (!job_assumes(j, packed_size != 0)) {
+			goto out_bad;
+		}
+		
+		launch_data_free(output_obj);		
 	case 0:
 		mig_deallocate(*outval, *outvalCnt);
 		*outval = 0;
@@ -7273,7 +7283,7 @@
 			
 			struct stat sb;
 			char pu_db[PATH_MAX];
-			snprintf(pu_db, sizeof(pu_db), "/var/db/launchd_job_state_db/%s", lbuf);
+			snprintf(pu_db, sizeof(pu_db), LAUNCHD_JOB_STATE_DB_PREFIX "/%s", lbuf);
 			
 			if( stat(pu_db, &sb) == -1 && job_assumes(ji, errno == ENOENT) ) {
 				job_assumes(ji, mkdir(pu_db, S_IRWXO) != -1);

Modified: branches/PR-6564965/launchd/src/vproc_priv.h
===================================================================
--- branches/PR-6564965/launchd/src/vproc_priv.h	2009-02-26 04:09:33 UTC (rev 23832)
+++ branches/PR-6564965/launchd/src/vproc_priv.h	2009-02-26 19:09:11 UTC (rev 23833)
@@ -64,6 +64,7 @@
 	VPROC_GSK_SHUTDOWN_DEBUGGING,
 	VPROC_GSK_PERUSER_SUSPEND,
 	VPROC_GSK_PERUSER_RESUME,
+	VPROC_GSK_JOB_ENABLED_DB,
 } vproc_gsk_t;
 
 typedef unsigned int vproc_flags_t;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090226/f824b282/attachment.html>


More information about the launchd-changes mailing list