safe

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

commit 6907eb1ddbe9042e63a63d9fca702a2cd20302d2
parent abc98ebaee60796bd9e4340ddd4fe6afbd2645fe
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 24 Jun 2019 08:59:49 +0200

Detach safe-agent from controlling terminal by default

Diffstat:
safe-agent.1 | 4+++-
safe-agent.c | 11+++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/safe-agent.1 b/safe-agent.1 @@ -6,7 +6,7 @@ .Nd Digital safe for your secrets .Sh SYNOPSIS .Nm -.Op Fl h +.Op Fl hd .Op Fl t Ar timeout .Op Fl f Ar socket .Sh DESCRIPTION @@ -22,6 +22,8 @@ to the running agent. .Bl -tag -width Ds .It Fl h Print a quick usage text. +.It Fl d +Do not detach the process from the controlling terminal. .It Fl t Ar timeout Retain the key for .Ar timeout diff --git a/safe-agent.c b/safe-agent.c @@ -135,7 +135,7 @@ sighandler(int signal) unlink(sockp); rmdir(dirname(sockp)); exit(0); - /* FALLTHROUGH */ + /* NOTREACHED */ case SIGALRM: case SIGUSR1: forgetkey(); @@ -183,13 +183,16 @@ int main(int argc, char *argv[]) { pid_t pid; - int timeout; + int dflag, timeout; size_t dirlen; char path[PATH_MAX] = SOCKDIR; pid = getpid(); ARGBEGIN { + case 'd': + dflag = 1; + break; case 'f': sockp = EARGF(usage()); break; @@ -214,6 +217,10 @@ main(int argc, char *argv[]) printf("SAFE_PID=%d\n", pid); printf("SAFE_SOCK=%s\n", sockp); printf("export SAFE_PID SAFE_SOCK\n"); + fflush(stdout); + + if (!dflag) + daemon(0, 0); signal(SIGINT, sighandler); signal(SIGTERM, sighandler);