Add LSFileQuarantineEnabled to the .plist
This commit is contained in:
parent
2eb6848eb8
commit
646d15b257
|
@ -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"];
|
||||
|
|
|
@ -1547,6 +1547,12 @@ bool checkReadyUpdate() {
|
|||
return false;
|
||||
}
|
||||
#endif // Q_OS_LINUX
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
Platform::RemoveQuarantine(QFileInfo(curUpdater).absolutePath());
|
||||
Platform::RemoveQuarantine(updater.absolutePath());
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,68 +158,6 @@ QAbstractNativeEventFilter *psNativeEventFilter() {
|
|||
void psWriteDump() {
|
||||
}
|
||||
|
||||
QString demanglestr(const QString &mangled) {
|
||||
if (mangled.isEmpty()) return mangled;
|
||||
|
||||
QByteArray cmd = ("c++filt -n " + mangled).toUtf8();
|
||||
FILE *f = popen(cmd.constData(), "r");
|
||||
if (!f) return "BAD_SYMBOL_" + mangled;
|
||||
|
||||
QString result;
|
||||
char buffer[4096] = { 0 };
|
||||
while (!feof(f)) {
|
||||
if (fgets(buffer, 4096, f) != NULL) {
|
||||
result += buffer;
|
||||
}
|
||||
}
|
||||
pclose(f);
|
||||
return result.trimmed();
|
||||
}
|
||||
|
||||
QStringList addr2linestr(uint64 *addresses, int count) {
|
||||
QStringList result;
|
||||
if (!count || cExeName().isEmpty()) return result;
|
||||
|
||||
result.reserve(count);
|
||||
QByteArray cmd = "addr2line -e " + EscapeShell(QFile::encodeName(cExeDir() + cExeName()));
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (addresses[i]) {
|
||||
cmd += qsl(" 0x%1").arg(addresses[i], 0, 16).toUtf8();
|
||||
}
|
||||
}
|
||||
FILE *f = popen(cmd.constData(), "r");
|
||||
|
||||
QStringList addr2lineResult;
|
||||
if (f) {
|
||||
char buffer[4096] = {0};
|
||||
while (!feof(f)) {
|
||||
if (fgets(buffer, 4096, f) != NULL) {
|
||||
addr2lineResult.push_back(QString::fromUtf8(buffer));
|
||||
}
|
||||
}
|
||||
pclose(f);
|
||||
}
|
||||
for (int i = 0, j = 0; i < count; ++i) {
|
||||
if (addresses[i]) {
|
||||
if (j < addr2lineResult.size() && !addr2lineResult.at(j).isEmpty() && !addr2lineResult.at(j).startsWith(qstr("0x"))) {
|
||||
QString res = addr2lineResult.at(j).trimmed();
|
||||
if (int index = res.indexOf(qstr("/Telegram/"))) {
|
||||
if (index > 0) {
|
||||
res = res.mid(index + qstr("/Telegram/").size());
|
||||
}
|
||||
}
|
||||
result.push_back(res);
|
||||
} else {
|
||||
result.push_back(QString());
|
||||
}
|
||||
++j;
|
||||
} else {
|
||||
result.push_back(QString());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool _removeDirectory(const QString &path) { // from http://stackoverflow.com/questions/2256945/removing-a-non-empty-directory-programmatically-in-c-or-c
|
||||
QByteArray pathRaw = QFile::encodeName(path);
|
||||
DIR *d = opendir(pathRaw.constData());
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/crash_reports.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "platform/mac/mac_utilities.h"
|
||||
#include "platform/platform_specific.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <CoreFoundation/CFURL.h>
|
||||
|
@ -117,6 +118,7 @@ bool Launcher::launchUpdater(UpdaterLaunch action) {
|
|||
return false;
|
||||
}
|
||||
path = [path stringByAppendingString:@"/Contents/Frameworks/Updater"];
|
||||
RemoveQuarantine(QFile::decodeName([path fileSystemRepresentation]));
|
||||
|
||||
NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:@"-workpath", Q2NSString(cWorkingDir()), @"-procid", nil];
|
||||
[args addObject:[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]];
|
||||
|
|
|
@ -19,6 +19,8 @@ inline bool TranslucentWindowsSupported(QPoint globalPosition) {
|
|||
|
||||
QString CurrentExecutablePath(int argc, char *argv[]);
|
||||
|
||||
void RemoveQuarantine(const QString &path);
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
inline void start() {
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <cstdlib>
|
||||
#include <execinfo.h>
|
||||
#include <sys/xattr.h>
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <CoreFoundation/CFURL.h>
|
||||
|
@ -85,85 +86,6 @@ void psWriteDump() {
|
|||
#endif // TDESKTOP_DISABLE_CRASH_REPORTS
|
||||
}
|
||||
|
||||
QString demanglestr(const QString &mangled) {
|
||||
QByteArray cmd = ("c++filt -n " + mangled).toUtf8();
|
||||
FILE *f = popen(cmd.constData(), "r");
|
||||
if (!f) return "BAD_SYMBOL_" + mangled;
|
||||
|
||||
QString result;
|
||||
char buffer[4096] = {0};
|
||||
while (!feof(f)) {
|
||||
if (fgets(buffer, 4096, f) != NULL) {
|
||||
result += buffer;
|
||||
}
|
||||
}
|
||||
pclose(f);
|
||||
return result.trimmed();
|
||||
}
|
||||
|
||||
QString escapeShell(const QString &str) {
|
||||
QString result;
|
||||
const QChar *b = str.constData(), *e = str.constEnd();
|
||||
for (const QChar *ch = b; ch != e; ++ch) {
|
||||
if (*ch == ' ' || *ch == '"' || *ch == '\'' || *ch == '\\') {
|
||||
if (result.isEmpty()) {
|
||||
result.reserve(str.size() * 2);
|
||||
}
|
||||
if (ch > b) {
|
||||
result.append(b, ch - b);
|
||||
}
|
||||
result.append('\\');
|
||||
b = ch;
|
||||
}
|
||||
}
|
||||
if (result.isEmpty()) return str;
|
||||
|
||||
if (e > b) {
|
||||
result.append(b, e - b);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList atosstr(uint64 *addresses, int count, uint64 base) {
|
||||
QStringList result;
|
||||
if (!count || cExeName().isEmpty()) return result;
|
||||
|
||||
result.reserve(count);
|
||||
QString cmdstr = "atos -o " + escapeShell(cExeDir() + cExeName()) + qsl("/Contents/MacOS/Telegram -l 0x%1").arg(base, 0, 16);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (addresses[i]) {
|
||||
cmdstr += qsl(" 0x%1").arg(addresses[i], 0, 16);
|
||||
}
|
||||
}
|
||||
QByteArray cmd = cmdstr.toUtf8();
|
||||
FILE *f = popen(cmd.constData(), "r");
|
||||
|
||||
QStringList atosResult;
|
||||
if (f) {
|
||||
char buffer[4096] = {0};
|
||||
while (!feof(f)) {
|
||||
if (fgets(buffer, 4096, f) != NULL) {
|
||||
atosResult.push_back(QString::fromUtf8(buffer));
|
||||
}
|
||||
}
|
||||
pclose(f);
|
||||
}
|
||||
for (int i = 0, j = 0; i < count; ++i) {
|
||||
if (addresses[i]) {
|
||||
if (j < atosResult.size() && !atosResult.at(j).isEmpty() && !atosResult.at(j).startsWith(qstr("0x"))) {
|
||||
result.push_back(atosResult.at(j).trimmed());
|
||||
} else {
|
||||
result.push_back(QString());
|
||||
}
|
||||
++j;
|
||||
} else {
|
||||
result.push_back(QString());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
void psDeleteDir(const QString &dir) {
|
||||
objc_deleteDir(dir);
|
||||
}
|
||||
|
@ -272,6 +194,14 @@ QString CurrentExecutablePath(int argc, char *argv[]) {
|
|||
return NS2QString([[NSBundle mainBundle] bundlePath]);
|
||||
}
|
||||
|
||||
void RemoveQuarantine(const QString &path) {
|
||||
const auto kQuarantineAttribute = "com.apple.quarantine";
|
||||
|
||||
DEBUG_LOG(("Removing quarantine attribute: %1").arg(path));
|
||||
const auto local = QFile::encodeName(path);
|
||||
removexattr(local.data(), kQuarantineAttribute, 0);
|
||||
}
|
||||
|
||||
void RegisterCustomScheme() {
|
||||
#ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME
|
||||
OSStatus result = LSSetDefaultHandlerForURLScheme(CFSTR("tg"), (CFStringRef)[[NSBundle mainBundle] bundleIdentifier]);
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
<string>public.app-category.social-networking</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>LSFileQuarantineEnabled</key>
|
||||
<true/>
|
||||
<key>NOTE</key>
|
||||
<string></string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
|
|
Loading…
Reference in New Issue