fix(process-registry): use portable /bin/sh probe for systemd-run scope availability (#105365)
This commit is contained in:
@@ -207,7 +207,12 @@ def _systemd_run_user_scope_available() -> bool:
|
||||
"""True if ``systemd-run --user --scope`` can create a cgroup.
|
||||
``shutil.which`` alone is insufficient: system services and containers may lack
|
||||
the user D-Bus bus even with the binary on PATH (every spawn would fail with
|
||||
``Failed to connect to user bus``), so a cheap ``/bin/true`` probe is run and cached."""
|
||||
``Failed to connect to user bus``), so a cheap probe is run and cached.
|
||||
|
||||
The probe payload is ``/bin/sh -c 'exit 0'`` rather than ``/bin/true``: NixOS has
|
||||
no FHS ``/bin`` (only ``sh``), so an absolute ``/bin/true`` probe fails there for a
|
||||
reason unrelated to scope availability and disables restart-safe cron dispatch on
|
||||
every scheduled fire (#105365).``"""
|
||||
global _SYSTEMD_SCOPE_AVAILABLE, _SYSTEMD_SCOPE_PROBED_AT
|
||||
verdict = _systemd_scope_cached()
|
||||
if verdict is not None:
|
||||
@@ -228,7 +233,7 @@ def _systemd_run_user_scope_available() -> bool:
|
||||
# Unique unit avoids collisions; the timeout bounds D-Bus.
|
||||
probe_unit = f"hermes-probe-scope-{os.getpid()}-{uuid.uuid4().hex[:8]}"
|
||||
result = subprocess.run(
|
||||
_systemd_scope_argv(binary, probe_unit, "/bin/true"),
|
||||
_systemd_scope_argv(binary, probe_unit, "/bin/sh", "-c", "exit 0"),
|
||||
capture_output=True,
|
||||
timeout=3,
|
||||
env=systemd_user_bus_env(),
|
||||
|
||||
Reference in New Issue
Block a user