[92095] trunk/dports/x11/xinit
jeremyhu at macports.org
jeremyhu at macports.org
Wed Apr 18 10:12:54 PDT 2012
Revision: 92095
https://trac.macports.org/changeset/92095
Author: jeremyhu at macports.org
Date: 2012-04-18 10:12:54 -0700 (Wed, 18 Apr 2012)
Log Message:
-----------
xinit: Fix a bug in privileged_startx error handling, and fix privileged_startx on Tiger
Modified Paths:
--------------
trunk/dports/x11/xinit/Portfile
Added Paths:
-----------
trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch
trunk/dports/x11/xinit/files/0002-launchd-Don-t-provide-the-LaunchAgent-on-Tiger.patch
trunk/dports/x11/xinit/files/0003-launchd-Provide-more-verbose-error-reporting-for-lau.patch
trunk/dports/x11/xinit/files/0004-launchd-Load-privileged_startx-properly-on-Tiger.patch
trunk/dports/x11/xinit/files/0005-launchd-Fix-the-destination-of-moved-aside-directori.patch
Removed Paths:
-------------
trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch
Modified: trunk/dports/x11/xinit/Portfile
===================================================================
--- trunk/dports/x11/xinit/Portfile 2012-04-18 17:02:13 UTC (rev 92094)
+++ trunk/dports/x11/xinit/Portfile 2012-04-18 17:12:54 UTC (rev 92095)
@@ -4,7 +4,7 @@
name xinit
version 1.3.2
-revision 2
+revision 3
categories x11
platforms darwin
maintainers jeremyhu openmaintainer
@@ -35,9 +35,18 @@
patchfiles \
disable-launchagent.patch \
- 0001-launchd-privileged_startx-Improved-error-resolution.patch
+ 0001-launchd-privileged_startx-Improved-error-resolution.patch \
+ 0002-launchd-Don-t-provide-the-LaunchAgent-on-Tiger.patch \
+ 0003-launchd-Provide-more-verbose-error-reporting-for-lau.patch \
+ 0004-launchd-Load-privileged_startx-properly-on-Tiger.patch \
+ 0005-launchd-Fix-the-destination-of-moved-aside-directori.patch
+
patch.pre_args -p1
+use_autoreconf yes
+autoreconf.args -fvi
+depends_build-append port:xorg-util-macros
+
configure.args --with-launchd-id-prefix=org.macports
configure.args-append RAWCPP=${configure.cpp}
@@ -56,30 +65,32 @@
post-activate {
system "launchctl load /Library/LaunchDaemons/org.macports.privileged_startx.plist"
- ui_msg "###############################################################################"
- ui_msg "# To choose MacPorts' X11 as the default server, you must install xorg-server,"
- ui_msg "# load the LaunchAgent, logout, and log back in. To load the LaunchAgent,"
- ui_msg "# please execute the following:"
+ if {${os.major} > 9} {
+ ui_msg "###############################################################################"
+ ui_msg "# To choose MacPorts' X11 as the default server, you must install xorg-server,"
+ ui_msg "# load the LaunchAgent, logout, and log back in. To load the LaunchAgent,"
+ ui_msg "# please execute the following:"
- if { ${os.major} < 10 } {
- ui_msg "# sudo launchctl load -w /Library/LaunchAgents/org.macports.startx.plist"
- ui_msg "# "
- ui_msg "# This will be required after every upgrade of the xinit port on Leopard"
- } else {
- ui_msg "# launchctl load -w /Library/LaunchAgents/org.macports.startx.plist"
- ui_msg "# "
- ui_msg "# This will be remembered across port updates on Snow Leopard and later."
- }
+ if { ${os.major} < 10 } {
+ ui_msg "# sudo launchctl load -w /Library/LaunchAgents/org.macports.startx.plist"
+ ui_msg "# "
+ ui_msg "# This will be required after every upgrade of the xinit port on Leopard"
+ } else {
+ ui_msg "# launchctl load -w /Library/LaunchAgents/org.macports.startx.plist"
+ ui_msg "# "
+ ui_msg "# This will be remembered across port updates on Snow Leopard and later."
+ }
- # OS X 10.6.3 was the first version whose native X11 allowed the modern socket naming
- # for better X11 server coexistence, so we require it for installing the LaunchAgent
- if {[vercmp ${os.version} 10.3.0] < 0} {
- ui_msg "# "
- ui_msg "# Note that doing so on your OS version may make the Apple-provided version"
- ui_msg "# fail to launch."
+ # OS X 10.6.3 was the first version whose native X11 allowed the modern socket naming
+ # for better X11 server coexistence, so we require it for installing the LaunchAgent
+ if {[vercmp ${os.version} 10.3.0] < 0} {
+ ui_msg "# "
+ ui_msg "# Note that doing so on your OS version may make the Apple-provided version"
+ ui_msg "# fail to launch."
+ }
+
+ ui_msg "###############################################################################"
}
-
- ui_msg "###############################################################################"
}
pre-deactivate {
Deleted: trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch
===================================================================
--- trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch 2012-04-18 17:02:13 UTC (rev 92094)
+++ trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch 2012-04-18 17:12:54 UTC (rev 92095)
@@ -1,66 +0,0 @@
-From 49dd0d562ce95e8467830eedbd25ffa97ec88f0e Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston <jeremyhu at apple.com>
-Date: Fri, 17 Feb 2012 17:35:26 -0800
-Subject: [PATCH] launchd/privileged_startx: Improved error resolution
-
-Rather than just failing to do anything when directories aren't what we
-want them to be, we now try our best to fix the situation.
-
-Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
----
- launchd/privileged_startx/10-tmpdirs.cpp | 36 +++++++++++++++++++++++++----
- 1 files changed, 31 insertions(+), 5 deletions(-)
- mode change 100755 => 100644 launchd/privileged_startx/10-tmpdirs.cpp
-
-diff --git a/launchd/privileged_startx/10-tmpdirs.cpp b/launchd/privileged_startx/10-tmpdirs.cpp
-old mode 100755
-new mode 100644
-index 8012597..7f2c139
---- xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
-+++ xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
-@@ -36,11 +36,37 @@ else
- MKTEMP=mktemp
- fi
-
-+STAT=/usr/bin/stat
-+
- for dir in /tmp/.ICE-unix /tmp/.X11-unix /tmp/.font-unix ; do
-- XCOMM Use mktemp rather than mkdir to avoid possible security issue
-- XCOMM if $dir exists and is a symlink
-- if ${MKTEMP} -d ${dir} >& /dev/null ; then
-- chmod 1777 $dir
-- chown root:wheel $dir
-+ success=0
-+ for attempt in 1 2 3 4 5 ; do
-+ if [ -h ${dir} ] ; then
-+ echo "Possible man in the middle attack (symlink) detected on ${dir}, removing." >&2
-+ rm ${dir}
-+ fi
-+
-+ check=`${STAT} -f '%#p %u %g' ${dir}`
-+ if [ "${check}" = "041777 0 0" ] ; then
-+ success=1
-+ break
-+ else
-+ echo "Invalid permissions (${check}) found on ${dir}, moving to ${dir}.$$" >&2
-+ mv ${dir} ${dir}.$$
-+ fi
-+
-+ # Use mktemp rather than mkdir to avoid possible security issue
-+ # if $dir exists and is a symlink (ie protect against a race
-+ # against the above check)
-+ if ${MKTEMP} -d ${dir} >& /dev/null ; then
-+ chmod 1777 $dir
-+ chown 0:0 $dir
-+ success=1
-+ break
-+ fi
-+ done
-+
-+ if [ "${success}" -eq 0 ] ; then
-+ echo "Could not successfully create ${dir}" >&2
- fi
- done
---
-1.7.9
-
Added: trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch
===================================================================
--- trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch (rev 0)
+++ trunk/dports/x11/xinit/files/0001-launchd-privileged_startx-Improved-error-resolution.patch 2012-04-18 17:12:54 UTC (rev 92095)
@@ -0,0 +1,66 @@
+From 49cfa8b7253096d24b2ef6a8d0ba32c4bae9ac23 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston <jeremyhu at apple.com>
+Date: Fri, 17 Feb 2012 17:35:26 -0800
+Subject: [PATCH 1/5] launchd/privileged_startx: Improved error resolution
+
+Rather than just failing to do anything when directories aren't what we
+want them to be, we now try our best to fix the situation.
+
+Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
+---
+ launchd/privileged_startx/10-tmpdirs.cpp | 34 ++++++++++++++++++++++++------
+ 1 file changed, 28 insertions(+), 6 deletions(-)
+
+diff --git xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
+index 8012597..f48033d 100755
+--- xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
++++ xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
+@@ -1,5 +1,5 @@
+ XCOMM!/bin/sh
+-XCOMM Copyright (c) 2008 Apple Inc.
++XCOMM Copyright (c) 2008-2012 Apple Inc.
+ XCOMM
+ XCOMM Permission is hereby granted, free of charge, to any person
+ XCOMM obtaining a copy of this software and associated documentation files
+@@ -36,11 +36,33 @@ else
+ MKTEMP=mktemp
+ fi
+
++STAT=/usr/bin/stat
++
+ for dir in /tmp/.ICE-unix /tmp/.X11-unix /tmp/.font-unix ; do
+- XCOMM Use mktemp rather than mkdir to avoid possible security issue
+- XCOMM if $dir exists and is a symlink
+- if ${MKTEMP} -d ${dir} >& /dev/null ; then
+- chmod 1777 $dir
+- chown root:wheel $dir
++ success=0
++ for attempt in 1 2 3 4 5 ; do
++ check=`${STAT} -f '%#p %u %g' ${dir}`
++ if [ "${check}" = "041777 0 0" ] ; then
++ success=1
++ break
++ else
++ saved=$(${MKTEMP} -d /tmp/${dir}-XXXXXXXX)
++ mv ${dir} ${saved}
++ echo "${dir} exists but is insecure. It has been moved into ${saved}"
++ fi
++
++ # Use mktemp rather than mkdir to avoid possible security issue
++ # if $dir exists and is a symlink (ie protect against a race
++ # against the above check)
++ if ${MKTEMP} -d ${dir} >& /dev/null ; then
++ chmod 1777 $dir
++ chown 0:0 $dir
++ success=1
++ break
++ fi
++ done
++
++ if [ "${success}" -eq 0 ] ; then
++ echo "Could not successfully create ${dir}" >&2
+ fi
+ done
+--
+1.7.10
+
Added: trunk/dports/x11/xinit/files/0002-launchd-Don-t-provide-the-LaunchAgent-on-Tiger.patch
===================================================================
--- trunk/dports/x11/xinit/files/0002-launchd-Don-t-provide-the-LaunchAgent-on-Tiger.patch (rev 0)
+++ trunk/dports/x11/xinit/files/0002-launchd-Don-t-provide-the-LaunchAgent-on-Tiger.patch 2012-04-18 17:12:54 UTC (rev 92095)
@@ -0,0 +1,77 @@
+From 2d9bdc819adbe45ec3ffdc72429fd92b7f613601 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston <jeremyhu at apple.com>
+Date: Wed, 18 Apr 2012 09:20:37 -0700
+Subject: [PATCH 2/5] 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 <jeremyhu at apple.com>
+---
+ launchd/Makefile.am | 7 ++++++-
+ launchd/user_startx/launchd_startx.c | 23 +----------------------
+ 2 files changed, 7 insertions(+), 23 deletions(-)
+
+diff --git xinit-1.3.2/launchd/Makefile.am xinit-1.3.2/launchd/Makefile.am
+index f8781ed..0135b7f 100644
+--- xinit-1.3.2/launchd/Makefile.am
++++ xinit-1.3.2/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 xinit-1.3.2/launchd/user_startx/launchd_startx.c xinit-1.3.2/launchd/user_startx/launchd_startx.c
+index f83cd61..67419a4 100644
+--- xinit-1.3.2/launchd/user_startx/launchd_startx.c
++++ xinit-1.3.2/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 <sys/wait.h>
+ #include <string.h>
+ #include <stdlib.h>
+-
+-/* 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 <spawn.h>
+-#else
+-#include <errno.h>
+-#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;
+--
+1.7.10
+
Added: trunk/dports/x11/xinit/files/0003-launchd-Provide-more-verbose-error-reporting-for-lau.patch
===================================================================
--- trunk/dports/x11/xinit/files/0003-launchd-Provide-more-verbose-error-reporting-for-lau.patch (rev 0)
+++ trunk/dports/x11/xinit/files/0003-launchd-Provide-more-verbose-error-reporting-for-lau.patch 2012-04-18 17:12:54 UTC (rev 92095)
@@ -0,0 +1,40 @@
+From 4cd122efcfa47afbe8c2ebeee6d8fd48914839a7 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston <jeremyhu at apple.com>
+Date: Wed, 18 Apr 2012 09:47:33 -0700
+Subject: [PATCH 3/5] launchd: Provide more verbose error reporting for
+ launchd checkin failures
+
+Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
+---
+ launchd/privileged_startx/server.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git xinit-1.3.2/launchd/privileged_startx/server.c xinit-1.3.2/launchd/privileged_startx/server.c
+index cfbb623..a93cae3 100644
+--- xinit-1.3.2/launchd/privileged_startx/server.c
++++ xinit-1.3.2/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);
+ }
+
+--
+1.7.10
+
Added: trunk/dports/x11/xinit/files/0004-launchd-Load-privileged_startx-properly-on-Tiger.patch
===================================================================
--- trunk/dports/x11/xinit/files/0004-launchd-Load-privileged_startx-properly-on-Tiger.patch (rev 0)
+++ trunk/dports/x11/xinit/files/0004-launchd-Load-privileged_startx-properly-on-Tiger.patch 2012-04-18 17:12:54 UTC (rev 92095)
@@ -0,0 +1,30 @@
+From c781653f956043e0ee476d4e95e0ae93b27aff96 Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston <jeremyhu at apple.com>
+Date: Wed, 18 Apr 2012 09:52:18 -0700
+Subject: [PATCH 4/5] launchd: Load privileged_startx properly on Tiger
+
+Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
+---
+ launchd/privileged_startx/privileged_startx.plist.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git xinit-1.3.2/launchd/privileged_startx/privileged_startx.plist.cpp xinit-1.3.2/launchd/privileged_startx/privileged_startx.plist.cpp
+index 533fc32..e23e892 100644
+--- xinit-1.3.2/launchd/privileged_startx/privileged_startx.plist.cpp
++++ xinit-1.3.2/launchd/privileged_startx/privileged_startx.plist.cpp
+@@ -11,8 +11,12 @@
+ <string>SCRIPTDIR</string>
+ </array>
+ #ifdef TIGER_LAUNCHD
++ <key>RunAtLoad</key>
++ <true/>
+ <key>KeepAlive</key>
+ <true/>
++ <key>ServiceIPC</key>
++ <true/>
+ #else
+ <key>MachServices</key>
+ <dict>
+--
+1.7.10
+
Added: trunk/dports/x11/xinit/files/0005-launchd-Fix-the-destination-of-moved-aside-directori.patch
===================================================================
--- trunk/dports/x11/xinit/files/0005-launchd-Fix-the-destination-of-moved-aside-directori.patch (rev 0)
+++ trunk/dports/x11/xinit/files/0005-launchd-Fix-the-destination-of-moved-aside-directori.patch 2012-04-18 17:12:54 UTC (rev 92095)
@@ -0,0 +1,27 @@
+From eda973a32552c916e7e7cce8877674106cbda0cb Mon Sep 17 00:00:00 2001
+From: Jeremy Huddleston <jeremyhu at apple.com>
+Date: Wed, 18 Apr 2012 10:02:07 -0700
+Subject: [PATCH 5/5] launchd: Fix the destination of moved-aside directories
+ in privileged_startx
+
+Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
+---
+ launchd/privileged_startx/10-tmpdirs.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
+index f48033d..7786426 100755
+--- xinit-1.3.2/launchd/privileged_startx/10-tmpdirs.cpp
++++ xinit-1.3.2/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
+--
+1.7.10
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120418/8e2057ae/attachment-0001.html>
More information about the macports-changes
mailing list