Cleanup tape error reporting.

Use always clrerror(mt_com.mt_op) where possible to never make an error
on what we do the error reporting on. The mt_com.mt_op contains the last
ioctl operation that failed. Also add some missing error reporting which
makes converity happy.
Fix compiler warnings when not using dynamic backend loading.
Fix Windows build.
Sync LMDB code.
First attempt at making things somewhat cleaner.

- On windows also compile all shared objects into a dll.
- Implement the DCR (Device Control Record) as an inherited class of
  SMARTALLOC just like most others and implement a proper constructor
  for it. The new_dcr function is now replaced with a instantiate of the
  class and then a call to setup_new_dcr_device()
- Abstract the askdir functions as methods of the DCR (Device Control
  Record) and implement a special derived class for the stored and btape
  that abstracts the special functions for those and make the rest use
  the default dummy methods. This way we can nice and cleanly implement
  this for the different programs.
- Drop the wait_device_release conditional global variable, instead
  create a single function entry point release_device_cond() that gets
  called when we want the conditional variable to be signaled.
Tweak layout.
Fix problem with new DCR constructor.

Coverity found a valid problem with the new DCR constructor that cannot
use the dev variable as that is a non initialized variable in the
constructor so use a proper local error buffer.
Change the socket constructors.

As all BSOCK_XX classes are a derived class of BSOCK it makes more sense
to initialize the shared members in the BSOCK constructor. As on
creation of a devived class the base class constructor gets called
anyway this will work nicely. We also don't have to intialize everything
to zero as the BSOCK class is a derived class from the SMARTALLOC class
and as such the constructor of that class will initialize the memory to
zero.
Fix problem now we use call a real constructor for the DCR.

We can no longer use the side effect of an assignment calling a
constructor to fill two variables so do it in two steps.
Initialize m_fd in the base DEVICE class.

As all device classes are derived classes of DEVICE we can initialize
the members of the base class in the constructor of the base class as
that is called anyway as part of the instantiation of the derived class.
Tweak BSOCK classes one more time.

Got bitten by the famous undefined reference to `vtable for ...`
Fix same problem also for other bsock classes.

If we ever implement them and start using them we will run into the same
problems as we have seen for the used BSOCK_TCP class.
For the time being disable the backend configdir option on windows.

Until we find a good way to set the good backenddir on windows we use
the windows black magic way of using the search path for finding the
right catalog backend dll.
Fix wrong call of acl_access_ok

A typo in calling acl_access_ok was fixed.

Fixes #327: "No authorization for Client" on any operations from BAT.

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
Add support for newer APIs

The API world hasn't been frozen over the years and POSIX
nowadays defines some new APIs which we might want to start exploring.

This patch adds support for the following new APIs:

fchown()/lchown() replacing the chown call.
fchmod()/lchmod() replacing the chmod call.
utimes()/futimes()/futimens()/lutimes() replacing the utime call.

If those APIs are available they are prefered rather then using the
standard chown(), chmod() and utime() APIs.

We move away from using utime when possible because POSIX.1-2008
marks utime() as obsolete.
Rebuild configure and config.h.in