Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

register_server: Check write access to secrets file when rotate_key.

Mateusz Mandera89a22fb07621
diff --git a/zerver/management/commands/register_server.py b/zerver/management/commands/register_server.py
index a2acc9f6e53..8772ebbf68a 100644
--- a/zerver/management/commands/register_server.py
+++ b/zerver/management/commands/register_server.py
@@ -1,3 +1,4 @@
+import os
import subprocess
from argparse import ArgumentParser
from typing import Any, Dict
@@ -80,6 +81,8 @@ class Command(ZulipBaseCommand):
"contact_email": settings.ZULIP_ADMINISTRATOR,
}
if options["rotate_key"]:
+ if not os.access(SECRETS_FILENAME, os.W_OK):
+ raise CommandError(f"{SECRETS_FILENAME} is not writable by the current user.")
request["new_org_key"] = get_random_string(64)
print(