Skip to content

Commit

Permalink
Merge pull request #27 from NethServer/noPasswordInEnv
Browse files Browse the repository at this point in the history
Store admin password in separate file NethServer/dev#6969
  • Loading branch information
stephdl authored Jul 29, 2024
2 parents 8250a7c + 80441a0 commit cb29c17
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
5 changes: 1 addition & 4 deletions imageroot/actions/configure-module/20configure
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ password = data.get("admin_password", "")
agent.set_env("TRAEFIK_HOST", host)
agent.set_env("TRAEFIK_HTTP2HTTPS", h2hs)
agent.set_env("TRAEFIK_LETS_ENCRYPT", le)
agent.set_env("ADMIN_PASSWORD", password)
agent.write_envfile("password.env", {"password": password})

# Make sure everything is saved inside the environment file
# just before starting systemd unit
agent.dump_env()

# Find default traefik instance for current node
default_traefik_id = agent.resolve_agent_id('traefik@node')
Expand Down
6 changes: 5 additions & 1 deletion imageroot/actions/get-configuration/20read
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import agent
# Prepare return variable
config = {}

config["admin_password"] = os.environ.get("ADMIN_PASSWORD",'')
if os.path.exists("password.env"):
config["admin_password"] = agent.read_envfile("password.env")["password"]
else:
config["admin_password"] = ""

config["host"] = os.environ.get("TRAEFIK_HOST",'')
config["http2https"] = os.environ.get("TRAEFIK_HTTP2HTTPS","False") == "True"
config["lets_encrypt"] = os.environ.get("TRAEFIK_LETS_ENCRYPT","False") == "True"
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/collabora.service
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ExecStart=/usr/bin/podman run --conmon-pidfile %t/collabora.pid \
--replace -d --name collabora --cap-add MKNOD \
--env aliasgroup2=https://${TRAEFIK_HOST}:443 \
--env username=admin \
--env password=${ADMIN_PASSWORD} \
--env-file=%S/state/password.env \
--env "extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:security.capabilities=false" \
--env dictionnaries="de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru" \
--publish 127.0.0.1:${TCP_PORT}:9980 \
Expand Down
18 changes: 18 additions & 0 deletions imageroot/update-module.d/10upgrade_password
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

#
# Copyright (C) 2024 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#
import sys
import agent
import os

# perform the upgrade from collabora:1.0.5

# Get the ADMIN_PASSWORD environment variable
admin_password = os.getenv('ADMIN_PASSWORD')

if admin_password:
agent.write_envfile("password.env", {"password": admin_password})
agent.unset_env("ADMIN_PASSWORD")

0 comments on commit cb29c17

Please sign in to comment.