Tweak sql update function.

Use only one function to do the database update and pass as argument the
minimum number of affected rows that must be met.
Switch to new version number.

Start adding new features.
Rebuild configure.
Print BSR to memory buffer.

Print the BSR to a memory buffer and write that out in one go.
This allows you to use a printed BSR in any reporting.
Tweak indent.
Allow cancel by JobId on storage daemon.

Sometimes the Director already removed the Job from its running queue
but the Storage daemon still thinks it doing a backup (or other Job)
and you cannot cancel the Job from within a console anymore. This piece
of code allows you to cancel a Storage Daemon Job by JobId. E.g. do
a status sd on the Storage Daemon make sure what Job you want to cancel
and issue a cancel storage=<Storage Daemon> Jobid=<JobId> This way you
can also remove a Job that blocks any other Jobs from running without
the need to restart the whole Storage Daemon.

Fixes #13: Allow cancel by JobId on storage daemon.
Implementation of an allowed scriptdir keyword

Implement an allowed scriptdir keyword in the filed that sets the
directories in which any runscript must be located so we can limit
the attack surface of the filedaemon.

Currently the filed will execute any script in any directory which
makes it a serious security concern by much of the bigger customers
security officers.

This new keyword implemented per director and a global one which is
used as a fallback when a specific one for a specific director is not
configured.

Fixes #31: Implementation of an allowed scriptdir keyword
Implementation of an allowed job command keyword

Implement an allowed Job command keyword in the filed that sets which
of the different Job commands we should accept. Currently the filed
will execute any Job command unless people specify the -b or -r option
(backup only/restore only) which makes it a serious security concern by
much of the bigger customers security officers.

This new keyword implements a per director and a global list which is used
as a fallback when a specific one for a specific director is not configured.

We won't filter all the commands issued by the director only
the important ones. Things which we allow to be filtered are:

- backup
- restore
- verify
- estimate
- runscript

Fixes #32: Implementation of an allowed job command keyword
Initial working version of SD-SD replication.

This code implements the replication of data between two Storage Daemons
used by the migrate and copy jobs. This is an extenstion of the existing
migration and copy job functionality. The old code already could select
two different storage resources on two different Storage Daemons but it
would then only connect to the write storage and ask there for the read
storage which is ofcourse not known there. This code checks to see if
the read and write storage is located on diffferent Storage Daemons by
comparing the address, SDport and password of the remote storage daemon.

If it detects there are two Storage Daemons involved it will use the
new SD-SD communication protocol to perform a replicate of the data from
the read storage to the write storage.

This patch implements the following:
- Refactored code for authenticating a daemon, this was refactored so
  that clients like the bconsole and qt-console from now on use the
  now working authenticate_with_director method of the bsock class so
  we don't duplicate code to much. Also the other authentication was
  refactored as part of this overhaul of the authentication system.
  There are now generic functions which allow to authenticate a certain
  daemon and a specific authentication is implemented using these
  functions. For the SD-SD authentication there is some extra code to be
  able to have one storage daemon start the challenge and the let the
  other response otherwise the authentication would never work as both
  challenge each other at the same time.
- Refactored a lot of code to properly use a boolean when things are
  a boolean and not polute the code with assigning true to an integer
  variable. That by incident false is 0 and true is 1 doesn't mean
  that you shouldn't just call a variable of the type bool and mix
  and match integer and boolean all over the code. A lot done more
  to come.
- Most protocol messages are now put into static char variables in the
  code instead of defining them directly in the code call. This was done
  in some parts of the code but not nearly enough this is a good step
  in the right direction.
- You can bandwith limit your replication sessions in multiple ways.
  - set a bandwidth limit in the migration/copy job
  - set a bandwitdh limit for the writing SD in the SD definition
    in the director config.
  - set a bandwitdh limit for the reading SD in the SD definition
    in the director config.
  - set a bandwidth limit on the reading SD in the storage daemon config
  - set a bandwidth limit on the writing SD in the storage daemon config
  - change the bandwith via the console setbandwidth cmd.
- The already allocated mig_jcr for a migration and copy Job is used
  to track the communication with the writing SD. The reading SD is
  controlled via the normal jcr structure. For this to work the mig_jcr
  is created without a so called Messages resource so when using the
  mig_jcr for controlling the writing SD we don't get those nasty mail
  and database logging as if the Job actually did run.
- A new SD-SD communication protocol is implemented and this can be
  extended in the future to perform other SD-SD protocol features. For
  now the generic listener of the SD will understand the following
  incoming connections:
    - FD - SD backup and restore sessions which start with the following
      sequence: Hello Start Job <jobname>
    - SD - SD replication of data which start with the following
      sequence: Hello Start Storage Job <jobname>
    - DIR - SD controlling sessions for controlling the SD from the
      director.
- The old one Storage Daemon migrate and copy is still available and
  when the director finds out both the read and write storage is one
  the same SD it will use this optimized and fastest code path where
  the SD reads the data and directly writes the data to other media
  available to the same SD. SD-SD network replication is only used when
  the two SDs are determined to be different this way we only use the
  network when really neeeded and the one SD replication using internal
  stuctures is way faster then any loopback network send protocol.
- Comments are fixed along the way.
- Parts of lib/message.c are reindented as it used the wrong indention
  levels.

Fixes #7: Job migration/copy between different SDs
Cleanup of compression framework

As part of the integration of the LZO2 compression a new set of data
streams was introduced. Each compression stream now starts with a
so called compression header which says what compression was used.
We should deprecate the old GZIP datastreams e.g. still allow them to
be restored but not use them from now on and implement GZIP compression
using the same compression header which will cleanup the code enormously
and as we are planning on adding additional compression methods it would
be nice if all compression uses the same coding style and we deprecate
the old and non flexible GZIP datastreams.

Fixes #34: Cleanup of compression framework
Encryption cipher is hardcoded

The crypto framework support multiple encryption ciphers but the code
hardcodes the cipher to AES128.

The crypto framework support the following ciphers:
- AES128
- AES192
- AES256
- BLOWFISH

openssl (< 1.0) also has support for the following block ciphers.
- CAMELLIA128
- CAMELLIA192
- CAMELLIA256

openssl (> 1.0) also has support for the following block ciphers.
- AES128HMACSHA1
- AES256HMACSHA1

Adding support for these extra block ciphers seems obvious e.g. set the
right NID and entry point to the cipher.

Fixes #46: Encryption cipher is hardcoded
Allow BAREOS to interface to multiple crypto libs.

OPENSSL gives all kind of headaches as its not compatible to AGPLv3 and
as such you always need a linkage exception in your LICENSE. Allowing
to interface to GNUTLS (LGPL) or Mozilla NSS (MPL/GPL/LGPL) makes this
probem much easier to swallow. This is the first work to allow either
one of the following crypto/TLS frameworks:

- None
- OpenSSL
- GNUTLS
- Mozilla NSS

Also only link and include the crypto specific headers and libs in
the place that actually defines the abstraction layer and not all over
the code.
Rebuild configure and config.h.in
add missing directories

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
Tweak fix compile error.
Tweak copyright.
Fix compile problem when no lzo2 enabled.
Tweak fix compiler warning.
Tweak fix compiler warning.
Tweak fix when no compression is enabled.