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
(cherry picked from commit 78032815aeb10c22ff45b49702e9c9df82ab471c)
This commit is contained in:
parent
ac4e33a9cd
commit
f9fae16456
|
@ -20,6 +20,10 @@
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.3.0</string>
|
<string>2.3.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>2.3.0</string>
|
||||||
|
<key>CFBundleVersionString</key>
|
||||||
|
<string>2.3.0</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>x11a</string>
|
<string>x11a</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
|
|
|
@ -43,33 +43,55 @@ static char x11_path[PATH_MAX + 1];
|
||||||
|
|
||||||
static void set_x11_path() {
|
static void set_x11_path() {
|
||||||
CFURLRef appURL = NULL;
|
CFURLRef appURL = NULL;
|
||||||
|
CFBundleRef bundle = NULL;
|
||||||
OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
|
OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
|
||||||
|
UInt32 ver;
|
||||||
|
|
||||||
switch (osstatus) {
|
switch (osstatus) {
|
||||||
case noErr:
|
case noErr:
|
||||||
if (appURL == NULL) {
|
if (appURL == NULL) {
|
||||||
fprintf(stderr, "xinit: Invalid response from LSFindApplicationForInfo(%s)\n",
|
fprintf(stderr, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)\n",
|
||||||
kX11AppBundleId);
|
kX11AppBundleId);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
|
bundle = CFBundleCreate(NULL, appURL);
|
||||||
fprintf(stderr, "xinit: Error resolving URL for %s\n", kX11AppBundleId);
|
if(!bundle) {
|
||||||
exit(2);
|
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));
|
strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "XQuartz: X11.app = %s\n", x11_path);
|
fprintf(stderr, "Xquartz: X11.app = %s\n", x11_path);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case kLSApplicationNotFoundErr:
|
case kLSApplicationNotFoundErr:
|
||||||
fprintf(stderr, "XQuartz: Unable to find application for %s\n", kX11AppBundleId);
|
fprintf(stderr, "Xquartz: Unable to find application for %s\n", kX11AppBundleId);
|
||||||
exit(4);
|
exit(10);
|
||||||
default:
|
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);
|
kX11AppBundleId, (int)osstatus);
|
||||||
exit(5);
|
exit(11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue