Add configure probe for libevent

This will become mandatory for the server, so require it for the
build (at least for right now).  Attempt pkg-config first and then
fall back on more manual probing.

Change-Id: I19d9871f547c54c4749f768113bdca712783a4af
Reviewed-on: https://gerrit.stanford.edu/1375
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Fix comment cut and paste error in PCRE Autoconf macro

Change-Id: Id1557781a0202ab6b0d18136ef9d222d76a5351f
Reviewed-on: https://gerrit.stanford.edu/1376
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Add remctl server implementation details

Preliminary documentation of the architecture of the remctl server.
Written mostly to put down the details of the event loops, in
preparation for rewriting them to use libevent, and to provide a
framework for further documentation.

Change-Id: Ib52b3e22aaf8fe60b60365b828987cf348e98dd6
Reviewed-on: https://gerrit.stanford.edu/1377
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Switch the process event loop to libevent

Replace the complex hand-coded client event loop, using select,
with a rewritten one using libevent.  This fixes race conditions
in noticing the client exit properly and removes the need for the
five-second polling to see whether the client has exited.  It also
provides a framework for eventual added complexity in the event
loop.

Import the buffer utility functions from rra-c-util and use that
to manage the client output buffer for now.  This will probably be
replaced with evbuffers.

This is the first cut, using basic libevent functionality.  The
next step will be to use bufferevents in some places and extend the
use of libevent to other event loops in the server.

Currently requires libevent 2.x.  Portability to libevent 1.4.3
will come in a subsequent commit.

Change-Id: Ia8e4cd0a857c710dbc0c348578648084466e886b
Reviewed-on: https://gerrit.stanford.edu/1378
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Send the maximum permissible amount of MESSAGE_OUTPUT data

Rather than capping the data returned by the server in one
MESSAGE_OUTPUT token at the rather arbitrary length of 65,000 octets,
send up to the maximum amount of data permitted by the protocol.  This
also slightly increases the maximum length of the output returned
under the version one protocol.

Change-Id: Ia3e54957aeb67974ede66fda781aeb4a2c97171a
Reviewed-on: https://gerrit.stanford.edu/1379
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Use socketpair instead of pipe for server child processes

libevent's buffevent mechanism requires sockets instead of pipes.
Switch from pipe to socketpair in anticipation of converting some
of the data handling to buffevent.

Change-Id: I278df53d47ca65693982d2ee75c01c1285a25f43
Reviewed-on: https://gerrit.stanford.edu/1380
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Update Perl module versions for the upcoming release

Change-Id: I884e766a8669f9707bd46e7443369189c362dd7e
Reviewed-on: https://gerrit.stanford.edu/1381
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Convert stdin handling to use a bufferevent

Queue up stdin input to the process using a bufferevent rather
than manually handling the writes.

Change-Id: I488b670921aa2953bbb462af43816145d4d57f3b
Reviewed-on: https://gerrit.stanford.edu/1382
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Switch to bufferevents for standard output and error

Use bufferevents to manage standard output and standard error from
the process as well.  Replace all the remaining uses of the buffer
object in the server with evbuffers instead.

Change-Id: Ic6d59de1bc35dcae564fb62777863bda2935ddd0
Reviewed-on: https://gerrit.stanford.edu/1383
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Remove the buffer util library again

All the code that was using it has been converted to evbuffers
instead.

Change-Id: I4f21b22c05e73c2162de67b14aaf2bd1d9f51e63
Reviewed-on: https://gerrit.stanford.edu/1384
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Use sysdie on failure before exec when running commands

We were avoiding sysdie because we had a particular desired exit
status.  Use a callback to set the exit status instead and switch
to sysdie.

Change-Id: I770fcf75946519b3371274c12fe6a66a4df07340
Reviewed-on: https://gerrit.stanford.edu/1385
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Suppress debug messages for each argument

We were reporting, at debug level, the length of every argument
to the server.  This seems unnecessary.  It produces a lot of
output and I've never used this to diagnose problems.  Stop doing
this.

Change-Id: I1fefe18893525e71c999b7d0f953c1a1f6c77197
Reviewed-on: https://gerrit.stanford.edu/1386
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Remove unnecessary includes from server/commands.c

Change-Id: I408efd26f894ee137250e7dec9743c8fd6205d92
Reviewed-on: https://gerrit.stanford.edu/1387
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Simplify process I/O sockets

Since we're now using socketpair, we can use a single socket for
both standard input and standard output (and, for protocol version
one, standard error as well).  Do this along with the resulting
code simplification and unification of some callbacks.  Handle
ECONNRESET errors alongside EPIPE now that we're doing both input
and output on the same socket.

Change-Id: I960f39e71ca8db9405a0b41b01a334b5e82ed8e9
Reviewed-on: https://gerrit.stanford.edu/1388
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>
Use an evbuffer to store input data for a process

Start isolating the process event loop from the rest of the code
by not reusing the struct iovec representation of the input data.
Instead, convert it to an evbuffer first.

This does make another copy of the data.  We will rethink this if
it shows up as a performance issue.

Change-Id: Ie37dea0e9b4a58fa4f481ed0a4fd5ba8bb7ebdab
Reviewed-on: https://gerrit.stanford.edu/1389
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Russ Allbery <rra@stanford.edu>