diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-05-28 14:11:06 +0200 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-05-28 14:11:06 +0200 |
commit | dab9f09e2fb19652611e07353c126d90aef5312a (patch) | |
tree | 08e88a350bbc1ea658bce05353c09ca5e9575c54 /bin | |
parent | a39311109485ac73425afff0521af5f772ff63e7 (diff) | |
download | pykolab-dab9f09e2fb19652611e07353c126d90aef5312a.tar.gz |
Introduce a timeout for requests that end prematurely and never reach the data protocol state (#780)
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/kolab_smtp_access_policy.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bin/kolab_smtp_access_policy.py b/bin/kolab_smtp_access_policy.py index bc53278..ed1ce21 100755 --- a/bin/kolab_smtp_access_policy.py +++ b/bin/kolab_smtp_access_policy.py @@ -1222,12 +1222,18 @@ def read_request_input(): containing the request. """ + start_time = time.time() + log.debug(_("Starting to loop for new request")) policy_request = {} end_of_request = False while not end_of_request: + if (time.time()-start_time) >= conf.timeout: + log.warning(_("Timeout for policy request reading exceeded")) + sys.exit(1) + request_line = sys.stdin.readline() if request_line.strip() == '': if policy_request.has_key('request'): @@ -1268,6 +1274,12 @@ if __name__ == "__main__": _("Access Policy Options") ) + access_policy_group.add_option( "--timeout", + dest = "timeout", + action = "store", + default = 10, + help = _("SMTP Policy request timeout.")) + access_policy_group.add_option( "--verify-recipient", dest = "verify_recipient", action = "store_true", |