Fix subprocess watching.

Currently, the subprocess watching code polls with a delay between attempts.
Instead, introduce wait_with_timeout() and use it, simplifying this code.

Signed-off-by: Elly Fong-Jones <elly@leptoquark.net>
Merge pull request #114 from elly/refactor

Fix subprocess watching.
David Hill noticed that we sometimes leave &warp_time uninitalized
add verbosity for privilege dropping attempt
Merge branch 'master' of github.com:ioerror/tlsdate
Add integration testing.

These new integration tests mostly focus on tlsdated's subprocess code.

Signed-off-by: Elly Fong-Jones <elly@leptoquark.net>
Merge pull request #116 from elly/integration

Add integration testing.
Update CHANGELOG for integration tests.
Merge pull request #117 from elly/integration-changelog

Update CHANGELOG for integration tests.
Refactor event loop.

Refactor the event loop to be modular and testable. Also, add support for
detecting corruption of the realtime clock, as can be caused by suspend/resume
cycles without an rtc battery. The event loop is now driven by a tree of events,
which are either sources (currently suspend/resume events, periodic events, and
network route events) or composite events.

Signed-off-by: Elly Fong-Jones <elly@leptoquark.net>
tlsdate: add optional --showtime support for "raw"

Add support for optional arguments to --showtime, "raw" and "human".

Human readable output is what --showtime and -V do already.  Passing
in --showtime=raw will tell tlsdate-helper to write the raw
unix time directly to stdout in host byte order.

The purpose of this change is to provide easier integration of
privilege isolation for time setting.  If tlsdate is called from
a wrapper, like tlsdated, it should be possible to pass the time back
to a privileged time-setter with the minimum of needed parsing.
tlsdate, docs: make -V taken an optional arg to simplify showtime

Update the man pages and simplify the processing of -V
and --showtime to share the optional argument path.
Merge pull request #118 from elly/event-loop

Refactor event loop.
Merge pull request #119 from redpig/showtime=raw

tlsdate: add optional --showtime support for "raw"
Rudimentary support for HTTP Date headers

Since I'm going on a personal crusade to kill off gmt_unix_time, I
should provide an alternative.  That alternative can be the Date
header from HTTP -- unlike gmt_unix_time, the Date header is required
by the RFC to actually be an accurate clock-like clock, and nobody is
trying to get rid of it.

This code is pretty hack-ish and does some nonportable stuff, like
using memmem() and timegm().  It's not super-tolerant of
non-standards-compliant HTTP servers.  I hope I didn't make any
pointer mistakes.
Change check for RTC to be configure based.

Previously I had disabled it with #ifdef __linux__, but that's not
very good autoconf style.
Describe what an HTTP date is
Don't log raw dates, in case they contain junk.
Document magic "1900" value
In verbose mode, display TLS time as well as HTTPS time