<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[23012] trunk/launchd/src/launchd_core_logic.c</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/launchd/changeset/23012">23012</a></dd>
<dt>Author</dt> <dd>zarzycki@apple.com</dd>
<dt>Date</dt> <dd>2007-01-18 12:13:26 -0800 (Thu, 18 Jan 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre><rdar://problem/4927819> Launch agent LimitLoadToSessionType values in array result in incorrect launching of process</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunklaunchdsrclaunchd_core_logicc">trunk/launchd/src/launchd_core_logic.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunklaunchdsrclaunchd_core_logicc"></a>
<div class="modfile"><h4>Modified: trunk/launchd/src/launchd_core_logic.c (23011 => 23012)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1096,11 +1096,7 @@
</span><span class="cx">                 } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADFROMHOSTS) == 0) {
</span><span class="cx">                         return;
</span><span class="cx">                 } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE) == 0) {
</span><del>-                        if (strcmp(value, "Aqua") == 0) {
-                                job_reparent_hack(j, "Aqua");
-                        } else if (strcmp(value, "LoginWindow") == 0) {
-                                job_reparent_hack(j, "LoginWindow");
-                        }
</del><ins>+                        job_reparent_hack(j, value);
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="lines">@@ -1281,6 +1277,9 @@
</span><span class="cx"> void
</span><span class="cx"> job_import_array(job_t j, const char *key, launch_data_t value)
</span><span class="cx"> {
</span><ins>+        size_t i, value_cnt = launch_data_array_get_count(value);
+        const char *str;
+
</ins><span class="cx">         switch (key[0]) {
</span><span class="cx">         case 'l':
</span><span class="cx">         case 'L':
</span><span class="lines">@@ -1288,16 +1287,23 @@
</span><span class="cx">                         return;
</span><span class="cx">                 } else if (strcasecmp(key, LAUNCH_JOBKEY_LIMITLOADFROMHOSTS) == 0) {
</span><span class="cx">                         return;
</span><ins>+                } 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);
+                                }
+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case 'q':
</span><span class="cx">         case 'Q':
</span><span class="cx">                 if (strcasecmp(key, LAUNCH_JOBKEY_QUEUEDIRECTORIES) == 0) {
</span><del>-                        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);
</del><ins>+                        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);
+                                }
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="lines">@@ -1305,11 +1311,11 @@
</span><span class="cx">         case 'w':
</span><span class="cx">         case 'W':
</span><span class="cx">                 if (strcasecmp(key, LAUNCH_JOBKEY_WATCHPATHS) == 0) {
</span><del>-                        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);
</del><ins>+                        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);
+                                }
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="lines">@@ -1322,9 +1328,9 @@
</span><span class="cx">         case 's':
</span><span class="cx">         case 'S':
</span><span class="cx">                 if (strcasecmp(key, LAUNCH_JOBKEY_STARTCALENDARINTERVAL) == 0) {
</span><del>-                        size_t i = 0, ci_cnt = launch_data_array_get_count(value);
-                        for (i = 0; i < ci_cnt; i++)
</del><ins>+                        for (i = 0; i < value_cnt; i++) {
</ins><span class="cx">                                 calendarinterval_new_from_obj(j, launch_data_array_get_index(value, i));
</span><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="lines">@@ -2437,6 +2443,10 @@
</span><span class="cx">         tmptm.tm_wday = -1;
</span><span class="cx">         tmptm.tm_mon = -1;
</span><span class="cx">
</span><ins>+        if (!job_assumes(j, obj != NULL)) {
+                return false;
+        }
+
</ins><span class="cx">         if (LAUNCH_DATA_DICTIONARY != launch_data_get_type(obj)) {
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="lines">@@ -4159,8 +4169,12 @@
</span><span class="cx"> {
</span><span class="cx">         jobmgr_t jmi = NULL;
</span><span class="cx">
</span><ins>+        if (strcasecmp(where, "Aqua") != 0 && strcasecmp(where, "LoginWindow") != 0) {
+                return;
+        }
+
</ins><span class="cx">         SLIST_FOREACH(jmi, &root_jobmgr->submgrs, sle) {
</span><del>-                if (strcmp(jmi->name, where) == 0) {
</del><ins>+                if (strcasecmp(jmi->name, where) == 0) {
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
</body>
</html>