[launchd-changes] [23852] trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 2 21:21:25 PST 2009
Revision: 23852
http://trac.macosforge.org/projects/launchd/changeset/23852
Author: dsorresso at apple.com
Date: 2009-03-02 21:21:24 -0800 (Mon, 02 Mar 2009)
Log Message:
-----------
Merged in latest changes from trunk.
Modified Paths:
--------------
trunk/launchd/src/launch_internal.h
trunk/launchd/src/launchctl.c
trunk/launchd/src/launchd.c
trunk/launchd/src/launchd.h
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/libvproc.c
trunk/launchd/src/vproc_priv.h
Property Changed:
----------------
trunk/
trunk/launchd/src/bootstrap.h
trunk/launchd/src/bootstrap_priv.h
trunk/launchd/src/launch.h
trunk/launchd/src/launch_internal.h
trunk/launchd/src/launch_priv.h
trunk/launchd/src/protocol_vproc.defs
trunk/launchd/src/vproc.h
trunk/launchd/src/vproc_internal.h
trunk/launchd/src/vproc_priv.h
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5092682:23731-23742
/branches/PR-5898404:23681-23700
/branches/PR-5978442:23651-23701
/branches/PR-6132016:23719-23738
/branches/PR-6271234:23818-23822
/branches/PR-6562592:23812-23822
/branches/PR-6589133:23810-23822
/branches/PR-6609410:23828
+ /branches/PR-5092682:23731-23742
/branches/PR-5898404:23681-23700
/branches/PR-5978442:23651-23701
/branches/PR-6132016:23719-23738
/branches/PR-6271234:23818-23822
/branches/PR-6562592:23812-23822
/branches/PR-6564965:23832-23851
/branches/PR-6589133:23810-23822
/branches/PR-6609410:23828
Property changes on: trunk/launchd/src/bootstrap.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5898404/launchd/src/libbootstrap_public.h:23681-23700
/branches/PR-5978442/launchd/src/libbootstrap_public.h:23651-23701
/branches/PR-6271234/launchd/src/bootstrap.h:23818-23822
/branches/PR-6562592/launchd/src/bootstrap.h:23812-23822
/branches/PR-6589133/launchd/src/bootstrap.h:23810-23822
/branches/PR-6609410/launchd/src/bootstrap.h:23828
+ /branches/PR-5898404/launchd/src/libbootstrap_public.h:23681-23700
/branches/PR-5978442/launchd/src/libbootstrap_public.h:23651-23701
/branches/PR-6271234/launchd/src/bootstrap.h:23818-23822
/branches/PR-6562592/launchd/src/bootstrap.h:23812-23822
/branches/PR-6564965/launchd/src/bootstrap.h:23832-23851
/branches/PR-6589133/launchd/src/bootstrap.h:23810-23822
/branches/PR-6609410/launchd/src/bootstrap.h:23828
Property changes on: trunk/launchd/src/bootstrap_priv.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5898404/launchd/src/libbootstrap_private.h:23681-23700
/branches/PR-5978442/launchd/src/libbootstrap_private.h:23651-23701
/branches/PR-6271234/launchd/src/bootstrap_priv.h:23818-23822
/branches/PR-6562592/launchd/src/bootstrap_priv.h:23812-23822
/branches/PR-6589133/launchd/src/bootstrap_priv.h:23810-23822
/branches/PR-6609410/launchd/src/bootstrap_priv.h:23828
+ /branches/PR-5898404/launchd/src/libbootstrap_private.h:23681-23700
/branches/PR-5978442/launchd/src/libbootstrap_private.h:23651-23701
/branches/PR-6271234/launchd/src/bootstrap_priv.h:23818-23822
/branches/PR-6562592/launchd/src/bootstrap_priv.h:23812-23822
/branches/PR-6564965/launchd/src/bootstrap_priv.h:23832-23851
/branches/PR-6589133/launchd/src/bootstrap_priv.h:23810-23822
/branches/PR-6609410/launchd/src/bootstrap_priv.h:23828
Property changes on: trunk/launchd/src/launch.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5898404/launchd/src/liblaunch_public.h:23681-23700
/branches/PR-5978442/launchd/src/liblaunch_public.h:23651-23701
/branches/PR-6271234/launchd/src/launch.h:23818-23822
/branches/PR-6562592/launchd/src/launch.h:23812-23822
/branches/PR-6589133/launchd/src/launch.h:23810-23822
/branches/PR-6609410/launchd/src/launch.h:23828
+ /branches/PR-5898404/launchd/src/liblaunch_public.h:23681-23700
/branches/PR-5978442/launchd/src/liblaunch_public.h:23651-23701
/branches/PR-6271234/launchd/src/launch.h:23818-23822
/branches/PR-6562592/launchd/src/launch.h:23812-23822
/branches/PR-6564965/launchd/src/launch.h:23832-23851
/branches/PR-6589133/launchd/src/launch.h:23810-23822
/branches/PR-6609410/launchd/src/launch.h:23828
Modified: trunk/launchd/src/launch_internal.h
===================================================================
--- trunk/launchd/src/launch_internal.h 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/launch_internal.h 2009-03-03 05:21:24 UTC (rev 23852)
@@ -22,6 +22,8 @@
#pragma GCC visibility push(default)
+#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);
Property changes on: trunk/launchd/src/launch_internal.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5898404/launchd/src/liblaunch_internal.h:23681-23700
/branches/PR-5978442/launchd/src/liblaunch_internal.h:23651-23701
/branches/PR-6271234/launchd/src/launch_internal.h:23818-23822
/branches/PR-6562592/launchd/src/launch_internal.h:23812-23822
/branches/PR-6589133/launchd/src/launch_internal.h:23810-23822
/branches/PR-6609410/launchd/src/launch_internal.h:23828
+ /branches/PR-5898404/launchd/src/liblaunch_internal.h:23681-23700
/branches/PR-5978442/launchd/src/liblaunch_internal.h:23651-23701
/branches/PR-6271234/launchd/src/launch_internal.h:23818-23822
/branches/PR-6562592/launchd/src/launch_internal.h:23812-23822
/branches/PR-6564965/launchd/src/launch_internal.h:23832-23851
/branches/PR-6589133/launchd/src/launch_internal.h:23810-23822
/branches/PR-6609410/launchd/src/launch_internal.h:23828
Property changes on: trunk/launchd/src/launch_priv.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5898404/launchd/src/liblaunch_private.h:23681-23700
/branches/PR-5978442/launchd/src/liblaunch_private.h:23651-23701
/branches/PR-6271234/launchd/src/launch_priv.h:23818-23822
/branches/PR-6562592/launchd/src/launch_priv.h:23812-23822
/branches/PR-6589133/launchd/src/launch_priv.h:23810-23822
/branches/PR-6609410/launchd/src/launch_priv.h:23828
+ /branches/PR-5898404/launchd/src/liblaunch_private.h:23681-23700
/branches/PR-5978442/launchd/src/liblaunch_private.h:23651-23701
/branches/PR-6271234/launchd/src/launch_priv.h:23818-23822
/branches/PR-6562592/launchd/src/launch_priv.h:23812-23822
/branches/PR-6564965/launchd/src/launch_priv.h:23832-23851
/branches/PR-6589133/launchd/src/launch_priv.h:23810-23822
/branches/PR-6609410/launchd/src/launch_priv.h:23828
Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/launchctl.c 2009-03-03 05:21:24 UTC (rev 23852)
@@ -28,9 +28,11 @@
#include "vproc_priv.h"
#include "vproc_internal.h"
#include "bootstrap_priv.h"
+#include "launch_internal.h"
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFPriv.h>
+#include <CoreFoundation/CFLogUtilities.h>
#include <TargetConditionals.h>
#if HAVE_SECURITY
#include <Security/Security.h>
@@ -103,6 +105,7 @@
#define assumes(e) \
(__builtin_expect(!(e), 0) ? _log_launchctl_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true)
+#define CFTypeCheck(cf, type) (CFGetTypeID(cf) == type ## GetTypeID())
struct load_unload_state {
launch_data_t pass0;
@@ -113,6 +116,7 @@
};
static void myCFDictionaryApplyFunction(const void *key, const void *value, void *context);
+static void job_override(CFTypeRef key, CFTypeRef val, CFMutableDictionaryRef job);
static CFTypeRef CFTypeCreateFromLaunchData(launch_data_t obj);
static CFArrayRef CFArrayCreateFromLaunchArray(launch_data_t arr);
static CFDictionaryRef CFDictionaryCreateFromLaunchDictionary(launch_data_t dict);
@@ -259,6 +263,16 @@
static bool bootstrapping_peruser;
static bool g_shutdown_debugging = false;
+static bool g_job_overrides_db_has_changed = false;
+static CFMutableDictionaryRef g_job_overrides_db = NULL;
+static char g_job_overrides_db_path[PATH_MAX];
+
+#if 0
+static bool g_job_cache_db_has_changed = false;
+static launch_data_t g_job_cache_db = NULL;
+#endif
+static char g_job_cache_db_path[PATH_MAX];
+
int
main(int argc, char *const argv[])
{
@@ -336,6 +350,32 @@
}
}
+ char *db = NULL;
+ vproc_err_t verr = vproc_swap_string(NULL, VPROC_GSK_JOB_OVERRIDES_DB, NULL, &db);
+ if( verr ) {
+ fprintf(stderr, "Could not get location of job overrides database.\n");
+ g_job_overrides_db_path[0] = 0;
+ } else {
+ strncpy(g_job_overrides_db_path, db, strlen(db));
+ free(db);
+
+ 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);
+ }
+ }
+
+ verr = vproc_swap_string(NULL, VPROC_GSK_JOB_CACHE_DB, NULL, &db);
+ if( verr ) {
+ fprintf(stderr, "Could not get location of job cache database.\n");
+ g_job_cache_db_path[0] = 0;
+ } else {
+ strncpy(g_job_cache_db_path, db, strlen(db));
+ free(db);
+
+ /* Create our launch_data_t from the file... */
+ }
+
if (NULL == readline) {
fprintf(stderr, "missing library: readline\n");
exit(EXIT_FAILURE);
@@ -692,24 +732,58 @@
}
}
+void
+job_override(CFTypeRef key, CFTypeRef val, CFMutableDictionaryRef job)
+{
+ if( !CFTypeCheck(key, CFString) ) {
+ return;
+ }
+ if( CFStringCompare(key, CFSTR(LAUNCH_JOBKEY_LABEL), kCFCompareCaseInsensitive) == 0 ) {
+ return;
+ }
+
+ CFDictionarySetValue(job, key, val);
+}
+
launch_data_t
read_plist_file(const char *file, bool editondisk, bool load)
{
CFPropertyListRef plist = CreateMyPropertyListFromFile(file);
launch_data_t r = NULL;
- if (NULL == plist) {
+ if( NULL == plist ) {
fprintf(stderr, "%s: no plist was returned for: %s\n", getprogname(), file);
return NULL;
}
- if (editondisk) {
- if (load) {
- CFDictionaryRemoveValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED));
+ CFStringRef label = CFDictionaryGetValue(plist, CFSTR(LAUNCH_JOBKEY_LABEL));
+ if( g_job_overrides_db && label && CFTypeCheck(label, CFString) ) {
+ CFDictionaryRef overrides = CFDictionaryGetValue(g_job_overrides_db, label);
+ if( overrides && CFTypeCheck(overrides, CFDictionary) ) {
+ CFDictionaryApplyFunction(overrides, (CFDictionaryApplierFunction)job_override, (void *)plist);
+ }
+ }
+
+ if( editondisk ) {
+ if( g_job_overrides_db ) {
+ CFMutableDictionaryRef job = (CFMutableDictionaryRef)CFDictionaryGetValue(g_job_overrides_db, label);
+ 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 {
- CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED), kCFBooleanTrue);
+ if (load) {
+ CFDictionaryRemoveValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED));
+ } else {
+ CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED), kCFBooleanTrue);
+ }
+ WriteMyPropertyListToFile(plist, file);
}
- WriteMyPropertyListToFile(plist, file);
}
r = CF2launch_data(plist);
@@ -929,18 +1003,18 @@
job_disabled_logic(launch_data_t obj)
{
bool r = false;
-
+
switch (launch_data_get_type(obj)) {
- case LAUNCH_DATA_DICTIONARY:
- launch_data_dict_iterate(obj, job_disabled_dict_logic, &r);
- break;
- case LAUNCH_DATA_BOOL:
- r = launch_data_get_bool(obj);
- break;
- default:
- break;
+ case LAUNCH_DATA_DICTIONARY:
+ launch_data_dict_iterate(obj, job_disabled_dict_logic, &r);
+ break;
+ case LAUNCH_DATA_BOOL:
+ r = launch_data_get_bool(obj);
+ break;
+ default:
+ break;
}
-
+
return r;
}
@@ -1399,7 +1473,7 @@
fprintf(stderr, "%s: CFURLCreateDataAndPropertiesFromResource(%s) failed: %d\n", getprogname(), posixfile, (int)errorCode);
}
- propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resourceData, kCFPropertyListMutableContainers, &errorString);
+ propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resourceData, kCFPropertyListMutableContainersAndLeaves, &errorString);
if (!propertyList) {
fprintf(stderr, "%s: propertyList is NULL\n", getprogname());
}
@@ -2268,6 +2342,10 @@
}
}
+ if( g_job_overrides_db_has_changed ) {
+ WriteMyPropertyListToFile(g_job_overrides_db, g_job_overrides_db_path);
+ }
+
return 0;
}
@@ -2951,7 +3029,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;
}
@@ -3553,6 +3631,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_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: trunk/launchd/src/launchd.c
===================================================================
--- trunk/launchd/src/launchd.c 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/launchd.c 2009-03-03 05:21:24 UTC (rev 23852)
@@ -81,6 +81,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"
@@ -118,6 +119,7 @@
bool network_up;
char g_username[128] = "__Uninitialized__";
char g_my_label[128] = "__Uninitialized__";
+char g_launchd_database_dir[PATH_MAX];
FILE *g_console = NULL;
int
@@ -188,7 +190,7 @@
if( pwent ) {
strlcpy(g_username, pwent->pw_name, sizeof(g_username) - 1);
}
-
+
snprintf(g_my_label, sizeof(g_my_label), "com.apple.launchd.peruser.%u", getuid());
auditinfo_addr_t auinfo;
@@ -198,6 +200,7 @@
}
g_audit_session_port = _audit_session_self();
+ snprintf(g_launchd_database_dir, sizeof(g_launchd_database_dir), LAUNCHD_DB_PREFIX "/com.apple.launchd.peruser.%u", getuid());
runtime_syslog(LOG_DEBUG, "Per-user launchd for UID %u (%s) has begun.", getuid(), g_username);
}
@@ -206,12 +209,8 @@
if( g_use_gmalloc ) {
runtime_syslog(LOG_NOTICE | LOG_CONSOLE, "*** Using libgmalloc ***");
}
-
- struct stat sb;
- if( stat("/var/db/.launchd_flat_per_user_namespace", &sb) == 0 ) {
- runtime_syslog(LOG_NOTICE | LOG_CONSOLE, "Flat per-user Mach namespaces enabled.");
- }
- /* We just wanted to print status about the per-user namespace. PID 1 doesn't have a flat namespace. */
+
+ /* PID 1 doesn't have a flat namespace. */
g_flat_mach_namespace = false;
}
@@ -437,8 +436,36 @@
g_audit_session_port = _audit_session_self();
#endif
+
+ strcpy(g_launchd_database_dir, LAUNCHD_DB_PREFIX "/com.apple.launchd");
}
+char *
+launchd_data_base_path(int db_type)
+{
+ static char result[PATH_MAX];
+ static int last_db_type = -1;
+
+ if( db_type == last_db_type ) {
+ return result;
+ }
+
+ switch( db_type ) {
+ case LAUNCHD_DB_TYPE_OVERRIDES :
+ snprintf(result, sizeof(result), "%s/%s", g_launchd_database_dir, "overrides.plist");
+ last_db_type = db_type;
+ break;
+ case LAUNCHD_DB_TYPE_JOBCACHE :
+ snprintf(result, sizeof(result), "%s/%s", g_launchd_database_dir, "jobcache.launchdata");
+ last_db_type = db_type;
+ break;
+ default :
+ break;
+ }
+
+ return result;
+}
+
int
_fd(int fd)
{
Modified: trunk/launchd/src/launchd.h
===================================================================
--- trunk/launchd/src/launchd.h 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/launchd.h 2009-03-03 05:21:24 UTC (rev 23852)
@@ -35,6 +35,7 @@
extern bool g_force_old_kill_path;
extern bool g_simulate_pid1_crash;
extern FILE *g_console;
+extern char g_launchd_database_dir[PATH_MAX];
bool init_check_pid(pid_t);
@@ -44,6 +45,13 @@
void launchd_single_user(void);
boolean_t launchd_mach_ipc_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);
+enum {
+ LAUNCHD_DB_TYPE_OVERRIDES,
+ LAUNCHD_DB_TYPE_JOBCACHE,
+ LAUNCHD_DB_TYPE_LAST,
+};
+char *launchd_data_base_path(int db_type);
+
void mach_start_shutdown(void);
int _fd(int fd);
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/launchd_core_logic.c 2009-03-03 05:21:24 UTC (rev 23852)
@@ -3255,7 +3255,7 @@
}
if( j->clean_kill ) {
- job_log(j, LOG_DEBUG | LOG_CONSOLE, "Clean job failed to exit %u seconds after receiving SIGKILL.", LAUNCHD_CLEAN_KILL_TIMER);
+ job_log(j, LOG_DEBUG | LOG_CONSOLE, "Clean job failed to exit %u second after receiving SIGKILL.", LAUNCHD_CLEAN_KILL_TIMER);
job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL));
j->clean_exit_timer_expired = true;
@@ -3280,7 +3280,7 @@
uint64_t td = runtime_get_nanoseconds_since(j->sent_signal_time);
td /= NSEC_PER_SEC;
- td -= j->exit_timeout;
+ td -= j->clean_kill ? 0 : j->exit_timeout;
job_log(j, LOG_WARNING | LOG_CONSOLE, "Did not die after sending SIGKILL %llu seconds ago...", td);
} else if( should_enqueue && (!j->exit_timeout || (LAUNCHD_SAMPLE_TIMEOUT < j->exit_timeout)) ) {
@@ -5434,7 +5434,7 @@
continue;
}
- bool active = job_active(ji);
+ bool active = ji->p;
if( active && !ji->stopped ) {
/* If the job is active and we haven't told it to stop yet, stop it. */
job_stop(ji);
@@ -5494,7 +5494,7 @@
continue;
}
- bool active = job_active(ji);
+ bool active = ji->p;
if( active && !ji->stopped ) {
/* If the job is active and we haven't told it to stop yet, stop it. */
job_stop(ji);
@@ -5556,7 +5556,7 @@
continue;
}
- bool active = job_active(ji);
+ bool active = ji->p;
if( active && !ji->stopped ) {
/* If the job is active and we haven't told it to stop yet, stop it. */
job_stop(ji);
@@ -5601,6 +5601,12 @@
jobmgr_do_garbage_collection(jmi);
}
+ if( SLIST_EMPTY(&jm->submgrs) ) {
+ jobmgr_log(jm, LOG_DEBUG, "No submanagers left.");
+ } else {
+ jobmgr_log(jm, LOG_DEBUG, "Still have submanagers.");
+ }
+
jobmgr_t _jm = jobmgr_do_hopefully_first_shutdown_phase(jm);
if( !_jm ) {
_jm = jobmgr_do_normal_shutdown_phase(jm) ? : jobmgr_do_hopefully_last_shutdown_phase(jm);
@@ -6890,6 +6896,28 @@
launch_data_free(output_obj);
break;
+ case VPROC_GSK_JOB_OVERRIDES_DB:
+ if( !job_assumes(j, (output_obj = launch_data_new_string(launchd_data_base_path(LAUNCHD_DB_TYPE_OVERRIDES))) != NULL) ) {
+ 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);
+ break;
+ case VPROC_GSK_JOB_CACHE_DB:
+ if( !job_assumes(j, (output_obj = launch_data_new_string(launchd_data_base_path(LAUNCHD_DB_TYPE_JOBCACHE))) != NULL) ) {
+ 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);
+ break;
case 0:
mig_deallocate(*outval, *outvalCnt);
*outval = 0;
@@ -7098,45 +7126,45 @@
g_shutdown_debugging = true;
}
break;
- case VPROC_GSK_PERUSER_SUSPEND:
- if( pid1_magic && ldc->euid == 0 ) {
- mach_port_t junk = MACH_PORT_NULL;
- job_t jpu = jobmgr_lookup_per_user_context_internal(j, (uid_t)inval, false, &junk);
- if( jpu ) {
- job_t ji = NULL;
- LIST_FOREACH( ji, &j->suspended_perusers, suspended_peruser_sle ) {
- if( (int64_t)(ji->mach_uid) == inval ) {
- job_log(j, LOG_WARNING, "Job tried to suspend per-user launchd for UID %u twice.", ji->mach_uid);
- break;
- }
- }
-
- if( ji == NULL ) {
- jpu->peruser_suspend_count++;
- LIST_INSERT_HEAD(&j->suspended_perusers, jpu, suspended_peruser_sle);
- job_stop(jpu);
- }
- }
- }
- break;
- case VPROC_GSK_PERUSER_RESUME:
- if( pid1_magic && ldc->euid == 0 ) {
- job_t ji = NULL, jt = NULL;
- LIST_FOREACH_SAFE( ji, &j->suspended_perusers, suspended_peruser_sle, jt ) {
+ case VPROC_GSK_PERUSER_SUSPEND:
+ if( pid1_magic && ldc->euid == 0 ) {
+ mach_port_t junk = MACH_PORT_NULL;
+ job_t jpu = jobmgr_lookup_per_user_context_internal(j, (uid_t)inval, false, &junk);
+ if( jpu ) {
+ job_t ji = NULL;
+ LIST_FOREACH( ji, &j->suspended_perusers, suspended_peruser_sle ) {
if( (int64_t)(ji->mach_uid) == inval ) {
- ji->peruser_suspend_count--;
- LIST_REMOVE(ji, suspended_peruser_sle);
+ job_log(j, LOG_WARNING, "Job tried to suspend per-user launchd for UID %u twice.", ji->mach_uid);
break;
}
}
if( ji == NULL ) {
- job_log(j, LOG_WARNING, "Job tried to resume per-user launchd for UID %llu that it did not suspend.", inval);
- } else if( ji->peruser_suspend_count == 0 ) {
- job_dispatch(ji, false);
+ jpu->peruser_suspend_count++;
+ LIST_INSERT_HEAD(&j->suspended_perusers, jpu, suspended_peruser_sle);
+ job_stop(jpu);
}
}
- break;
+ }
+ break;
+ case VPROC_GSK_PERUSER_RESUME:
+ if( pid1_magic && ldc->euid == 0 ) {
+ job_t ji = NULL, jt = NULL;
+ LIST_FOREACH_SAFE( ji, &j->suspended_perusers, suspended_peruser_sle, jt ) {
+ if( (int64_t)(ji->mach_uid) == inval ) {
+ ji->peruser_suspend_count--;
+ LIST_REMOVE(ji, suspended_peruser_sle);
+ break;
+ }
+ }
+
+ if( ji == NULL ) {
+ job_log(j, LOG_WARNING, "Job tried to resume per-user launchd for UID %llu that it did not suspend.", inval);
+ } else if( ji->peruser_suspend_count == 0 ) {
+ job_dispatch(ji, false);
+ }
+ }
+ break;
case 0:
break;
default:
@@ -7309,6 +7337,28 @@
ji->per_user = true;
ji->kill_via_shmem = true;
+ struct stat sb;
+ char pu_db[PATH_MAX];
+ snprintf(pu_db, sizeof(pu_db), LAUNCHD_DB_PREFIX "/%s", lbuf);
+
+ int err = -1;
+ if( (err = stat(pu_db, &sb)) == -1 && job_assumes(ji, errno == ENOENT) ) {
+ job_assumes(ji, mkdir(pu_db, S_IRWXU) != -1);
+ job_assumes(ji, (err = stat(pu_db, &sb)) != -1);
+ }
+
+ if( err != -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) {
job_remove(ji);
ji = NULL;
Modified: trunk/launchd/src/libvproc.c
===================================================================
--- trunk/launchd/src/libvproc.c 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/libvproc.c 2009-03-03 05:21:24 UTC (rev 23852)
@@ -855,21 +855,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;
}
Property changes on: trunk/launchd/src/protocol_vproc.defs
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5092682/launchd/src/protocol_job.defs:23731-23742
/branches/PR-5898404/launchd/src/protocol_job.defs:23681-23700
/branches/PR-5978442/launchd/src/protocol_job.defs:23651-23701
/branches/PR-6132016/launchd/src/protocol_job.defs:23719-23738
/branches/PR-6271234/launchd/src/protocol_vproc.defs:23818-23822
/branches/PR-6562592/launchd/src/protocol_vproc.defs:23812-23822
/branches/PR-6589133/launchd/src/protocol_vproc.defs:23810-23822
/branches/PR-6609410/launchd/src/protocol_vproc.defs:23828
+ /branches/PR-5092682/launchd/src/protocol_job.defs:23731-23742
/branches/PR-5898404/launchd/src/protocol_job.defs:23681-23700
/branches/PR-5978442/launchd/src/protocol_job.defs:23651-23701
/branches/PR-6132016/launchd/src/protocol_job.defs:23719-23738
/branches/PR-6271234/launchd/src/protocol_vproc.defs:23818-23822
/branches/PR-6562592/launchd/src/protocol_vproc.defs:23812-23822
/branches/PR-6564965/launchd/src/protocol_vproc.defs:23832-23851
/branches/PR-6589133/launchd/src/protocol_vproc.defs:23810-23822
/branches/PR-6609410/launchd/src/protocol_vproc.defs:23828
Property changes on: trunk/launchd/src/vproc.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5092682/launchd/src/libvproc_public.h:23731-23742
/branches/PR-5898404/launchd/src/libvproc_public.h:23681-23700
/branches/PR-5978442/launchd/src/libvproc_public.h:23651-23701
/branches/PR-6132016/launchd/src/libvproc_public.h:23719-23738
/branches/PR-6271234/launchd/src/vproc.h:23818-23822
/branches/PR-6562592/launchd/src/vproc.h:23812-23822
/branches/PR-6589133/launchd/src/vproc.h:23810-23822
/branches/PR-6609410/launchd/src/vproc.h:23828
+ /branches/PR-5092682/launchd/src/libvproc_public.h:23731-23742
/branches/PR-5898404/launchd/src/libvproc_public.h:23681-23700
/branches/PR-5978442/launchd/src/libvproc_public.h:23651-23701
/branches/PR-6132016/launchd/src/libvproc_public.h:23719-23738
/branches/PR-6271234/launchd/src/vproc.h:23818-23822
/branches/PR-6562592/launchd/src/vproc.h:23812-23822
/branches/PR-6564965/launchd/src/vproc.h:23832-23851
/branches/PR-6589133/launchd/src/vproc.h:23810-23822
/branches/PR-6609410/launchd/src/vproc.h:23828
Property changes on: trunk/launchd/src/vproc_internal.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5898404/launchd/src/libvproc_internal.h:23681-23700
/branches/PR-5978442/launchd/src/libvproc_internal.h:23651-23701
/branches/PR-6271234/launchd/src/vproc_internal.h:23818-23822
/branches/PR-6562592/launchd/src/vproc_internal.h:23812-23822
/branches/PR-6589133/launchd/src/vproc_internal.h:23810-23822
/branches/PR-6609410/launchd/src/vproc_internal.h:23828
+ /branches/PR-5898404/launchd/src/libvproc_internal.h:23681-23700
/branches/PR-5978442/launchd/src/libvproc_internal.h:23651-23701
/branches/PR-6271234/launchd/src/vproc_internal.h:23818-23822
/branches/PR-6562592/launchd/src/vproc_internal.h:23812-23822
/branches/PR-6564965/launchd/src/vproc_internal.h:23832-23851
/branches/PR-6589133/launchd/src/vproc_internal.h:23810-23822
/branches/PR-6609410/launchd/src/vproc_internal.h:23828
Modified: trunk/launchd/src/vproc_priv.h
===================================================================
--- trunk/launchd/src/vproc_priv.h 2009-03-02 22:45:26 UTC (rev 23851)
+++ trunk/launchd/src/vproc_priv.h 2009-03-03 05:21:24 UTC (rev 23852)
@@ -66,6 +66,8 @@
VPROC_GSK_SHUTDOWN_DEBUGGING,
VPROC_GSK_PERUSER_SUSPEND,
VPROC_GSK_PERUSER_RESUME,
+ VPROC_GSK_JOB_OVERRIDES_DB,
+ VPROC_GSK_JOB_CACHE_DB,
} vproc_gsk_t;
typedef unsigned int vproc_flags_t;
Property changes on: trunk/launchd/src/vproc_priv.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/PR-5092682/launchd/src/libvproc_private.h:23731-23742
/branches/PR-5898404/launchd/src/libvproc_private.h:23681-23700
/branches/PR-5978442/launchd/src/libvproc_private.h:23651-23701
/branches/PR-6132016/launchd/src/libvproc_private.h:23719-23738
/branches/PR-6271234/launchd/src/vproc_priv.h:23818-23822
/branches/PR-6562592/launchd/src/vproc_priv.h:23812-23822
/branches/PR-6589133/launchd/src/vproc_priv.h:23810-23822
/branches/PR-6609410/launchd/src/vproc_priv.h:23828
+ /branches/PR-5092682/launchd/src/libvproc_private.h:23731-23742
/branches/PR-5898404/launchd/src/libvproc_private.h:23681-23700
/branches/PR-5978442/launchd/src/libvproc_private.h:23651-23701
/branches/PR-6132016/launchd/src/libvproc_private.h:23719-23738
/branches/PR-6271234/launchd/src/vproc_priv.h:23818-23822
/branches/PR-6562592/launchd/src/vproc_priv.h:23812-23822
/branches/PR-6564965/launchd/src/vproc_priv.h:23832-23851
/branches/PR-6589133/launchd/src/vproc_priv.h:23810-23822
/branches/PR-6609410/launchd/src/vproc_priv.h:23828
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090302/e69400e1/attachment-0001.html>
More information about the launchd-changes
mailing list