URI: 
       tRemove test on errno from logic - safe - password protected secret keeper
  HTML git clone git://git.z3bra.org/safe.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit d29f4d7d42826983eb47319afa94fe4b7af696ca
   DIR parent 3c694e0f523bbb3332de0efa5721c3940b1a556a
  HTML Author: Willy Goiffon <dev@z3bra.org>
       Date:   Wed, 26 Jun 2019 14:32:18 +0200
       
       Remove test on errno from logic
       
       Diffstat:
         M safe.c                              |      11 +++++++----
       
       1 file changed, 7 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/safe.c b/safe.c
       t@@ -320,7 +320,7 @@ readsecret(struct safe *s, int in, int out)
        int
        main(int argc, char *argv[])
        {
       -        int fd, haskey = 0, aflag = 0, pflag = 0;
       +        int fd, haskey = 0, hasmaster = 1, aflag = 0, pflag = 0;
                char *secret = NULL, *sockp = NULL, *safe = SAFE;
                struct safe s;
        
       t@@ -358,8 +358,11 @@ main(int argc, char *argv[])
        
                /* open master password as read only to retrieve salt */
                fd = open(MASTER, O_RDONLY);
       -        if (fd < 0 && errno != ENOENT)
       -                err(1, "%s", MASTER);
       +        if (fd < 0) {
       +                if (errno != ENOENT)
       +                        err(1, "%s", MASTER);
       +                hasmaster = 0;
       +        }
        
                if (!pflag && sockp) {
                        if (!readkey(&s, sockp))
       t@@ -376,7 +379,7 @@ main(int argc, char *argv[])
                        sodium_mlock(passphrase, pplen);
        
                        /* write master password entry if not present */
       -                if (fd < 0 && errno == ENOENT) {
       +                if (!hasmaster) {
                                uint8_t *passphrase2 = NULL;
                                size_t pplen2 = 0;