It's too easy to screw things up by replacing the running pixie, by
calling the pixie with no arguments. The old behaviour is available via
the shiny new `--replace' option.
pixie \- Catacomb passphrase pixie
.SH "SYNOPSIS"
.B pixie
pixie \- Catacomb passphrase pixie
.SH "SYNOPSIS"
.B pixie
.RB [ \-c
.IR command ]
.RB [ \-t
.RB [ \-c
.IR command ]
.RB [ \-t
the socket already exists, the pixie currently listening on the socket
is told to quit.
.TP
the socket already exists, the pixie currently listening on the socket
is told to quit.
.TP
+.B "\-r, \-\-replace"
+If there's already a pixie listening on the socket then ask it to quit.
+The default behaviour is to report an error and exit in this case.
+.TP
.BI "\-c, \-\-command=" command
Specifies a shell command to be run by the pixie when an unknown
passphrase is requested by a client.
.BI "\-c, \-\-command=" command
Specifies a shell command to be run by the pixie when an unknown
passphrase is requested by a client.
.PP
If the attempt failed because a file with the required name already
exists and is not a socket, the pixie reports an error and exits. If
.PP
If the attempt failed because a file with the required name already
exists and is not a socket, the pixie reports an error and exits. If
-there's already a socket with that name, the pixie connects to it, sends
+there's already a socket with that name, the pixie quits unless the
+.B \-\-replace
+option is given: in the latter case, the pixie connects to it, sends
a
.B QUIT
request to the server, waits for a second and retries. If the
a
.B QUIT
request to the server, waits for a second and retries. If the
#define F_SYSLOG 1u
#define F_FETCH 2u
#define F_SYSLOG 1u
#define F_FETCH 2u
/*----- Event logging -----------------------------------------------------*/
/*----- Event logging -----------------------------------------------------*/
pxlog("stale socket found; removing it");
unlink(sun->sun_path);
close(fd);
pxlog("stale socket found; removing it");
unlink(sun->sun_path);
close(fd);
+ } else if (flags & F_REPLACE) {
if (verbose)
pxlog("server already running; shutting it down");
if (write(fd, "QUIT\n", 5) < 0) {
if (verbose)
pxlog("server already running; shutting it down");
if (write(fd, "QUIT\n", 5) < 0) {
+ } else
+ die(EXIT_FAILURE, "pixie already running; not starting");
goto again;
}
chmod(sun->sun_path, 0600);
goto again;
}
chmod(sun->sun_path, 0600);
-q, --quiet Emit fewer log messages.\n\
-v, --version Emit more log messages.\n\
-s, --socket=FILE Name the pixie's socket.\n\
-q, --quiet Emit fewer log messages.\n\
-v, --version Emit more log messages.\n\
-s, --socket=FILE Name the pixie's socket.\n\
+-r, --replace Replace existing pixie, if one is running.\n\
-c, --command=COMMAND Shell command to read a passphrase.\n\
-f, --fetch Fetch passphrases from the terminal.\n\
-t, --timeout=TIMEOUT Length of time to retain a passphrase in memory.\n\
-c, --command=COMMAND Shell command to read a passphrase.\n\
-f, --fetch Fetch passphrases from the terminal.\n\
-t, --timeout=TIMEOUT Length of time to retain a passphrase in memory.\n\
{ "passphrase", 0, 0, 'P' },
{ "verify-passphrase", 0, 0, '+' },
{ "socket", OPTF_ARGREQ, 0, 's' },
{ "passphrase", 0, 0, 'P' },
{ "verify-passphrase", 0, 0, '+' },
{ "socket", OPTF_ARGREQ, 0, 's' },
+ { "replace", 0, 0, 'r' },
{ "command", OPTF_ARGREQ, 0, 'c' },
{ "fetch", 0, 0, 'f' },
{ "timeout", OPTF_ARGREQ, 0, 't' },
{ "command", OPTF_ARGREQ, 0, 'c' },
{ "fetch", 0, 0, 'f' },
{ "timeout", OPTF_ARGREQ, 0, 't' },
- int i = mdwopt(argc, argv, "hVuqvCPs:c:ft:idl", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "hVuqvCPs:rc:ft:idl", opts, 0, 0, 0);
case 's':
path = optarg;
break;
case 's':
path = optarg;
break;
+ case 'r':
+ flags |= F_REPLACE;
+ break;
case 't':
if ((timeout = pixserv_timeout(optarg)) == 0)
die(1, "bad timeout `%s'", optarg);
case 't':
if ((timeout = pixserv_timeout(optarg)) == 0)
die(1, "bad timeout `%s'", optarg);