main: sanitize commas from fsname

The cipherdir path is used as the fsname, as displayed
in "df -T". Now, having a comma in fsname triggers a sanity check
in go-fuse, aborting the mount with:

  /bin/fusermount: mount failed: Invalid argument
  fuse.NewServer failed: fusermount exited with code 256

Sanitize fsname by replacing any commas with underscores.

https://github.com/rfjakob/gocryptfs/issues/262
This commit is contained in:
Jakob Unterwurzacher 2018-09-18 19:35:31 +02:00
parent e8d8ae54d3
commit 5ca6243eeb
2 changed files with 22 additions and 0 deletions

View File

@ -309,6 +309,11 @@ func initGoFuse(fs pathfs.FileSystem, args *argContainer) *fuse.Server {
if args.fsname != "" {
fsname = args.fsname
}
fsname2 := strings.Replace(fsname, ",", "_", -1)
if fsname2 != fsname {
tlog.Warn.Printf("Warning: %q will be displayed as %q in \"df -T\"", fsname, fsname2)
fsname = fsname2
}
mOpts.Options = append(mOpts.Options, "fsname="+fsname)
// Second column, "Type", will be shown as "fuse." + Name
mOpts.Name = "gocryptfs"

View File

@ -518,3 +518,20 @@ func TestConfigPipe(t *testing.T) {
}
test_helpers.UnmountPanic(mnt)
}
// Ciphertext dir and mountpoint contains a comma
// https://github.com/rfjakob/gocryptfs/issues/262
func TestComma(t *testing.T) {
dir0 := test_helpers.InitFS(t)
dir := dir0 + ",foo,bar"
err := os.Rename(dir0, dir)
if err != nil {
t.Fatal(err)
}
mnt := dir + ".mnt"
err = test_helpers.Mount(dir, mnt, false, "-extpass", "echo test", "-wpanic=0")
if err != nil {
t.Fatalf("Failed to mount %q on %q: %v", dir, mnt, err)
}
test_helpers.UnmountPanic(mnt)
}