~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
math/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.
[catacomb]
/
progs
/
pixie.c
diff --git
a/progs/pixie.c
b/progs/pixie.c
index
d964c0f
..
3fd3208
100644
(file)
--- a/
progs/pixie.c
+++ b/
progs/pixie.c
@@
-83,6
+83,7
@@
static unsigned flags = 0;
#define F_SYSLOG 1u
#define F_FETCH 2u
#define F_SYSLOG 1u
#define F_FETCH 2u
+#define F_REPLACE 4u
/*----- Event logging -----------------------------------------------------*/
/*----- Event logging -----------------------------------------------------*/
@@
-683,13
+684,13
@@
static void pixserv_line(char *s, size_t len, void *p)
if (strcmp(q, "help") == 0) {
if (pixserv_write(px, "\
INFO Commands supported:\n\
if (strcmp(q, "help") == 0) {
if (pixserv_write(px, "\
INFO Commands supported:\n\
-INFO
HELP
\n\
-INFO
LIST
\n\
-INFO
PASS tag [expire]
\n\
-INFO
VERIFY tag [expire
]\n\
-INFO
FLUSH [tag]
\n\
-INFO
SET tag [expire] -- phrase
\n\
-INFO
QUIT
\n\
+INFO
flush [TAG]
\n\
+INFO
help
\n\
+INFO
list
\n\
+INFO
pass TAG [EXPIRE
]\n\
+INFO
quit
\n\
+INFO
set TAG [EXPIRE] -- PHRASE
\n\
+INFO
verify TAG [EXPIRE]
\n\
OK\n\
"))
goto close;
OK\n\
"))
goto close;
@@
-774,7
+775,7
@@
OK\n\
goto close;
} else {
p_flush(tag);
goto close;
} else {
p_flush(tag);
- p_add(tag, s, t);
+ p_add(tag, s
? s : ""
, t);
if (pixserv_write(px, "OK\n")) goto close;
}
}
if (pixserv_write(px, "OK\n")) goto close;
}
}
@@
-1005,7
+1006,7
@@
static void pix_setup(struct sockaddr_un *sun, size_t sz)
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 {
+ } 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) {
@@
-1014,7
+1015,8
@@
static void pix_setup(struct sockaddr_un *sun, size_t sz)
}
sleep(1);
close(fd);
}
sleep(1);
close(fd);
- }
+ } else
+ die(EXIT_FAILURE, "pixie already running; not starting");
goto again;
}
chmod(sun->sun_path, 0600);
goto again;
}
chmod(sun->sun_path, 0600);
@@
-1188,6
+1190,7
@@
protect important keys. Options provided:\n\
-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\
@@
-1241,7
+1244,7
@@
int main(int argc, char *argv[])
/* --- Set up the locked memory area --- */
l_init(&lm, 16384);
/* --- Set up the locked memory area --- */
l_init(&lm, 16384);
-
setuid(getuid()
);
+
if (setuid(getuid())) _exit(125
);
/* --- Parse command line arguments --- */
/* --- Parse command line arguments --- */
@@
-1262,6
+1265,7
@@
int main(int argc, char *argv[])
{ "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' },
@@
-1276,7
+1280,7
@@
int main(int argc, char *argv[])
{ 0, 0, 0, 0 }
};
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "hVuqvCPs:c:ft:idl", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "hVuqvCPs:
r
c:ft:idl", opts, 0, 0, 0);
if (i < 0)
break;
if (i < 0)
break;
@@
-1320,6
+1324,9
@@
int main(int argc, char *argv[])
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);