From 2f42766717cc9792c61e7346a230b12848a17a4f Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 24 Jul 2012 20:43:06 +0000 Subject: [PATCH 1/3] Monotone-Parent: bdb3c86bf127fecd411885ad5bcf84eb8af9f672 Monotone-Revision: b226b4ac380c34d6adb7ee8a0fab3a0632d83b37 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-24T20:43:06 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ OpenChange/samba-get-config.py | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100755 OpenChange/samba-get-config.py diff --git a/ChangeLog b/ChangeLog index 03159f886..d09c9c0d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-07-24 Wolfgang Sourdeau + + * OpenChange/samba-get-config.py: new utility taking a samba + configuration variable and prints the value on stdout + 2012-07-20 Ludovic Marcotte * UI/MailPartViewers/UIxMailRenderingContext.m diff --git a/OpenChange/samba-get-config.py b/OpenChange/samba-get-config.py new file mode 100755 index 000000000..c91c3ed44 --- /dev/null +++ b/OpenChange/samba-get-config.py @@ -0,0 +1,8 @@ +#!/usr/bin/python + +import sys +import samba.param + +a = samba.param.LoadParm() +a.load_default() +print a.get(sys.argv[1]) From 3cdf0347d55587dc4a908f252e641ea859974dbc Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 24 Jul 2012 20:43:40 +0000 Subject: [PATCH 2/3] Monotone-Parent: b226b4ac380c34d6adb7ee8a0fab3a0632d83b37 Monotone-Revision: 204d5491d1eef2c2a95ac2f31f32e5ab833a3ad8 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-24T20:43:40 Monotone-Branch: ca.inverse.sogo --- OpenChange/iCalEvent+MAPIStore.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenChange/iCalEvent+MAPIStore.m b/OpenChange/iCalEvent+MAPIStore.m index 82785046a..cacec6ea2 100644 --- a/OpenChange/iCalEvent+MAPIStore.m +++ b/OpenChange/iCalEvent+MAPIStore.m @@ -169,8 +169,7 @@ [self setTimeStampAsDate: value]; /* SUMMARY */ - value = [properties - objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)]; + value = [properties objectForKey: MAPIPropertyKey (PidTagNormalizedSubject)]; if (value) [self setSummary: value]; From 5aa0db4d7b71fc17f4bbff747fdefd241c9263f0 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 24 Jul 2012 20:45:03 +0000 Subject: [PATCH 3/3] Monotone-Parent: 204d5491d1eef2c2a95ac2f31f32e5ab833a3ad8 Monotone-Revision: 63de63b9d1691f5af7ec1b790f5201ae73cfa036 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-24T20:45:03 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ OpenChange/GNUmakefile | 3 +++ OpenChange/MAPIStoreUserContext.m | 35 ++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d09c9c0d0..b04d654d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-07-24 Wolfgang Sourdeau + * OpenChange/MAPIStoreUserContext.m + (-initWithUsername:andTDBIndexing:): attempt to read the user + password from a property list. + * OpenChange/samba-get-config.py: new utility taking a samba configuration variable and prints the value on stdout diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index 91b75ec0e..afed24ce2 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -26,6 +26,8 @@ BUNDLE_INSTALL_DIR = $(SOGO_LIBDIR) UNRTF_DIR = unrtf-$(UNRTF_VERSION) +SAMBA_PRIVATE_DIR = $(shell ./samba-get-config.py "private dir") + $(SOGOBACKEND)_SUBPROJECTS += $(UNRTF_DIR)/src $(SOGOBACKEND)_PRINCIPAL_CLASS = MAPIApplication @@ -190,6 +192,7 @@ $(SOGOBACKEND)_LIB_DIRS += \ ADDITIONAL_INCLUDE_DIRS += \ -Werror -Wall \ + -DSAMBA_PRIVATE_DIR=@"\"$(SAMBA_PRIVATE_DIR)\"" \ $(LIBMAPI_CFLAGS) \ $(LIBMAPISTORE_CFLAGS) \ -I$(UNRTF_DIR)/src \ diff --git a/OpenChange/MAPIStoreUserContext.m b/OpenChange/MAPIStoreUserContext.m index bf5d97f0c..7e6f7ec5a 100644 --- a/OpenChange/MAPIStoreUserContext.m +++ b/OpenChange/MAPIStoreUserContext.m @@ -20,8 +20,10 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import +#import #import #import @@ -95,9 +97,37 @@ static NSMapTable *contextsTable = nil; return self; } +- (NSString *) _readUserPassword: (NSString *) newUsername +{ + NSString *password; + NSData *content; + id plist; + NSPropertyListFormat plistFormat; + NSString *error; + + password = nil; + + content = [NSData dataWithContentsOfFile: SAMBA_PRIVATE_DIR + @"/mapistore/SOGo/userpwds.plist"]; + if (content) + { + plist = [NSPropertyListSerialization + propertyListFromData: content + mutabilityOption: NSPropertyListImmutable + format: &plistFormat + errorDescription: &error]; + if ([plist respondsToSelector: @selector (objectForKey:)]) + password = [plist objectForKey: newUsername]; + } + + return password; +} + - (id) initWithUsername: (NSString *) newUsername andTDBIndexing: (struct tdb_wrap *) indexingTdb { + NSString *userPassword; + if ((self = [self init])) { /* "username" will be retained by table */ @@ -109,7 +139,10 @@ static NSMapTable *contextsTable = nil; authenticator = [MAPIStoreAuthenticator new]; [authenticator setUsername: username]; /* TODO: very hackish (IMAP access) */ - [authenticator setPassword: username]; + userPassword = [self _readUserPassword: newUsername]; + if ([userPassword length] == 0) + userPassword = username; + [authenticator setPassword: userPassword]; } return self;