safe

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

commit 32c829dd0d53fdfdb9427e11e82c79399080e320
parent 8d00f4085a08c0720d01d6e2eda5d186882f07fc
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 24 Jun 2019 15:08:29 +0200

Add SAFE_DIR environment variable to set safe location

Diffstat:
safe.1 | 6+++---
safe.c | 12+++++++-----
2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/safe.1 b/safe.1 @@ -73,10 +73,10 @@ Retrieve a secret from your safe .Sh ENVIRONMENT .Bl -tag -width "SAFE_SOCK" +.It Ev SAFE_DIR +Defines the location of your safe (default: .secrets) .It Ev SAFE_SOCK -If this variable is set, -.Nm -will read the key from the UNIX-domain socket pointed to by this variable. +Path to the UNIX-domain socket used to communicate with the agent. .Sh BUGS When the agent does not have the key in memory, .Nm diff --git a/safe.c b/safe.c @@ -327,6 +327,7 @@ main(int argc, char *argv[]) char *secret = NULL, *sockp = NULL, *safe = SAFE; struct safe s; + safe = getenv("SAFE_DIR"); sockp = getenv("SAFE_SOCK"); ARGBEGIN { @@ -349,11 +350,12 @@ main(int argc, char *argv[]) if (sodium_init() < 0) return -1; - if (safe) { - mkdir(safe, 0700); - if (chdir(safe) < 0) - err(1, "chdir: %s", safe); - } + if (!safe) + safe = SAFE; + + mkdir(safe, 0700); + if (chdir(safe) < 0) + err(1, "chdir: %s", safe); /* open master password as read only to retrieve salt */ fd = open(MASTER, O_RDONLY);