diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libnpass/libnpass.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libnpass/libnpass.c b/src/libnpass/libnpass.c index 37fc40c..b9ce58e 100644 --- a/src/libnpass/libnpass.c +++ b/src/libnpass/libnpass.c @@ -105,7 +105,7 @@ pass_store_t pass_store_type(const char *spath) { err_ret(PASS_STORE_INV, "PASSWORD_STORE_DIR not set"); r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s", - pass_dir, spath); + pass_dir, (spath) ? spath : ""); if (r >= (int) sizeof(abs_path)) err_ret(PASS_STORE_INV, "path exceeded PATH_MAX"); r = stat(abs_path, &sbuf); @@ -132,10 +132,11 @@ DIR *openstore(const char *spath) { DIR *d; const char *path; char abs_path[PATH_MAX]; + pass_store_t store_type; - r = set_pass_dir(); - if (r) - err_ret(NULL, "PASSWORD_STORE_DIR not set"); + store_type = pass_store_type(spath); + if (store_type != PASS_STORE_DIR) + err_ret(NULL, "%s is not a passwordstore directory", spath); if (spath) { r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s", @@ -263,8 +264,13 @@ int pass_init(const char *fpr) int pass_cat(FILE *out, const char *path) { int r; + pass_store_t store_type; char pass_path[PATH_MAX]; + store_type = pass_store_type(path); + if (store_type != PASS_STORE_ENC) + err_ret(1, "%s is not a passwordstore file", path); + r = set_pass_dir(); if (r) err_ret(1, "PASSWORD_STORE_DIR not set"); |