From 78d181dc74ffb3e67ee0d90780b86e00e03073eb Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Wed, 2 Sep 2009 10:43:25 -0700 Subject: launchd: Added --with-launchd-id-prefix option to set non-standard launchd id prefix (org.x is still default) --- Makefile.am | 8 ++++++-- configure.ac | 6 ++++++ privileged_startx/Makefile.am | 7 +++++-- privileged_startx/org.x.privileged_startx.plist.cpp | 4 ++-- privileged_startx/privileged_startx_types.h | 6 +++++- privileged_startx/server.c | 6 +++++- startx.cpp | 2 +- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 951d51a..a9ae6c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,10 +56,14 @@ CPP_FILES_FLAGS = \ -DXINITDIR=$(XINITDIR) $(PROGCPPDEFS) -DLIBDIR=$(libdir) \ -DSHELL_CMD=$(SHELL_CMD) $(STARTX_COOKIE_FLAGS) \ -D__libexecdir__="$(libexecdir)" \ - -D__bindir__="$(bindir)" + -D__bindir__="$(bindir)" \ + -DLAUNCHD_ID_PREFIX=\"$(launchdidprefix)\" if LAUNCHD -launchagents_PRE = org.x.startx.plist.cpp +$(launchdidprefix).startx.plist.cpp: org.x.startx.plist.cpp + cp $< $@ + +launchagents_PRE = $(launchdidprefix).startx.plist.cpp launchagents_DATA = $(launchagents_PRE:plist.cpp=plist) SUBDIRS = privileged_startx diff --git a/configure.ac b/configure.ac index 7e2fb82..7f354f9 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,9 @@ AC_ARG_WITH(launchagents-dir, AS_HELP_STRING([--with-launchagents-dir=PATH], [ AC_ARG_WITH(launchdaemons-dir, AS_HELP_STRING([--with-launchdaemons-dir=PATH], [Path to launchd's LaunchDaemonss directory (default: /Library/LaunchDaemons)]), [ launchdaemonsdir="${withval}" ], [ launchdaemonsdir="/Library/LaunchDaemons" ]) +AC_ARG_WITH(launchd-id-prefix, AS_HELP_STRING([--with-launchd-id-prefix=PATH], [Prefix to use for launchd identifiers (default: org.x)]), + [ launchdidprefix="${withval}" ], + [ launchdidprefix="org.x" ]) if test "x$LAUNCHD" = "xauto"; then unset LAUNCHD @@ -123,8 +126,11 @@ else launchagentsdir="" launchdaemonsdir="" fi + +AC_DEFINE_UNQUOTED(LAUNCHD_ID_PREFIX, "$launchdidprefix", [Prefix to use for launchd identifiers]) AC_SUBST([launchagentsdir]) AC_SUBST([launchdaemonsdir]) +AC_SUBST([launchdidprefix]) AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = "xyes"]) AM_CONDITIONAL(TIGER_LAUNCHD, [test "x$TIGER_LAUNCHD" = "xyes"]) diff --git a/privileged_startx/Makefile.am b/privileged_startx/Makefile.am index 2d68544..453f6e7 100644 --- a/privileged_startx/Makefile.am +++ b/privileged_startx/Makefile.am @@ -34,7 +34,7 @@ xinitrc_PROGRAMS = privileged_startx privstartx_SCRIPTS = 10-tmpdirs 20-font_cache AM_CPPFLAGS = -DXINITDIR=\"$(xinitrcdir)\" -DSCRIPTDIR=\"$(privstartxdir)\" -DBINDIR=\"$(bindir)\" -CPP_FILES_FLAGS = -DXINITDIR="$(xinitrcdir)" -DSCRIPTDIR="$(privstartxdir)" -DBINDIR="$(bindir)" +CPP_FILES_FLAGS = -DXINITDIR="$(xinitrcdir)" -DSCRIPTDIR="$(privstartxdir)" -DBINDIR="$(bindir)" -DLAUNCHD_ID_PREFIX="$(launchdidprefix)" if TIGER_LAUNCHD CPP_FILES_FLAGS += -DTIGER_LAUNCHD @@ -55,7 +55,10 @@ BUILT_SOURCES = \ privileged_startxServer.h \ privileged_startx.h -launchdaemons_PRE = org.x.privileged_startx.plist.cpp +$(launchdidprefix).privileged_startx.plist.cpp: org.x.privileged_startx.plist.cpp + cp $< $@ + +launchdaemons_PRE = $(launchdidprefix).privileged_startx.plist.cpp launchdaemons_DATA = $(launchdaemons_PRE:plist.cpp=plist) 10-tmpdirs: 10-tmpdirs.cpp Makefile diff --git a/privileged_startx/org.x.privileged_startx.plist.cpp b/privileged_startx/org.x.privileged_startx.plist.cpp index 7400cc4..02e1cce 100644 --- a/privileged_startx/org.x.privileged_startx.plist.cpp +++ b/privileged_startx/org.x.privileged_startx.plist.cpp @@ -3,7 +3,7 @@ Label - org.x.privileged_startx + LAUNCHD_ID_PREFIX.privileged_startx ProgramArguments XINITDIR/privileged_startx @@ -16,7 +16,7 @@ #else MachServices - org.x.privileged_startx + LAUNCHD_ID_PREFIX.privileged_startx TimeOut diff --git a/privileged_startx/privileged_startx_types.h b/privileged_startx/privileged_startx_types.h index fef7195..8928e64 100644 --- a/privileged_startx/privileged_startx_types.h +++ b/privileged_startx/privileged_startx_types.h @@ -1,6 +1,10 @@ #ifndef _PRIV_STARTX_TYPES_H_ #define _PRIV_STARTX_TYPES_H_ -#define BOOTSTRAP_NAME "org.x.privileged_startx" +#ifdef HAVE_CONFIG_H +#include +#endif + +#define BOOTSTRAP_NAME LAUNCHD_ID_PREFIX".privileged_startx" #endif diff --git a/privileged_startx/server.c b/privileged_startx/server.c index 6dd4f2b..ee508db 100644 --- a/privileged_startx/server.c +++ b/privileged_startx/server.c @@ -26,6 +26,10 @@ * prior written authorization. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -153,7 +157,7 @@ int server_main(const char *dir) { mp = launch_data_get_machport(svc); #else - mp = checkin_or_register("org.x.privileged_startx"); + mp = checkin_or_register(LAUNCHD_ID_PREFIX".privileged_startx"); #endif if (mp == MACH_PORT_NULL) { diff --git a/startx.cpp b/startx.cpp index a1adbf5..664f120 100644 --- a/startx.cpp +++ b/startx.cpp @@ -85,7 +85,7 @@ serverargs="" #ifdef __APPLE__ if [ "x$X11_PREFS_DOMAIN" = x ] ; then - X11_PREFS_DOMAIN="org.x.X11" + X11_PREFS_DOMAIN=LAUNCHD_ID_PREFIX".X11" fi XCOMM Initialize defaults (this will cut down on "safe" error messages) -- cgit v1.2.3 From 49b50db0cb1ecc5611a242d12b9ca05b961c91ac Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 3 Sep 2009 19:02:56 -0700 Subject: launchd: Include LAUNCHD_ID_PREFIX in the socket name for reverse lookup to tell which launchd id owns $DISPLAY --- Makefile.am | 2 +- org.x.startx.plist.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index a9ae6c1..ae7ad77 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,7 +57,7 @@ CPP_FILES_FLAGS = \ -DSHELL_CMD=$(SHELL_CMD) $(STARTX_COOKIE_FLAGS) \ -D__libexecdir__="$(libexecdir)" \ -D__bindir__="$(bindir)" \ - -DLAUNCHD_ID_PREFIX=\"$(launchdidprefix)\" + -DLAUNCHD_ID_PREFIX="$(launchdidprefix)" if LAUNCHD $(launchdidprefix).startx.plist.cpp: org.x.startx.plist.cpp diff --git a/org.x.startx.plist.cpp b/org.x.startx.plist.cpp index 4f3ce74..845ce0e 100644 --- a/org.x.startx.plist.cpp +++ b/org.x.startx.plist.cpp @@ -3,14 +3,14 @@ Label - org.x.startx + LAUNCHD_ID_PREFIX.startx ProgramArguments __bindir__/startx Sockets - :0 + LAUNCHD_ID_PREFIX-:0 SecureSocketWithKey DISPLAY -- cgit v1.2.3 From 98c7700d5bff9e61a7f29d8a611edc8a34961e8e Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Fri, 4 Sep 2009 00:36:18 -0700 Subject: launchd: Update the DISPLAY envvar to not have a - ... call me paranoid, but I feel safer without it Also added some extra debugging fluff to distingush between two similar statements. --- org.x.startx.plist.cpp | 2 +- privileged_startx/client.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/org.x.startx.plist.cpp b/org.x.startx.plist.cpp index 845ce0e..bd4c9e9 100644 --- a/org.x.startx.plist.cpp +++ b/org.x.startx.plist.cpp @@ -10,7 +10,7 @@ Sockets - LAUNCHD_ID_PREFIX-:0 + LAUNCHD_ID_PREFIX:0 SecureSocketWithKey DISPLAY diff --git a/privileged_startx/client.c b/privileged_startx/client.c index a33dd02..8e1a771 100644 --- a/privileged_startx/client.c +++ b/privileged_startx/client.c @@ -45,9 +45,9 @@ int client_main(void) { kr = bootstrap_look_up(bootstrap_port, BOOTSTRAP_NAME, &mp); if (kr != KERN_SUCCESS) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - fprintf(stderr, "bootstrap_look_up(): %s\n", bootstrap_strerror(kr)); + fprintf(stderr, "privileged_startx: bootstrap_look_up(%s): %s\n", BOOTSTRAP_NAME, bootstrap_strerror(kr)); #else - fprintf(stderr, "bootstrap_look_up(): %ul\n", (unsigned long)kr); + fprintf(stderr, "privileged_startx: bootstrap_look_up(%s): %ul\n", BOOTSTRAP_NAME, (unsigned long)kr); #endif exit(EXIT_FAILURE); } -- cgit v1.2.3