mirror of
https://github.com/gopasspw/gopass.git
synced 2026-05-30 11:18:48 +02:00
09ea7700cc
Fixes #2897. Two bugs were present: 1. CleanPath in pkg/fsutil incorrectly expanded ~/... when GOPASS_HOMEDIR was set: it used path[2:] (stripping both '~' and '/'), concatenating without a path separator. E.g. '~/.local' with GOPASS_HOMEDIR=/foo became '/foo.local' instead of '/foo/.local'. Fix: use path[1:] to keep the separator, matching the existing os.UserHomeDir branch. 2. Absolute paths were written to config for [mounts] path entries, making configs non-portable across machines/platforms when synced. Fix: - Add ShrinkPath() to pkg/fsutil: converts an absolute path back to a ~/... relative form when it falls under GOPASS_HOMEDIR (if set) or the user home directory. This makes stored paths portable. - Call ShrinkPath() in Config.SetPath() and Config.SetMountPath() so paths are always persisted in ~/... form. - Apply CleanPath() in Config.Path() and Config.MountPath() so callers always receive a fully-expanded absolute path regardless of what is stored on disk. - Expand rootPath via CleanPath() in newWithOptions() before passing it to gitconfig.LoadAll(), since the gitconfig library does not perform tilde expansion. Without this the root store local config was loaded from a literal '~/' directory relative to the working directory. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>