diff --git a/ChangeLog b/ChangeLog index 5e85fa1fd..0f7b688ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ * SoObjects/Appointments/SOGoAppointmentObject.m (-PUTAction:) We check if uid is not nil prior comparing it to the owner. This fixes bug #1323 + * Added patches included in bug #1348 - which now allows + group-based ACLs for IMAP. 2011-07-02 Ludovic Marcotte diff --git a/Documentation/SOGo Installation Guide.odt b/Documentation/SOGo Installation Guide.odt index 8b9b63a6c..e196ff83a 100644 Binary files a/Documentation/SOGo Installation Guide.odt and b/Documentation/SOGo Installation Guide.odt differ diff --git a/NEWS b/NEWS index 473570415..bf239b1cf 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ New Features - initial support for threaded-view in the webmail interface - sogo-tool: new "rename-user" command that automatically updates all the references in the database after modifying a user id +- groups support for IMAP ACLs Enhancements - improved list selection and contextual menu behavior in all web modules diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 98e4592e5..71a2ef435 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -898,7 +898,7 @@ static NSString *defaultUserID = @"anyone"; return character; } -- (NSString *) _sogoAclsToImapAcls: (NSArray *) sogoAcls +- (NSString *) _sogoACLsToIMAPACLs: (NSArray *) sogoAcls { NSMutableString *imapAcls; NSEnumerator *acls; @@ -943,6 +943,15 @@ static NSString *defaultUserID = @"anyone"; return imapAcls; } +- (NSString *) _sogoACLUIDToIMAPUID: (NSString *) uid +{ + if ([uid hasPrefix: @"@"]) + return [[[[context activeUser] domainDefaults] imapAclGroupIdPrefix] + stringByAppendingString: [uid substringFromIndex: 1]]; + else + return uid; +} + - (void) _removeIMAPExtUsernames { NSMutableDictionary *newIMAPAcls; @@ -963,6 +972,32 @@ static NSString *defaultUserID = @"anyone"; mailboxACL = newIMAPAcls; } +- (void) _convertIMAPGroupnames +{ + NSMutableDictionary *newIMAPAcls; + NSEnumerator *usernames; + NSString *username; + NSString *newUsername; + NSString *imapPrefix; + + imapPrefix = [[[context activeUser] domainDefaults] imapAclGroupIdPrefix]; + + newIMAPAcls = [[NSMutableDictionary alloc] init]; + + usernames = [[mailboxACL allKeys] objectEnumerator]; + while ((username = [usernames nextObject])) + { + if ([username hasPrefix: imapPrefix]) + newUsername = [@"@" stringByAppendingString: [username substringFromIndex: [imapPrefix length]]]; + else + newUsername = username; + [newIMAPAcls setObject: [mailboxACL objectForKey: username] + forKey: newUsername]; + } + [mailboxACL release]; + mailboxACL = newIMAPAcls; +} + - (void) _readMailboxACL { [mailboxACL release]; @@ -970,6 +1005,7 @@ static NSString *defaultUserID = @"anyone"; mailboxACL = [[self imap4Connection] aclForMailboxAtURL: [self imap4URL]]; [mailboxACL retain]; + [self _convertIMAPGroupnames]; if ([[self mailAccountFolder] imapAclConformsToIMAPExt]) [self _removeIMAPExtUsernames]; } @@ -1061,7 +1097,7 @@ static NSString *defaultUserID = @"anyone"; uids = [users objectEnumerator]; while ((currentUID = [uids nextObject])) - [client deleteACL: folderName uid: currentUID]; + [client deleteACL: folderName uid: [self _sogoACLUIDToIMAPUID: currentUID]]; [mailboxACL release]; mailboxACL = nil; } @@ -1071,9 +1107,9 @@ static NSString *defaultUserID = @"anyone"; { NSString *acls, *folderName; - acls = [self _sogoAclsToImapAcls: roles]; + acls = [self _sogoACLsToIMAPACLs: roles]; folderName = [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]]; - [[imap4 client] setACL: folderName rights: acls uid: uid]; + [[imap4 client] setACL: folderName rights: acls uid: [self _sogoACLUIDToIMAPUID: uid]]; [mailboxACL release]; mailboxACL = nil; diff --git a/SoObjects/SOGo/SOGoDefaults.plist b/SoObjects/SOGo/SOGoDefaults.plist index 26d65ba03..8acd155df 100644 --- a/SoObjects/SOGo/SOGoDefaults.plist +++ b/SoObjects/SOGo/SOGoDefaults.plist @@ -5,6 +5,7 @@ WOPidFile = "/var/run/sogo/sogo.pid"; NGImap4ConnectionStringSeparator = "/"; + NGImap4ConnectionGroupIdPrefix = "$"; NGImap4DisableIMAP4Pooling = YES; SOGoZipPath = "/usr/bin/zip"; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index 48b87dac8..02cc332f9 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -43,6 +43,7 @@ - (NSString *) imapServer; - (NSString *) sieveServer; - (NSString *) imapAclStyle; +- (NSString *) imapAclGroupIdPrefix; - (NSString *) imapFolderSeparator; - (BOOL) imapAclConformsToIMAPExt; - (BOOL) forceIMAPLoginWithEmail; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index 1b9dc4fe0..6acc35978 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -124,6 +124,11 @@ return [self stringForKey: @"SOGoIMAPAclStyle"]; } +- (NSString *) imapAclGroupIdPrefix +{ + return [self stringForKey: @"NGImap4ConnectionGroupIdPrefix"]; +} + - (NSString *) imapFolderSeparator { return [self stringForKey: @"NGImap4ConnectionStringSeparator"];