diff options
Diffstat (limited to 'pass_util.c')
-rw-r--r-- | pass_util.c | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/pass_util.c b/pass_util.c index d08f982..01fb8b3 100644 --- a/pass_util.c +++ b/pass_util.c @@ -85,37 +85,17 @@ int pass_init(const char *fpr) const char *pass_cat(const char *path) { int r; - char *rc; - char gpg_id_path[PATH_MAX], fpr[FPR_MAX], pass_path[PATH_MAX]; - FILE *gpg_id; + char pass_path[PATH_MAX]; r = set_pass_dir(); if (r) err_die(NULL, "PASSWORD_STORE_DIR not set"); - r = snprintf(gpg_id_path, sizeof(gpg_id_path), "%s/%s", pass_dir, ".gpg-id"); - if (r > (int) sizeof(gpg_id_path)) - err_die(NULL, "path exceeded PATH_MAX"); - - gpg_id = fopen(gpg_id_path, "r"); - if (!gpg_id) - err_die(NULL, "%s %s", gpg_id_path, strerror(errno)); - - rc = fgets(fpr, sizeof(fpr), gpg_id); - if (!rc) - err_die(NULL, "failed to read %s", gpg_id_path); - - fclose(gpg_id); - - r = gpg_key_validate(fpr); - if (r) - err_die(NULL, "key not usable, try gpg --list-keys"); - r = snprintf(pass_path, sizeof(pass_path), "%s/%s.gpg", pass_dir, path); - if (r > (int) sizeof(gpg_id_path)) + if (r >= (int) sizeof(pass_path)) err_die(NULL, "path exceeded PATH_MAX"); - r = gpg_decrypt(fpr, pass_path, pass_out, sizeof(pass_out)); + r = gpg_decrypt(pass_path, pass_out, sizeof(pass_out)); return r ? NULL : pass_out; } |