From bb943e414d3fc8b71ebb169e31c261cd2dcd6d37 Mon Sep 17 00:00:00 2001 From: Hivert Quentin Date: Fri, 17 Nov 2023 15:50:41 +0100 Subject: [PATCH] fix(sogo-tool): add protection to expire-sessions if the input is not an integer --- Documentation/SOGoInstallationGuide.asciidoc | 3 +-- Tools/SOGoToolExpireUserSessions.m | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 2db47d228..e48a43717 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -3515,13 +3515,12 @@ without activity for specified number of minutes. Those users will have to log i sogo-tool expire-sessions [nbMinutes] * *nbMinutes* Integer, number of minutes. All session without activity in these last minutes will be removed. -* _*Warning*_ Putting anything other that a number will be count as 0 minutes... Example: ---- sogo-tool expire-sessions #Will print usage. sogo-tool expire-sessions 160 #Will remove session which last activity is older than 160 minutes. -sogo-tool expire-sessions --help #Will remove session which last activity is older than 0 minutes. +sogo-tool expire-sessions 0 #Will remove session which last activity is older than 0 minutes. ---- sogo-tool manage-acl diff --git a/Tools/SOGoToolExpireUserSessions.m b/Tools/SOGoToolExpireUserSessions.m index aeedc00e9..9aabd1d6a 100644 --- a/Tools/SOGoToolExpireUserSessions.m +++ b/Tools/SOGoToolExpireUserSessions.m @@ -140,7 +140,12 @@ NSLog(@"Remove all sessions older than %d min", sessionExpireMinutes); - if (sessionExpireMinutes >= 0) + if (sessionExpireMinutes == 0 && ![[arguments objectAtIndex: 0] isEqualToString:@"0"]) + { + //If the input is not a number intValue return 0 so we check that's really the case + [self usage]; + } + else if (sessionExpireMinutes >= 0) { rc = [self expireUserSessionOlderThan: sessionExpireMinutes]; }