~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
server/keymgmt.c: Replace ad-hoc `die' with an `ABORT'-level warning.
[tripe]
/
server
/
tripe.c
diff --git
a/server/tripe.c
b/server/tripe.c
index
b843885
..
93d40b9
100644
(file)
--- a/
server/tripe.c
+++ b/
server/tripe.c
@@
-292,9
+292,7
@@
int main(int argc, char *argv[])
rand_noisesrc(RAND_GLOBAL, &noise_source);
rand_seed(RAND_GLOBAL, MAXHASHSZ);
signal(SIGPIPE, SIG_IGN);
rand_noisesrc(RAND_GLOBAL, &noise_source);
rand_seed(RAND_GLOBAL, MAXHASHSZ);
signal(SIGPIPE, SIG_IGN);
- for (i = 0; tunnels[i]; i++)
- tunnels[i]->init();
- p_init(ailist); freeaddrinfo(ailist);
+
if (!(f & f_daemon)) {
af = AF_WARN;
#ifndef NTRACE
if (!(f & f_daemon)) {
af = AF_WARN;
#ifndef NTRACE
@@
-303,16
+301,34
@@
int main(int argc, char *argv[])
if (f & f_foreground)
af |= AF_FOREGROUND;
a_create(STDIN_FILENO, STDOUT_FILENO, af);
if (f & f_foreground)
af |= AF_FOREGROUND;
a_create(STDIN_FILENO, STDOUT_FILENO, af);
+ a_switcherr();
+ }
+
+ p_init();
+ for (i = 0; tunnels[i]; i++)
+ tunnels[i]->init();
+ p_bind(ailist); freeaddrinfo(ailist);
+
+ for (i = 0; tunnels[i]; i++) {
+ if (tunnels[i]->flags&TUNF_PRIVOPEN) {
+ ps_split(f & f_daemon);
+ break;
+ }
}
}
- ps_split(f & f_daemon);
- a_init(csock, u, g, csockmode);
+
+ a_init();
+ a_signals();
+ a_listen(csock, u, g, csockmode);
u_setugid(u, g);
km_init(kr_priv, kr_pub, tag_priv);
kx_init();
if (f & f_daemon) {
u_setugid(u, g);
km_init(kr_priv, kr_pub, tag_priv);
kx_init();
if (f & f_daemon) {
- if (daemonize())
- die(EXIT_FAILURE, "couldn't become a daemon: %s", strerror(errno));
+ if (daemonize()) {
+ a_warn("SERVER", "daemon-error", "?ERRNO", A_END);
+ exit(EXIT_FAILURE);
+ }
a_daemon();
a_daemon();
+ a_switcherr();
}
tv.tv_sec = time(0) + T_INTERVAL;
}
tv.tv_sec = time(0) + T_INTERVAL;