Serve unlink-dangling, so a leftover enable link goes through the seat

systemctl disable leaves a link whose unit file is gone, and the manager
keeps asking for the unit. The verb removes only such links in the
account's or the machine's own configuration, on the person's word, and
records each with its reason before removing it (hq issue 332).
This commit is contained in:
jochen
2026-10-08 17:53:53 +02:00
parent e740683ca4
commit 87c9d9f7e5
7 changed files with 395 additions and 9 deletions
+7 -1
View File
@@ -98,7 +98,7 @@ func execRunner(cmd string, args []string, env []string) Ran {
const MeshUnitHeader = "# Generated by the mesh."
// acts are the verbs that change the system manager's state, which polkit keeps from a non-root account.
var acts = map[string]bool{"start": true, "stop": true, "restart": true, "enable": true, "disable": true, "reset-failed": true}
var acts = map[string]bool{"start": true, "stop": true, "restart": true, "enable": true, "disable": true, "reset-failed": true, "daemon-reload": true}
// escalated is the command as it is run: as given when this process is root, or in the user scope, or
// when the call is a systemctl read; else through sudo without a prompt — an act on the system manager,
@@ -141,6 +141,12 @@ type Manager struct {
Home string
// ReadDir lists a directory, to find the enable links naming a unit (wanted.go).
ReadDir func(dir string) ([]Entry, error)
// Lstat reads one path again just before it is removed, and Remove removes one the account owns (unlink.go).
Lstat func(path string) (Entry, error)
Remove func(path string) error
// State is the module's state directory, where each removed link is recorded.
State string
Now func() time.Time
}
var userBus = regexp.MustCompile(`(?i)Failed to connect to (user scope )?bus`)