Skip to content

Enable mounting to "/Volumes" on macOS #194

@alexanderharm

Description

@alexanderharm

Right now running gocryptfs encdir /Volumes/encdir errors out. However, osxfuse automatically creates the encdir if mounted to /Volumes because this would require root permissions which the user might not have.

I guess mount.go needs to be modified to not check the directory existence when the mount path matches /Volumes/* on macOS.

I'm willing to write a PR myself but I'm a total Go newbie. Not sure that these are the only critical references in the source:

gocryptfs/mount.go

Lines 38 to 65 in a4dff6a

args.mountpoint, err = filepath.Abs(flagSet.Arg(1))
if err != nil {
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
os.Exit(exitcodes.MountPoint)
}
// We cannot mount "/home/user/.cipher" at "/home/user" because the mount
// will hide ".cipher" also for us.
if args.cipherdir == args.mountpoint || strings.HasPrefix(args.cipherdir, args.mountpoint+"/") {
tlog.Fatal.Printf("Mountpoint %q would shadow cipherdir %q, this is not supported",
args.mountpoint, args.cipherdir)
os.Exit(exitcodes.MountPoint)
}
// Reverse-mounting "/foo" at "/foo/mnt" means we would be recursively
// encrypting ourselves.
if strings.HasPrefix(args.mountpoint, args.cipherdir+"/") {
tlog.Fatal.Printf("Mountpoint %q is contained in cipherdir %q, this is not supported",
args.mountpoint, args.cipherdir)
os.Exit(exitcodes.MountPoint)
}
if args.nonempty {
err = checkDir(args.mountpoint)
} else {
err = checkDirEmpty(args.mountpoint)
}
if err != nil {
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
os.Exit(exitcodes.MountPoint)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions