From 806d768bbcdd66b1b535318b36ef1019f2c49704 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 16 Jan 2026 12:14:48 +0100 Subject: [PATCH] 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 --- CHANGELOG.md | 2 ++ VERSION | 2 +- backend/update.py | 31 +++++++++++++++------------- project-management/PROJECT_STATUS.md | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef9c71..51944d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 | ๐Ÿงช 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 | ๐Ÿž 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 diff --git a/VERSION b/VERSION index 448a0fa..c2c0004 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.4 \ No newline at end of file +0.3.5 diff --git a/backend/update.py b/backend/update.py index aee873f..f234cf3 100644 --- a/backend/update.py +++ b/backend/update.py @@ -199,30 +199,33 @@ def report_status( def _run_async(script_path: Path, settings: Settings) -> None: - env = os.environ.copy() - env["SKD_UPDATE_SERVICE_URL"] = settings.update_service_url - env["SKD_UPDATE_PROJECT_ID"] = settings.update_project_id - env["SKD_UPDATE_TOKEN"] = _get_fresh_token(settings) - env["SKD_UPDATE_STATUS_FILE"] = settings.update_status_file - env["SKD_UPDATE_LOG_FILE"] = settings.update_log_file + # Explicitly gather the env vars we need to pass + env_vars = { + "SKD_UPDATE_SERVICE_URL": settings.update_service_url, + "SKD_UPDATE_PROJECT_ID": settings.update_project_id, + "SKD_UPDATE_TOKEN": _get_fresh_token(settings), + "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. - # 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. + # Construct systemd-run command with --setenv for each variable cmd = [ "systemd-run", "--unit=skd-update", "--collect", "--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( cmd, - env=env, cwd="/", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, diff --git a/project-management/PROJECT_STATUS.md b/project-management/PROJECT_STATUS.md index 3bb3ac2..3f23976 100644 --- a/project-management/PROJECT_STATUS.md +++ b/project-management/PROJECT_STATUS.md @@ -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) # Projekt-Status