[23012] trunk/launchd/src/launchd_core_logic.c
Revision: 23012 http://trac.macosforge.org/projects/launchd/changeset/23012 Author: zarzycki@apple.com Date: 2007-01-18 12:13:26 -0800 (Thu, 18 Jan 2007) Log Message: ----------- <rdar://problem/4927819> Launch agent LimitLoadToSessionType values in array result in incorrect launching of process Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-01-12 22:13:03 UTC (rev 23011) +++ trunk/launchd/src/launchd_core_logic.c 2007-01-18 20:13:26 UTC (rev 23012) @@ -1096,11 +1096,7 @@ } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADFROMHOSTS) == 0) { return; } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE) == 0) { - if (strcmp(value, "Aqua") == 0) { - job_reparent_hack(j, "Aqua"); - } else if (strcmp(value, "LoginWindow") == 0) { - job_reparent_hack(j, "LoginWindow"); - } + job_reparent_hack(j, value); return; } break; @@ -1281,6 +1277,9 @@ void job_import_array(job_t j, const char *key, launch_data_t value) { + size_t i, value_cnt = launch_data_array_get_count(value); + const char *str; + switch (key[0]) { case 'l': case 'L': @@ -1288,16 +1287,23 @@ return; } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADFROMHOSTS) == 0) { return; + } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE) == 0) { + for (i = 0; i < value_cnt; i++) { + str = launch_data_get_string(launch_data_array_get_index(value, i)); + if (job_assumes(j, str != NULL)) { + job_reparent_hack(j, str); + } + } } break; case 'q': case 'Q': if (strcasecmp(key, LAUNCH_JOBKEY_QUEUEDIRECTORIES) == 0) { - size_t i, qd_cnt = launch_data_array_get_count(value); - const char *thepath; - for (i = 0; i < qd_cnt; i++) { - thepath = launch_data_get_string(launch_data_array_get_index(value, i)); - semaphoreitem_new(j, DIR_NOT_EMPTY, thepath); + for (i = 0; i < value_cnt; i++) { + str = launch_data_get_string(launch_data_array_get_index(value, i)); + if (job_assumes(j, str != NULL)) { + semaphoreitem_new(j, DIR_NOT_EMPTY, str); + } } } @@ -1305,11 +1311,11 @@ case 'w': case 'W': if (strcasecmp(key, LAUNCH_JOBKEY_WATCHPATHS) == 0) { - size_t i, wp_cnt = launch_data_array_get_count(value); - const char *thepath; - for (i = 0; i < wp_cnt; i++) { - thepath = launch_data_get_string(launch_data_array_get_index(value, i)); - semaphoreitem_new(j, PATH_CHANGES, thepath); + for (i = 0; i < value_cnt; i++) { + str = launch_data_get_string(launch_data_array_get_index(value, i)); + if (job_assumes(j, str != NULL)) { + semaphoreitem_new(j, PATH_CHANGES, str); + } } } break; @@ -1322,9 +1328,9 @@ case 's': case 'S': if (strcasecmp(key, LAUNCH_JOBKEY_STARTCALENDARINTERVAL) == 0) { - size_t i = 0, ci_cnt = launch_data_array_get_count(value); - for (i = 0; i < ci_cnt; i++) + for (i = 0; i < value_cnt; i++) { calendarinterval_new_from_obj(j, launch_data_array_get_index(value, i)); + } } break; default: @@ -2437,6 +2443,10 @@ tmptm.tm_wday = -1; tmptm.tm_mon = -1; + if (!job_assumes(j, obj != NULL)) { + return false; + } + if (LAUNCH_DATA_DICTIONARY != launch_data_get_type(obj)) { return false; } @@ -4159,8 +4169,12 @@ { jobmgr_t jmi = NULL; + if (strcasecmp(where, "Aqua") != 0 && strcasecmp(where, "LoginWindow") != 0) { + return; + } + SLIST_FOREACH(jmi, &root_jobmgr->submgrs, sle) { - if (strcmp(jmi->name, where) == 0) { + if (strcasecmp(jmi->name, where) == 0) { break; } }
participants (1)
-
source_changes@macosforge.org