tAdd SAFE_DIR environment variable to set safe location - 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 32c829dd0d53fdfdb9427e11e82c79399080e320
DIR parent 8d00f4085a08c0720d01d6e2eda5d186882f07fc
HTML 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:
M safe.1 | 6 +++---
M safe.c | 12 +++++++-----
2 files changed, 10 insertions(+), 8 deletions(-)
---
DIR diff --git a/safe.1 b/safe.1
t@@ -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
DIR diff --git a/safe.c b/safe.c
t@@ -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 {
t@@ -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);