aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libnpass/libnpass.c16
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,