From df3676ed71257e2e0f2b87a04045ffc09b67e2d7 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 30 Mar 2012 03:58:26 +0000 Subject: [PATCH 1/5] Monotone-Parent: 1a5084ea5db1351b0b2a65c92046fb196a2c9d41 Monotone-Revision: b17a7a4c24c0ba780716921107d7401a2b21049e Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-03-30T03:58:26 --- Scripts/sogo.cron | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/sogo.cron b/Scripts/sogo.cron index 2ddfa0e07..f92405c89 100644 --- a/Scripts/sogo.cron +++ b/Scripts/sogo.cron @@ -2,14 +2,14 @@ # Vacation messages expiration # Make sure to set authname and authpassword with the credentials of a sieve admin -#0 0 * * * sogo /usr/sbin/sogo-tool expire-autoreply authname:authpassword +#0 0 * * * sogo /usr/sbin/sogo-tool expire-autoreply authname:authpassword # Email alarms - runs every minutes -#* * * * * sogo /usr/sbin/sogo-ealarms-notify +#* * * * * sogo /usr/sbin/sogo-ealarms-notify # Daily backups # - writes to /home/sogo/backups/ by default # - will keep 31 days worth of backups by default # - runs once a day by default, but can run more frequently # - make sure to set the path to sogo-backup.sh correctly -#30 0 * * * sogo /usr/share/doc/sogo/sogo-backup.sh +#30 0 * * * sogo /usr/share/doc/sogo/sogo-backup.sh From 4b059f29bde625d3673b16b0f533abd934d9df96 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 30 Mar 2012 03:59:04 +0000 Subject: [PATCH 2/5] Updated NEWS file. Monotone-Parent: b17a7a4c24c0ba780716921107d7401a2b21049e Monotone-Revision: 5325a12bb039335f9bac5a41915b567afd63a0ae Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-03-30T03:59:04 --- NEWS | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index c93bb922b..2a4b56934 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,14 @@ 1.3.15 (2012-04-DD) ------------------- New Features - - + - Sources address books are now exposed in Apple and iOS AddressBook app + using the "directory gateway" extension of CardDAV + Enhancements - + Bug Fixes - - + - fixed wrong date validation in preferences module affecting French users 1.3.14 (2012-03-23) ------------------- From c1b2384852560e973c6155eb6a7071b3782c88d4 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 30 Mar 2012 13:31:00 +0000 Subject: [PATCH 3/5] Minor improvement to the IE-only CSS. Monotone-Parent: 5325a12bb039335f9bac5a41915b567afd63a0ae Monotone-Revision: 0d7d8533911c3bec7d5b51cc919acb5aa7e15e7d Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-03-30T13:31:00 --- UI/WebServerResources/iefixes.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/UI/WebServerResources/iefixes.css b/UI/WebServerResources/iefixes.css index 7d545b4a5..3426b8de6 100644 --- a/UI/WebServerResources/iefixes.css +++ b/UI/WebServerResources/iefixes.css @@ -54,9 +54,6 @@ DIV#bgDialogDiv IMG.dragMessage { filter: alpha(opacity=70); } -TD.mailer_fieldname -{ width: 8em; } - TABLE.messageList TD { white-space: pre; } From b906cf066abaa36784811456fb023dc0f09c3ac1 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 30 Mar 2012 21:21:51 +0000 Subject: [PATCH 4/5] See ChangeLog. Monotone-Parent: 0d7d8533911c3bec7d5b51cc919acb5aa7e15e7d Monotone-Revision: 73baf2c24acbb1fb98296fc8ab448b3b3c5ba7a7 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-03-30T21:21:51 --- ChangeLog | 9 +++++++++ OGoContentStore/OCSContactFieldExtractor.m | 2 +- Tools/SOGoToolRemoveDoubles.m | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1a24929e..7d935bc7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-04-03 Francis Lachapelle + + * Tools/SOGoToolRemoveDoubles.m (-removeDoublesFromFolder) + (-amountOfFilledQuickFields): lowered the case of the + telephonenumber table fieldname. + + * OGoContentStore/OCSContactFieldExtractor.m + (-extractQuickFieldsFromVCard): idem. + 2012-03-29 Francis Lachapelle * UI/WebServerResources/UIxPreferences.js (savePreferences): fixed diff --git a/OGoContentStore/OCSContactFieldExtractor.m b/OGoContentStore/OCSContactFieldExtractor.m index d74e06fd0..8b1445316 100644 --- a/OGoContentStore/OCSContactFieldExtractor.m +++ b/OGoContentStore/OCSContactFieldExtractor.m @@ -54,7 +54,7 @@ forKey: @"c_givenName"]; value = [vCard preferredTel]; if (value) - [fields setObject: value forKey: @"c_telephoneNumber"]; + [fields setObject: value forKey: @"c_telephonenumber"]; value = [vCard preferredEMail]; if (![value isNotNull]) value = @""; diff --git a/Tools/SOGoToolRemoveDoubles.m b/Tools/SOGoToolRemoveDoubles.m index a4be92c3f..79ab21bd5 100644 --- a/Tools/SOGoToolRemoveDoubles.m +++ b/Tools/SOGoToolRemoveDoubles.m @@ -304,7 +304,7 @@ { quickFields = [NSArray arrayWithObjects: @"c_givenname", @"c_cn", @"c_sn", @"c_screenname", @"c_l", @"c_mail", - @"c_o", @"c_ou", @"c_telephoneNumber", nil]; + @"c_o", @"c_ou", @"c_telephonenumber", nil]; [quickFields retain]; } @@ -466,7 +466,7 @@ fields = [NSArray arrayWithObjects: @"c_name", @"c_givenname", @"c_cn", @"c_sn", @"c_screenname", @"c_l", @"c_mail", @"c_o", - @"c_ou", @"c_telephoneNumber", @"c_content", @"c_version", + @"c_ou", @"c_telephonenumber", @"c_content", @"c_version", @"c_creationdate", @"c_lastmodified", nil]; qualifier = [EOQualifier qualifierWithQualifierFormat: @"c_component = %@", @"vcard"]; From e034585c2bf4a5e2f61c099ff80d95fbd4c54c5f Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Wed, 4 Apr 2012 20:14:52 +0000 Subject: [PATCH 5/5] * Added a new tool: 'sogo-tool expire-sessions' Along with the associated new cronjob, this allows user sessions expiration without a custom script. * While there, sort tools in sogo-tool output Monotone-Parent: 73baf2c24acbb1fb98296fc8ab448b3b3c5ba7a7 Monotone-Revision: 858274c7be3ad2a6383c2f85c8ad10907bb43292 Monotone-Author: jraby@inverse.ca Monotone-Date: 2012-04-04T20:14:52 --- ChangeLog | 8 ++ Scripts/sogo.cron | 5 + Tools/GNUmakefile | 3 +- Tools/SOGoToolExpireUserSessions.m | 178 +++++++++++++++++++++++++++++ Tools/sogo-tool.m | 4 +- 5 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 Tools/SOGoToolExpireUserSessions.m diff --git a/ChangeLog b/ChangeLog index 7d935bc7a..e37e82dbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-04-04 Jean Raby + + * Added a new tool: 'sogo-tool expire-sessions' + Along with the associated new cronjob, this allows + user sessions expiration without a custom script. + + * While there, sort tools in sogo-tool output + 2012-04-03 Francis Lachapelle * Tools/SOGoToolRemoveDoubles.m (-removeDoublesFromFolder) diff --git a/Scripts/sogo.cron b/Scripts/sogo.cron index f92405c89..b9824d1e6 100644 --- a/Scripts/sogo.cron +++ b/Scripts/sogo.cron @@ -4,6 +4,11 @@ # Make sure to set authname and authpassword with the credentials of a sieve admin #0 0 * * * sogo /usr/sbin/sogo-tool expire-autoreply authname:authpassword +# Session cleanup - runs every minute +# - Ajust the nbMinutes parameter to suit your needs +# Example: Sessions without activity since 60 minutes will be dropped: +#* * * * * sogo /usr/sbin/sogo-tool expire-sessions 60 + # Email alarms - runs every minutes #* * * * * sogo /usr/sbin/sogo-ealarms-notify diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index 33417f935..99235cb8d 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -18,7 +18,8 @@ $(SOGO_TOOL)_OBJC_FILES += \ SOGoToolRemove.m \ SOGoToolRenameUser.m \ SOGoToolUserPreferences.m \ - SOGoToolExpireAutoReply.m + SOGoToolExpireAutoReply.m \ + SOGoToolExpireUserSessions.m TOOL_NAME += $(SOGO_TOOL) ### diff --git a/Tools/SOGoToolExpireUserSessions.m b/Tools/SOGoToolExpireUserSessions.m new file mode 100644 index 000000000..8eb530f3b --- /dev/null +++ b/Tools/SOGoToolExpireUserSessions.m @@ -0,0 +1,178 @@ +/* SOGoToolExpireUserSessions.m - this file is part of SOGo + * + * Copyright (C) 2012 Inverse inc. + * + * Author: Jean Raby + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import +#import +#import +#import +#import + +#import + +#import +#import + +#import + +#import +#import +#import +#import + +#import "SOGoTool.h" + +@interface SOGoToolExpireUserSessions : SOGoTool +@end + +@implementation SOGoToolExpireUserSessions + ++ (void) initialize +{ +} + ++ (NSString *) command +{ + return @"expire-sessions"; +} + ++ (NSString *) description +{ + return @"Expires user sessions without activity for specified number of minutes"; +} + +- (void) usage +{ + fprintf (stderr, "expire-sessions [nbMinutes]\n\n" + " nbMinutes Number of minutes of inactivity after which a user session will be expired\n" + "\n" + "The SOGoSessionExpireMinutes user default will be used if nbMinutes is not specified\n" + "The expire-sessions action should be configured as a cronjob.\n"); +} + +- (BOOL) expireUserSessionOlderThan: (int) nbMinutes +{ + BOOL rc; + EOAdaptorChannel *channel; + GCSChannelManager *cm; + NSArray *attrs, *qValues; + NSDictionary *qresult; + NSException *ex; + NSString *sql, *sessionsFolderURL; + NSURL *tableURL; + NSUserDefaults *ud; + + unsigned int now, oldest; + int sessionsToDelete; + + rc=YES; + ud = [NSUserDefaults standardUserDefaults]; + now = [[NSCalendarDate calendarDate] timeIntervalSince1970]; + oldest = now - (nbMinutes * 60); + + sessionsFolderURL = [ud stringForKey: @"OCSSessionsFolderURL"]; + if (!sessionsFolderURL) + { + if (verbose) + NSLog(@"Couldn't read OCSSessionsFolderURL"); + return rc = NO; + } + + tableURL = [[NSURL alloc] initWithString: sessionsFolderURL]; + cm = [GCSChannelManager defaultChannelManager]; + channel = [cm acquireOpenChannelForURL: tableURL]; + if (!channel) + { + /* FIXME: nice error msg */ + NSLog(@"Can't aquire channel"); + return rc=NO; + } + + sql = [NSString stringWithFormat: @"SELECT count(*) FROM %@ WHERE c_lastseen <= %d;", + [tableURL gcsTableName], oldest]; + ex = [channel evaluateExpressionX: sql]; + if (ex) + { + NSLog(@"%@", [ex reason]); + [ex raise]; + return rc=NO; + } + + attrs = [channel describeResults: NO]; + /* only one row */ + qresult = [channel fetchAttributes: attrs withZone: NULL]; + qValues = [qresult allValues]; + sessionsToDelete = [[qValues objectAtIndex: 0] intValue]; + if (sessionsToDelete) + { + if (verbose) + NSLog(@"Will be removing %d sessions", sessionsToDelete); + [channel cancelFetch]; + sql = [NSString stringWithFormat: @"DELETE FROM %@ WHERE c_lastseen <= %d;", + [tableURL gcsTableName], oldest]; + if (verbose) + NSLog(@"Removing sessions older than %d minute(s)", nbMinutes); + ex = [channel evaluateExpressionX: sql]; + if (ex) + { + NSLog(@"An exception occured while deleting old sessions: %@", [ex reason]); + [ex raise]; + return rc=NO; + } + } + else + { + if (verbose) + NSLog(@"No session to remove", sessionsToDelete); + } + + [cm releaseChannel: channel]; + return rc; +} + +- (BOOL) run +{ + BOOL rc; + int sessionExpireMinutes=0; + + rc = NO; + + if ([arguments count]) + { + sessionExpireMinutes = [[arguments objectAtIndex: 0] intValue]; + } + + if (sessionExpireMinutes > 0) + { + rc = [self expireUserSessionOlderThan: sessionExpireMinutes]; + } + else + { + [self usage]; + } + + return rc; +} + +@end diff --git a/Tools/sogo-tool.m b/Tools/sogo-tool.m index fc93456e9..ca7f052c0 100644 --- a/Tools/sogo-tool.m +++ b/Tools/sogo-tool.m @@ -143,11 +143,11 @@ [helpString appendString: @" argument1, ...\targuments passed to the" @" specified command\n\n"]; [helpString appendString: @" Available commands:\n"]; - toolsEnum = [[tools allKeys] objectEnumerator]; + toolsEnum = [[[tools allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] objectEnumerator]; while ((command = [toolsEnum nextObject])) { currentTool = [tools objectForKey: command]; - [helpString appendFormat: @"\t%@\t-- %@\n", + [helpString appendFormat: @"\t%-20@-- %@\n", command, [currentTool objectAtIndex: 1]]; }