Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Docker image: avoid changing user during generate
Browse files Browse the repository at this point in the history
The intention was always that the config files get written as the initial user
(normally root) - only the data directory needs to be writable by Synapse. This
got changed in #5970, but that seems
to have been a mistake.
  • Loading branch information
richvdh committed Oct 29, 2021
1 parent 3ed17ff commit d9c6f17
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions docker/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def generate_config_from_template(config_dir, config_path, environ, ownership):
]

if ownership is not None:
log(f"Setting ownership on /data to {ownership}")
subprocess.check_output(["chown", "-R", ownership, "/data"])
args = ["gosu", ownership] + args

Expand All @@ -144,12 +145,18 @@ def run_generate_config(environ, ownership):
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")

if ownership is not None:
# make sure that synapse has perms to write to the data dir.
log(f"Setting ownership on {data_dir} to {ownership}")
subprocess.check_output(["chown", ownership, data_dir])

# create a suitable log config from our template
log_config_file = "%s/%s.log.config" % (config_dir, server_name)
if not os.path.exists(log_config_file):
log("Creating log config %s" % (log_config_file,))
convert("/conf/log.config", log_config_file, environ)

# generate the main config file, and a signing key.
args = [
"python",
"-m",
Expand All @@ -168,15 +175,7 @@ def run_generate_config(environ, ownership):
"--open-private-ports",
]
# log("running %s" % (args, ))

if ownership is not None:
# make sure that synapse has perms to write to the data dir.
subprocess.check_output(["chown", ownership, data_dir])

args = ["gosu", ownership] + args
os.execv("/usr/sbin/gosu", args)
else:
os.execv("/usr/local/bin/python", args)
os.execv("/usr/local/bin/python", args)


def main(args, environ):
Expand Down

0 comments on commit d9c6f17

Please sign in to comment.