safe

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

commit 41e7172dd2f4194452b6c03709e0cc5f3c7418b8
parent e4c62d2894b9a3536e0251575bae76a12a3f152c
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue, 25 Jun 2019 14:36:25 +0200

Fail early when pushing key if socket is not set

Diffstat:
safe.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/safe.c b/safe.c @@ -361,11 +361,16 @@ main(int argc, char *argv[]) if (fd < 0 && errno != ENOENT) err(1, "%s", MASTER); - if (sockp && !pflag) { + if (!pflag && sockp) { if (!readkey(&s, sockp)) haskey = 1; } + if (pflag && !sockp) { + fprintf(stderr, "SAFE_SOCK variable is not set\n"); + return -1; + } + if (!haskey) { readpass("password:", &passphrase, &pplen); sodium_mlock(passphrase, pplen); @@ -412,12 +417,8 @@ main(int argc, char *argv[]) } close(fd); - if (pflag) { - if (!sockp) - return -1; - + if (pflag) return pushkey(&s, sockp); - } secret = argv[0];