diff options
author | Jakob Unterwurzacher | 2025-06-28 16:22:29 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2025-07-09 19:28:09 +0200 |
commit | b499c26526ff3a257310ed9fc2c04680d3ee4ab6 (patch) | |
tree | b2a8408eaf40f6ed94e18a36d29a03d43d8b9715 /internal/fusefrontend_reverse/root_node.go | |
parent | 8372f8b94769827c2055195f59f7ea277e3aef9f (diff) |
fusefrontend_reverse: switch from sabhiram/go-gitignore to internal/go-git-gitignore
Diffstat (limited to 'internal/fusefrontend_reverse/root_node.go')
-rw-r--r-- | internal/fusefrontend_reverse/root_node.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/fusefrontend_reverse/root_node.go b/internal/fusefrontend_reverse/root_node.go index 9c2de28..9f4040d 100644 --- a/internal/fusefrontend_reverse/root_node.go +++ b/internal/fusefrontend_reverse/root_node.go @@ -16,12 +16,11 @@ import ( "github.com/rfjakob/gocryptfs/v2/internal/contentenc" "github.com/rfjakob/gocryptfs/v2/internal/exitcodes" "github.com/rfjakob/gocryptfs/v2/internal/fusefrontend" + gitignore "github.com/rfjakob/gocryptfs/v2/internal/go-git-gitignore" "github.com/rfjakob/gocryptfs/v2/internal/inomap" "github.com/rfjakob/gocryptfs/v2/internal/nametransform" "github.com/rfjakob/gocryptfs/v2/internal/syscallcompat" "github.com/rfjakob/gocryptfs/v2/internal/tlog" - - ignore "github.com/sabhiram/go-gitignore" ) // RootNode is the root directory in a `gocryptfs -reverse` mount @@ -34,7 +33,7 @@ type RootNode struct { // Content encryption helper contentEnc *contentenc.ContentEnc // Tests whether a path is excluded (hidden) from the user. Used by -exclude. - excluder ignore.IgnoreParser + excluder gitignore.Matcher // inoMap translates inode numbers from different devices to unique inode // numbers. inoMap *inomap.InoMap @@ -132,14 +131,18 @@ func (rn *RootNode) findLongnameParent(fd int, diriv []byte, longname string) (p return } -// isExcludedPlain finds out if the plaintext path "pPath" is -// excluded (used when -exclude is passed by the user). -func (rn *RootNode) isExcludedPlain(pPath string) bool { +// isExcludedSt finds out if the plaintext path "pPath" with the stat result +// "st.Mode" is excluded (used when -exclude is passed by the user). +func (rn *RootNode) isExcludedMode(pPath string, mode uint32) bool { // root dir can't be excluded if pPath == "" { return false } - return rn.excluder != nil && rn.excluder.MatchesPath(pPath) + if rn.excluder == nil { + return false + } + isDir := mode&syscall.S_IFDIR != 0 + return rn.excluder.Match(strings.Split(pPath, "/"), isDir) } // excludeDirEntries filters out directory entries that are "-exclude"d. @@ -154,8 +157,9 @@ func (rn *RootNode) excludeDirEntries(d *dirfdPlus, entries []fuse.DirEntry) (fi // filepath.Join handles the case of pDir="" correctly: // Join("", "foo") -> "foo". This does not: pDir + "/" + name" p := filepath.Join(d.pPath, entry.Name) - if rn.isExcludedPlain(p) { - // Skip file + if rn.isExcludedMode(p, entry.Mode) { + // Skip file, and don't leak the plaintext name in the logs. + tlog.Debug.Printf("excludeDirEntries: ino%d is excluded. Skipping.", entry.Ino) continue } filtered = append(filtered, entry) |