chiark / gitweb /
Merge branches 'cleanup' and 'services'
authorMark Wooding <mdw@distorted.org.uk>
Mon, 1 Jan 2007 15:30:39 +0000 (15:30 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 1 Jan 2007 15:30:39 +0000 (15:30 +0000)
* cleanup:
  server/admin: Fix tokenization of statistics output.
  Fix typos in messages.
  doc: Various small cleanups to tripe-admin.5.
  cleanup: Various simple whitespace changes.
  cleanup: Rename a few badly-chosen variables.

* services:
  doc: Document the services messages.
  admin: Implement the main job commands.
  admin: Implement job table infrastructure.
  admin: Service ownership infrastructure and commands.
  servutil: Implement version number comparison.
  admin: New ?TOKENS formatting directive.
  admin: Rename the unknown-service error.
  admin: Improve handling of background jobs.
  admin: Option parser macros.
  admin: Put all command options at the start of the command-line.
  admin: Fix premature close in a_bgrelease.
  admin: Remove locking; new safe client destruction.

Conflicts:

server/admin.c

client/tripectl.c
doc/tripe-admin.5.in
init/tripe-init.in
pkstream/pkstream.c
proxy/tripe-mitm.c
server/admin.c
server/tripe.c

index 4aece8d10462f2632a93c88796998d0ed2a9ef00..7386b304b3a7dd808b4cd46a978fd5073e543498 100644 (file)
@@ -268,10 +268,7 @@ static void logfile(const char *name)
   }
 }
 
-static void sighup(int sig, void *v)
-{
-  logfile(logname);
-}
+static void sighup(int sig, void *v) { logfile(logname); }
 
 static void cleanup(void)
 {
@@ -287,9 +284,7 @@ static void sigdie(int sig)
 }
 
 static void version(FILE *fp)
-{
-  pquis(fp, "$, TrIPE version " VERSION "\n");
-}
+  { pquis(fp, "$, TrIPE version " VERSION "\n"); }
 
 static void usage(FILE *fp)
 {
index 17c835978bdba124234275653306a37c8eb8a346..822bbf508b588eddb4b7814bc8f0394b76e5d2ac 100644 (file)
@@ -223,14 +223,13 @@ An Internet socket, naming an IPv4 address and UDP port.  On output, the
 address is always in numeric dotted-quad form, and the port is given as
 a plain number.  On input, DNS hostnames and symbolic port names are
 permitted.  Name resolution does not block the main server, but will
-block the requesting client.  This hopefully makes life simpler for
-stupid clients.  Complex clients which don't wish to be held up can open
-extra connections or do the resolution themselves.)
+block the requesting client, unless the command is run in the background.
 .PP
 If, on input, no recognised address family token is found, the following
 words are assumed to represent an
 .B INET
