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 {
[TSSocketManager becomeActive];
[AppAudioManager.sharedInstance awake];
if ([TSAccountManager isRegistered]) {
[TSSocketManager becomeActive];
[AppAudioManager.sharedInstance awake];
[PushManager.sharedManager verifyPushPermissions];
[AppAudioManager.sharedInstance requestRequiredPermissionsIfNeeded];
}
// Hacky way to clear notification center after processed push
[UIApplication.sharedApplication setApplicationIconBadgeNumber:1];
[UIApplication.sharedApplication setApplicationIconBadgeNumber:0];
[self removeScreenProtection];
if (Environment.isRedPhoneRegistered) {
[PushManager.sharedManager verifyPushPermissions];
[AppAudioManager.sharedInstance requestRequiredPermissionsIfNeeded];
}
}
- (void)applicationWillResignActive:(UIApplication *)application{

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

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

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

Loading…
Cancel
Save