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:12:37 +0200 |
commit | 70851f82d1d67336cde884569d37bc484361e53f (patch) | |
tree | f2932807a7ea219546d15a5e7050c0a6ae215fd3 /bin/kolab_smtp_access_policy.py | |
parent | 3b3d2b56a880e9ce08a3bb1279860d4dc6eed069 (diff) | |
download | pykolab-70851f82d1d67336cde884569d37bc484361e53f.tar.gz |
Introduce a timeout for requests that end prematurely and never reach the data protocol state (#780)
Diffstat (limited to 'bin/kolab_smtp_access_policy.py')
-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", |