-address.
+address.  Addresses output by the server always have an address family
+token.
 .SS "Key-value output"
 Some commands (e.g.,
 .B STATS
@@ -330,7 +329,7 @@ or in a greeting message.
 .B "DAEMON"
 Causes the server to disassociate itself from its terminal and become a
 background task.  This only works once.  A warning is issued.
-.TP
+.SP
 .BI "EPING \fR[" options "\fR] " peer
 Sends an encrypted ping to the peer, and expects an encrypted response.
 This checks that the peer is running (and not being impersonated), and
@@ -447,10 +446,16 @@ Run the command in the background, using the given
 .BI "\-timeout " time
 Wait for
 .I time
-seconds before giving up on a response.  The default is 5 seconds.  (The
-time format is the same as for the
-.B "ADD \-keepalive"
-option.)
+seconds before giving up on a response.  The default is 5 seconds.  The
+.I time
+is expressed as a nonnegative integer followed optionally by
+.BR d ,
+.BR h ,
+.BR m ,
+or
+.BR s
+for days, hours, minutes, or seconds respectively; if no suffix is
+given, seconds are assumed.
 .\"-opts
 .RE
 .SP
@@ -1327,6 +1332,7 @@ An administration client issued a warning.
 .SH "SUMMARY"
 .SS "Command responses"
 .nf
+.BI "BGDETACH " tag
 .BI "BGFAIL " tag " " tokens \fR...
 .BI "BGINFO " tag " " tokens \fR...
 .BI "BGOK " tag
index e3d835ac6f24a10bf27af251868a5e7963f3dc35..e609a653af0a1765e5c1badef08ff6c0e08b646e 100755 (executable)
@@ -160,7 +160,7 @@ case "$1" in
     elif kill `cat $pidfile`; then
       echo " done (killed violently)"
     else
-      echo " it doesn't want do die!"
+      echo " it doesn't want to die!"
       exit 1
     fi
     ;;
index e291a9bd446850728343f95945f49c16a111b1e1..6e36adc2a945f883b9348e4296cde8231771e02f 100644 (file)
@@ -89,14 +89,10 @@ static size_t pk_nmax = 128, pk_szmax = 1024 * 1024;
 /*----- Main code ---------------------------------------------------------*/
 
 static int nonblockify(int fd)
-{
-  return (fdflags(fd, O_NONBLOCK, O_NONBLOCK, 0, 0));
-}
+  { return (fdflags(fd, O_NONBLOCK, O_NONBLOCK, 0, 0)); }
 
 static int cloexec(int fd)
-{
-  return (fdflags(fd, 0, 0, FD_CLOEXEC, FD_CLOEXEC));
-}
+  { return (fdflags(fd, 0, 0, FD_CLOEXEC, FD_CLOEXEC)); }
 
 static void dolisten(void);
 
@@ -318,9 +314,7 @@ static void usage(FILE *fp)
 }
 
 static void version(FILE *fp)
