Exclude Signal files from backup & encrypt when possible.

pull/1/head
Frederic Jacobs 10 years ago
parent bcd98f90ee
commit fb0281fd61

@ -228,19 +228,17 @@ static NSString* const kCallSegue = @"2.0_6.0_Call_Segue";
} }
-(void) applicationDidBecomeActive:(UIApplication *)application { -(void) applicationDidBecomeActive:(UIApplication *)application {
[TSSocketManager becomeActive]; if ([TSAccountManager isRegistered]) {
[AppAudioManager.sharedInstance awake]; [TSSocketManager becomeActive];
[AppAudioManager.sharedInstance awake];
[PushManager.sharedManager verifyPushPermissions];
[AppAudioManager.sharedInstance requestRequiredPermissionsIfNeeded];
}
// Hacky way to clear notification center after processed push // Hacky way to clear notification center after processed push
[UIApplication.sharedApplication setApplicationIconBadgeNumber:1]; [UIApplication.sharedApplication setApplicationIconBadgeNumber:1];
[UIApplication.sharedApplication setApplicationIconBadgeNumber:0]; [UIApplication.sharedApplication setApplicationIconBadgeNumber:0];
[self removeScreenProtection]; [self removeScreenProtection];
if (Environment.isRedPhoneRegistered) {
[PushManager.sharedManager verifyPushPermissions];
[AppAudioManager.sharedInstance requestRequiredPermissionsIfNeeded];
}
} }
- (void)applicationWillResignActive:(UIApplication *)application{ - (void)applicationWillResignActive:(UIApplication *)application{

@ -8,6 +8,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <CocoaLumberjack/DDFileLogger.h>
@interface DebugLogger : NSObject @interface DebugLogger : NSObject
MacrosSingletonInterface MacrosSingletonInterface
@ -20,4 +22,6 @@ MacrosSingletonInterface
- (void)wipeLogs; - (void)wipeLogs;
@property (nonatomic) DDFileLogger *fileLogger;
@end @end

@ -11,12 +11,9 @@
#pragma mark Logging - Production logging wants us to write some logs to a file in case we need it for debugging. #pragma mark Logging - Production logging wants us to write some logs to a file in case we need it for debugging.
#import <CocoaLumberjack/DDTTYLogger.h> #import <CocoaLumberjack/DDTTYLogger.h>
#import <CocoaLumberjack/DDFileLogger.h>
@interface DebugLogger () @interface DebugLogger ()
@property (nonatomic) DDFileLogger *fileLogger;
@end @end
@implementation DebugLogger @implementation DebugLogger

@ -22,6 +22,8 @@
- (BOOL)isImage; - (BOOL)isImage;
- (BOOL)isVideo; - (BOOL)isVideo;
-(NSURL*)mediaURL; -(NSURL*)mediaURL;
+ (void)deleteAttachments; + (void)deleteAttachments;
+ (NSString*)attachmentsFolder;
@end @end

@ -11,6 +11,7 @@
#import <YapDatabase/YapDatabaseRelationship.h> #import <YapDatabase/YapDatabaseRelationship.h>
#import <CocoaLumberjack/DDLog.h> #import <CocoaLumberjack/DDLog.h>
#import "CryptoTools.h" #import "CryptoTools.h"
#import "DebugLogger.h"
#import "NSData+Base64.h" #import "NSData+Base64.h"
#import "TSThread.h" #import "TSThread.h"
@ -43,7 +44,7 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass";
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init]; sharedMyManager = [[self alloc] init];
[sharedMyManager protectDatabaseFile]; [sharedMyManager protectSignalFiles];
}); });
return sharedMyManager; return sharedMyManager;
} }
@ -79,32 +80,25 @@ static NSString * keychainDBPassAccount = @"TSDatabasePass";
[self.database registerExtension:[[YapDatabaseRelationship alloc] init] withName:@"TSRelationships"]; [self.database registerExtension:[[YapDatabaseRelationship alloc] init] withName:@"TSRelationships"];
} }
/** - (void)protectSignalFiles{
* Protects the preference and logs file with disk encryption and prevents them to leak to iCloud. [self protectFolderAtPath:[TSAttachmentStream attachmentsFolder]];
*/ [self protectFolderAtPath:[self dbPath]];
[self protectFolderAtPath:[NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"]];
}
- (void)protectDatabaseFile{ - (void)protectFolderAtPath:(NSString*)path {
NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication};
NSError *error; NSError *error;
NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication,
NSURLIsExcludedFromBackupKey:@YES};
[NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:[self dbPath] error:&error]; BOOL success = [NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:path error:&error];
[[NSURL fileURLWithPath:[self dbPath]] setResourceValue:@YES
forKey:NSURLIsExcludedFromBackupKey
error:&error];
if (error) { if (error || !success) {
DDLogError(@"Error while removing log files from backup: %@", error.description); DDLogError(@"Error while removing files from backup: %@", error.description);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"WARNING", @"") SignalAlertView(NSLocalizedString(@"WARNING", @""), @"DISABLING_BACKUP_FAILED");
message:NSLocalizedString(@"DISABLING_BACKUP_FAILED", @"")
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"")
otherButtonTitles:nil];
[alert show];
return; return;
} }
} }
- (YapDatabaseConnection *)newDatabaseConnection { - (YapDatabaseConnection *)newDatabaseConnection {

Loading…
Cancel
Save