diff --git a/modules/mesh-files/cmd/mesh-files/files_test.go b/modules/mesh-files/cmd/mesh-files/files_test.go index 027b54bb5..73e6b9068 100644 --- a/modules/mesh-files/cmd/mesh-files/files_test.go +++ b/modules/mesh-files/cmd/mesh-files/files_test.go @@ -711,6 +711,11 @@ func TestTheReadsFallBackToRoot(t *testing.T) { if ls, err := g.List(secretDir); err != nil || ls.Secret == "" || len(ls.Entries) != 1 || ls.Entries[0].Name != "id_rsa" { t.Errorf("a secret place was not listed through root: %+v %v", ls, err) } + g.root.fail = map[string]error{"/usr/bin/stat -c " + statFormat + " -- " + in + "/gone": errors.New( + "sudo -n /usr/bin/stat: stat: cannot statx '" + in + "/gone': No such file or directory")} + if st, err := g.Stat([]string{in + "/gone"}, false); err != nil || !strings.Contains(st.Paths[0].Stopped, "does not exist") { + t.Errorf("a missing path under a closed directory: %+v %v", st, err) + } g.root.calls = nil if _, err := g.Read(locked+"/.ssh/id_rsa", ReadAsk{}); err == nil || len(g.root.calls) != 0 { t.Errorf("a credential file was read: %v %v", err, g.root.calls) diff --git a/modules/mesh-files/cmd/mesh-files/reads.go b/modules/mesh-files/cmd/mesh-files/reads.go index 754a2e8a0..fc9c67f3e 100644 --- a/modules/mesh-files/cmd/mesh-files/reads.go +++ b/modules/mesh-files/cmd/mesh-files/reads.go @@ -314,6 +314,10 @@ var rootTypes = map[string]string{"regular file": "file", "regular empty file": func (r Reader) componentAsRoot(p string, names accounts, mounts map[string]Mount) (Component, bool) { out, err := r.Root.Run("/usr/bin/stat", "-c", statFormat, "--", p) f := strings.Split(strings.TrimSpace(string(out)), "|") + if err != nil && strings.Contains(err.Error(), "No such file or directory") { + // root reached the place and it is not there: said as missing, not as refused by the file modes. + return Component{Path: p, Unreachd: why(fs.ErrNotExist)}, true + } if err != nil || len(f) != 6 { return Component{}, false }