From 5f5390886004f785b4338fcff27f287c9aa6cd8c Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Mon, 25 Apr 2011 23:09:03 -0700 Subject: launchd: Enable stdout/stderr redirection to ASL Don't rely on launchd to do our logging for us. Signed-off-by: Jeremy Huddleston Reviewed-by: Daniel A. Steffen --- launchd/privileged_startx/Makefile.am | 1 + launchd/privileged_startx/server.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'launchd/privileged_startx') diff --git a/launchd/privileged_startx/Makefile.am b/launchd/privileged_startx/Makefile.am index 2cf4c82..d0f2322 100644 --- a/launchd/privileged_startx/Makefile.am +++ b/launchd/privileged_startx/Makefile.am @@ -41,6 +41,7 @@ CPP_FILES_FLAGS += -DTIGER_LAUNCHD endif dist_privileged_startx_SOURCES = \ + ../console_redirect.c \ server.c \ client.c \ privileged_startx.c diff --git a/launchd/privileged_startx/server.c b/launchd/privileged_startx/server.c index dfe2c58..d513ec0 100644 --- a/launchd/privileged_startx/server.c +++ b/launchd/privileged_startx/server.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 Apple Inc. +/* Copyright (c) 2008-2011 Apple Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files @@ -77,6 +77,9 @@ struct idle_globals idle_globals; /* Default script dir */ const char *script_dir = SCRIPTDIR; +/* console_redirect.c */ +extern int console_redirect(aslclient aslc, aslmsg amsg, int stdout_level, int stderr_level); + #ifndef LAUNCH_JOBKEY_MACHSERVICES static mach_port_t checkin_or_register(char *bname) { kern_return_t kr; @@ -118,7 +121,10 @@ int server_main(const char *dir) { long idle_timeout = DEFAULT_IDLE_TIMEOUT; #endif - launch_data_t config = NULL, checkin = NULL; + launch_data_t config = NULL, checkin = NULL, label = NULL; + const char *labelstr = "privileged_startx"; + aslclient aslc; + checkin = launch_data_new_string(LAUNCH_KEY_CHECKIN); config = launch_msg(checkin); if (!config || launch_data_get_type(config) == LAUNCH_DATA_ERRNO) { @@ -132,6 +138,14 @@ int server_main(const char *dir) { "script directory set: %s", script_dir); } + label = launch_data_dict_lookup(config, LAUNCH_JOBKEY_LABEL); + if (label) { + labelstr = launch_data_get_string(label); + } + + aslc = asl_open(labelstr, "user", ASL_OPT_NO_DELAY); + (void)console_redirect(aslc, NULL, ASL_LEVEL_INFO, ASL_LEVEL_NOTICE); + #ifdef LAUNCH_JOBKEY_MACHSERVICES launch_data_t tmv; tmv = launch_data_dict_lookup(config, LAUNCH_JOBKEY_TIMEOUT); -- cgit v1.2.3