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:
@@ -31,6 +31,14 @@ const home = "/home/operator"
|
||||
|
||||
func withTree(m *Manager, t tree) *Manager {
|
||||
m.Home, m.ReadDir = home, t.readDir
|
||||
m.Lstat = func(path string) (Entry, error) {
|
||||
for _, e := range t[filepath.Dir(path)] {
|
||||
if e.Name == filepath.Base(path) {
|
||||
return e, nil
|
||||
}
|
||||
}
|
||||
return Entry{}, fs.ErrNotExist
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -263,6 +271,7 @@ func TestAGlobIsRefusedAsAUnitByEveryVerb(t *testing.T) {
|
||||
}
|
||||
var calls []call
|
||||
m := withTree(operator(fake(func(call) Ran { return Ran{} }, &calls)), tree{})
|
||||
m.State = t.TempDir()
|
||||
for _, tool := range tools(m) {
|
||||
verb := strings.TrimPrefix(tool.Name, seat+".")
|
||||
if verb == "units" || verb == "failed" {
|
||||
@@ -418,6 +427,9 @@ func TestReadDirListsByLstat(t *testing.T) {
|
||||
if !reflect.DeepEqual(entries, want) {
|
||||
t.Fatalf("%+v", entries)
|
||||
}
|
||||
if e, err := lstatEntry(filepath.Join(dir, "x.service")); err != nil || e.Link != "" || e.Dangles || e.Dir {
|
||||
t.Fatalf("%+v %v", e, err)
|
||||
}
|
||||
if _, err := readDir(filepath.Join(dir, "absent")); !errors.Is(err, fs.ErrNotExist) {
|
||||
t.Fatalf("a missing directory: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user