pass: fix interpolation of $PASSWORD_STORE_DIR, and use os.UserHomeDir()#287
pass: fix interpolation of $PASSWORD_STORE_DIR, and use os.UserHomeDir()#287crazy-max merged 2 commits intodocker:masterfrom
Conversation
commit a13ff50 simplified the handling of env-vars in getPassDir(), but moved interpolation of env-vars to the end of the function. As a result, a custom path passed through `$PASSWORD_STORE_DIR` would now be interpolated, instead of taken as-is. For example; PASSWORD_STORE_DIR=$PWD/world Would now interpolate `$PWD`, instead of using a literal `$PWD`. This patch changes the logic to only expand env-vars for the default location. Signed-off-by: Sebastiaan van Stijn <[email protected]>
|
I'll do a follow-up to improve the home-dir lookup (now that we made |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #287 +/- ##
=======================================
Coverage 54.68% 54.68%
=======================================
Files 9 9
Lines 673 673
=======================================
Hits 368 368
Misses 262 262
Partials 43 43
☔ View full report in Codecov by Sentry. |
|
@crazy-max ptal 😅 |
| return passDir | ||
| } | ||
| return os.ExpandEnv(passDir) | ||
| return os.ExpandEnv("$HOME/.password-store") |
There was a problem hiding this comment.
I think it would be safer to use os.UserHomeDir():
| return os.ExpandEnv("$HOME/.password-store") | |
| homedir, err := os.UserHomeDir() | |
| if err != nil { | |
| return "", err | |
| } | |
| return path.Join(homedir, ".password-store"), nil |
WDYT?
There was a problem hiding this comment.
Heh, yes, I have something like that staged #287 (comment)
I'll do a follow-up to improve the home-dir lookup (now that we made pass compile for other platforms as well), but making this fix separate first.
There was a problem hiding this comment.
I actually started with that, and then changed it back to the most minimal changes for this PR 😅
Use stdlib's os.UserHomeDir() instead of depending only on $HOME. Note that this does not yet does nss lookups for situations where $HOME / $USERPROFILE is not set. Signed-off-by: Sebastiaan van Stijn <[email protected]>
|
Added a commit to use |
commit a13ff50 (#109) simplified the handling of env-vars in getPassDir(), but moved interpolation of env-vars to the end of the function.
As a result, a custom path passed through
$PASSWORD_STORE_DIRwould now be interpolated, instead of taken as-is. For example;Would now interpolate
$PWD, instead of using a literal$PWD.This patch changes the logic to only expand env-vars for the default location.
pass: make home-dir resolution platform agnostic
Use stdlib's
os.UserHomeDir()instead of depending only on$HOME. Note thatthis does not yet does nss lookups for situations where
$HOME/$USERPROFILEis not set.