From 2d9bdc819adbe45ec3ffdc72429fd92b7f613601 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 18 Apr 2012 09:20:37 -0700 Subject: launchd: Don't provide the LaunchAgent on Tiger Tiger's launchd doesn't support all the features we need from it. Signed-off-by: Jeremy Huddleston --- launchd/Makefile.am | 7 ++++++- launchd/user_startx/launchd_startx.c | 23 +---------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/launchd/Makefile.am b/launchd/Makefile.am index f8781ed..0135b7f 100644 --- a/launchd/Makefile.am +++ b/launchd/Makefile.am @@ -1,3 +1,8 @@ -SUBDIRS = privileged_startx user_startx +DIST_SUBDIRS = privileged_startx user_startx +SUBDIRS = privileged_startx + +if !TIGER_LAUNCHD +SUBDIRS += user_startx +endif EXTRA_DIST = console_redirect.h diff --git a/launchd/user_startx/launchd_startx.c b/launchd/user_startx/launchd_startx.c index f83cd61..67419a4 100644 --- a/launchd/user_startx/launchd_startx.c +++ b/launchd/user_startx/launchd_startx.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Apple Inc. +/* Copyright (c) 2011-2012 Apple Inc. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files @@ -37,15 +37,7 @@ #include #include #include - -/* Using MIN_REQUIRED instead of MAX_ALLOWED logic due to posix_spawn not - * being marked with availability macros until 10.7 - */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 #include -#else -#include -#endif #include "console_redirect.h" @@ -64,20 +56,7 @@ int main(int argc, char **argv, char **envp) { xi_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO); xi_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO); -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 assert(posix_spawnp(&child, argv[1], NULL, NULL, &argv[1], envp) == 0); -#else - switch(child = fork()) { - case -1: - perror("fork"); - return errno; - case 0: - return execvp(argv[1], &argv[1]); - default: - break; - } -#endif - wait4(child, &pstat, 0, (struct rusage *)0); return pstat; -- cgit v1.2.3 From 4cd122efcfa47afbe8c2ebeee6d8fd48914839a7 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 18 Apr 2012 09:47:33 -0700 Subject: launchd: Provide more verbose error reporting for launchd checkin failures Signed-off-by: Jeremy Huddleston --- launchd/privileged_startx/server.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/launchd/privileged_startx/server.c b/launchd/privileged_startx/server.c index cfbb623..a93cae3 100644 --- a/launchd/privileged_startx/server.c +++ b/launchd/privileged_startx/server.c @@ -125,9 +125,19 @@ int server_main(const char *dir) { aslclient aslc; checkin = launch_data_new_string(LAUNCH_KEY_CHECKIN); + if (!checkin) { + asl_log(NULL, NULL, ASL_LEVEL_ERR, "unable to create launchd checkin string"); + exit(EXIT_FAILURE); + } + config = launch_msg(checkin); - if (!config || launch_data_get_type(config) == LAUNCH_DATA_ERRNO) { - asl_log(NULL, NULL, ASL_LEVEL_ERR, "launchd checkin failed"); + if (!config) { + asl_log(NULL, NULL, ASL_LEVEL_ERR, "could not send a message to launchd"); + exit(EXIT_FAILURE); + } + + if (launch_data_get_type(config) == LAUNCH_DATA_ERRNO) { + asl_log(NULL, NULL, ASL_LEVEL_ERR, "launchd checkin failed eith error: %d %s", launch_data_get_errno(config), strerror(launch_data_get_errno(config))); exit(EXIT_FAILURE); } -- cgit v1.2.3 From c781653f956043e0ee476d4e95e0ae93b27aff96 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 18 Apr 2012 09:52:18 -0700 Subject: launchd: Load privileged_startx properly on Tiger Signed-off-by: Jeremy Huddleston --- launchd/privileged_startx/privileged_startx.plist.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/launchd/privileged_startx/privileged_startx.plist.cpp b/launchd/privileged_startx/privileged_startx.plist.cpp index 533fc32..e23e892 100644 --- a/launchd/privileged_startx/privileged_startx.plist.cpp +++ b/launchd/privileged_startx/privileged_startx.plist.cpp @@ -11,8 +11,12 @@ SCRIPTDIR #ifdef TIGER_LAUNCHD + RunAtLoad + KeepAlive + ServiceIPC + #else MachServices -- cgit v1.2.3 From eda973a32552c916e7e7cce8877674106cbda0cb Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 18 Apr 2012 10:02:07 -0700 Subject: launchd: Fix the destination of moved-aside directories in privileged_startx Signed-off-by: Jeremy Huddleston --- launchd/privileged_startx/10-tmpdirs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launchd/privileged_startx/10-tmpdirs.cpp b/launchd/privileged_startx/10-tmpdirs.cpp index f48033d..7786426 100755 --- a/launchd/privileged_startx/10-tmpdirs.cpp +++ b/launchd/privileged_startx/10-tmpdirs.cpp @@ -46,7 +46,7 @@ for dir in /tmp/.ICE-unix /tmp/.X11-unix /tmp/.font-unix ; do success=1 break else - saved=$(${MKTEMP} -d /tmp/${dir}-XXXXXXXX) + saved=$(${MKTEMP} -d ${dir}-XXXXXXXX) mv ${dir} ${saved} echo "${dir} exists but is insecure. It has been moved into ${saved}" fi -- cgit v1.2.3