From e898e9a320c982a075c5d301a2e1e6d1dbd2cdf1 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Thu, 23 May 2019 22:23:01 +0200 Subject: [PATCH] Make totpcgi log errors Signed-off-by: Patrick Uiterwijk --- roles/totpcgi/files/index.cgi | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/roles/totpcgi/files/index.cgi b/roles/totpcgi/files/index.cgi index 1bef479eea..52cadc88fe 100644 --- a/roles/totpcgi/files/index.cgi +++ b/roles/totpcgi/files/index.cgi @@ -190,4 +190,15 @@ def cgimain(): sys.stdout.write(success_string) if __name__ == '__main__': - cgimain() + try: + cgimain() + except Exception: + logging.exception("Server error during processing") + output = 'ERR\nInternal server error\n' + sys.stdout.write('Status: 500 SERVER ERROR\n') + sys.stdout.write('Content-type: text/plain\n') + sys.stdout.write('Content-Length: %s\n' % len(output)) + sys.stdout.write('\n') + + sys.stdout.write(output) + sys.exit(0)