safe

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

commit 8d00f4085a08c0720d01d6e2eda5d186882f07fc
parent c07b6ff8bcc151cd80a182e7ee90aea3631a9386
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 24 Jun 2019 14:55:43 +0200

Fallback to password prompt if agent fails

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

diff --git a/safe.c b/safe.c @@ -189,30 +189,23 @@ readkey(struct safe *s, char *path) addr.sun_family = AF_UNIX; strcpy(addr.sun_path, path); - if ((sfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - err(1, "%s", path); + if ((sfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) return -1; - } - if (connect(sfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - err(1, "%s", path); + if (connect(sfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) return -1; - } - if ((n = xread(sfd, s->salt, sizeof(s->salt), NULL)) < 0) { - err(1, "%s", path); + if ((n = xread(sfd, s->salt, sizeof(s->salt), NULL)) < 0) return -1; - } if (!n) { + errno = ENOKEY; close(sfd); return -1; } - if (xread(sfd, s->key, sizeof(s->key), NULL) < 0) { - err(1, "%s", path); + if (xread(sfd, s->key, sizeof(s->key), NULL) < 0) return -1; - } close(sfd);