if there is no password file for specific user, try to read global password file

This way we can have a master password for imap access
This commit is contained in:
Jesús García Sáez
2014-03-17 21:08:12 +01:00
committed by Julio García
parent c6b8be742d
commit 3b2174eeec

View File

@@ -100,16 +100,12 @@ static NSMapTable *contextsTable = nil;
return self;
}
- (NSString *) _readUserPassword: (NSString *) newUsername
- (NSString *) _readPasswordFile: (NSString *) path
{
NSString *password, *path;
NSString *password;
NSData *content;
password = nil;
path = [NSString stringWithFormat: SAMBA_PRIVATE_DIR
@"/mapistore/%@/password", newUsername];
password = nil;
content = [NSData dataWithContentsOfFile: path];
if (content)
@@ -124,6 +120,24 @@ static NSMapTable *contextsTable = nil;
return password;
}
- (NSString *) _readUserPassword: (NSString *) newUsername
{
NSString *password, *path;
path = [NSString stringWithFormat: SAMBA_PRIVATE_DIR
@"/mapistore/%@/password", newUsername];
password = [self _readPasswordFile: path];
if (password == nil)
{
// Try to get master password
path = [NSString stringWithFormat: SAMBA_PRIVATE_DIR @"/mapistore/master.password"];
password = [self _readPasswordFile: path];
}
return password;
}
- (id) initWithUsername: (NSString *) newUsername
andTDBIndexing: (struct indexing_context *) indexing
{