safe

Password protected secret keeper
git clone git://git.z3bra.org/safe.git
Log | Files | Refs | README | LICENSE

commit c78fe1cc1ee4a1684eb98c85334011aad6d7b59b
parent c985b9ecaa5571f5e89066de0fc6a386a3a7e556
Author: z3bra <contactatz3bradotorg>
Date:   Wed, 22 May 2019 09:43:27 +0200

Add function to list secrets

Diffstat:
safe.c | 20+++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/safe.c b/safe.c @@ -140,6 +140,14 @@ deriv(char *pw, struct safe *s) err(1, "crypto_pwhash"); } +void +list_secrets(struct safe *s) +{ + struct secret *tmp; + SLIST_FOREACH(tmp, &s->secrets, entry) + printf("%s\t%s\n", tmp->hex, tmp->name); +} + int store_secret(struct safe *s, int fd, char *name) { @@ -248,7 +256,7 @@ deinit(struct safe *s) int main(int argc, char *argv[]) { - int aflag = 0; + int aflag = 0, lflag = 0; char *secret = NULL, *safe = SAFE; struct safe s; @@ -256,6 +264,9 @@ main(int argc, char *argv[]) case 'a': aflag = 1; break; + case 'l': + lflag = 1; + break; case 's': safe = EARGF(usage()); break; @@ -263,7 +274,7 @@ main(int argc, char *argv[]) usage(); } ARGEND - if (argc != 1) + if (argc != 1 && !lflag) usage(); if (safe) { @@ -279,7 +290,10 @@ main(int argc, char *argv[]) secret = argv[0]; - if (aflag) { + if (lflag) { + list_secrets(&s); + return 0; + } else if (aflag) { store_secret(&s, STDIN_FILENO, secret); deinit(&s); } else {