mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-06-24 09:14:56 +03:00
The teardown cleanup added for #15183 only runs on a clean disconnect. If the service or its --server crashes before then, the headless logind session scope and the /tmp/.X<n> lock files it created leak the same way #15183 leaked them, with nothing to reclaim them afterwards. Record the session scope and display when the headless session starts, and on the next --server start reap exactly what the previous run recorded, then drop the marker. It only ever touches the one scope and display the previous run recorded, never a scan, so unrelated sessions are untouched; the reap and X cleanup reuse the teardown path. A logind session id is only unique within a boot: the counter lives in /run and resets, so a recorded "session-N.scope" can name a different, live session after a reboot. Tag the marker with the boot id and only reap the scope when it matches the current boot. A leaked cgroup cannot outlive a reboot, so nothing legitimate is lost cross-boot; the X lock cleanup stays pid-guarded and runs either way. Signed-off-by: TBX3D <88289044+TBX3D@users.noreply.github.com>