diff options
-rw-r--r-- | gpg.c | 5 | ||||
-rw-r--r-- | gpg.h | 2 | ||||
-rw-r--r-- | pass_util.c | 26 |
3 files changed, 5 insertions, 28 deletions
@@ -64,7 +64,7 @@ int gpg_key_validate(const char *fpr) return 0; } -int gpg_decrypt(const char *fpr, const char *path, char *pass_out, size_t n) +int gpg_decrypt(const char *path, char *pass_out, size_t n) { int r; gpgme_data_t in, out; @@ -74,9 +74,6 @@ int gpg_decrypt(const char *fpr, const char *path, char *pass_out, size_t n) if (r) return r; - err = gpgme_get_key(ctx, fpr, &key, 1); - fail_if_err(err); - err = gpgme_data_new_from_file(&in, path, 1); fail_if_err(err); err = gpgme_data_new(&out); @@ -2,5 +2,5 @@ #include <sys/types.h> int gpg_key_validate(const char *fpr); -int gpg_decrypt(const char *fpr, const char *path, char *pass_out, size_t n); +int gpg_decrypt(const char *path, char *pass_out, size_t n); int gpg_encrypt(FILE *stream, const char *fpr, const char *pass, size_t n); 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; } |