xserver: Branch 'xorg-server-1.4-apple' - 2 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Mon May 12 10:37:05 PDT 2008


 hw/xquartz/bundle/Info.plist          |    4 +++
 hw/xquartz/mach-startup/bundle-main.c |   35 +++++++++++++++------------
 hw/xquartz/mach-startup/stub.c        |   44 +++++++++++++++++++++++++---------
 3 files changed, 57 insertions(+), 26 deletions(-)

New commits:
commit 78032815aeb10c22ff45b49702e9c9df82ab471c
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon May 12 10:36:44 2008 -0700

    XQuartz: Added some version checking protection so we don't trigger an infinite exec loop with new /usr/X11/bin/Xquartz and older X11.app

diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
index 4b0830f..30bb3c8 100644
--- a/hw/xquartz/bundle/Info.plist
+++ b/hw/xquartz/bundle/Info.plist
@@ -20,6 +20,10 @@
 		<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
 		<string>2.3.0</string>
+	<key>CFBundleVersion</key>
+		<string>2.3.0</string>
+	<key>CFBundleVersionString</key>
+		<string>2.3.0</string>
 	<key>CFBundleSignature</key>
 		<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 70f222c..3be5f65 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -43,33 +43,55 @@ static char x11_path[PATH_MAX + 1];
 
 static void set_x11_path() {
     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, "xinit: Invalid response from LSFindApplicationForInfo(%s)\n", 
+                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, "xinit: Error resolving URL for %s\n", kX11AppBundleId);
-                exit(2);
+                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);
+            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(4);
+            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", 
+            fprintf(stderr, "Xquartz: Unable to find application for %s, error code = %d\n", 
                     kX11AppBundleId, (int)osstatus);
-            exit(5);
+            exit(11);
     }
 }
 
commit 3b0afb47c3d8ad922cb2315ed8034f4d77d4a249
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon May 12 09:27:27 2008 -0700

    XQuartz: More startup work... listen if we're the actual server

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 24b67d8..b0ff9df 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -139,6 +139,9 @@ static void startup_trigger_thread(void *arg) {
 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;
 
     for(i=1; i < argc; i++) {
         if(!strcmp(argv[i], "--listenonly")) {
@@ -147,6 +150,11 @@ int main(int argc, char **argv, char **envp) {
         }
     }
 
+    /* TODO: This should be unconditional once we figure out fd passing */
+    if((argc > 1 && argv[1][0] == ':') || listenOnly) {
+        mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
+    }
+
     /* Check if we need to do something other than listen, and make another
      * thread handle it.
      */
@@ -154,23 +162,20 @@ int main(int argc, char **argv, char **envp) {
         struct arg *args = (struct arg*)malloc(sizeof(struct arg));
         if(!args)
             FatalError("Could not allocate memory.\n");
-        
+
         args->argc = argc;
         args->argv = argv;
         args->envp = envp;
 
         create_thread(startup_trigger_thread, args);
-    } else {
-        /* TODO: This should actually fall through rather than be the else
-         *       case once we figure out how to get the stub to pass the
-         *       file descriptor.  For now, we only listen if we are explicitly
-         *       told to.
-         */
-
-        mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
-        mach_port_t mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
-        kern_return_t kr;
-        
+    }
+
+    /* TODO: This should actually fall through rather than be the else
+     *       case once we figure out how to get the stub to pass the
+     *       file descriptor.  For now, we only listen if we are explicitly
+     *       told to.
+     */
+    if((argc > 1 && argv[1][0] == ':') || listenOnly) {
         /* Main event loop */
         kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
         if (kr != KERN_SUCCESS) {
@@ -179,7 +184,7 @@ int main(int argc, char **argv, char **envp) {
             exit(EXIT_FAILURE);
         }
     }
-    
+
     return EXIT_SUCCESS;
 }
 
@@ -208,7 +213,7 @@ int main(int argc, char **argv, char **envp) {
         return server_main(argc, argv, envp);
 #endif
     }
-    
+
     /* 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
      */
@@ -227,7 +232,7 @@ int main(int argc, char **argv, char **envp) {
             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);


More information about the xorg-commit mailing list