Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicate kernel options #854

Closed
JokerQyou opened this issue Jun 15, 2024 · 0 comments · Fixed by #855
Closed

Avoid duplicate kernel options #854

JokerQyou opened this issue Jun 15, 2024 · 0 comments · Fixed by #855

Comments

@JokerQyou
Copy link
Contributor

This is a follow-up to #557. I would like to know if the proposed changes are acceptable.

The -ko volname=XXX does not work, because gocryptfs sets volname to directory base name of the mountpoint first, then expect to override it with duplicate option-value pair. Relevant codes:

gocryptfs/mount.go

Lines 437 to 442 in f06f27e

// Add a volume name if running osxfuse. Otherwise the Finder will show it as
// something like "osxfuse Volume 0 (gocryptfs)".
if runtime.GOOS == "darwin" {
volname := strings.Replace(path.Base(args.mountpoint), ",", "_", -1)
mOpts.Options = append(mOpts.Options, "volname="+volname)
}

gocryptfs/mount.go

Lines 467 to 473 in f06f27e

// Add additional mount options (if any) after the stock ones, so the user has
// a chance to override them.
if args.ko != "" {
parts := strings.Split(args.ko, ",")
tlog.Debug.Printf("Adding -ko mount options: %v", parts)
mOpts.Options = append(mOpts.Options, parts...)
}

Basically, it would produce -o volname=BaseNameOfMountPoint,volname=CustomVolName option for macFUSE.
This appears logical at first glance, but it doesn't work as expected. macFUSE only reads the initial volname value set by gocryptfs and does not check for updates to this option later on.

I swapped these two code blocks and test on macOS Sonoma and it works as expected, the volname option can now be overridden correctly.

I think it's worth rewriting this part of gocryptfs so it only sets each option exactly once - use only user-provided option if possible, only inject stock options if they are not provided.

JokerQyou added a commit to JokerQyou/gocryptfs that referenced this issue Jun 15, 2024
Merge stock kernel options with user-provided ones before passing to go-fuse.

Before: `-ko volname=custom` would result in `-o volname=mountpoint,volname=custom` to macFUSE.

After: `-ko volname=custom` would produce `-o volname=custom` with no duplicates.

Fixes rfjakob#854 and rfjakob#557
rfjakob pushed a commit that referenced this issue Jul 27, 2024
Merge stock kernel options with user-provided ones before passing to go-fuse.

Before: `-ko volname=custom` would result in `-o volname=mountpoint,volname=custom` to macFUSE.

After: `-ko volname=custom` would produce `-o volname=custom` with no duplicates.

Fixes #854 and #557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant