safe

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

commit ac52d5dbb901eb0a7039843b3bd87acd3b2f7d64
parent cadbbb3e8554063b5f363c0b395fa7849072dfa5
Author: Willy Goiffon <dev@z3bra.org>
Date:   Fri, 28 Jun 2019 14:02:23 +0200

Allow decrypting secrets when -r is specified

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

diff --git a/safe.c b/safe.c @@ -435,15 +435,8 @@ main(int argc, char *argv[]) hasmaster = 0; } - if (!rflag && sockp) { - if (!readkey(&s, sockp)) - haskey = 1; - } - - if (rflag && !sockp) { - fprintf(stderr, "SAFE_SOCK variable is not set\n"); - return -1; - } + if (sockp && !readkey(&s, sockp)) + haskey = 1; if (!haskey) { if (readpass(prompt, &passphrase, &pplen) < 0) @@ -495,11 +488,20 @@ main(int argc, char *argv[]) } close(fd); - if (rflag) - return pushkey(&s, sockp); + /* push the key to a running agent */ + if (rflag) { + if (!sockp) { + fprintf(stderr, "SAFE_SOCK variable is not set\n"); + return -1; + } + pushkey(&s, sockp); + } secret = argv[0]; + if (!secret) + return 0; + if (aflag) { mkdir_p(dirname(secret), 0700); fd = open(secret, O_WRONLY | O_CREAT | O_EXCL, 0600);