.br
\&
.RB [ \-p
-.IR program ]
+.IR path ]
.RB [ \-S
.IB arg , arg ,\fR...]
.
.B tripectl
will start a new
.B tripe
-server, rather than connecting to an existing one. This is most useful
-if you want to collect logging information from the server, and want to
-avoid losing any. For example, the command
+server, rather than connecting to an existing one.
+.PP
+The command line for the new server is
+.IP
+.I path
+.B \-F
+.B \-d.\&
+.B \-a
+.I socket
+.I dash-S-options
+.PP
+where
+.I dash-S-options
+is the concatenation of the arguments of
+.B \-S
+options, split at commas.
+.PP
+Starting a
+.B tripe
+server through
+.B tripectl
+is most useful if you want to collect logging information from the
+server, and want to avoid losing any. For example, the command
.VS
tripectl -Ds -f tripe.log
.VE
DA_UNSHIFT(&spawnopts, (char *)sock);
DA_UNSHIFT(&spawnopts, "-a");
DA_UNSHIFT(&spawnopts, "-d.");
+ DA_UNSHIFT(&spawnopts, "-F");
DA_UNSHIFT(&spawnopts, (char *)spawnpath);
DA_PUSH(&spawnopts, 0);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pfd))
#define F_DAEMON 1u
#define F_INIT 2u
+#define F_FOREGROUND 4u
#define T_RESOLVE SEC(30)
#define T_PING SEC(5)
T( trace(T_ADMIN, "admin: completing destruction of connection %u",
a->seq); )
+ /* --- If this is the foreground client then shut down --- */
+
+ if (a->f & AF_FOREGROUND) {
+ T( trace(T_ADMIN, "admin: foreground client quit: shutting down"); )
+ a_warn("SERVER", "quit", "foreground-eof", A_END);
+ a_quit();
+ }
+
/* --- Abort any background jobs in progress --- */
for (bg = a->bg; bg; bg = bbg) {
static void usage(FILE *fp)
{
- pquis(fp, "Usage: $ [-D] [-d DIR] [-b ADDR] [-p PORT] [-n TUNNEL]\n\
+ pquis(fp, "Usage: $ [-DF] [-d DIR] [-b ADDR] [-p PORT] [-n TUNNEL]\n\
[-U USER] [-G GROUP] [-a SOCKET] [-T TRACE-OPTS]\n\
[-k PRIV-KEYRING] [-K PUB-KEYRING] [-t KEY-TAG]\n");
}
--tunnels Display IP tunnel drivers and exit.\n\
\n\
-D, --daemon Run in the background.\n\
+-F, --foreground Quit when stdin reports end-of-file.\n\
-d, --directory=DIR Switch to directory DIR [default " CONFIGDIR "].\n\
-b, --bind-address=ADDR Bind UDP socket to this IP ADDR.\n\
-p, --port=PORT Select UDP port to listen to "
unsigned f = 0;
int i;
int selerr = 0;
+ unsigned af;
struct timeval tv;
uid_t u = -1;
gid_t g = -1;
#define f_bogus 1u
#define f_daemon 2u
+#define f_foreground 4u
ego(argv[0]);
T( trace_on(stderr, 0); )
{ "tunnels", 0, 0, '0' },
{ "daemon", 0, 0, 'D' },
+ { "foreground", 0, 0, 'F' },
{ "uid", OPTF_ARGREQ, 0, 'U' },
{ "setuid", OPTF_ARGREQ, 0, 'U' },
{ "gid", OPTF_ARGREQ, 0, 'G' },
{ 0, 0, 0, 0 }
};
- i = mdwopt(argc, argv, "hvuDU:G:b:n:p:d:k:K:t:a:" T("T:"),
+ i = mdwopt(argc, argv, "hvuDFU:G:b:n:p:d:k:K:t:a:" T("T:"),
opts, 0, 0, 0);
if (i < 0)
break;
case 'G':
g = u_getgroup(optarg);
break;
+ case 'F':
+ f |= f_foreground;
+ break;
case 'b': {
struct hostent *h = gethostbyname(optarg);
usage(stderr);
exit(EXIT_FAILURE);
}
+ if (!(~f & (f_daemon | f_foreground)))
+ die(EXIT_FAILURE, "foreground operation for a daemon is silly");
if (chdir(dir)) {
die(EXIT_FAILURE, "can't set current directory to `%s': %s",
tunnels[i]->init();
p_init(baddr, port);
if (!(f & f_daemon)) {
+ af = AF_WARN;
#ifndef NTRACE
- a_create(STDIN_FILENO, STDOUT_FILENO, AF_TRACE | AF_WARN);
-#else
- a_create(STDIN_FILENO, STDOUT_FILENO, AF_WARN);
+ af |= AF_TRACE;
#endif
+ if (f & f_foreground)
+ af |= AF_FOREGROUND;
+ a_create(STDIN_FILENO, STDOUT_FILENO, af);
}
u_setugid(u, g);
km_init(kr_priv, kr_pub, tag_priv);