tFail early when pushing key if socket is not set - safe - password protected secret keeper
(HTM) git clone git://git.z3bra.org/safe.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 41e7172dd2f4194452b6c03709e0cc5f3c7418b8
(DIR) parent e4c62d2894b9a3536e0251575bae76a12a3f152c
(HTM) 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:
M safe.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
---
(DIR) diff --git a/safe.c b/safe.c
t@@ -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);
t@@ -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];