Complete implementation of CFEngine protocol over TLS
Complete implementation of CFEngine protocol over TLS

Client now correctly establishes a TLS session with server. During the
handshake they exchange both-ways in-memory certificates, self-signed
with their private key, the same key used in the previous protocol SAUTH
command. So the trust model has not changed, i.e. if the client is
bootstrapped to that server, the public key each peer is stored in the
other peer's ppkeys directory, and will be checked if it matches to the
one sent via the TLS handshake.

Various refactoring took place:

* Separated tls functions in different files depending on their usage:
  client, server, generic.

* Union in conn_info is removed since we always need the socket file
  descriptor.

* Struct fields no longer needed were thrown away.

* SSL context and other structures are initialised only once to avoid
  avoid allocating on every connection.

* Compatibility of server with old clients implemented and tested.

* CAUTH, SAUTH were deprecated from the new protocol. All other S*
  commands (SGET, SOPENDIR, SSYNCH, SMD5, SVAR, SCONTEXT, SQUERY were
  removed as well from the new server protocol loop, and client always
  uses the non-encrypted versions (which are always encrypted due to the
  TLS session encapsulating them).

* Deprecated very old protocol commands AUTH and CLASSES.

* Added a line oriented pre-session dialog to exchange VERSION and
  IDENTITY.

* Changed the testall script to run either from OBJDIR or
  OBJDIR/tests/acceptance

* Added two file transfer digest verify acceptance tests, one for
  encrypt=true and one for encrypt=false.

* Removed STARTTLS command: The server can now distinguish old from new
  protocol by peeking into the TCP stream using recv(MSG_PEEK).

* Renamed policy_hub for non-bootstrapped client from 'undefined' to
  'policy_hub_undefined' so that user gets a clue when this does not
  resolve...

* Removed shortcut for connections to localhost, it was error-prone
  since connections are not only used for file transfers but also for
  query reporting etc. Check for localhost should be done on a higher
  level (it is already done for file transfers in
  ScheduleCopyOperation().

* Simplified TLSSend, TLSRecv by removing code for non-blocking
  sockets. Code was audited, couldn't find any use of non-blocking
  sockets. This was done primarily to sanitize error messages, since
  retrying is useless in a blocking connection and error stack was being
  messed up. @cduclos if we need non-blocking functionality in the
  future we can introduce it in separate functions.

* configure.ac: -lssl requires -lcrypto and -lcrypto requires -ldl.

* Catch error when searching address in lastseen.

* Naming conventions and code style were changed to match CFEngine's.

* Lots of logging changes.

martingehrke/masterfiles,martingehrke/masterfiles,maciejmrowiec/masterfiles,maciejmrowiec/masterfiles,frap/masterfiles-1,phnakarin/masterfiles,phnakarin/masterfiles,frap/masterfiles-1,frap/masterfiles-1,phnakarin/masterfiles,maciejmrowiec/masterfiles,tzz/masterfiles,martingehrke/masterfiles