xserver: Branch 'master' - 3 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 2 21:12:50 UTC 2021
hw/xquartz/X11Application.m | 3
hw/xquartz/bundle/mk_bundke.sh | 2
hw/xquartz/mach-startup/Makefile.am | 14 +---
hw/xquartz/mach-startup/bundle_trampoline.c | 87 ++++++++++++++++++++++++++++
hw/xquartz/mach-startup/meson.build | 4 -
5 files changed, 94 insertions(+), 16 deletions(-)
New commits:
commit 9d329a0fb17c1a7840408d329ee2e2a04d357387
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date: Sun Feb 21 21:49:58 2021 -0800
xquartz: Remove a check for NSAppKitVersionNumber >= NSAppKitVersionNumber10_7
This check is always true on our supported systems.
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8b9b1f104..c0ec8ddb5 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1541,8 +1541,7 @@ handle_mouse:
}
#endif
- if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_7 &&
- XQuartzScrollInDeviceDirection &&
+ if (XQuartzScrollInDeviceDirection &&
[e isDirectionInvertedFromDevice]) {
deltaX *= -1;
deltaY *= -1;
commit 839b49ac05c3285434d8487b48d8b52323187e44
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date: Sun Feb 21 21:49:14 2021 -0800
xquartz: Don't include strndup.c any more since we no longer support 10.8 and older
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 62f85f16a..e250b2869 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -15,13 +15,6 @@ dist_X11_bin_SOURCES = \
dist_X11_SOURCES = \
bundle_trampoline.c
-# strndup(3) was added in Mac OS X 10.7, but we do this unconditionally to deal
-# with the case where we build on Lion but target Snow Leopard as the minimum
-# OS version.
-#if NEED_STRNDUP
-dist_X11_bin_SOURCES += $(top_srcdir)/os/strndup.c
-#endif
-
nodist_X11_bin_SOURCES = \
mach_startupServer.c \
mach_startupUser.c
diff --git a/hw/xquartz/mach-startup/meson.build b/hw/xquartz/mach-startup/meson.build
index 1d5318441..a1c782b1f 100644
--- a/hw/xquartz/mach-startup/meson.build
+++ b/hw/xquartz/mach-startup/meson.build
@@ -58,10 +58,6 @@ endif
x11_bin = executable('X11.bin',
[
'bundle-main.c',
- # strndup(3) was added in Mac OS X 10.7 (Lion), but we do this
- # unconditionally to deal with the case where we build on 10.7 or later,
- # but target 10.6 (Snow Leopard) or earlier as the minimum OS version.
- '../../../os/strndup.c',
mach_startup[1], # mach_startupServer.c
mach_startup[3], # mach_startupUser.c
],
commit 677eb6827bd68bdf29e3539d1e10e9872896efec
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date: Sun Feb 21 20:58:42 2021 -0800
xquartz: Add a launch trampoline to better integrate with modern versions of macOS
Fixes: https://github.com/XQuartz/XQuartz/issues/6
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
diff --git a/hw/xquartz/bundle/mk_bundke.sh b/hw/xquartz/bundle/mk_bundke.sh
index 971d7b6ce..f83b4da82 100755
--- a/hw/xquartz/bundle/mk_bundke.sh
+++ b/hw/xquartz/bundle/mk_bundke.sh
@@ -24,7 +24,7 @@ install -m 644 ${BUILDDIR}/Info.plist ${BUNDLE_ROOT}/Contents
install -m 644 ${SRCDIR}/PkgInfo ${BUNDLE_ROOT}/Contents
mkdir -p ${BUNDLE_ROOT}/Contents/MacOS
-install -m 755 ${SRCDIR}/X11.sh ${BUNDLE_ROOT}/Contents/MacOS/X11
+install -m 755 ${SRCDIR}/X11.sh ${BUNDLE_ROOT}/Contents/MacOS
if [[ $(id -u) == 0 ]] ; then
chown -R root:admin ${BUNDLE_ROOT}
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 59696f8bb..62f85f16a 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -7,10 +7,13 @@ AM_CPPFLAGS = \
AM_CFLAGS = $(DIX_CFLAGS)
x11appdir = $(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/MacOS
-x11app_PROGRAMS = X11.bin
+x11app_PROGRAMS = X11.bin X11
dist_X11_bin_SOURCES = \
- bundle-main.c
+ bundle-main.c
+
+dist_X11_SOURCES = \
+ bundle_trampoline.c
# strndup(3) was added in Mac OS X 10.7, but we do this unconditionally to deal
# with the case where we build on Lion but target Snow Leopard as the minimum
diff --git a/hw/xquartz/mach-startup/bundle_trampoline.c b/hw/xquartz/mach-startup/bundle_trampoline.c
new file mode 100644
index 000000000..f8611269b
--- /dev/null
+++ b/hw/xquartz/mach-startup/bundle_trampoline.c
@@ -0,0 +1,87 @@
+/* Copyright (c) 2021 Apple Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+ * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
+
+#include <assert.h>
+#include <mach-o/dyld.h>
+#include <libgen.h>
+#include <spawn.h>
+#include <sys/syslimits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* We wnt XQuartz.app to inherit a login shell environment. This is handled by the X11.sh
+ * script which re-execs the main binary from a login shell environment. However, recent
+ * versions of macOS require that the main executable of an app be Mach-O for full system
+ * fidelity.
+ *
+ * Failure to do so results in two problems:
+ * 1) bash is seen as the responsible executable for Security & Privacy, and the user doesn't
+ * get prompted to allow filesystem access (https://github.com/XQuartz/XQuartz/issues/6).
+ * 2) The process is launched under Rosetta for compatability, which results in
+ * the subsequent spawn of the real executable under Rosetta rather than natively.
+ *
+ * This trampoline provides the mach-o needed by LaunchServices and TCC to satisfy those
+ * needs and simply execs the startup script which then execs the main binary.
+ */
+
+static char *executable_path() {
+ uint32_t bufsize = PATH_MAX;
+ char *buf = calloc(1, bufsize);
+
+ if (_NSGetExecutablePath(buf, &bufsize) == -1) {
+ free(buf);
+ buf = calloc(1, bufsize);
+ assert(_NSGetExecutablePath(buf, &bufsize) == 0);
+ }
+
+ return buf;
+}
+
+int main(int argc, char **argv, char **envp) {
+ char const * const executable_directory = dirname(executable_path());
+ char *executable = NULL;
+
+ asprintf(&executable, "%s/X11.sh", executable_directory);
+ if (access(executable, X_OK) == -1) {
+ free(executable);
+ asprintf(&executable, "%s/X11", executable_directory);
+ }
+ assert(access(executable, X_OK) == 0);
+
+ argv[0] = executable;
+
+ posix_spawnattr_t attr;
+ assert(posix_spawnattr_init(&attr) == 0);
+ assert(posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETEXEC) == 0);
+
+ pid_t child_pid;
+ assert(posix_spawn(&child_pid, executable, NULL, &attr, argv, envp) == 0);
+
+ return EXIT_FAILURE;
+}
More information about the xorg-commit
mailing list