aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gpg.c5
-rw-r--r--gpg.h2
-rw-r--r--pass_util.c26
3 files changed, 5 insertions, 28 deletions
diff --git a/gpg.c b/gpg.c
index 3d37c09..8daeb3c 100644
--- a/gpg.c
+++ b/gpg.c
@@ -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);
diff --git a/gpg.h b/gpg.h
index 461a9d5..eda5e72 100644
--- a/gpg.h
+++ b/gpg.h
@@ -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;
}