reverse mode: -exclude: filter out excluded .name files

Fixes https://github.com/rfjakob/gocryptfs/issues/286 :

While the actual file is properly excluded, the * .name file is still leaked in the directory listing:

```
drwxr-xr-x 2 sebastian sebastian 4,0K Dez 17 14:58 .
drwxr-xr-x 7 sebastian sebastian 4,0K Dez 17 14:45 ..
-r-------- 1 sebastian sebastian  408 Dez 17 14:56 gocryptfs.conf
-r--r--r-- 1 sebastian sebastian   16 Dez 17 14:58 gocryptfs.diriv
-r--r--r-- 1 sebastian sebastian  320 Dez 17 14:58 gocryptfs.longname.3vZ_r3eDPb1_fL3j5VA4rd_bcKWLKT9eaxOVIGK5HFA.name
```
This commit is contained in:
Jakob Unterwurzacher 2019-01-04 17:59:00 +01:00
parent 58f62ada46
commit 6b94f5ef51

View File

@ -74,6 +74,15 @@ func NewFS(args fusefrontend.Args, c *contentenc.ContentEnc, n *nametransform.Na
os.Exit(exitcodes.ExcludeError)
}
fs.cExclude = append(fs.cExclude, cPath)
if !fs.args.PlaintextNames {
// If we exclude
// gocryptfs.longname.3vZ_r3eDPb1_fL3j5VA4rd_bcKWLKT9eaxOVIGK5HFA
// we should also exclude
// gocryptfs.longname.3vZ_r3eDPb1_fL3j5VA4rd_bcKWLKT9eaxOVIGK5HFA.name
if nametransform.IsLongContent(filepath.Base(cPath)) {
fs.cExclude = append(fs.cExclude, cPath+nametransform.LongNameSuffix)
}
}
}
tlog.Debug.Printf("-exclude: %v -> %v", fs.args.Exclude, fs.cExclude)
}
@ -361,10 +370,10 @@ func (rfs *ReverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse.
}
entries[i].Name = cName
}
// Filter out excluded entries
entries = rfs.excludeDirEntries(cipherPath, entries)
// Add virtual files
entries = append(entries, virtualFiles[:nVirtual]...)
// Filter out excluded entries
entries = rfs.excludeDirEntries(cipherPath, entries)
return entries, fuse.OK
}