From 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 Mon Sep 17 00:00:00 2001 From: marha Date: Sat, 25 Jul 2009 19:39:46 +0000 Subject: Added xorg-server-1.6.2.tar.gz --- xorg-server/hw/xquartz/mach-startup/Makefile.am | 74 ++ xorg-server/hw/xquartz/mach-startup/Makefile.in | 754 +++++++++++++++++++++ xorg-server/hw/xquartz/mach-startup/bundle-main.c | 581 ++++++++++++++++ xorg-server/hw/xquartz/mach-startup/launchd_fd.c | 82 +++ xorg-server/hw/xquartz/mach-startup/launchd_fd.h | 36 + .../hw/xquartz/mach-startup/mach_startup.defs | 50 ++ .../hw/xquartz/mach-startup/mach_startup_types.h | 9 + xorg-server/hw/xquartz/mach-startup/stub.c | 345 ++++++++++ 8 files changed, 1931 insertions(+) create mode 100644 xorg-server/hw/xquartz/mach-startup/Makefile.am create mode 100644 xorg-server/hw/xquartz/mach-startup/Makefile.in create mode 100644 xorg-server/hw/xquartz/mach-startup/bundle-main.c create mode 100644 xorg-server/hw/xquartz/mach-startup/launchd_fd.c create mode 100644 xorg-server/hw/xquartz/mach-startup/launchd_fd.h create mode 100644 xorg-server/hw/xquartz/mach-startup/mach_startup.defs create mode 100644 xorg-server/hw/xquartz/mach-startup/mach_startup_types.h create mode 100644 xorg-server/hw/xquartz/mach-startup/stub.c (limited to 'xorg-server/hw/xquartz/mach-startup') diff --git a/xorg-server/hw/xquartz/mach-startup/Makefile.am b/xorg-server/hw/xquartz/mach-startup/Makefile.am new file mode 100644 index 000000000..b0112949d --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/Makefile.am @@ -0,0 +1,74 @@ +AM_CPPFLAGS = \ + -DBUILD_DATE=\"$(BUILD_DATE)\" \ + -DXSERVER_VERSION=\"$(VERSION)\" \ + -DX11BINDIR=\"$(bindir)\" + +x11appdir = $(APPLE_APPLICATIONS_DIR)/X11.app/Contents/MacOS +x11app_PROGRAMS = X11.bin + +dist_X11_bin_SOURCES = \ + bundle-main.c + +nodist_X11_bin_SOURCES = \ + mach_startupServer.c \ + mach_startupUser.c + +X11_bin_LDADD = \ + $(top_builddir)/hw/xquartz/libXquartz.la \ + $(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \ + $(top_builddir)/dix/dixfonts.lo \ + $(top_builddir)/miext/rootless/librootless.la \ + $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \ + $(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin + +X11_bin_LDFLAGS = \ + -XCClinker -Objc \ + -Wl,-u,_miDCInitialize \ + -Wl,-framework,Carbon \ + -Wl,-framework,Cocoa \ + -Wl,-framework,CoreAudio \ + -Wl,-framework,IOKit + +if GLX +X11_bin_LDADD += \ + $(top_builddir)/hw/xquartz/GL/libCGLCore.la \ + $(top_builddir)/glx/libglx.la + +X11_bin_LDFLAGS += \ + -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \ + -Wl,-framework,OpenGL +endif + +if RECORD +X11_bin_LDADD += \ + $(top_builddir)/record/librecord.la +endif + +bin_PROGRAMS = Xquartz + +dist_Xquartz_SOURCES = \ + stub.c \ + launchd_fd.c + +nodist_Xquartz_SOURCES = \ + mach_startupUser.c + +Xquartz_LDFLAGS = \ + -Wl,-framework,CoreServices + +BUILT_SOURCES = \ + mach_startupServer.c \ + mach_startupUser.c \ + mach_startupServer.h \ + mach_startup.h + +CLEANFILES = \ + $(BUILT_SOURCES) + +$(BUILT_SOURCES): $(srcdir)/mach_startup.defs + mig -sheader mach_startupServer.h $(srcdir)/mach_startup.defs + +EXTRA_DIST = \ + launchd_fd.h \ + mach_startup.defs \ + mach_startup_types.h diff --git a/xorg-server/hw/xquartz/mach-startup/Makefile.in b/xorg-server/hw/xquartz/mach-startup/Makefile.in new file mode 100644 index 000000000..fbdedad9b --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/Makefile.in @@ -0,0 +1,754 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +x11app_PROGRAMS = X11.bin$(EXEEXT) +@GLX_TRUE@am__append_1 = \ +@GLX_TRUE@ $(top_builddir)/hw/xquartz/GL/libCGLCore.la \ +@GLX_TRUE@ $(top_builddir)/glx/libglx.la + +@GLX_TRUE@am__append_2 = \ +@GLX_TRUE@ -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \ +@GLX_TRUE@ -Wl,-framework,OpenGL + +@RECORD_TRUE@am__append_3 = \ +@RECORD_TRUE@ $(top_builddir)/record/librecord.la + +bin_PROGRAMS = Xquartz$(EXEEXT) +subdir = hw/xquartz/mach-startup +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(x11appdir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +x11appPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) $(x11app_PROGRAMS) +dist_X11_bin_OBJECTS = bundle-main.$(OBJEXT) +nodist_X11_bin_OBJECTS = mach_startupServer.$(OBJEXT) \ + mach_startupUser.$(OBJEXT) +X11_bin_OBJECTS = $(dist_X11_bin_OBJECTS) $(nodist_X11_bin_OBJECTS) +am__DEPENDENCIES_1 = +X11_bin_DEPENDENCIES = $(top_builddir)/hw/xquartz/libXquartz.la \ + $(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \ + $(top_builddir)/dix/dixfonts.lo \ + $(top_builddir)/miext/rootless/librootless.la \ + $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__append_1) $(am__append_3) +X11_bin_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(X11_bin_LDFLAGS) \ + $(LDFLAGS) -o $@ +dist_Xquartz_OBJECTS = stub.$(OBJEXT) launchd_fd.$(OBJEXT) +nodist_Xquartz_OBJECTS = mach_startupUser.$(OBJEXT) +Xquartz_OBJECTS = $(dist_Xquartz_OBJECTS) $(nodist_Xquartz_OBJECTS) +Xquartz_LDADD = $(LDADD) +Xquartz_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xquartz_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(dist_X11_bin_SOURCES) $(nodist_X11_bin_SOURCES) \ + $(dist_Xquartz_SOURCES) $(nodist_Xquartz_SOURCES) +DIST_SOURCES = $(dist_X11_bin_SOURCES) $(dist_Xquartz_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APPLE_APPLICATION_ID = @APPLE_APPLICATION_ID@ +APPLE_APPLICATION_NAME = @APPLE_APPLICATION_NAME@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DOLT_BASH = @DOLT_BASH@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTCOMPILE = @LTCOMPILE@ +LTCXXCOMPILE = @LTCXXCOMPILE@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@ +XPBPROXY_LIBS = @XPBPROXY_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = \ + -DBUILD_DATE=\"$(BUILD_DATE)\" \ + -DXSERVER_VERSION=\"$(VERSION)\" \ + -DX11BINDIR=\"$(bindir)\" + +x11appdir = $(APPLE_APPLICATIONS_DIR)/X11.app/Contents/MacOS +dist_X11_bin_SOURCES = \ + bundle-main.c + +nodist_X11_bin_SOURCES = \ + mach_startupServer.c \ + mach_startupUser.c + +X11_bin_LDADD = $(top_builddir)/hw/xquartz/libXquartz.la \ + $(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \ + $(top_builddir)/dix/dixfonts.lo \ + $(top_builddir)/miext/rootless/librootless.la \ + $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \ + $(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin \ + $(am__append_1) $(am__append_3) +X11_bin_LDFLAGS = -XCClinker -Objc -Wl,-u,_miDCInitialize \ + -Wl,-framework,Carbon -Wl,-framework,Cocoa \ + -Wl,-framework,CoreAudio -Wl,-framework,IOKit $(am__append_2) +dist_Xquartz_SOURCES = \ + stub.c \ + launchd_fd.c + +nodist_Xquartz_SOURCES = \ + mach_startupUser.c + +Xquartz_LDFLAGS = \ + -Wl,-framework,CoreServices + +BUILT_SOURCES = \ + mach_startupServer.c \ + mach_startupUser.c \ + mach_startupServer.h \ + mach_startup.h + +CLEANFILES = \ + $(BUILT_SOURCES) + +EXTRA_DIST = \ + launchd_fd.h \ + mach_startup.defs \ + mach_startup_types.h + +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xquartz/mach-startup/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xquartz/mach-startup/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +install-x11appPROGRAMS: $(x11app_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(x11appdir)" || $(MKDIR_P) "$(DESTDIR)$(x11appdir)" + @list='$(x11app_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(x11appPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(x11appdir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(x11appPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(x11appdir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-x11appPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(x11app_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(x11appdir)/$$f'"; \ + rm -f "$(DESTDIR)$(x11appdir)/$$f"; \ + done + +clean-x11appPROGRAMS: + @list='$(x11app_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +X11.bin$(EXEEXT): $(X11_bin_OBJECTS) $(X11_bin_DEPENDENCIES) + @rm -f X11.bin$(EXEEXT) + $(X11_bin_LINK) $(X11_bin_OBJECTS) $(X11_bin_LDADD) $(LIBS) +Xquartz$(EXEEXT): $(Xquartz_OBJECTS) $(Xquartz_DEPENDENCIES) + @rm -f Xquartz$(EXEEXT) + $(Xquartz_LINK) $(Xquartz_OBJECTS) $(Xquartz_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bundle-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd_fd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mach_startupServer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mach_startupUser.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stub.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(x11appdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-x11appPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-x11appPROGRAMS + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-x11appPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool clean-x11appPROGRAMS ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + install-x11appPROGRAMS installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-x11appPROGRAMS + + +$(BUILT_SOURCES): $(srcdir)/mach_startup.defs + mig -sheader mach_startupServer.h $(srcdir)/mach_startup.defs +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c new file mode 100644 index 000000000..fd70f26ed --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c @@ -0,0 +1,581 @@ +/* main.c -- X application launcher + + Copyright (c) 2007 Jeremy Huddleston + Copyright (c) 2007 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include "mach_startup.h" +#include "mach_startupServer.h" + +#include "launchd_fd.h" +/* From darwinEvents.c ... but don't want to pull in all the server cruft */ +void DarwinListenOnOpenFD(int fd); + +extern int noPanoramiXExtension; + +extern int xquartz_resetenv_display; + +#define DEFAULT_CLIENT X11BINDIR "/xterm" +#define DEFAULT_STARTX X11BINDIR "/startx" +#define DEFAULT_SHELL "/bin/sh" + +#ifndef BUILD_DATE +#define BUILD_DATE "" +#endif +#ifndef XSERVER_VERSION +#define XSERVER_VERSION "?" +#endif + +const int __crashreporter_info__len = 4096; +const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE; +char __crashreporter_info__buf[4096]; +char *__crashreporter_info__ = __crashreporter_info__buf; + +static char *server_bootstrap_name = "org.x.X11"; + +#define DEBUG 1 + +/* This is in quartzStartup.c */ +int server_main(int argc, char **argv, char **envp); + +static int execute(const char *command); +static char *command_from_prefs(const char *key, const char *default_value); + +/*** Pthread Magics ***/ +static pthread_t create_thread(void *func, void *arg) { + pthread_attr_t attr; + pthread_t tid; + + pthread_attr_init (&attr); + pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); + pthread_create (&tid, &attr, func, arg); + pthread_attr_destroy (&attr); + + return tid; +} + +/*** Mach-O IPC Stuffs ***/ + +union MaxMsgSize { + union __RequestUnion__mach_startup_subsystem req; + union __ReplyUnion__mach_startup_subsystem rep; +}; + +static mach_port_t checkin_or_register(char *bname) { + kern_return_t kr; + mach_port_t mp; + + /* If we're started by launchd or the old mach_init */ + kr = bootstrap_check_in(bootstrap_port, bname, &mp); + if (kr == KERN_SUCCESS) + return mp; + + /* We probably were not started by launchd or the old mach_init */ + kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr)); + exit(EXIT_FAILURE); + } + + kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr)); + exit(EXIT_FAILURE); + } + + kr = bootstrap_register(bootstrap_port, bname, mp); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr)); + exit(EXIT_FAILURE); + } + + return mp; +} + +/*** $DISPLAY handoff ***/ +static int accept_fd_handoff(int connected_fd) { + int launchd_fd; + + char databuf[] = "display"; + struct iovec iov[1]; + + iov[0].iov_base = databuf; + iov[0].iov_len = sizeof(databuf); + + union { + struct cmsghdr hdr; + char bytes[CMSG_SPACE(sizeof(int))]; + } buf; + + struct msghdr msg; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + msg.msg_control = buf.bytes; + msg.msg_controllen = sizeof(buf); + msg.msg_name = 0; + msg.msg_namelen = 0; + msg.msg_flags = 0; + + struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); + + msg.msg_controllen = cmsg->cmsg_len; + + *((int*)CMSG_DATA(cmsg)) = -1; + + if(recvmsg(connected_fd, &msg, 0) < 0) { + fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno)); + return -1; + } + + launchd_fd = *((int*)CMSG_DATA(cmsg)); + + return launchd_fd; +} + +typedef struct { + int fd; + string_t filename; +} socket_handoff_t; + +/* This thread accepts an incoming connection and hands off the file + * descriptor for the new connection to accept_fd_handoff() + */ +static void socket_handoff_thread(void *arg) { + socket_handoff_t *handoff_data = (socket_handoff_t *)arg; + int launchd_fd = -1; + int connected_fd; + + /* Now actually get the passed file descriptor from this connection + * If we encounter an error, keep listening. + */ + while(launchd_fd == -1) { + connected_fd = accept(handoff_data->fd, NULL, NULL); + if(connected_fd == -1) { + fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno)); + sleep(2); + continue; + } + + launchd_fd = accept_fd_handoff(connected_fd); + if(launchd_fd == -1) + fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); + + close(connected_fd); + } + + close(handoff_data->fd); + unlink(handoff_data->filename); + free(handoff_data); + + /* TODO: Clean up this race better... giving xinitrc time to run... need to wait for 1.5 branch: + * + * From ajax: + * There's already an internal callback chain for setting selection [in 1.5] + * ownership. See the CallSelectionCallback at the bottom of + * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook + * into it. + */ + + unsigned remain = 3000000; + fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd); + while((remain = usleep(remain)) > 0); + + fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); + DarwinListenOnOpenFD(launchd_fd); +} + +static int create_socket(char *filename_out) { + struct sockaddr_un servaddr_un; + struct sockaddr *servaddr; + socklen_t servaddr_len; + int ret_fd; + size_t try, try_max; + + for(try=0, try_max=5; try < try_max; try++) { + tmpnam(filename_out); + + /* Setup servaddr_un */ + memset (&servaddr_un, 0, sizeof (struct sockaddr_un)); + servaddr_un.sun_family = AF_UNIX; + strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path)); + + servaddr = (struct sockaddr *) &servaddr_un; + servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out); + + ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); + if(ret_fd == -1) { + fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno)); + continue; + } + + if(bind(ret_fd, servaddr, servaddr_len) != 0) { + fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno)); + close(ret_fd); + return 0; + } + + if(listen(ret_fd, 10) != 0) { + fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno)); + close(ret_fd); + return 0; + } + +#ifdef DEBUG + fprintf(stderr, "X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out); +#endif + + return ret_fd; + } + + return 0; +} + +static int launchd_socket_handed_off = 0; + +kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) { + socket_handoff_t *handoff_data; + + launchd_socket_handed_off = 1; + + handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t)); + if(!handoff_data) { + fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n"); + return KERN_FAILURE; + } + + handoff_data->fd = create_socket(handoff_data->filename); + if(!handoff_data->fd) { + return KERN_FAILURE; + } + + strlcpy(filename, handoff_data->filename, STRING_T_SIZE); + + create_thread(socket_handoff_thread, handoff_data); + +#ifdef DEBUG + fprintf(stderr, "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); +#endif + + return KERN_SUCCESS; +} + +kern_return_t do_request_pid(mach_port_t port, int *my_pid) { + *my_pid = getpid(); + return KERN_SUCCESS; +} + +/*** Server Startup ***/ +kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv, + mach_msg_type_number_t argvCnt, + string_array_t envp, + mach_msg_type_number_t envpCnt) { + /* And now back to char ** */ + char **_argv = alloca((argvCnt + 1) * sizeof(char *)); + char **_envp = alloca((envpCnt + 1) * sizeof(char *)); + size_t i; + + /* If we didn't get handed a launchd DISPLAY socket, we shoul + * unset DISPLAY or we can run into problems with pbproxy + */ + if(!launchd_socket_handed_off) + unsetenv("DISPLAY"); + + if(!_argv || !_envp) { + return KERN_FAILURE; + } + + fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt); + for(i=0; i < argvCnt; i++) { + _argv[i] = argv[i]; + fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); + } + _argv[argvCnt] = NULL; + + for(i=0; i < envpCnt; i++) { + _envp[i] = envp[i]; + } + _envp[envpCnt] = NULL; + + if(server_main(argvCnt, _argv, _envp) == 0) + return KERN_SUCCESS; + else + return KERN_FAILURE; +} + +int startup_trigger(int argc, char **argv, char **envp) { + Display *display; + const char *s; + + /* Take care of the case where we're called like a normal DDX */ + if(argc > 1 && argv[1][0] == ':') { + size_t i; + kern_return_t kr; + mach_port_t mp; + string_array_t newenvp; + string_array_t newargv; + + /* We need to count envp */ + int envpc; + for(envpc=0; envp[envpc]; envpc++); + + /* We have fixed-size string lengths due to limitations in IPC, + * so we need to copy our argv and envp. + */ + newargv = (string_array_t)alloca(argc * sizeof(string_t)); + newenvp = (string_array_t)alloca(envpc * sizeof(string_t)); + + if(!newargv || !newenvp) { + fprintf(stderr, "Memory allocation failure\n"); + exit(EXIT_FAILURE); + } + + for(i=0; i < argc; i++) { + strlcpy(newargv[i], argv[i], STRING_T_SIZE); + } + for(i=0; i < envpc; i++) { + strlcpy(newenvp[i], envp[i], STRING_T_SIZE); + } + + kr = bootstrap_look_up(bootstrap_port, server_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)); +#else + fprintf(stderr, "bootstrap_look_up(): %ul\n", (unsigned long)kr); +#endif + exit(EXIT_FAILURE); + } + + kr = start_x11_server(mp, newargv, argc, newenvp, envpc); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr)); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); + } + + /* If we have a process serial number and it's our only arg, act as if + * the user double clicked the app bundle: launch app_to_run if possible + */ + if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) { + /* Now, try to open a display, if so, run the launcher */ + display = XOpenDisplay(NULL); + if(display) { + /* Could open the display, start the launcher */ + XCloseDisplay(display); + + return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT)); + } + } + + /* Start the server */ + if((s = getenv("DISPLAY"))) { + fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s); + unsetenv("DISPLAY"); + + /* This tells X11Controller to not use the environment's DISPLAY and reset it based on the server's display */ + xquartz_resetenv_display = 1; + } else { + fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); + } + return execute(command_from_prefs("startx_script", DEFAULT_STARTX)); +} + +/** Setup the environment we want our child processes to inherit */ +static void ensure_path(const char *dir) { + char buf[1024], *temp; + + /* Make sure /usr/X11/bin is in the $PATH */ + temp = getenv("PATH"); + if(temp == NULL || temp[0] == 0) { + snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir); + setenv("PATH", buf, TRUE); + } else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) { + snprintf(buf, sizeof(buf), "%s:%s", temp, dir); + setenv("PATH", buf, TRUE); + } +} + +static void setup_env() { + char *temp; + const char *pds = NULL; + + /* Pass on our prefs domain to startx and its inheritors (mainly for + * quartz-wm and the Xquartz stub's MachIPC) + */ + CFBundleRef bundle = CFBundleGetMainBundle(); + if(bundle) { + CFStringRef pd = CFBundleGetIdentifier(bundle); + if(pd) { + pds = CFStringGetCStringPtr(pd, 0); + if(pds) { + server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1)); + strcpy(server_bootstrap_name, pds); + setenv("X11_PREFS_DOMAIN", pds, 1); + } + } + } + + /* If we're not org.x.X11, we want to unset DISPLAY, so we don't + * use the launchd DISPLAY socket. + */ + if(pds == NULL || strcmp(pds, "org.x.X11") != 0) + unsetenv("DISPLAY"); + + /* Make sure PATH is right */ + ensure_path(X11BINDIR); + + /* cd $HOME */ + temp = getenv("HOME"); + if(temp != NULL && temp[0] != '\0') + chdir(temp); +} + +/*** Main ***/ +int main(int argc, char **argv, char **envp) { + Bool listenOnly = FALSE; + int i; + mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE; + mach_port_t mp; + kern_return_t kr; + + /* Setup our environment for our children */ + setup_env(); + + /* The server must not run the PanoramiX operations. */ + noPanoramiXExtension = TRUE; + + /* Setup the initial crasherporter info */ + strlcpy(__crashreporter_info__, __crashreporter_info__base, __crashreporter_info__len); + + fprintf(stderr, "X11.app: main(): argc=%d\n", argc); + for(i=0; i < argc; i++) { + fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); + if(!strcmp(argv[i], "--listenonly")) { + listenOnly = TRUE; + } + } + + mp = checkin_or_register(server_bootstrap_name); + if(mp == MACH_PORT_NULL) { + fprintf(stderr, "NULL mach service: %s", server_bootstrap_name); + return EXIT_FAILURE; + } + + /* Check if we need to do something other than listen, and make another + * thread handle it. + */ + if(!listenOnly) { + if(fork() == 0) { + return startup_trigger(argc, argv, envp); + } + } + + /* Main event loop */ + fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n"); + kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "org.x.X11(mp): %s\n", mach_error_string(kr)); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +static int execute(const char *command) { + const char *newargv[4]; + const char **p; + + newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL); + newargv[1] = "-c"; + newargv[2] = command; + newargv[3] = NULL; + + fprintf(stderr, "X11.app: Launching %s:\n", command); + for(p=newargv; *p; p++) { + fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p); + } + + execvp (newargv[0], (char * const *) newargv); + perror ("X11.app: Couldn't exec."); + return(1); +} + +static char *command_from_prefs(const char *key, const char *default_value) { + char *command = NULL; + + CFStringRef cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII); + CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication); + + if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) { + CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII); + + CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication); + CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication); + + int len = strlen(default_value) + 1; + command = (char *)malloc(len * sizeof(char)); + if(!command) + return NULL; + strcpy(command, default_value); + } else { + int len = CFStringGetLength((CFStringRef)PlistRef) + 1; + command = (char *)malloc(len * sizeof(char)); + if(!command) + return NULL; + CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII); + } + + if (PlistRef) + CFRelease(PlistRef); + + return command; +} diff --git a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c new file mode 100644 index 000000000..44a243a58 --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c @@ -0,0 +1,82 @@ +/* Copyright (c) 2008 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 +#include +#include + +#include "launchd_fd.h" + +int launchd_display_fd() { + launch_data_t sockets_dict, checkin_request, checkin_response; + launch_data_t listening_fd_array, listening_fd; + + /* Get launchd fd */ + if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) { + fprintf(stderr,"launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n"); + return ERROR_FD; + } + + if ((checkin_response = launch_msg(checkin_request)) == NULL) { + fprintf(stderr,"launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno)); + return ERROR_FD; + } + + if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) { + // ignore EACCES, which is common if we weren't started by launchd + if (launch_data_get_errno(checkin_response) != EACCES) + fprintf(stderr,"launchd check-in failed: %s\n", strerror(launch_data_get_errno(checkin_response))); + return ERROR_FD; + } + + sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS); + if (NULL == sockets_dict) { + fprintf(stderr,"launchd check-in: no sockets found to answer requests on!\n"); + return ERROR_FD; + } + + if (launch_data_dict_get_count(sockets_dict) > 1) { + fprintf(stderr,"launchd check-in: some sockets will be ignored!\n"); + return ERROR_FD; + } + + listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0"); + if (NULL == listening_fd_array) { + fprintf(stderr,"launchd check-in: No known sockets found to answer requests on!\n"); + return ERROR_FD; + } + + if (launch_data_array_get_count(listening_fd_array)!=1) { + fprintf(stderr,"launchd check-in: Expected 1 socket from launchd, got %u)\n", + (unsigned)launch_data_array_get_count(listening_fd_array)); + return ERROR_FD; + } + + listening_fd=launch_data_array_get_index(listening_fd_array, 0); + return launch_data_get_fd(listening_fd); +} diff --git a/xorg-server/hw/xquartz/mach-startup/launchd_fd.h b/xorg-server/hw/xquartz/mach-startup/launchd_fd.h new file mode 100644 index 000000000..5083fae21 --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/launchd_fd.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2008 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. + */ + +#ifndef _XQUARTZ_LAUNCHD_FD_H_ +#define _XQUARTZ_LAUNCHD_FD_H_ + +#define ERROR_FD -1 + +int launchd_display_fd(void); + +#endif /* _XQUARTZ_LAUNCHD_FD_H_ */ \ No newline at end of file diff --git a/xorg-server/hw/xquartz/mach-startup/mach_startup.defs b/xorg-server/hw/xquartz/mach-startup/mach_startup.defs new file mode 100644 index 000000000..e47f49c3c --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/mach_startup.defs @@ -0,0 +1,50 @@ +/* Copyright (c) 2008 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 +#include +import "mach_startup_types.h"; + +subsystem mach_startup 1000; +serverprefix do_; + +type string_t = c_string[1024]; +type string_array_t = array[] of string_t; + +routine start_x11_server( + port : mach_port_t; + argv : string_array_t; + envp : string_array_t); + +routine request_fd_handoff_socket ( + port : mach_port_t; + out socket_filename : string_t); + +routine request_pid ( + port : mach_port_t; + out pid : int); diff --git a/xorg-server/hw/xquartz/mach-startup/mach_startup_types.h b/xorg-server/hw/xquartz/mach-startup/mach_startup_types.h new file mode 100644 index 000000000..459c750db --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/mach_startup_types.h @@ -0,0 +1,9 @@ +#ifndef _MACH_STARTUP_TYPES_H_ +#define _MACH_STARTUP_TYPES_H_ + +#define STRING_T_SIZE 1024 + +typedef char string_t[STRING_T_SIZE]; +typedef string_t * string_array_t; + +#endif diff --git a/xorg-server/hw/xquartz/mach-startup/stub.c b/xorg-server/hw/xquartz/mach-startup/stub.c new file mode 100644 index 000000000..893d19c8d --- /dev/null +++ b/xorg-server/hw/xquartz/mach-startup/stub.c @@ -0,0 +1,345 @@ +/* Copyright (c) 2008 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 + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include +#include + +static char *server_bootstrap_name = "org.x.X11"; + +/* The launchd startup is only designed for the primary X11.app that is + * org.x.X11... server_bootstrap_name might be differnet if we were triggered to + * start by another X11.app. + */ +#define kX11AppBundleId "org.x.X11" +#define kX11AppBundlePath "/Contents/MacOS/X11" + +#include +#include +#include +#include "mach_startup.h" + +#include + +#include + +#include "launchd_fd.h" + +#ifndef BUILD_DATE +#define BUILD_DATE "?" +#endif +#ifndef XSERVER_VERSION +#define XSERVER_VERSION "?" +#endif + +#define DEBUG 1 + +static char x11_path[PATH_MAX + 1]; + +static pid_t x11app_pid = 0; + +static void set_x11_path() { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 + + CFURLRef appURL = NULL; + CFBundleRef bundle = NULL; + OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL); + UInt32 ver; + + switch (osstatus) { + case noErr: + if (appURL == NULL) { + fprintf(stderr, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)\n", + kX11AppBundleId); + exit(1); + } + + bundle = CFBundleCreate(NULL, appURL); + if(!bundle) { + fprintf(stderr, "Xquartz: Null value returned from CFBundleCreate().\n"); + exit(2); + } + + if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) { + fprintf(stderr, "Xquartz: Error resolving URL for %s\n", kX11AppBundleId); + exit(3); + } + + ver = CFBundleGetVersionNumber(bundle); + if(ver < 0x02308000) { + CFStringRef versionStr = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey); + const char * versionCStr = "Unknown"; + + if(versionStr) + versionCStr = CFStringGetCStringPtr(versionStr, kCFStringEncodingMacRoman); + + fprintf(stderr, "Xquartz: Could not find a new enough X11.app LSFindApplicationForInfo() returned\n"); + fprintf(stderr, " X11.app = %s\n", x11_path); + fprintf(stderr, " Version = %s (%x), Expected Version > 2.3.0\n", versionCStr, (unsigned)ver); + exit(9); + } + + strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path)); +#ifdef DEBUG + fprintf(stderr, "Xquartz: X11.app = %s\n", x11_path); +#endif + break; + case kLSApplicationNotFoundErr: + fprintf(stderr, "Xquartz: Unable to find application for %s\n", kX11AppBundleId); + exit(10); + default: + fprintf(stderr, "Xquartz: Unable to find application for %s, error code = %d\n", + kX11AppBundleId, (int)osstatus); + exit(11); + } +#else + /* TODO: Make Tiger smarter... but TBH, this should never get called on Tiger... */ + strlcpy(x11_path, "/Applications/Utilities/X11.app/Contents/MacOS/X11", sizeof(x11_path)); +#endif +} + +static int connect_to_socket(const char *filename) { + struct sockaddr_un servaddr_un; + struct sockaddr *servaddr; + socklen_t servaddr_len; + int ret_fd; + + /* Setup servaddr_un */ + memset (&servaddr_un, 0, sizeof (struct sockaddr_un)); + servaddr_un.sun_family = AF_UNIX; + strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path)); + + servaddr = (struct sockaddr *) &servaddr_un; + servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename); + + ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); + if(ret_fd == -1) { + fprintf(stderr, "Xquartz: Failed to create socket: %s - %s\n", filename, strerror(errno)); + return -1; + } + + if(connect(ret_fd, servaddr, servaddr_len) < 0) { + fprintf(stderr, "Xquartz: Failed to connect to socket: %s - %d - %s\n", filename, errno, strerror(errno)); + close(ret_fd); + return -1; + } + + return ret_fd; +} + +static void send_fd_handoff(int connected_fd, int launchd_fd) { + char databuf[] = "display"; + struct iovec iov[1]; + + iov[0].iov_base = databuf; + iov[0].iov_len = sizeof(databuf); + + union { + struct cmsghdr hdr; + char bytes[CMSG_SPACE(sizeof(int))]; + } buf; + + struct msghdr msg; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + msg.msg_control = buf.bytes; + msg.msg_controllen = sizeof(buf); + msg.msg_name = 0; + msg.msg_namelen = 0; + msg.msg_flags = 0; + + struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); + + msg.msg_controllen = cmsg->cmsg_len; + + *((int*)CMSG_DATA(cmsg)) = launchd_fd; + + if(sendmsg(connected_fd, &msg, 0) < 0) { + fprintf(stderr, "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s\n", connected_fd, errno, strerror(errno)); + return; + } + +#ifdef DEBUG + fprintf(stderr, "Xquartz: Message sent. Closing handoff fd.\n"); +#endif + + close(connected_fd); +} + +static void signal_handler(int sig) { + if(x11app_pid) + kill(x11app_pid, sig); + _exit(0); +} + +int main(int argc, char **argv, char **envp) { + int envpc; + kern_return_t kr; + mach_port_t mp; + string_array_t newenvp; + string_array_t newargv; + size_t i; + int launchd_fd; + string_t handoff_socket_filename; + sig_t handler; + + if(argc == 2 && !strcmp(argv[1], "-version")) { + fprintf(stderr, "X.org Release 7.3\n"); + fprintf(stderr, "X.Org X Server %s\n", XSERVER_VERSION); + fprintf(stderr, "Build Date: %s\n", BUILD_DATE); + return EXIT_SUCCESS; + } + + if(getenv("X11_PREFS_DOMAIN")) + server_bootstrap_name = getenv("X11_PREFS_DOMAIN"); + + /* We don't have a mechanism in place to handle this interrupt driven + * server-start notification, so just send the signal now, so xinit doesn't + * time out waiting for it and will just poll for the server. + */ + handler = signal(SIGUSR1, SIG_IGN); + if(handler == SIG_IGN) + kill(getppid(), SIGUSR1); + signal(SIGUSR1, handler); + + /* Pass on SIGs to X11.app */ + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + + /* Get the $DISPLAY FD */ + launchd_fd = launchd_display_fd(); + + kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); + if(kr != KERN_SUCCESS) { + set_x11_path(); + + /* This forking is ugly and will be cleaned up later */ + pid_t child = fork(); + if(child == -1) { + fprintf(stderr, "Xquartz: Could not fork: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + + if(child == 0) { + char *_argv[3]; + _argv[0] = x11_path; + _argv[1] = "--listenonly"; + _argv[2] = NULL; + fprintf(stderr, "Xquartz: Starting X server: %s --listenonly\n", x11_path); + return execvp(x11_path, _argv); + } + + /* Try connecting for 10 seconds */ + for(i=0; i < 80; i++) { + usleep(250000); + kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); + if(kr == KERN_SUCCESS) + break; + } + + if(kr != KERN_SUCCESS) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 + fprintf(stderr, "Xquartz: bootstrap_look_up(): %s\n", bootstrap_strerror(kr)); +#else + fprintf(stderr, "Xquartz: bootstrap_look_up(): %ul\n", (unsigned long)kr); +#endif + return EXIT_FAILURE; + } + } + + /* Get X11.app's pid */ + request_pid(mp, &x11app_pid); + + /* Handoff the $DISPLAY FD */ + if(launchd_fd != -1) { + size_t try, try_max; + int handoff_fd = -1; + + for(try=0, try_max=5; try < try_max; try++) { + if(request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) { + fprintf(stderr, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)\n", (int)try+1, (int)try_max); + continue; + } + + handoff_fd = connect_to_socket(handoff_socket_filename); + if(handoff_fd == -1) { + fprintf(stderr, "Xquartz: Failed to connect to socket (try %d of %d)\n", (int)try+1, (int)try_max); + continue; + } + +#ifdef DEBUG + fprintf(stderr, "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.\n", (int)try+1, (int)try_max, handoff_fd, handoff_socket_filename); +#endif + + send_fd_handoff(handoff_fd, launchd_fd); + close(handoff_fd); + break; + } + } + + /* Count envp */ + for(envpc=0; envp[envpc]; envpc++); + + /* We have fixed-size string lengths due to limitations in IPC, + * so we need to copy our argv and envp. + */ + newargv = (string_array_t)alloca(argc * sizeof(string_t)); + newenvp = (string_array_t)alloca(envpc * sizeof(string_t)); + + if(!newargv || !newenvp) { + fprintf(stderr, "Xquartz: Memory allocation failure\n"); + exit(EXIT_FAILURE); + } + + for(i=0; i < argc; i++) { + strlcpy(newargv[i], argv[i], STRING_T_SIZE); + } + for(i=0; i < envpc; i++) { + strlcpy(newenvp[i], envp[i], STRING_T_SIZE); + } + + kr = start_x11_server(mp, newargv, argc, newenvp, envpc); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "Xquartz: start_x11_server: %s\n", mach_error_string(kr)); + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} -- cgit v1.2.3