diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-04-11 22:27:41 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-04-11 22:27:41 +0530 |
commit | 3a2526a29301a31b277d3116be933df592764055 (patch) | |
tree | 1a89bb0260caf3172be34d93f6976b5af1e9a7ae /src/libnpass | |
parent | e331153dc3db0b2d21902001f3e617022f777305 (diff) |
libnpass: improve backward compatibility with original pass
Diffstat (limited to 'src/libnpass')
-rw-r--r-- | src/libnpass/libnpass.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libnpass/libnpass.c b/src/libnpass/libnpass.c index 34b95ec..b7a0ded 100644 --- a/src/libnpass/libnpass.c +++ b/src/libnpass/libnpass.c @@ -40,6 +40,7 @@ static int set_pass_dir(void) { int r; const char *env; + struct stat statbuf; env = getenv("PASSWORD_STORE_DIR"); if (env) { @@ -47,6 +48,21 @@ static int set_pass_dir(void) return 0; } + /* + * for backward compatibility with original pass + */ + env = getenv("HOME"); + if (env) { + r = snprintf(pass_dir, sizeof(pass_dir), "%s/%s", env, + ".password-store"); + if ((size_t)r > sizeof(pass_dir)) + err_ret(PASS_STORE_INV, "path exceeded PATH_MAX"); + + r = stat(pass_dir, &statbuf); + if (!r) + return 0; + } + env = getenv("XDG_DATA_HOME"); if (env) { r = snprintf(pass_dir, sizeof(pass_dir), "%s/%s", env, |