Add LSFileQuarantineEnabled to the .plist

This commit is contained in:
John Preston
2019-01-29 13:09:37 +03:00
parent 2eb6848eb8
commit 646d15b257
7 changed files with 39 additions and 141 deletions

View File

@@ -6,6 +6,7 @@ For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#import <Cocoa/Cocoa.h>
#include <sys/xattr.h>
NSString *appName = @"Telegram.app";
NSString *appDir = nil;
@@ -44,6 +45,20 @@ void writeLog(NSString *msg) {
[_logFile synchronizeFile];
}
void RemoveQuarantineAttribute(NSString *path) {
const char *kQuarantineAttribute = "com.apple.quarantine";
writeLog([@"Removing quarantine: " stringByAppendingString:path]);
removexattr([path fileSystemRepresentation], kQuarantineAttribute, 0);
}
void RemoveQuarantineFromBundle(NSString *path) {
RemoveQuarantineAttribute(path);
RemoveQuarantineAttribute([path stringByAppendingString:@"/Contents/MacOS/Telegram"]);
RemoveQuarantineAttribute([path stringByAppendingString:@"/Contents/Helpers/crashpad_handler"]);
RemoveQuarantineAttribute([path stringByAppendingString:@"/Contents/Frameworks/Updater"]);
}
void delFolder() {
writeLog([@"Fully clearing old path: " stringByAppendingString:[workDir stringByAppendingString:@"tupdates/ready"]]);
if (![[NSFileManager defaultManager] removeItemAtPath:[workDir stringByAppendingString:@"tupdates/ready"] error:nil]) {
@@ -232,6 +247,9 @@ int main(int argc, const char * argv[]) {
}
NSString *appPath = [[NSArray arrayWithObjects:appDir, appRealName, nil] componentsJoinedByString:@""];
RemoveQuarantineFromBundle(appPath);
NSMutableArray *args = [[NSMutableArray alloc] initWithObjects: @"-noupdate", nil];
if (toSettings) [args addObject:@"-tosettings"];
if (_debug) [args addObject:@"-debug"];