-{
-  pquis(fp, "$, tripe version " VERSION "\n");
-}
+  { pquis(fp, "$, tripe version " VERSION "\n"); }
 
 static void help(FILE *fp)
 {
index 9aa29901dda5756946376f49bf3db5c738e2fdf5..107362eed6bfb1ca1488cd03e6ddd088316f903f 100644 (file)
@@ -603,14 +603,10 @@ static void parse(char *p)
 /*----- Main driver -------------------------------------------------------*/
 
 static void version(FILE *fp)
-{
-  pquis(fp, "$, TrIPE version " VERSION "\n");
-}
+  { pquis(fp, "$, TrIPE version " VERSION "\n"); }
 
 static void usage(FILE *fp)
-{
-  pquis(fp, "Usage: $ [-k KEYRING] DIRECTIVE...\n");
-}
+  { pquis(fp, "Usage: $ [-k KEYRING] DIRECTIVE...\n"); }
 
 static void help(FILE *fp)
 {
index d020169310ce49dac816df321db48c97fe75b338..797b47869589b702813b2e48f71ba9c074064a3c 100644 (file)
@@ -341,6 +341,7 @@ static void a_vwrite(admin *a, const char *status, const char *tag,
                     const char *fmt, va_list ap)
 {
   dstr d = DSTR_INIT;
+
   if (tag) dstr_puts(&d, "BG");
   dstr_puts(&d, status);
   if (tag) quotify(&d, tag);
@@ -354,6 +355,7 @@ static void a_write(admin *a, const char *status, const char *tag,
                    const char *fmt, ...)
 {
   va_list ap;
+
   va_start(ap, fmt);
   a_vwrite(a, status, tag, fmt, ap);
   va_end(ap);
@@ -375,6 +377,7 @@ static void a_ok(admin *a) { a_write(a, "OK", 0, A_END); }
 static void a_info(admin *a, const char *fmt, ...)
 {
   va_list ap;
+
   va_start(ap, fmt);
   a_vwrite(a, "INFO", 0, fmt, ap);
   va_end(ap);
@@ -383,6 +386,7 @@ static void a_info(admin *a, const char *fmt, ...)
 static void a_fail(admin *a, const char *fmt, ...)
 {
   va_list ap;
+
   va_start(ap, fmt);
   a_vwrite(a, "FAIL", 0, fmt, ap);
   va_end(ap);
@@ -428,7 +432,7 @@ static void a_rawalert(unsigned f_and, unsigned f_eq, const char *status,
   dstr_destroy(&d);
 }
 
-static void a_valert(unsigned f_and, unsigned f_eq, const char *tag,
+static void a_valert(unsigned f_and, unsigned f_eq, const char *status,
                     const char *fmt, va_list ap)
 {
   dstr d = DSTR_INIT;
@@ -436,16 +440,17 @@ static void a_valert(unsigned f_and, unsigned f_eq, const char *tag,
   if (!(flags & F_INIT))
     return;
   a_vformat(&d, fmt, ap);
-  a_rawalert(f_and, f_eq, tag, fmt ? d.buf : 0, fmt ? d.len : 0);
+  a_rawalert(f_and, f_eq, status, fmt ? d.buf : 0, fmt ? d.len : 0);
   dstr_destroy(&d);
 }
 
-static void a_alert(unsigned f_and, unsigned f_eq, const char *tag,
+static void a_alert(unsigned f_and, unsigned f_eq, const char *status,
                    const char *fmt, ...)
 {
   va_list ap;
+
   va_start(ap, fmt);
-  a_valert(f_and, f_eq, tag, fmt, ap);
+  a_valert(f_and, f_eq, status, fmt, ap);
   va_end(ap);
 }
 
@@ -571,9 +576,7 @@ static void a_sigdie(int sig, void *v)
  */
 
 static void a_sighup(int sig, void *v)
-{
-  a_warn("SERVER", "ignore", "signal", "SIGHUP", A_END);
-}
+  { a_warn("SERVER", "ignore", "signal", "SIGHUP", A_END); }
 
 /* --- @a_parsetime@ --- *
  *
@@ -1613,9 +1616,7 @@ static void acmd_trace(admin *a, unsigned ac, char *av[])
 #endif
 
 static void acmd_watch(admin *a, unsigned ac, char *av[])
-{
-  traceish(a, ac, av, "watch", w_opts, &a->f);
-}
+  { traceish(a, ac, av, "watch", w_opts, &a->f); }
 
 static void alertcmd(admin *a, unsigned f_and, unsigned f_eq,
                     const char *status, char *av[])
@@ -1626,10 +1627,7 @@ static void acmd_warn(admin *a, unsigned ac, char *av[])
   { alertcmd(a, AF_WARN, AF_WARN, "WARN", av); }
 
 static void acmd_port(admin *a, unsigned ac, char *av[])
-{
-  a_info(a, "%u", p_port(), A_END);
-  a_ok(a);
-}
+  { a_info(a, "%u", p_port(), A_END); a_ok(a); }
 
 static void acmd_daemon(admin *a, unsigned ac, char *av[])
 {
@@ -1675,6 +1673,7 @@ static void acmd_bgcancel(admin *a, unsigned ac, char *av[])
 static void acmd_list(admin *a, unsigned ac, char *av[])
 {
   peer *p;
+
   for (p = p_first(); p; p = p_next(p))
     a_info(a, "%s", p_name(p), A_END);
   a_ok(a);
@@ -1790,17 +1789,27 @@ static void acmd_stats(admin *a, unsigned ac, char *av[])
   a_info(a, "start-time=%s", timestr(st->t_start), A_END);
   a_info(a, "last-packet-time=%s", timestr(st->t_last), A_END);
   a_info(a, "last-keyexch-time=%s", timestr(st->t_kx), A_END);
-  a_info(a, "packets-in=%lu bytes-in=%lu", st->n_in, st->sz_in, A_END);
-  a_info(a, "packets-out=%lu bytes-out=%lu",
-        st->n_out, st->sz_out, A_END);
-  a_info(a, "keyexch-packets-in=%lu keyexch-bytes-in=%lu",
-        st->n_kxin, st->sz_kxin, A_END);
-  a_info(a, "keyexch-packets-out=%lu keyexch-bytes-out=%lu",
-        st->n_kxout, st->sz_kxout, A_END);
-  a_info(a, "ip-packets-in=%lu ip-bytes-in=%lu",
-        st->n_ipin, st->sz_ipin, A_END);
-  a_info(a, "ip-packets-out=%lu ip-bytes-out=%lu",
-        st->n_ipout, st->sz_ipout, A_END);
+  a_info(a, "packets-in=%lu", st->n_in, "bytes-in=%lu", st->sz_in, A_END);
+  a_info(a,
+        "packets-out=%lu", st->n_out,
+        "bytes-out=%lu", st->sz_out,
+        A_END);
+  a_info(a,
+        "keyexch-packets-in=%lu", st->n_kxin,
+        "keyexch-bytes-in=%lu", st->sz_kxin,
+        A_END);
+  a_info(a,
+        "keyexch-packets-out=%lu", st->n_kxout,
+        "keyexch-bytes-out=%lu", st->sz_kxout,
+        A_END);
+  a_info(a,
+        "ip-packets-in=%lu", st->n_ipin,
+        "ip-bytes-in=%lu", st->sz_ipin,
+        A_END);
+  a_info(a,
+        "ip-packets-out=%lu", st->n_ipout, 
+        "ip-bytes-out=%lu", st->sz_ipout,
+        A_END);
   a_info(a, "rejected-packets=%lu", st->n_reject, A_END);
   a_ok(a);
 }
@@ -1808,6 +1817,7 @@ static void acmd_stats(admin *a, unsigned ac, char *av[])
 static void acmd_kill(admin *a, unsigned ac, char *av[])
 {
   peer *p;
+
   if ((p = a_findpeer(a, av[0])) != 0) {
     p_destroy(p);
     a_ok(a);
@@ -1817,6 +1827,7 @@ static void acmd_kill(admin *a, unsigned ac, char *av[])
 static void acmd_forcekx(admin *a, unsigned ac, char *av[])
 {
   peer *p;
+
   if ((p = a_findpeer(a, av[0])) != 0) {
     kx_start(&p->kx, 1);
     a_ok(a);
@@ -1842,6 +1853,7 @@ static void acmd_version(admin *a, unsigned ac, char *av[])
 static void acmd_tunnels(admin *a, unsigned ac, char *av[])
 {
   int i;
+
   for (i = 0; tunnels[i]; i++)
     a_info(a, "%s", tunnels[i]->name, A_END);
   a_ok(a);
@@ -1905,6 +1917,7 @@ static const acmd acmdtab[] = {
 static void acmd_help(admin *a, unsigned ac, char *av[])
 {
   const acmd *c;
+
   for (c = acmdtab; c->name; c++) {
     if (c->help)
       a_info(a, "%s", c->name, "*%s", c->help, A_END);
@@ -2148,10 +2161,7 @@ void a_preselect(void) { if (a_dead) a_destroypending(); }
  * Use:                Informs the admin module that it's a daemon.
  */
 
-void a_daemon(void)
-{
-  flags |= F_DAEMON;
-}
+void a_daemon(void) { flags |= F_DAEMON; }
 
 /* --- @a_init@ --- *
  *
index dd385fbdb47d5a4a6e0a48daeb1c57b0cdc4d2b9..b5bd21c4adcaffbd47bfd1431a43d96f2f51637c 100644 (file)
@@ -96,10 +96,7 @@ static void usage(FILE *fp)
        [-k PRIV-KEYRING] [-K PUB-KEYRING] [-t KEY-TAG]\n");
 }
 
-static void version(FILE *fp)
-{
-  pquis(fp, "$, version " VERSION "\n");
-}
+static void version(FILE *fp) { pquis(fp, "$, version " VERSION "\n"); }
 
 static void help(FILE *fp)
 {