Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zephyr: Use correct shell quoting for ssh.
Anders Kaseorg1346c5397aac
diff --git a/zerver/tests/test_zephyr.py b/zerver/tests/test_zephyr.pyindex 4b1ac764967..8c6dffaf05c 100644--- a/zerver/tests/test_zephyr.py+++ b/zerver/tests/test_zephyr.py@@ -66,10 +66,7 @@ class ZephyrTest(ZulipTestCase):'ssh','server','--',- '/home/zulip/python-zulip-api/zulip/integrations/zephyr/process_ccache',- 'starnine',- api_key,- 'MTIzNA=='])+ f'/home/zulip/python-zulip-api/zulip/integrations/zephyr/process_ccache starnine {api_key} MTIzNA=='])# Accounts whose Kerberos usernames are known not to match their# zephyr accounts are hardcoded, and should be handled properly.@@ -92,7 +89,4 @@ class ZephyrTest(ZulipTestCase):'ssh','server','--',- '/home/zulip/python-zulip-api/zulip/integrations/zephyr/process_ccache',- 'starnine',- api_key,- 'MTIzNA=='])+ f'/home/zulip/python-zulip-api/zulip/integrations/zephyr/process_ccache starnine {api_key} MTIzNA=='])diff --git a/zerver/views/zephyr.py b/zerver/views/zephyr.pyindex 7d733995907..7047bb23a27 100644--- a/zerver/views/zephyr.py+++ b/zerver/views/zephyr.py@@ -1,6 +1,7 @@import base64import loggingimport re+import shleximport subprocessfrom typing import Optional@@ -57,11 +58,14 @@ def webathena_kerberos_login(request: HttpRequest, user_profile: UserProfile,# TODO: Send these data via (say) rabbitmqtry:api_key = get_api_key(user_profile)+ command = [+ "/home/zulip/python-zulip-api/zulip/integrations/zephyr/process_ccache",+ user,+ api_key,+ base64.b64encode(ccache).decode("utf-8"),+ ]subprocess.check_call(["ssh", settings.PERSONAL_ZMIRROR_SERVER, "--",- "/home/zulip/python-zulip-api/zulip/integrations/zephyr/process_ccache",- user,- api_key,- base64.b64encode(ccache).decode("utf-8")])+ " ".join(map(shlex.quote, command))])except Exception:logging.exception("Error updating the user's ccache", stack_info=True)return json_error(_("We were unable to setup mirroring for you"))