fix: pass env vars to systemd-run via --setenv (v0.3.5)

- Previous fix failed because systemd-run does not inherit env vars by default
- Added explicit --setenv flags for SKD_UPDATE_* variables
- Bumped version to 0.3.5
This commit is contained in:
2026-01-16 12:14:48 +01:00
parent bf7d1e466a
commit 806d768bbc
4 changed files with 21 additions and 16 deletions

View File

@ -96,6 +96,8 @@ By: Codex (GPT-5)
| 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.3 erhoeht. By: Gemini CLI | | 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.3 erhoeht. By: Gemini CLI |
| 16.01.2026 | 🧪 Test | ID: Patch-Bump auf 0.3.4 zur finalen Verifizierung nach manuellem Git-Pull am Client. By: Gemini CLI | | 16.01.2026 | 🧪 Test | ID: Patch-Bump auf 0.3.4 zur finalen Verifizierung nach manuellem Git-Pull am Client. By: Gemini CLI |
| 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.4 erhoeht. By: Gemini CLI | | 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.4 erhoeht. By: Gemini CLI |
| 16.01.2026 | 🐞 Fix | ID: Environment-Variablen explizit via --setenv an systemd-run uebergeben (Fix fuer fehlenden Token im Updater). By: Gemini CLI |
| 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.5 erhoeht. By: Gemini CLI |
--- ---
## Legende ## Legende

View File

@ -1 +1 @@
0.3.4 0.3.5

View File

@ -199,30 +199,33 @@ def report_status(
def _run_async(script_path: Path, settings: Settings) -> None: def _run_async(script_path: Path, settings: Settings) -> None:
env = os.environ.copy() # Explicitly gather the env vars we need to pass
env["SKD_UPDATE_SERVICE_URL"] = settings.update_service_url env_vars = {
env["SKD_UPDATE_PROJECT_ID"] = settings.update_project_id "SKD_UPDATE_SERVICE_URL": settings.update_service_url,
env["SKD_UPDATE_TOKEN"] = _get_fresh_token(settings) "SKD_UPDATE_PROJECT_ID": settings.update_project_id,
env["SKD_UPDATE_STATUS_FILE"] = settings.update_status_file "SKD_UPDATE_TOKEN": _get_fresh_token(settings),
env["SKD_UPDATE_LOG_FILE"] = settings.update_log_file "SKD_UPDATE_STATUS_FILE": settings.update_status_file,
"SKD_UPDATE_LOG_FILE": settings.update_log_file,
}
# Use systemd-run to detach the update process from the current service unit. # Construct systemd-run command with --setenv for each variable
# This ensures the script survives 'systemctl stop skd'.
# We use --unit to give it a predictable name prefix (though unique suffix is added)
# and --scope (or --service) to create a new unit.
# Since we need root (and likely run as root), this should work.
# Note: --collect ensures garbage collection of the transient unit.
cmd = [ cmd = [
"systemd-run", "systemd-run",
"--unit=skd-update", "--unit=skd-update",
"--collect", "--collect",
"--description=Safe Kiddo Update Process", "--description=Safe Kiddo Update Process",
str(script_path),
] ]
for key, val in env_vars.items():
if val: # Only pass if not empty
cmd.append(f"--setenv={key}={val}")
cmd.append(str(script_path))
# We don't pass 'env' parameter to Popen because systemd-run ignores it
# for the target process (it only uses it for itself, but we use --setenv).
subprocess.Popen( subprocess.Popen(
cmd, cmd,
env=env,
cwd="/", cwd="/",
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,

View File

@ -1,4 +1,4 @@
ID: STATUS_000001 | Version: 0.3.4 | Status: Final ID: STATUS_000001 | Version: 0.3.5 | Status: Final
By: Codex (GPT-5) By: Codex (GPT-5)
# Projekt-Status # Projekt-Status