From 0c0317c09a960fb157c50f266978fc096890dcca Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 17 Jul 2025 20:57:16 -0700 Subject: [PATCH] Improve retrieval of main app icon for authorization dialog (#2743) When authorization is needed, create a bitmap representation of the main app icon to save to disk. Also remove legacy code related to icons. --- InstallerLauncher/SUInstallerLauncher.m | 142 +++++++++--------- .../SUInstallerLauncherProtocol.h | 2 +- Sparkle.xcodeproj/project.pbxproj | 20 +-- Sparkle/SPUInstallerDriver.m | 4 +- Sparkle/SUApplicationInfo.m | 31 ---- Sparkle/SUBundleIcon.h | 21 --- Sparkle/SUBundleIcon.m | 34 ----- 7 files changed, 74 insertions(+), 180 deletions(-) delete mode 100644 Sparkle/SUBundleIcon.h delete mode 100644 Sparkle/SUBundleIcon.m diff --git a/InstallerLauncher/SUInstallerLauncher.m b/InstallerLauncher/SUInstallerLauncher.m index d9a5e184..65b52b61 100644 --- a/InstallerLauncher/SUInstallerLauncher.m +++ b/InstallerLauncher/SUInstallerLauncher.m @@ -11,17 +11,24 @@ #import "SUFileManager.h" #import "SULog.h" #import "SPUMessageTypes.h" -#import "SUBundleIcon.h" #import "SPULocalCacheDirectory.h" #import "SPUInstallationType.h" #import "SUHost.h" -#import #import -#import #import +// We only fetch bundle icon for Installer Launcher XPC Service +#if defined(BUILDING_SPARKLE_SOURCES_EXTERNALLY) && BUILDING_SPARKLE_SOURCES_EXTERNALLY +#define FETCH_BUNDLE_ICON_FOR_AUTH 1 +#else +#define FETCH_BUNDLE_ICON_FOR_AUTH 0 +#endif +#if FETCH_BUNDLE_ICON_FOR_AUTH +#import +#else #include "AppKitPrevention.h" +#endif @implementation SUInstallerLauncher @@ -106,10 +113,8 @@ return (submittedJob == true); } -- (SUInstallerLauncherStatus)submitInstallerAtPath:(NSString *)installerPath withHostBundle:(NSBundle *)hostBundle updaterIdentifier:(NSString *)updaterIdentifier userName:(NSString *)userName homeDirectory:(NSString *)homeDirectory authorizationPrompt:(NSString *)authorizationPrompt inSystemDomain:(BOOL)systemDomain rootUser:(BOOL)rootUser SPU_OBJC_DIRECT +- (SUInstallerLauncherStatus)submitInstallerAtPath:(NSString *)installerPath withHostBundle:(NSBundle *)hostBundle iconBundlePath:(NSString *)iconBundlePath updaterIdentifier:(NSString *)updaterIdentifier userName:(NSString *)userName homeDirectory:(NSString *)homeDirectory authorizationPrompt:(NSString *)authorizationPrompt inSystemDomain:(BOOL)systemDomain rootUser:(BOOL)rootUser SPU_OBJC_DIRECT { - SUFileManager *fileManager = [[SUFileManager alloc] init]; - // No need to release the quarantine for this utility // In fact, we shouldn't because the tool may be located at a path we should not be writing too. @@ -164,81 +169,68 @@ AuthorizationRights rights = { .count = 1, .items = &right }; AuthorizationFlags flags = (AuthorizationFlags)(kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed); - - AuthorizationItem iconAuthorizationItem = {.name = kAuthorizationEnvironmentIcon, .valueLength = 0, .value = NULL, .flags = 0}; AuthorizationEnvironment authorizationEnvironment = {.count = 0, .items = NULL}; - // Find a 32x32 image representation of the icon, and write out a PNG version of it to a temporary location - // Then use the icon (if one is available) for the authorization prompt - // NSImage is not used because it relies on AppKit - NSURL *tempIconDestinationURL = nil; - NSURL *iconURL = [SUBundleIcon iconURLForHost:[[SUHost alloc] initWithBundle:hostBundle]]; - if (iconURL != nil) { - CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)iconURL, (CFDictionaryRef)@{}); - if (imageSource != NULL) { - size_t imageCount = CGImageSourceGetCount(imageSource); - for (size_t imageIndex = 0; imageIndex < imageCount; imageIndex++) { - CFDictionaryRef cfProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, imageIndex, (CFDictionaryRef)@{}); - NSDictionary *properties = CFBridgingRelease(cfProperties); +#if FETCH_BUNDLE_ICON_FOR_AUTH + NSString *tempIconDestinationPath = nil; + AuthorizationItem iconAuthorizationItem = {.name = kAuthorizationEnvironmentIcon, .valueLength = 0, .value = NULL, .flags = 0}; + char iconPathBuffer[] = "/tmp/XXXXXX.png"; + + // If an icon bundle path is specified, write out a representation of the icon's data to a temporary file. + // Then use that image data for the authorization prompt + if (iconBundlePath != nil) { + NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:iconBundlePath]; + + // Creating a bitmap representation at a specific size is much cheaper than asking for icon's TIFFRepresentation + // On older OS's we must create a 32x32 image otherwise it won't be scaled correctly in the dialog + // On newer OS's we can use a slightly higher resolution image + NSInteger imageDimensions; + if (@available(macOS 10.15, *)) { + imageDimensions = 64; + } else { + imageDimensions = 32; + } + + NSBitmapImageRep *iconBitmapRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:imageDimensions pixelsHigh:imageDimensions bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0]; + + [NSGraphicsContext saveGraphicsState]; + + NSGraphicsContext.currentContext = [NSGraphicsContext graphicsContextWithBitmapImageRep:iconBitmapRep]; + [icon drawInRect:NSMakeRect(0, 0, imageDimensions, imageDimensions)]; + + [NSGraphicsContext restoreGraphicsState]; + + NSData *pngData = [iconBitmapRep representationUsingType:NSBitmapImageFileTypePNG properties:@{}]; + + if (pngData != nil) { + // Use /tmp rather than NSTemporaryDirectory() or SUFileManager's temp directory function because we want: + // a) no spaces in the path (SU/NSFileManager fails here) + // b) short file path that does not exceed a small threshold (NSTemporaryDirectory() fails here) only apply to older systems (eg: macOS 10.8) + // The file also needs to be placed in a system readable place such as /tmp + // See https://github.com/sparkle-project/Sparkle/issues/347#issuecomment-149523848 for more info + int tempIconFile = mkstemps(iconPathBuffer, strlen(".png")); + if (tempIconFile == -1) { + SULog(SULogLevelError, @"Failed to open temp icon from path buffer with error: %d", errno); + } else { + close(tempIconFile); - NSNumber *pixelWidth = properties[(const NSString *)kCGImagePropertyPixelWidth]; - NSNumber *pixelHeight = properties[(const NSString *)kCGImagePropertyPixelHeight]; + tempIconDestinationPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:iconPathBuffer length:strlen(iconPathBuffer)]; - // If we don't find a 32x32 image representation, then we don't provide an icon - // Don't try to make up with it by eg: converting an image representation to this size - // The app developer should be providing the icon representation. - // The authorization API may not take other size dimensions. - NSNumber *targetDimension = @32; - if ([pixelWidth isKindOfClass:[NSNumber class]] && [pixelHeight isKindOfClass:[NSNumber class]] && [pixelWidth isEqualToNumber:targetDimension] && [pixelHeight isEqualToNumber:targetDimension]) { - - // Use /tmp rather than NSTemporaryDirectory() or SUFileManager's temp directory function because we want: - // a) no spaces in the path (SU/NSFileManager fails here) - // b) short file path that does not exceed a small threshold (NSTemporaryDirectory() fails here) - // These limitations only apply to older systems (eg: macOS 10.8) - // The file also needs to be placed in a system readable place such as /tmp - // See https://github.com/sparkle-project/Sparkle/issues/347#issuecomment-149523848 for more info - char pathBuffer[] = "/tmp/XXXXXX.png"; - int tempIconFile = mkstemps(pathBuffer, strlen(".png")); - if (tempIconFile == -1) { - SULog(SULogLevelError, @"Failed to open temp icon from path buffer with error: %d", errno); + if (tempIconDestinationPath != nil) { + if (![pngData writeToFile:tempIconDestinationPath atomically:NO]) { + SULog(SULogLevelError, @"Failed to write icon image data to %@", tempIconDestinationPath); } else { - close(tempIconFile); + iconAuthorizationItem.valueLength = strlen(iconPathBuffer); + iconAuthorizationItem.value = iconPathBuffer; - NSString *path = [[NSString alloc] initWithUTF8String:pathBuffer]; - tempIconDestinationURL = [NSURL fileURLWithPath:path]; - - CGImageDestinationRef imageDestination = NULL; - if (@available(macOS 11, *)) { - CFStringRef uti = (__bridge CFStringRef)[UTTypePNG identifier]; - imageDestination = CGImageDestinationCreateWithURL((CFURLRef)tempIconDestinationURL, uti, 1, NULL); - } -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 - else - { - imageDestination = CGImageDestinationCreateWithURL((CFURLRef)tempIconDestinationURL, kUTTypePNG, 1, NULL); - } -#endif - if (imageDestination != NULL) { - CGImageDestinationAddImageFromSource(imageDestination, imageSource, imageIndex, (CFDictionaryRef)@{}); - if (CGImageDestinationFinalize(imageDestination)) { - iconAuthorizationItem.valueLength = strlen(pathBuffer); - iconAuthorizationItem.value = pathBuffer; - - authorizationEnvironment.count = 1; - authorizationEnvironment.items = &iconAuthorizationItem; - } - - CFRelease(imageDestination); - } + authorizationEnvironment.count = 1; + authorizationEnvironment.items = &iconAuthorizationItem; } - - break; } } - - CFRelease(imageSource); } } +#endif // This should prompt up the authorization dialog if necessary OSStatus copyStatus = AuthorizationCopyRights(auth, &rights, &authorizationEnvironment, flags, NULL); @@ -252,9 +244,11 @@ } } - if (tempIconDestinationURL != nil) { - [fileManager removeItemAtURL:tempIconDestinationURL error:NULL]; +#if FETCH_BUNDLE_ICON_FOR_AUTH + if (tempIconDestinationPath != nil) { + [[NSFileManager defaultManager] removeItemAtPath:tempIconDestinationPath error:NULL]; } +#endif } Boolean submittedJob = false; @@ -403,7 +397,7 @@ static BOOL SPUUsesSystemDomainForBundlePath(NSString *path, BOOL rootUser } // Note: do not pass untrusted information such as paths to the installer and progress agent tools, when we can find them ourselves here -- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath updaterIdentifier:(NSString *)updaterIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler +- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath iconBundlePath:(NSString *)iconBundlePath updaterIdentifier:(NSString *)updaterIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler { dispatch_async(dispatch_get_main_queue(), ^{ // We could do a sort of preflight Authorization test instead of testing if we are running as root, @@ -535,7 +529,7 @@ static BOOL SPUUsesSystemDomainForBundlePath(NSString *path, BOOL rootUser return; } - SUInstallerLauncherStatus installerStatus = [self submitInstallerAtPath:installerPath withHostBundle:hostBundle updaterIdentifier:updaterIdentifier userName:userName homeDirectory:homeDirectory authorizationPrompt:authorizationPrompt inSystemDomain:inSystemDomain rootUser:rootUser]; + SUInstallerLauncherStatus installerStatus = [self submitInstallerAtPath:installerPath withHostBundle:hostBundle iconBundlePath:iconBundlePath updaterIdentifier:updaterIdentifier userName:userName homeDirectory:homeDirectory authorizationPrompt:authorizationPrompt inSystemDomain:inSystemDomain rootUser:rootUser]; BOOL submittedProgressTool = NO; if (installerStatus == SUInstallerLauncherSuccess) { diff --git a/InstallerLauncher/SUInstallerLauncherProtocol.h b/InstallerLauncher/SUInstallerLauncherProtocol.h index b43bbe75..a3c77dda 100644 --- a/InstallerLauncher/SUInstallerLauncherProtocol.h +++ b/InstallerLauncher/SUInstallerLauncherProtocol.h @@ -11,6 +11,6 @@ @protocol SUInstallerLauncherProtocol -- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath updaterIdentifier:(NSString *)updaterBundleIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler; +- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath iconBundlePath:(NSString *)iconBundlePath updaterIdentifier:(NSString *)updaterBundleIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler; @end diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 40687805..000d5bc4 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -106,10 +106,8 @@ 61EF67560E25B58D00F754E0 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; }; 61EF67590E25C5B400F754E0 /* SUHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 61EF67580E25C5B400F754E0 /* SUHost.h */; }; 654F352529B1548700B10EEB /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; }; - 654F352729B154AE00B10EEB /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 654F352629B154AE00B10EEB /* ImageIO.framework */; }; 654F352829B154B500B10EEB /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55C14F31136EFC2400649790 /* SystemConfiguration.framework */; }; 654F352929B154BB00B10EEB /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 724BB3B51D35AAC3005D534A /* ServiceManagement.framework */; }; - 654F352C29B154E900B10EEB /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6D399502814387000A8C0DA /* UniformTypeIdentifiers.framework */; }; 654F352D29B1551000B10EEB /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 721BC20A1D17A5AD002BC71E /* CoreServices.framework */; }; 7202DC9A269ABD3500737EC4 /* testappcast_phasedRollout.xml in Resources */ = {isa = PBXBuildFile; fileRef = 7202DC99269ABD3500737EC4 /* testappcast_phasedRollout.xml */; }; 72045CE026FEE535004F96E5 /* Downloader.xpc in Copy XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* Downloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; @@ -146,10 +144,6 @@ 720E217B1D0D00BF003A311C /* SPUUpdaterCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */; }; 720E217C1D0D00BF003A311C /* SPUUpdaterCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */; }; 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; }; - 7214B8811D456A8500CB5CED /* SUBundleIcon.h in Headers */ = {isa = PBXBuildFile; fileRef = 7214B87F1D456A8500CB5CED /* SUBundleIcon.h */; }; - 7214B8821D456A8500CB5CED /* SUBundleIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7214B8801D456A8500CB5CED /* SUBundleIcon.m */; }; - 7214B8831D456C2400CB5CED /* SUBundleIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7214B8801D456A8500CB5CED /* SUBundleIcon.m */; }; - 7214B8841D456C9500CB5CED /* SUBundleIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 7214B8801D456A8500CB5CED /* SUBundleIcon.m */; }; 72162B081C82C9600013C1C5 /* SULocalizations.h in Headers */ = {isa = PBXBuildFile; fileRef = 72162B071C82C9600013C1C5 /* SULocalizations.h */; }; 721BC20E1D1CDE55002BC71E /* SPULocalCacheDirectory.h in Headers */ = {isa = PBXBuildFile; fileRef = 721BC20C1D1CDE55002BC71E /* SPULocalCacheDirectory.h */; }; 721BC20F1D1CDE55002BC71E /* SPULocalCacheDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = 721BC20D1D1CDE55002BC71E /* SPULocalCacheDirectory.m */; }; @@ -315,6 +309,7 @@ 7269E4982648D3460088C213 /* SPUSkippedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E493264798200088C213 /* SPUSkippedUpdate.m */; }; 7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 7269E4992648F7C00088C213 /* SPUUserUpdateState.m */; }; 726B20612CF4F1D300E6F7DB /* DevSignedAppVersion2.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 726B20602CF4F1D300E6F7DB /* DevSignedAppVersion2.dmg */; }; + 726BA5132E25F60000CE93C3 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; }; 726DF88E1C84277600188804 /* SPUUserUpdateState.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SPUUserUpdateState.h */; settings = {ATTRIBUTES = (Public, ); }; }; 726E075C1CA3A6D6001A286B /* SPUSecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E075A1CA3A6D6001A286B /* SPUSecureCoding.h */; }; 726E075D1CA3A6D6001A286B /* SPUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SPUSecureCoding.m */; }; @@ -487,7 +482,6 @@ EA1E287022B66621004AA304 /* SUSignatures.m in Sources */ = {isa = PBXBuildFile; fileRef = EA1E286D22B665E8004AA304 /* SUSignatures.m */; }; EA1E287922B666EB004AA304 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1E287822B666EB004AA304 /* main.swift */; }; EA1E287E22B66705004AA304 /* libed25519.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA1E282D22B660BE004AA304 /* libed25519.a */; }; - F6D399512814387000A8C0DA /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6D399502814387000A8C0DA /* UniformTypeIdentifiers.framework */; }; F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; }; F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; }; FA30773D24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = FA30773C24CBC295007BA37D /* testlocalizedreleasenotesappcast.xml */; }; @@ -1054,8 +1048,6 @@ 720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUUpdaterCycle.h; sourceTree = ""; }; 720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUUpdaterCycle.m; sourceTree = ""; }; 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = ""; }; - 7214B87F1D456A8500CB5CED /* SUBundleIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBundleIcon.h; sourceTree = ""; }; - 7214B8801D456A8500CB5CED /* SUBundleIcon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBundleIcon.m; sourceTree = ""; }; 7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUInstallationType.h; sourceTree = ""; }; 72162B071C82C9600013C1C5 /* SULocalizations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULocalizations.h; sourceTree = ""; }; 721652671D3C8FED00FD13D8 /* SUInstallerLauncherStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerLauncherStatus.h; path = InstallerLauncher/SUInstallerLauncherStatus.h; sourceTree = SOURCE_ROOT; }; @@ -1581,7 +1573,6 @@ files = ( 721C245A1CB75756005440CB /* Cocoa.framework in Frameworks */, 724BB3B71D35ABA8005D534A /* Security.framework in Frameworks */, - F6D399512814387000A8C0DA /* UniformTypeIdentifiers.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1610,11 +1601,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 726BA5132E25F60000CE93C3 /* AppKit.framework in Frameworks */, 654F352D29B1551000B10EEB /* CoreServices.framework in Frameworks */, - 654F352C29B154E900B10EEB /* UniformTypeIdentifiers.framework in Frameworks */, 654F352929B154BB00B10EEB /* ServiceManagement.framework in Frameworks */, 654F352829B154B500B10EEB /* SystemConfiguration.framework in Frameworks */, - 654F352729B154AE00B10EEB /* ImageIO.framework in Frameworks */, 654F352529B1548700B10EEB /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2063,8 +2053,6 @@ 721BC20D1D1CDE55002BC71E /* SPULocalCacheDirectory.m */, 729F7EAD273F1840004592DC /* SPUUserAgent+Private.h */, 729F7EAE273F1840004592DC /* SPUUserAgent+Private.m */, - 7214B87F1D456A8500CB5CED /* SUBundleIcon.h */, - 7214B8801D456A8500CB5CED /* SUBundleIcon.m */, 61299A5B09CA6D4500B7442F /* SUConstants.h */, 61299A5F09CA6EB100B7442F /* SUConstants.m */, 55E6F33219EC9F6C00005E76 /* SUErrors.h */, @@ -2601,7 +2589,6 @@ 72B767CA1C9B707000A07552 /* SUAppcastDriver.h in Headers */, 61B5FC7009C51F4A00B25A18 /* SUAppcastItem.h in Headers */, 725602D51C83551C00DAA70E /* SUApplicationInfo.h in Headers */, - 7214B8811D456A8500CB5CED /* SUBundleIcon.h in Headers */, 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */, 14652F8419A978C200959E44 /* SUExport.h in Headers */, 7267E5E51D3D90AA00D1BF90 /* SUFileManager.h in Headers */, @@ -3502,7 +3489,6 @@ 5AA89BA623FE276A0094DAB8 /* SUSignatures.m in Sources */, 7267E5FA1D3DAC3600D1BF90 /* StatusInfo.m in Sources */, 720595EF1D700568000572E8 /* SUApplicationInfo.m in Sources */, - 7214B8831D456C2400CB5CED /* SUBundleIcon.m in Sources */, 722FB7E6260EE53F00EB571C /* SUNormalization.m in Sources */, 721C245E1CB757DE005440CB /* SUConstants.m in Sources */, 7267E5EB1D3D90C200D1BF90 /* SUFileManager.m in Sources */, @@ -3548,7 +3534,6 @@ 721D8A7B1D4963190032E472 /* SPULocalCacheDirectory.m in Sources */, 7267E5E11D3D901600D1BF90 /* SPUMessageTypes.m in Sources */, 5AA89BA523FE27660094DAB8 /* SUSignatures.m in Sources */, - 7214B8841D456C9500CB5CED /* SUBundleIcon.m in Sources */, 726E07BF1CAF0C6C001A286B /* SUConstants.m in Sources */, 7267E5E81D3D90AA00D1BF90 /* SUFileManager.m in Sources */, 726E07B21CAF08D6001A286B /* SUInstallerLauncher.m in Sources */, @@ -3679,7 +3664,6 @@ 7269E496264798200088C213 /* SPUSkippedUpdate.m in Sources */, 7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */, 725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */, - 7214B8821D456A8500CB5CED /* SUBundleIcon.m in Sources */, 72DBA37F1D62C23E002594A8 /* SUCodeSigningVerifier.m in Sources */, 61299A6009CA6EB100B7442F /* SUConstants.m in Sources */, 7267E5E61D3D90AA00D1BF90 /* SUFileManager.m in Sources */, diff --git a/Sparkle/SPUInstallerDriver.m b/Sparkle/SPUInstallerDriver.m index bc8a3519..57aaca30 100644 --- a/Sparkle/SPUInstallerDriver.m +++ b/Sparkle/SPUInstallerDriver.m @@ -468,7 +468,9 @@ mainBundleIdentifier = (bundleIdentifier == nil) ? mainBundleName : bundleIdentifier; } - [installerLauncher launchInstallerWithHostBundlePath:hostBundlePath updaterIdentifier:mainBundleIdentifier authorizationPrompt:authorizationPrompt installationType:installationType allowingDriverInteraction:driverAllowsInteraction completion:^(SUInstallerLauncherStatus result, BOOL systemDomain) { + NSString *iconBundlePath = mainBundleHost.bundlePath; + + [installerLauncher launchInstallerWithHostBundlePath:hostBundlePath iconBundlePath:iconBundlePath updaterIdentifier:mainBundleIdentifier authorizationPrompt:authorizationPrompt installationType:installationType allowingDriverInteraction:driverAllowsInteraction completion:^(SUInstallerLauncherStatus result, BOOL systemDomain) { dispatch_async(dispatch_get_main_queue(), ^{ #if INSTALLER_LAUNCHER_XPC_SERVICE_EMBEDDED retrievedLaunchStatus = YES; diff --git a/Sparkle/SUApplicationInfo.m b/Sparkle/SUApplicationInfo.m index 38b26ac6..7e749296 100644 --- a/Sparkle/SUApplicationInfo.m +++ b/Sparkle/SUApplicationInfo.m @@ -9,10 +9,8 @@ #if SPARKLE_BUILD_UI_BITS || !BUILDING_SPARKLE #import "SUApplicationInfo.h" -#import "SUBundleIcon.h" #import "SUHost.h" #import -#import @implementation SUApplicationInfo @@ -33,35 +31,6 @@ icon = [[NSWorkspace sharedWorkspace] iconForFile:host.bundlePath]; } - // I don't think any of the further fallbacks are needed but keeping them in case - - // Next try a specified icon URL to load the icon from - if (icon == nil) { - NSURL *iconURL = [SUBundleIcon iconURLForHost:host]; - icon = (iconURL == nil) ? nil : [[NSImage alloc] initWithContentsOfURL:iconURL]; - } - - // Next try standard app icon from asset catalog - if (!icon) { - icon = [host.bundle imageForResource:@SPARKLE_ICON_NAME]; - } - - // Use a default generic icon if none is defined. - if (!icon) { - // this assumption may not be correct (eg. even though we're not the main bundle, it could be still be a regular app) - // but still better than nothing if no icon was included - if (@available(macOS 11, *)) { - UTType *contentType = isMainBundle ? UTTypeApplication : UTTypeBundle; - icon = [[NSWorkspace sharedWorkspace] iconForContentType:contentType]; - } -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 - else - { - NSString *fileType = isMainBundle ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle; - icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType]; - } -#endif - } return icon; } diff --git a/Sparkle/SUBundleIcon.h b/Sparkle/SUBundleIcon.h deleted file mode 100644 index 91ca005e..00000000 --- a/Sparkle/SUBundleIcon.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// SUBundleIcon.h -// Sparkle -// -// Created by Mayur Pawashe on 7/24/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class SUHost; - -SPU_OBJC_DIRECT_MEMBERS @interface SUBundleIcon : NSObject - -+ (NSURL * _Nullable)iconURLForHost:(SUHost *)host; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUBundleIcon.m b/Sparkle/SUBundleIcon.m deleted file mode 100644 index 3061c65e..00000000 --- a/Sparkle/SUBundleIcon.m +++ /dev/null @@ -1,34 +0,0 @@ -// -// SUBundleIcon.m -// Sparkle -// -// Created by Mayur Pawashe on 7/24/16. -// Copyright © 2016 Sparkle Project. All rights reserved. -// - -#import "SUBundleIcon.h" -#import "SUHost.h" - - -#include "AppKitPrevention.h" - -@implementation SUBundleIcon - -// Note: To obtain the most current bundle icon file from the Info dictionary, this should take a SUHost, not a NSBundle -+ (NSURL *)iconURLForHost:(SUHost *)host -{ - NSString *resource = [host objectForInfoDictionaryKey:@"CFBundleIconFile"]; - if (resource == nil || ![resource isKindOfClass:[NSString class]]) { - return nil; - } - - NSURL *iconURL = [host.bundle URLForResource:resource withExtension:@"icns"]; - - // The resource could already be containing the path extension, so try again without the extra extension - if (iconURL == nil) { - iconURL = [host.bundle URLForResource:resource withExtension:nil]; - } - return iconURL; -} - -@end