Skip to content

Commit bef765b

Browse files
authored
generate configuration with correct user in start.py for docker (#16978)
1 parent 6d3ffdd commit bef765b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

changelog.d/16978.docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated start.py to generate config using the correct user ID when running as root (fixes #16824, #15202).

docker/start.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ def run_generate_config(environ: Mapping[str, str], ownership: Optional[str]) ->
160160
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
161161
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
162162

163-
if ownership is not None:
164-
# make sure that synapse has perms to write to the data dir.
165-
log(f"Setting ownership on {data_dir} to {ownership}")
166-
subprocess.run(["chown", ownership, data_dir], check=True)
167-
168163
# create a suitable log config from our template
169164
log_config_file = "%s/%s.log.config" % (config_dir, server_name)
170165
if not os.path.exists(log_config_file):
@@ -189,9 +184,15 @@ def run_generate_config(environ: Mapping[str, str], ownership: Optional[str]) ->
189184
"--generate-config",
190185
"--open-private-ports",
191186
]
187+
188+
if ownership is not None:
189+
# make sure that synapse has perms to write to the data dir.
190+
log(f"Setting ownership on {data_dir} to {ownership}")
191+
subprocess.run(["chown", ownership, data_dir], check=True)
192+
args = ["gosu", ownership] + args
193+
192194
# log("running %s" % (args, ))
193-
flush_buffers()
194-
os.execv(sys.executable, args)
195+
subprocess.run(args, check=True)
195196

196197

197198
def main(args: List[str], environ: MutableMapping[str, str]) -> None:

0 commit comments

Comments
 (0)