[pkg-bacula-commits] [bacula] 01/01: Imported upstream version 7.2.1~git20160102

Carsten Leonhardt leo at moszumanska.debian.org
Sat Jan 9 10:21:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

leo pushed a commit to branch upstream
in repository bacula.

commit 05c4ba2618d7c7bada284616a4daf3ee9f956aa3
Author: Carsten Leonhardt <leo at debian.org>
Date:   Sat Jan 9 11:18:30 2016 +0100

    Imported upstream version 7.2.1~git20160102
    
    Corresponds to upstream git up to commit
    7c91ff8c9af8c36631d0317d5e9ac2d57984e9f5
    
    Changes from upstream:
    src/lib/sha1.{h,c}: (#658326) remove, DFSG-nonfree, RFC 3174
---
 ChangeLog                                  |   2 -
 LICENSE                                    |  10 +-
 autoconf/configure.in                      |  27 +-
 configure                                  |  47 ++-
 examples/autochangers/chio-changer-freebsd | 194 +++++++++++
 examples/autochangers/rc-chio-changer      | 139 --------
 manpages/bextract.8                        |   3 +
 platforms/osx/Makefile.in                  |  27 +-
 platforms/rpms/suse/bacula-bat.spec.in     |   1 -
 src/c                                      |   1 -
 src/cats/bdb.h                             |   6 +
 src/cats/bvfs.c                            |   9 +-
 src/cats/cats.c                            |  14 +-
 src/cats/cats.h                            |   2 +
 src/cats/cats_null.c                       |   7 +-
 src/cats/grant_mysql_privileges.in         |  10 +-
 src/cats/mysql.c                           |  66 +++-
 src/cats/postgresql.c                      |  27 +-
 src/cats/protos.h                          |   7 +-
 src/cats/sql_delete.c                      |   1 -
 src/cats/sql_find.c                        |  78 ++++-
 src/cats/sql_get.c                         |   9 +-
 src/cats/sql_list.c                        | 166 +++++----
 src/cats/sql_update.c                      |   1 -
 src/cats/sqlite.c                          |  11 +-
 src/cats/update_sqlite3_tables.in          |  73 +++-
 src/console/authenticate.c                 |   1 -
 src/console/conio.c                        |   1 -
 src/console/conio.h                        |   1 -
 src/console/console.c                      |  31 +-
 src/console/console_conf.c                 |   1 -
 src/console/console_conf.h                 |   1 -
 src/console/func.h                         |   1 -
 src/dird/admin.c                           |   1 -
 src/dird/authenticate.c                    |   1 -
 src/dird/autoprune.c                       |   6 -
 src/dird/backup.c                          |   3 +-
 src/dird/bacula-dir.conf.in                |   5 +-
 src/dird/bsr.c                             |   1 -
 src/dird/catreq.c                          |   2 -
 src/dird/dir_plugins.c                     |   1 -
 src/dird/dird.c                            |  11 +-
 src/dird/dird_conf.c                       |  23 +-
 src/dird/dird_conf.h                       |   5 +
 src/dird/expand.c                          |  18 +-
 src/dird/fd_cmds.c                         |  36 +-
 src/dird/getmsg.c                          |   1 -
 src/dird/inc_conf.c                        |   1 -
 src/dird/job.c                             |  16 +-
 src/dird/jobq.c                            |   1 -
 src/dird/mac.c                             |   1 -
 src/dird/mac_sql.c                         |   1 -
 src/dird/mountreq.c                        |   1 -
 src/dird/msgchan.c                         |   1 -
 src/dird/newvol.c                          |   2 +-
 src/dird/next_vol.c                        |  31 ++
 src/dird/recycle.c                         |   1 -
 src/dird/restore.c                         |   1 -
 src/dird/run_conf.c                        |   1 -
 src/dird/scheduler.c                       |   1 -
 src/dird/snapshot.c                        |   1 -
 src/dird/ua_acl.c                          |   1 -
 src/dird/ua_cmds.c                         |  35 +-
 src/dird/ua_dotcmds.c                      |  21 +-
 src/dird/ua_input.c                        |   1 -
 src/dird/ua_label.c                        |   3 +-
 src/dird/ua_output.c                       |  46 ++-
 src/dird/ua_prune.c                        |   5 +-
 src/dird/ua_purge.c                        |  13 +-
 src/dird/ua_query.c                        |  16 +-
 src/dird/ua_restore.c                      |   9 +-
 src/dird/ua_run.c                          |  11 +-
 src/dird/ua_select.c                       |  13 +-
 src/dird/ua_server.c                       |   1 -
 src/dird/ua_status.c                       |  25 +-
 src/dird/ua_tree.c                         |   1 -
 src/dird/ua_update.c                       |   1 -
 src/dird/vbackup.c                         |  17 +-
 src/dird/verify.c                          |  86 ++++-
 src/filed/accurate.c                       |   1 -
 src/filed/authenticate.c                   |   1 -
 src/filed/backup.c                         |  22 +-
 src/filed/backup.h                         |   1 -
 src/filed/crypto.c                         |   1 -
 src/filed/estimate.c                       |   1 -
 src/filed/fd_plugins.c                     |   1 -
 src/filed/fd_plugins.h                     |   1 -
 src/filed/fd_snapshot.c                    |   1 -
 src/filed/fd_snapshot.h                    |   1 -
 src/filed/filed.c                          |  12 +-
 src/filed/filed.h                          |   4 +-
 src/filed/filed_conf.c                     |   1 -
 src/filed/filed_conf.h                     |   1 -
 src/filed/heartbeat.c                      |   1 +
 src/filed/job.c                            |  23 +-
 src/filed/protos.h                         |   4 +-
 src/filed/restore.c                        |   4 +-
 src/filed/status.c                         |   1 -
 src/filed/verify.c                         |   1 -
 src/filed/verify_vol.c                     | 535 ++++++++++++++++++++++-------
 src/filed/xattr.c                          |  15 +-
 src/findlib/Makefile.in                    |   4 +-
 src/findlib/attribs.c                      |   2 -
 src/findlib/bfile.c                        |   1 -
 src/findlib/bfile.h                        |   1 -
 src/findlib/create_file.c                  |   1 -
 src/findlib/drivetype.c                    |   2 -
 src/findlib/enable_priv.c                  |   1 -
 src/findlib/find.c                         |   1 -
 src/findlib/find.h                         |   3 +-
 src/findlib/find_one.c                     |   3 +-
 src/findlib/fstype.c                       |  20 +-
 src/findlib/match.c                        |   1 -
 src/findlib/mkpath.c                       |   1 -
 src/findlib/protos.h                       |   1 -
 src/findlib/savecwd.c                      |   1 -
 src/findlib/savecwd.h                      |   1 -
 src/findlib/win32filter.c                  |  96 ++++++
 src/findlib/win32filter.h                  |  59 ++++
 src/jcr.h                                  |   1 +
 src/lib/bpipe.c                            |   6 +
 src/lib/parse_conf.h                       |   2 +-
 src/plugins/fd/bpipe-fd.c                  |   7 +-
 src/plugins/fd/example-plugin-fd.c         |   1 -
 src/plugins/fd/test-deltaseq-fd.c          |   1 -
 src/plugins/fd/test-plugin-fd.c            |   1 -
 src/stored/acquire.c                       |   3 +-
 src/stored/askdir.c                        |  12 +-
 src/stored/bextract.c                      |  11 +-
 src/stored/block.c                         |   4 +-
 src/stored/block_util.c                    |  11 +-
 src/stored/bscan.c                         |  27 +-
 src/stored/device.c                        |   4 +-
 src/stored/dircmd.c                        |  35 +-
 src/stored/file_dev.c                      |   7 +
 src/stored/label.c                         |  17 +-
 src/stored/reserve.c                       |   6 +-
 src/stored/status.c                        |   3 +-
 src/stored/stored.c                        |  10 +-
 src/stored/tape_dev.c                      |   3 +
 src/tools/bbatch.c                         |  30 +-
 src/tools/bpluginfo.c                      |   4 +
 src/tools/bvfs_test.c                      |  27 +-
 src/tools/cats_test.c                      |   4 +
 src/tools/dbcheck.c                        |  72 ++--
 src/version.h                              |   8 +-
 146 files changed, 1824 insertions(+), 779 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6ffaa2f..9029f06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,8 +3,6 @@
 
 Release Version 7.2.0
 
-
-
 12Aug15
  - Put back missing close_msg(NULL) to flush daemon messages at job end
  - Add LICENSE-FOSS and update LICENSE for baculum
diff --git a/LICENSE b/LICENSE
index 83b6ff1..8f657c3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -27,7 +27,6 @@ General Public License are as follows:
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2015 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -59,6 +58,15 @@ AGPLv3 are as follows:
    the AGPLv3 in all respects for all of the code used other than for the
    Microsoft VSS code.
 
+The copyright for certain source files may include in addition to what is
+listed above the following copyright:
+
+   Copyright (C) 2000-2015 Free Software Foundation Europe e.V.
+
+The copyright on the Baculum code is:
+
+   Copyright (C) 2013-2015 Marcin Haba
+
 Copyrights of certain "script" files such as headers, shell script, Makefiles,
 etc ... were never explicitly defined. In almost all cases, they have
 been copyrighted with a BSD 2-Clause copyright to make them easier. However,
diff --git a/autoconf/configure.in b/autoconf/configure.in
index 0843981..7510751 100644
--- a/autoconf/configure.in
+++ b/autoconf/configure.in
@@ -90,14 +90,14 @@ dnl -------------------------------------------------------
 dnl Check for compiler.
 dnl ------------------------------------------------------
 
-AC_PROG_CC
+AC_PROG_CC		dnl this sets $GCC if using GNU C compiler
 AC_PROG_CXX
-AC_PROG_CC_C_O	       dnl Determine if C compiler support -c -o.
-AC_PROG_GCC_TRADITIONAL    dnl Determine if ioctl() need -traditional.
+AC_PROG_CC_C_O		dnl Determine if C compiler support -c -o.
+AC_PROG_GCC_TRADITIONAL dnl Determine if ioctl() need -traditional.
 
 BASECC=`basename $CC`
 have_gcc=no
-if test "x$BASECC" = xgcc; then
+if test x"$GCC" = "xyes"; then
    AC_DEFINE(HAVE_GCC)
    have_gcc=yes
 fi
@@ -1452,6 +1452,20 @@ AC_ARG_WITH(db_port,
 )
 AC_SUBST(db_port)
 
+dnl
+dnl Pickup MySQL SSL options for database user connection 
+dnl
+db_ssl_options=
+AC_ARG_WITH(db_ssl_options,
+   AC_HELP_STRING([--with-db-ssl-options=DBSSLOPTIONS], [specify SSL options for database user connection @<:@default=null@:>@]),
+   [
+       if test "x$withval" != "x" ; then
+	 db_ssl_options=$withval
+       fi
+   ]
+)
+AC_SUBST(db_ssl_options)
+
 #
 # Handle users and groups for each daemon
 #
@@ -2886,8 +2900,8 @@ AC_DEFINE(FDLIBS)
 CFLAGS=${CFLAGS--O}
 
 if test x$have_gcc = xyes ; then
-   CPPFLAGS="$CPPFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
-   CFLAGS="$CFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
+   CPPFLAGS="$CPPFLAGS -x c++ -fno-strict-aliasing -fno-exceptions -fno-rtti"
+   CFLAGS="$CFLAGS -x c++ -fno-strict-aliasing -fno-exceptions -fno-rtti"
 fi
 LDFLAGS=${LDFLAGS--O}
 CPPFLAGS="$CPPFLAGS"
@@ -3490,6 +3504,7 @@ Configuration on `date`:
    Database port:	     ${db_port}
    Database name:	     ${db_name}
    Database user:	     ${db_user}
+   Database SSL options:     ${db_ssl_options}
 
    Job Output Email:	     ${job_email}
    Traceback Email:	     ${dump_email}
diff --git a/configure b/configure
index e476645..3602d58 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for bacula 7.2.0.
+# Generated by GNU Autoconf 2.69 for bacula 7.2.1.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='bacula'
 PACKAGE_TARNAME='bacula'
-PACKAGE_VERSION='7.2.0'
-PACKAGE_STRING='bacula 7.2.0'
+PACKAGE_VERSION='7.2.1'
+PACKAGE_STRING='bacula 7.2.1'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -681,6 +681,7 @@ sd_group
 sd_user
 dir_group
 dir_user
+db_ssl_options
 db_port
 db_password
 db_user
@@ -986,6 +987,7 @@ with_db_name
 with_db_user
 with_db_password
 with_db_port
+with_db_ssl_options
 with_dir_user
 with_dir_group
 with_sd_user
@@ -1562,7 +1564,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures bacula 7.2.0 to adapt to many kinds of systems.
+\`configure' configures bacula 7.2.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1631,7 +1633,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of bacula 7.2.0:";;
+     short | recursive ) echo "Configuration of bacula 7.2.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1719,6 +1721,9 @@ Optional Packages:
   --with-db-user=UNAME    specify database user [default=bacula]
   --with-db-password=PWD  specify database password [default=*none*]
   --with-db-port=DBPORT   specify a database port [default=null]
+  --with-db-ssl-options=DBSSLOPTIONS
+                          specify SSL options for database user connection
+                          [default=null]
   --with-dir-user=USER    specify user for Director daemon
   --with-dir-group=GROUP  specify group for Director daemon
   --with-sd-user=USER     specify user for Storage daemon
@@ -1826,7 +1831,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-bacula configure 7.2.0
+bacula configure 7.2.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2761,7 +2766,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by bacula $as_me 7.2.0, which was
+It was created by bacula $as_me 7.2.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4075,8 +4080,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-ac_ext=cpp
+		ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -4756,7 +4760,7 @@ fi
 
 BASECC=`basename $CC`
 have_gcc=no
-if test "x$BASECC" = xgcc; then
+if test x"$GCC" = "xyes"; then
    $as_echo "#define HAVE_GCC 1" >>confdefs.h
 
    have_gcc=yes
@@ -23658,6 +23662,20 @@ fi
 
 
 
+db_ssl_options=
+
+# Check whether --with-db_ssl_options was given.
+if test "${with_db_ssl_options+set}" = set; then :
+  withval=$with_db_ssl_options;
+       if test "x$withval" != "x" ; then
+	 db_ssl_options=$withval
+       fi
+
+
+fi
+
+
+
 #
 # Handle users and groups for each daemon
 #
@@ -30493,8 +30511,8 @@ $as_echo "#define FDLIBS 1" >>confdefs.h
 CFLAGS=${CFLAGS--O}
 
 if test x$have_gcc = xyes ; then
-   CPPFLAGS="$CPPFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
-   CFLAGS="$CFLAGS -fno-strict-aliasing -fno-exceptions -fno-rtti"
+   CPPFLAGS="$CPPFLAGS -x c++ -fno-strict-aliasing -fno-exceptions -fno-rtti"
+   CFLAGS="$CFLAGS -x c++ -fno-strict-aliasing -fno-exceptions -fno-rtti"
 fi
 LDFLAGS=${LDFLAGS--O}
 CPPFLAGS="$CPPFLAGS"
@@ -31392,7 +31410,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by bacula $as_me 7.2.0, which was
+This file was extended by bacula $as_me 7.2.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -31458,7 +31476,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-bacula config.status 7.2.0
+bacula config.status 7.2.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -33730,6 +33748,7 @@ Configuration on `date`:
    Database port:	     ${db_port}
    Database name:	     ${db_name}
    Database user:	     ${db_user}
+   Database SSL options:     ${db_ssl_options}
 
    Job Output Email:	     ${job_email}
    Traceback Email:	     ${dump_email}
diff --git a/examples/autochangers/chio-changer-freebsd b/examples/autochangers/chio-changer-freebsd
new file mode 100755
index 0000000..b9cec93
--- /dev/null
+++ b/examples/autochangers/chio-changer-freebsd
@@ -0,0 +1,194 @@
+#!/bin/sh
+#
+# Copyright (C) 2015 Rudolf Cejka
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Bacula interface to tape libraries and autoloaders for FreeBSD
+# (by Rudolf Cejka <cejkar at fit.vutbr.cz>, v1.2, 2012/11/14)
+#
+#
+# If you set in your Device resource
+#   Changer Command = "path-to-this-script/chio-changer %c %o %S %a %d"
+# you will have the following input to this script:
+#   chio-changer "changer-device" "command" "slot" "tape-device" "drive-index"
+#                       $1           $2       $3         $4            $5
+# for example (on a FreeBSD system):
+#   chio-changer /dev/ch0 load 1 /dev/nsa0 0
+#
+# If you change the script, take care to return either the chio exit
+# code or a 0. If the script exits with a non-zero exit code, Bacula
+# will assume the request failed.
+#
+
+PROGNAME=`basename $0`
+
+# Uncomment the following line, if you want to log debug output.
+#DEBUG=/var/run/bacula/${PROGNAME}.log
+
+# Uncomment the following line, if you need to eject a tape before moving
+# it from the drive.
+#OFFLINE=yes
+
+# Uncomment one or more of the following lines, if you need to wait for
+# some time (in seconds) after unloading, loading or transferring a tape.
+#OFFLINE_SLEEP=10
+#LOAD_SLEEP=10
+#MOVE_SLEEP=10
+
+# Uncomment the following line, if you do not have a changer with volume
+# reader.
+#FAKE_BARCODES=/usr/local/etc/bacula-barcodes
+
+usage()
+{
+  cat <<EOF
+Usage: ${PROGNAME} <changer-device> <cmd> [slot] [tape-device] [drive-index]
+
+Commands (<cmd>):
+  unload          Unload a tape into the slot from where it was loaded
+  load <slot>     Load a tape from the slot <slot> (1-based)
+  transfer <slot> <slotdst> Transfer a tape from the slot <slot> to
+                  the slot <slotdst> (1-based)
+  list            List full storage slots
+  listall         List all storage slots and drives with source information
+  loaded          Give slot from where the tape was loaded (0 = empty drive)
+  slots           Give number of available slots
+
+Example:
+  ${PROGNAME} /dev/ch0 load 1        Load a tape from the slot 1
+
+EOF
+  exit 1
+}
+
+# Default settings
+CHANGER=/dev/ch0
+TAPE=/dev/nsa0
+DRIVE=0
+
+CHIO=/bin/chio
+MT=/usr/bin/mt
+
+if [ -n "${DEBUG}" ]; then
+  MSG=$0
+  for PAR; do MSG="${MSG} \"${PAR}\""; done
+  echo `date +"%Y/%m/%d %H:%M:%S"` ${MSG} >> ${DEBUG}
+fi
+
+if [ -n "$1" ]; then
+  CHANGER=$1;
+fi
+COMMAND=$2
+SLOT=$3
+SLOTDST=$4
+if [ -n "$4" ]; then
+  TAPE=$4
+fi
+if [ -n "$5" ]; then
+  DRIVE=$5
+fi
+
+case ${COMMAND} in
+unload)
+  if [ "${OFFLINE}" = yes ]; then
+    ${MT} -f ${TAPE} offline
+    if [ $? = 0 -a -n "${OFFLINE_SLEEP}" ]; then
+      sleep ${OFFLINE_SLEEP}
+    fi
+  fi
+  if [ -z "${SLOT}" ]; then
+    ${CHIO} -f ${CHANGER} return drive ${DRIVE}
+  else
+    ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${SLOT} - 1))
+  fi
+  if [ $? -ne 0 ]; then
+    # In case of an error, try to unload the cartridge to the first free slot
+    FREE=`${CHIO} -f ${CHANGER} status slot | \
+      sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \
+      awk 'BEGIN { n = 0 } { n = $1 + 1; exit } END { print n }'`
+    if [ ${FREE} -gt 0 ]; then
+      ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${FREE} - 1))
+    else
+      exit 1
+    fi
+  fi
+  ;;
+load)
+  if [ -z "${SLOT}" ]; then
+    usage
+  fi
+  ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) drive ${DRIVE}
+  if [ $? -ne 0 ]; then
+    exit 1
+  fi
+  if [ -n "${LOAD_SLEEP}" ]; then
+    sleep ${LOAD_SLEEP}
+  fi
+  ;;
+transfer)
+  if [ -z "${SLOT}" -o -z "${SLOTDST}" ]; then
+    usage
+  fi
+  ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) slot $((${SLOTDST} - 1))
+  if [ $? -ne 0 ]; then
+    exit 1
+  fi
+  if [ -n "${MOVE_SLEEP}" ]; then
+    sleep ${MOVE_SLEEP}
+  fi
+  ;;
+list)
+  if [ -z "${FAKE_BARCODES}" ]; then
+    ${CHIO} -f ${CHANGER} status -v slot | \
+      sed -ne 's/^slot *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*/\1:\2/p' | \
+      awk -F: '{ print $1 + 1 ":" $2 }'
+  else
+    if [ -f "${FAKE_BARCODES}" ]; then
+      grep -v -e "^#" -e "^$" < ${FAKE_BARCODES}
+    else
+      echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing"
+      exit 1
+    fi
+  fi
+  ;;
+listall)
+  if [ -z "${FAKE_BARCODES}" ]; then
+    ${CHIO} -f ${CHANGER} status -vS | \
+      sed -ne '
+      s/^slot *\([0-9]*\):.*ENAB.*FULL.*voltag.*<\([^:]*\):.*/I:\1:F:\2/p;t
+      s/^slot *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*/S:\1:F:\2/p;t
+      s/^drive *\([0-9]*\):.*FULL.*voltag.*<\([^:]*\):.*source.*<[^0-9]*\([0-9]*\)>.*/D:\1:F:\3:\2/p;t
+      s/^slot *\([0-9]*\):.*ENAB.*voltag.*<\([^:]*\):.*/I:\1:E/p;t
+      s/^slot *\([0-9]*\):.*voltag.*<\([^:]*\):.*/S:\1:E/p;t
+      s/^drive *\([0-9]*\):.*voltag.*<\([^:]*\):.*/D:\1:E/p' | \
+      awk -F: '{ for (n = 1; n <= NF; n++) printf "%s%s",
+      (n == ($1 == "D" ? 4 : 2)) ? ($n == "" ? 0 : $n + 1) : $n,
+      (n == NF) ? "\n" : ":" }'
+  else
+    if [ -f "${FAKE_BARCODES}" ]; then
+      grep -v -e "^#" -e "^$" < ${FAKE_BARCODES} | \
+        awk -F: '{ print "S:" $1 (match($2, "^ *$") ? ":E" : ":F:" $2) }'
+    else
+      echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing"
+      exit 1
+    fi
+  fi
+  ;;
+loaded)
+  # If a tape is loaded, but the source slot is unknown (for example,
+  # after library reboot), try to report the first free slot
+  FREE=`${CHIO} -f ${CHANGER} status slot | \
+    sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \
+    awk 'BEGIN { n = 0 } { n = $1 + 1; exit } END { print n }'`
+  ${CHIO} -f ${CHANGER} status -S drive | \
+    sed -ne 's/^drive *'${DRIVE}':.*FULL.*source.*<[^0-9]*\([0-9]*\)>.*/\1/p' \
+    | awk 'BEGIN { n = 0 } { n = ($1 == "") ? '${FREE}' : $1 + 1 } \
+    END { print n }'
+  ;;
+slots)
+  ${CHIO} -f ${CHANGER} status | grep -c "^slot "
+  ;;
+*)
+  usage
+  ;;
+esac
diff --git a/examples/autochangers/rc-chio-changer b/examples/autochangers/rc-chio-changer
deleted file mode 100644
index 7007842..0000000
--- a/examples/autochangers/rc-chio-changer
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/bin/sh
-#
-# Bacula interface to chio autoloader
-# (by Rudolf Cejka <cejkar at fit.vutbr.cz>)
-#
-# $Id$
-#
-# If you set in your Device resource
-#   Changer Command = "path-to-this-script/chio-changer %c %o %S %a %d"
-# you will have the following input to this script:
-#   chio-changer "changer-device" "command" "slot" "tape-device" "drive-index"
-#                       $1           $2       $3         $4            $5
-# for example (on a FreeBSD system):
-#   chio-changer /dev/ch0 load 1 /dev/nsa0 0
-#
-# If you change the script, take care to return either the chio exit
-# code or a 0. If the script exits with a non-zero exit code, Bacula
-# will assume the request failed.
-#
-
-# Uncomment the following line, if you need to eject a tape before moving
-# it from the drive.
-#OFFLINE=yes
-
-# Uncomment the following line, if you need to wait for some time
-# (in seconds) after (un)loading a tape.
-#SLEEP=10
-
-# Uncomment the following line, if you do not have a changer with volume
-# reader.
-#FAKE_BARCODES=/usr/local/etc/bacula-barcodes
-
-PROGNAME=`basename $0`
-
-usage()
-{
-  cat <<EOF
-Usage: ${PROGNAME} <changer-device> <cmd> [slot] [tape-device] [drive-index]
-
-Commands (<cmd>):
-  unload          Unloads a tape into the slot from where it was loaded.
-  load <slot>     Loads a tape from the slot <slot> (1-based).
-  list            Lists full storage slots.
-  loaded          Gives slot from where the tape was loaded (0 = empty drive).
-  slots           Gives number of available slots.
-
-Example:
-  ${PROGNAME} /dev/ch0 load 1        Loads a tape from first slot 1.
-
-EOF
-}
-
-# Default settings
-CHANGER=/dev/ch0
-TAPE=/dev/nsa0
-DRIVE=0
-
-CHIO=/bin/chio
-MT=/usr/bin/mt
-
-if [ $# -lt 2 ]; then
-  usage
-  exit 1
-fi
-
-if [ -n "$1" ]; then
-  CHANGER=$1;
-fi
-COMMAND=$2
-SLOT=$3
-if [ -n "$4" ]; then
-  TAPE=$4
-fi
-if [ -n "$5" ]; then
-  DRIVE=$5
-fi
-
-case ${COMMAND} in
-unload)
-  if [ "${OFFLINE}" = yes ]; then
-    ${MT} -f ${TAPE} offline
-  fi
-  if [ -n "${SLEEP}" ]; then
-    sleep ${SLEEP}
-  fi
-  if [ -z "${SLOT}" ]; then
-    ${CHIO} -f ${CHANGER} return drive ${DRIVE}
-  else
-    ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot $((${SLOT} - 1))
-  fi
-  if [ $? -ne 0 ]; then
-    # Try to unload the cartridge to the first free slot.
-    FREE=`${CHIO} -f ${CHANGER} status slot | \
-      sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | head -1`
-    if [ -n "${FREE}" ]; then
-      ${CHIO} -f ${CHANGER} move drive ${DRIVE} slot ${FREE}
-    else
-      exit 1
-    fi
-  fi
-  ;;
-load)
-  ${CHIO} -f ${CHANGER} move slot $((${SLOT} - 1)) drive ${DRIVE}
-  RET=$?
-  if [ -n "${SLEEP}" ]; then
-    sleep ${SLEEP}
-  fi
-  exit ${RET}
-  ;;
-list)
-  if [ -z "${FAKE_BARCODES}" ]; then
-    ${CHIO} -f ${CHANGER} status -v slot | \
-      sed -ne 's/^slot *\([0-9]*:\).*FULL.*voltag.*<\(.*\):.*/\1\2/p' | \
-      awk -F: '{print $1 + 1 ":" $2 }'
-  else
-    if [ -f "${FAKE_BARCODES}" ]; then
-      grep -v -e "^#" -e "^$" < ${FAKE_BARCODES}
-    else
-      echo "${PROGNAME}: Barcode file ${FAKE_BARCODES} is missing"
-      exit 1
-    fi
-  fi
-  ;;
-loaded)
-  FREE=`${CHIO} -f ${CHANGER} status slot | \
-    sed -ne '/FULL/d;s/^slot *\([0-9]*\):.*/\1/p' | \
-    awk 'BEGIN { n = 0 } { n = $1 + 1 ; exit } END { print n }'`
-  ${CHIO} -f ${CHANGER} status -S drive | \
-    sed -ne 's/^drive *'${DRIVE}':.*FULL.*source.*<[^0-9]*\([0-9]*\)>.*/\1/p' \
-    | awk 'BEGIN { n = 0 } { n = ($1 == "") ? '${FREE}' : $1 + 1 } \
-      END { print n }'
-  ;;
-slots)
-  ${CHIO} -f ${CHANGER} status | grep -c "^slot "
-  ;;
-*)
-  usage
-  ;;
-esac
diff --git a/manpages/bextract.8 b/manpages/bextract.8
index f5aff66..4cd9157 100644
--- a/manpages/bextract.8
+++ b/manpages/bextract.8
@@ -48,6 +48,9 @@ Specify include list.
 .BI \-p
 Proceed in spite of I/O errors.
 .TP
+.BI \-t\  
+Read data from volume, do not write anything
+.TP
 .B \-v
 Set verbose mode.
 .TP
diff --git a/platforms/osx/Makefile.in b/platforms/osx/Makefile.in
index f62e031..512c81e 100644
--- a/platforms/osx/Makefile.in
+++ b/platforms/osx/Makefile.in
@@ -16,12 +16,12 @@ BACULA_VERSION:=@VERSION@
 BACULA_DL_URL:=http://downloads.sourceforge.net/project/bacula/bacula/${BACULA_VERSION}/bacula-${BACULA_VERSION}.tar.gz
 
 # Build universal binary. Comment out when building versions of bacula < 3.0.0
-ARCHFLAGS:=-arch i386 -arch ppc
-MACOSX_SDK_SYSROOT:=/Developer/SDKs/MacOSX10.4u.sdk
-MACOSX_VERSION_FLAGS:=-mmacosx-version-min=10.4
+ARCHFLAGS:=
+MACOSX_SDK_SYSROOT:=
+MACOSX_VERSION_FLAGS:=
 
 # Tools
-PM:=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
+PB:=/usr/bin/pkgbuild
 MAKE:=/usr/bin/make
 CURL:=/usr/bin/curl
 TAR:=/usr/bin/tar
@@ -73,17 +73,17 @@ CONFIGFLAGS:= \
   --with-basename=@BASENAME@ \
   --with-hostname=@HOSTNAME@ \
   --with-working-dir=${BACULA_WORKING_DIR}
-CPPFLAGS:=-isysroot ${MACOSX_SDK_SYSROOT} ${MACOSX_VERSION_FLAGS}
-CFLAGS:=-O -g ${ARCHFLAGS}
+CPPFLAGS:=
+CFLAGS:=-O -g
 CXXFLAGS:=${CFLAGS}
-LDFLAGS:=-Wl,-syslibroot,${MACOSX_SDK_SYSROOT} ${MACOSX_VERSION_FLAGS} ${ARCHFLAGS}
+LDFLAGS:=
 
 # required on snow leopard: compiling for 10.4 requires usage of gcc 4.0
 # system defaults to version 4.2
-CC:=gcc-4.0
-CPP:=cpp-4.0
-CXX:=g++-4.0
-CXXPP:=cpp-4.0
+CC:=gcc
+CPP:=cpp
+CXX:=g++
+CXXPP:=cpp
 
 # Placeholders for *.in files
 INFILE_SUBST=\
@@ -99,8 +99,11 @@ dmg: pkg
 pkg: ${BACULA_DESTDIR} ${BACULA_PMDOC} ${WORKING_DIR}/resources
 	mkdir -p "${PACKAGE_DIR}"
 
-	${PM} --doc "${BACULA_PMDOC}" --id "${PACKAGE_ID}" --no-recommend --out "${PACKAGE_BUNDLE}"
+	mkdir -p "${CURDIR}/${BACULA_DESTDIR}${WORKING_DIR}"
 
+	${PB} --identifier "${PACKAGE_ID}" --root "${CURDIR}/${BACULA_DESTDIR}" "Bacula Enterprise File Daemon-${BACULA_VERSION}.pkg"
+	
+	cp "Bacula Enterprise File Daemon-${BACULA_VERSION}.pkg" "${PACKAGE_DIR}"
 	cp ${WORKING_DIR}/resources/ReadMe.html "${PACKAGE_DIR}/ReadMe.html"
 
 	sed ${INFILE_SUBST} \
diff --git a/platforms/rpms/suse/bacula-bat.spec.in b/platforms/rpms/suse/bacula-bat.spec.in
index 33d5308..5c220bf 100644
--- a/platforms/rpms/suse/bacula-bat.spec.in
+++ b/platforms/rpms/suse/bacula-bat.spec.in
@@ -127,7 +127,6 @@ BuildRequires: openssl-devel, fontconfig-devel, libpng-devel, libstdc++-devel, z
 
 Requires: openssl
 Requires: fontconfig
-Requires: libgcc
 Requires: libpng
 %if 0%{?suse_version} > 1210
 Requires: libstdc++.6
diff --git a/src/c b/src/c
index aeb8489..04d8f08 100644
--- a/src/c
+++ b/src/c
@@ -1,7 +1,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/cats/bdb.h b/src/cats/bdb.h
index cc53b4a..87b260b 100644
--- a/src/cats/bdb.h
+++ b/src/cats/bdb.h
@@ -42,6 +42,11 @@ public:
    char *m_db_driverdir;              /* database driver dir */
    int m_ref_count;                   /* reference count */
    int m_db_port;                     /* port for host name address */
+   char *m_db_ssl_key;                /* path name to the key file */
+   char *m_db_ssl_cert;               /* path name to the certificate file */
+   char *m_db_ssl_ca;                 /* path name to the certificate authority file */
+   char *m_db_ssl_capath;             /* path name to a directory that contains trusted SSL CA certificates in PEM format */
+   char *m_db_ssl_cipher;             /* a list of permissible ciphers to use for SSL encryption */
    bool m_disabled_batch_insert;      /* explicitly disabled batch insert mode ? */
    bool m_dedicated;                  /* is this connection dedicated? */
    bool m_use_fatal_jmsg;             /* use Jmsg(M_FATAL) after bad queries? */
@@ -114,6 +119,7 @@ public:
    int bdb_delete_snapshot_record(JCR *jcr, SNAPSHOT_DBR *sr);
 
    /* sql_find.c */
+   bool bdb_find_last_job_end_time(JCR *jcr, JOB_DBR *jr, POOLMEM **etime, char *job);
    bool bdb_find_last_job_start_time(JCR *jcr, JOB_DBR *jr, POOLMEM **stime, char *job, int JobLevel);
    bool bdb_find_job_start_time(JCR *jcr, JOB_DBR *jr, POOLMEM **stime, char *job);
    bool bdb_find_last_jobid(JCR *jcr, const char *Name, JOB_DBR *jr);
diff --git a/src/cats/bvfs.c b/src/cats/bvfs.c
index 1d4619d..ff236cb 100644
--- a/src/cats/bvfs.c
+++ b/src/cats/bvfs.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2009-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -482,7 +481,7 @@ static int update_path_hierarchy_cache(JCR *jcr,
       "AND h.PPathId NOT IN (SELECT PathId FROM PathVisibility WHERE JobId=%s)",
            jobid, jobid, jobid );
 
-   }  else if (mdb->bdb_get_type_index() == SQL_TYPE_MYSQL) {
+   } else if (mdb->bdb_get_type_index() == SQL_TYPE_MYSQL) {
       Mmsg(mdb->cmd,
   "INSERT INTO PathVisibility (PathId, JobId)  "
    "SELECT a.PathId,%s "
@@ -494,7 +493,7 @@ static int update_path_hierarchy_cache(JCR *jcr,
       "LEFT JOIN PathVisibility AS b ON (b.JobId=%s and a.PathId = b.PathId) "
       "WHERE b.PathId IS NULL",  jobid, jobid, jobid);
 
-   } else {                     /* TODO: Test the MYSQL Query with PostgreSQL */
+   } else {
       Mmsg(mdb->cmd,
   "INSERT INTO PathVisibility (PathId, JobId)  "
    "SELECT a.PathId,%s "
@@ -1367,7 +1366,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink,
          result[i++] = str_to_int64(row[1]); /* JobId */
          result[i++] = str_to_int64(row[2]); /* FilenameId */
          result[i++] = str_to_int64(row[3]); /* PathId */
-      }
+      } 
 
       i=0;
       while (num > 0) {
@@ -1440,5 +1439,5 @@ void Bvfs::insert_missing_delta(char *output_table, int64_t *res)
       Dmsg1(dbglevel_sql, "Can't exec q=%s\n", db->cmd);
    }
 }
-
+ 
 #endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_POSTGRESQL */
diff --git a/src/cats/cats.c b/src/cats/cats.c
index 4d189d0..5e19cd5 100644
--- a/src/cats/cats.c
+++ b/src/cats/cats.c
@@ -1,17 +1,16 @@
 /* 
    Bacula(R) - The Network Backup Solution
-
+ 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
-
+ 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
-
+ 
    You may use this file and others of this release according to the
    license defined in the LICENSE file, which includes the Affero General
    Public License, v3.0 ("AGPLv3") and some additional permissions and
    terms pursuant to its AGPLv3 Section 7.
-
+ 
    This notice must be preserved when any source code is 
    conveyed and/or propagated.
 
@@ -71,7 +70,10 @@ BDB *BDB::bdb_clone_database_connection(JCR *jcr, bool mult_db_connections)
     */ 
    return db_init_database(jcr, mdb->m_db_driver, mdb->m_db_name, 
              mdb->m_db_user, mdb->m_db_password, mdb->m_db_address, 
-             mdb->m_db_port, mdb->m_db_socket, true, 
+             mdb->m_db_port, mdb->m_db_socket,
+             mdb->m_db_ssl_key, mdb->m_db_ssl_cert,
+             mdb->m_db_ssl_ca, mdb->m_db_ssl_capath,
+             mdb->m_db_ssl_cipher, true,
              mdb->m_disabled_batch_insert); 
 } 
  
diff --git a/src/cats/cats.h b/src/cats/cats.h
index f1ee5dc..2908f15 100644
--- a/src/cats/cats.h
+++ b/src/cats/cats.h
@@ -159,6 +159,7 @@ struct JOB_DBR {
    char cEndTime[MAX_TIME_LENGTH];
    char cRealEndTime[MAX_TIME_LENGTH];
    /* Extra stuff not in DB */
+   int order;                         /* 0 ASC, 1 DESC */
    int limit;                         /* limit records to display */
    faddr_t rec_addr;
    uint32_t FileIndex;                /* added during Verify */
@@ -369,6 +370,7 @@ public:
    char    cLastWritten[MAX_TIME_LENGTH];  /* LastWritten returned from DB */
    char    cLabelDate[MAX_TIME_LENGTH];    /* LabelData returned from DB */
    char    cInitialWrite[MAX_TIME_LENGTH]; /* InitialWrite returned from DB */
+   char   *exclude_list;                   /* Optionnal exclude list for db_find_next_volume() */
    bool    set_first_written;
    bool    set_label_date;
 };
diff --git a/src/cats/cats_null.c b/src/cats/cats_null.c
index df00f8e..f3da1c2 100644
--- a/src/cats/cats_null.c
+++ b/src/cats/cats_null.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -27,8 +26,10 @@
  
 BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name,
          const char *db_user, const char *db_password, const char *db_address,
-         int db_port, const char *db_socket, bool mult_db_connections,
-         bool disable_batch_insert)
+         int db_port, const char *db_socket, const char *db_ssl_key,
+         const char *db_ssl_cert, const char *db_ssl_ca,
+         const char *db_ssl_capath, const char *db_ssl_cipher,
+         bool mult_db_connections, bool disable_batch_insert)
 { 
    Jmsg(jcr, M_FATAL, 0, _("Please replace this null libbaccats library with a proper one.\n"));
    return NULL; 
diff --git a/src/cats/grant_mysql_privileges.in b/src/cats/grant_mysql_privileges.in
index f1fcca5..ab85680 100644
--- a/src/cats/grant_mysql_privileges.in
+++ b/src/cats/grant_mysql_privileges.in
@@ -12,11 +12,15 @@ db_password=@db_password@
 if [ "$db_password" != "" ]; then
    pass="identified by '$db_password'"
 fi
-
+db_ssl_options=@db_ssl_options@
+if [ "$db_ssl_options" != "" ]; then
+   ssl_options="require $db_ssl_options"
+fi
+ 
 if $bindir/mysql $* -u root -f <<END-OF-DATA
 use mysql
-grant all privileges on ${db_name}.* to ${db_user}@localhost ${pass};
-grant all privileges on ${db_name}.* to ${db_user}@"%" ${pass};
+grant all privileges on ${db_name}.* to ${db_user}@localhost ${pass} ${ssl_options};
+grant all privileges on ${db_name}.* to ${db_user}@"%" ${pass} ${ssl_options};
 select * from user;
 flush privileges;
 END-OF-DATA
diff --git a/src/cats/mysql.c b/src/cats/mysql.c
index 2cc45c4..3ac8af7 100644
--- a/src/cats/mysql.c
+++ b/src/cats/mysql.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -93,6 +92,8 @@ BDB_MYSQL::~BDB_MYSQL()
  */ 
 BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name, const char *db_user, 
                        const char *db_password, const char *db_address, int db_port, const char *db_socket, 
+                       const char *db_ssl_key, const char *db_ssl_cert, const char *db_ssl_ca,
+                       const char *db_ssl_capath, const char *db_ssl_cipher,
                        bool mult_db_connections, bool disable_batch_insert) 
 { 
    BDB_MYSQL *mdb = NULL; 
@@ -130,9 +131,24 @@ BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name, cons
    if (db_address) { 
       mdb->m_db_address = bstrdup(db_address); 
    } 
-   if (db_socket) { 
+   if (db_socket) {
       mdb->m_db_socket = bstrdup(db_socket); 
    } 
+   if (db_ssl_key) {
+      mdb->m_db_ssl_key = bstrdup(db_ssl_key);
+   }
+   if (db_ssl_cert) {
+      mdb->m_db_ssl_cert = bstrdup(db_ssl_cert);
+   }
+   if (db_ssl_ca) {
+      mdb->m_db_ssl_ca = bstrdup(db_ssl_ca);
+   }
+   if (db_ssl_capath) {
+      mdb->m_db_ssl_capath = bstrdup(db_ssl_capath);
+   }
+   if (db_ssl_cipher) {
+      mdb->m_db_ssl_cipher = bstrdup(db_ssl_cipher);
+   }
    mdb->m_db_port = db_port; 
  
    if (disable_batch_insert) { 
@@ -200,6 +216,20 @@ bool BDB_MYSQL::bdb_open_database(JCR *jcr)
    mysql_init(&mdb->m_instance); 
  
    Dmsg0(50, "mysql_init done\n"); 
+
+   /*
+   * Sets the appropriate certificate options for
+   * establishing secure connection using SSL to the database.
+   */
+   if (mdb->m_db_ssl_key) {
+      mysql_ssl_set(&(mdb->m_instance),
+                   mdb->m_db_ssl_key,
+                   mdb->m_db_ssl_cert,
+                   mdb->m_db_ssl_ca,
+                   mdb->m_db_ssl_capath,
+                   mdb->m_db_ssl_cipher);
+   }
+
    /* 
     * If connection fails, try at 5 sec intervals for 30 seconds. 
     */ 
@@ -227,7 +257,7 @@ bool BDB_MYSQL::bdb_open_database(JCR *jcr)
    Dmsg0(50, "mysql_real_connect done\n"); 
    Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->m_db_user, mdb->m_db_name, 
         (mdb->m_db_password == NULL) ? "(NULL)" : mdb->m_db_password); 
- 
+
    if (mdb->m_db_handle == NULL) { 
       Mmsg2(&mdb->errmsg, _("Unable to connect to MySQL server.\n" 
 "Database=%s User=%s\n" 
@@ -244,6 +274,19 @@ bool BDB_MYSQL::bdb_open_database(JCR *jcr)
       goto get_out; 
    } 
  
+   /* get the current cipher used for SSL connection */
+   if (mdb->m_db_ssl_key) {
+      const char *cipher;
+      if (mdb->m_db_ssl_cipher) {
+         free(mdb->m_db_ssl_cipher);
+      }
+      cipher = (const char *)mysql_get_ssl_cipher(&(mdb->m_instance));
+      if (cipher) {
+         mdb->m_db_ssl_cipher = bstrdup(cipher);
+      }
+      Dmsg1(50, "db_ssl_ciper=%s\n", (mdb->m_db_ssl_cipher == NULL) ? "(NULL)" : mdb->m_db_ssl_cipher);
+   }
+
    mdb->m_connected = true; 
    if (!bdb_check_version(jcr)) { 
       goto get_out; 
@@ -311,7 +354,22 @@ void BDB_MYSQL::bdb_close_database(JCR *jcr)
       } 
       if (mdb->m_db_socket) { 
          free(mdb->m_db_socket); 
-      } 
+      }
+      if (mdb->m_db_ssl_key) {
+         free(mdb->m_db_ssl_key);
+      }
+      if (mdb->m_db_ssl_cert) {
+         free(mdb->m_db_ssl_cert);
+      }
+      if (mdb->m_db_ssl_ca) {
+         free(mdb->m_db_ssl_ca);
+      }
+      if (mdb->m_db_ssl_capath) {
+         free(mdb->m_db_ssl_capath);
+      }
+      if (mdb->m_db_ssl_cipher) {
+         free(mdb->m_db_ssl_cipher);
+      }
       delete mdb; 
       if (db_list->size() == 0) { 
          delete db_list; 
diff --git a/src/cats/postgresql.c b/src/cats/postgresql.c
index 76ac3dd..f8fa4a9 100644
--- a/src/cats/postgresql.c
+++ b/src/cats/postgresql.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -41,7 +40,7 @@
 #include  "postgres_ext.h"       /* needed for NAMEDATALEN */
 #include  "pg_config_manual.h"   /* get NAMEDATALEN on version 8.3 or later */
 #define __BDB_POSTGRESQL_H_ 1
-#include "bdb_postgresql.h"
+#include  "bdb_postgresql.h"
 
 #define dbglvl_dbg   DT_SQL|100
 #define dbglvl_info  DT_SQL|50
@@ -99,11 +98,11 @@ BDB_POSTGRESQL::~BDB_POSTGRESQL()
  * Initialize database data structure. In principal this should
  * never have errors, or it is really fatal.
  */
-BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name,
-                       const char *db_user, const char *db_password,
-                       const char *db_address, int db_port,
-                       const char *db_socket, bool mult_db_connections,
-                       bool disable_batch_insert)
+BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name, const char *db_user, 
+                       const char *db_password, const char *db_address, int db_port, const char *db_socket, 
+                       const char *db_ssl_key, const char *db_ssl_cert, const char *db_ssl_ca,
+                       const char *db_ssl_capath, const char *db_ssl_cipher,
+                       bool mult_db_connections, bool disable_batch_insert) 
 {
    BDB_POSTGRESQL *mdb = NULL;
 
@@ -129,9 +128,7 @@ BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name,
    mdb = New(BDB_POSTGRESQL());
    if (!mdb) goto get_out;
 
-   /*
-    * Initialize the parent class members.
-    */
+   /* Initialize the parent class members. */
    mdb->m_db_name = bstrdup(db_name);
    mdb->m_db_user = bstrdup(db_user);
    if (db_password) {
@@ -165,7 +162,7 @@ BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name,
 #endif /* USE_BATCH_FILE_INSERT */ 
    } 
    mdb->m_allow_transactions = mult_db_connections;
-
+ 
    /* At this time, when mult_db_connections == true, this is for
     * specific console command such as bvfs or batch mode, and we don't
     * want to share a batch mode or bvfs. In the future, we can change
@@ -315,7 +312,7 @@ void BDB_POSTGRESQL::bdb_close_database(JCR *jcr)
       db_list->remove(mdb);
       if (mdb->m_connected && mdb->m_db_handle) {
          PQfinish(mdb->m_db_handle);
-      }
+      } 
       if (is_rwl_valid(&mdb->m_lock)) {
          rwl_destroy(&mdb->m_lock);
       } 
@@ -678,7 +675,7 @@ get_out:
 ok_out: 
    return retval; 
 }  
-
+ 
 void BDB_POSTGRESQL::sql_free_result(void)
 {
    BDB_POSTGRESQL *mdb = this;
@@ -743,10 +740,10 @@ SQL_ROW BDB_POSTGRESQL::sql_fetch_row(void)
    Dmsg1(dbglvl_info, "sql_fetch_row finishes returning %p\n", row);
  
    return row; 
-}
+} 
 
 const char *BDB_POSTGRESQL::sql_strerror(void)
-{
+{   
    BDB_POSTGRESQL *mdb = this;
    return PQerrorMessage(mdb->m_db_handle);
 } 
diff --git a/src/cats/protos.h b/src/cats/protos.h
index cc6510c..61c9119 100644
--- a/src/cats/protos.h
+++ b/src/cats/protos.h
@@ -46,7 +46,10 @@
 BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name,
         const char *db_user, const char *db_password,
         const char *db_address, int db_port,
-        const char *db_socket, bool mult_db_connections, bool disable_batch_insert);
+        const char *db_socket, const char *db_ssl_key,
+        const char *db_ssl_cert, const char *db_ssl_ca,
+        const char *db_ssl_capath, const char *db_ssl_cipher,
+        bool mult_db_connections, bool disable_batch_insert);
 
 /* Database prototypes and defines */
 
@@ -160,6 +163,8 @@ void bdb_free_restoreobject_record(JCR *jcr, ROBJECT_DBR *rr);
 
 
 /* sql_find.c */
+#define db_find_last_job_end_time(jcr, mdb, jr, etime, job) \
+           mdb->bdb_find_last_job_end_time(jcr, jr, etime, job)
 #define db_find_last_job_start_time(jcr, mdb, jr, stime, job, JobLevel) \
            mdb->bdb_find_last_job_start_time(jcr, jr, stime, job, JobLevel)
 #define db_find_job_start_time(jcr, mdb, jr, stime, job) \
diff --git a/src/cats/sql_delete.c b/src/cats/sql_delete.c
index 7a6faa8..97bff2b 100644
--- a/src/cats/sql_delete.c
+++ b/src/cats/sql_delete.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/cats/sql_find.c b/src/cats/sql_find.c
index 7c83b2e..c9b2d5b 100644
--- a/src/cats/sql_find.c
+++ b/src/cats/sql_find.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -42,14 +41,66 @@
  */
 
 /*
+ * Find the most recent successful real end time for a job given.
+ *
+ *  RealEndTime is returned in etime
+ *  Job name is returned in job (MAX_NAME_LENGTH)
+ *
+ * Returns: false on failure
+ *          true  on success, jr is unchanged, but etime and job are set
+ */
+bool BDB::bdb_find_last_job_end_time(JCR *jcr, JOB_DBR *jr, POOLMEM **etime, 
+          char *job)
+{
+   SQL_ROW row;
+   char ed1[50], ed2[50];
+   char esc_name[MAX_ESCAPE_NAME_LENGTH];
+
+   bdb_lock();
+   bdb_escape_string(jcr, esc_name, jr->Name, strlen(jr->Name));
+   pm_strcpy(etime, "0000-00-00 00:00:00");   /* default */
+   job[0] = 0;
+
+   Mmsg(cmd,
+        "SELECT RealEndTime, Job FROM Job WHERE JobStatus IN ('T','W') AND Type='%c' AND "
+        "Level IN ('%c','%c','%c') AND Name='%s' AND ClientId=%s AND FileSetId=%s "
+        "ORDER BY RealEndTime DESC LIMIT 1", jr->JobType, 
+        L_FULL, L_DIFFERENTIAL, L_INCREMENTAL, esc_name, 
+        edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2));
+
+   if (!QueryDB(jcr, cmd)) {
+      Mmsg2(&errmsg, _("Query error for end time request: ERR=%s\nCMD=%s\n"),
+         sql_strerror(), cmd);
+      goto bail_out;
+   }
+   if ((row = sql_fetch_row()) == NULL) {
+      sql_free_result();
+      Mmsg(errmsg, _("No prior backup Job record found.\n"));
+      goto bail_out;
+   }
+   Dmsg1(100, "Got end time: %s\n", row[0]);
+   pm_strcpy(etime, row[0]);
+   bstrncpy(job, row[1], MAX_NAME_LENGTH);
+
+   sql_free_result();
+   bdb_unlock();
+   return true;
+
+bail_out:
+   bdb_unlock();
+   return false;
+}
+
+
+/*
  * Find job start time if JobId specified, otherwise
  * find last Job start time Incremental and Differential saves.
  *
  *  StartTime is returned in stime
  *  Job name is returned in job (MAX_NAME_LENGTH)
  *
- * Returns: 0 on failure
- *          1 on success, jr is unchanged, but stime and job are set
+ * Returns: false on failure
+ *          true  on success, jr is unchanged, but stime and job are set
  */
 bool BDB::bdb_find_job_start_time(JCR *jcr, JOB_DBR *jr, POOLMEM **stime, char *job)
 {
@@ -208,10 +259,11 @@ bool BDB::bdb_find_failed_job_since(JCR *jcr, JOB_DBR *jr, POOLMEM *stime, int &
 
    /* Differential is since last Full backup */
    Mmsg(cmd,
-"SELECT Level FROM Job WHERE JobStatus NOT IN ('T','W') AND "
-"Type='%c' AND Level IN ('%c','%c') AND Name='%s' AND ClientId=%s "
-"AND FileSetId=%s AND StartTime>'%s' "
-"ORDER BY StartTime DESC LIMIT 1",
+   "SELECT Level FROM Job WHERE JobStatus IN ('%c','%c', '%c', '%c') AND "
+      "Type='%c' AND Level IN ('%c','%c') AND Name='%s' AND ClientId=%s "
+      "AND FileSetId=%s AND StartTime>'%s' "
+      "ORDER BY StartTime DESC LIMIT 1",
+         JS_Canceled, JS_ErrorTerminated, JS_Error, JS_FatalError,
          jr->JobType, L_FULL, L_DIFFERENTIAL, esc_name,
          edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2),
          stime);
@@ -260,6 +312,7 @@ bool BDB::bdb_find_last_jobid(JCR *jcr, const char *Name, JOB_DBR *jr)
            edit_int64(jr->ClientId, ed1));
    } else if (jr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG ||
               jr->JobLevel == L_VERIFY_DISK_TO_CATALOG ||
+              jr->JobLevel == L_VERIFY_DATA ||
               jr->JobType == JT_BACKUP) {
       if (Name) {
          bdb_escape_string(jcr, esc_name, (char*)Name,
@@ -342,11 +395,19 @@ int BDB::bdb_find_next_volume(JCR *jcr, int item, bool InChanger, MEDIA_DBR *mr)
    } else {
       POOL_MEM changer(PM_FNAME);
       POOL_MEM voltype(PM_FNAME);
+      POOL_MEM exclude(PM_FNAME);
       /* Find next available volume */
       if (InChanger) {
          Mmsg(changer, " AND InChanger=1 AND StorageId=%s ",
                  edit_int64(mr->StorageId, ed1));
       }
+      /* Volumes will be automatically excluded from the query, we just take the
+       * first one of the list 
+       */
+      if (mr->exclude_list && *mr->exclude_list) {
+         item = 1;
+         Mmsg(exclude, " AND MediaId NOT IN (%s) ", mr->exclude_list);
+      }
       if (strcmp(mr->VolStatus, "Recycle") == 0 ||
           strcmp(mr->VolStatus, "Purged") == 0) {
          order = "AND Recycle=1 ORDER BY LastWritten ASC,MediaId";  /* take oldest that can be recycled */
@@ -364,11 +425,12 @@ int BDB::bdb_find_next_volume(JCR *jcr, int item, bool InChanger, MEDIA_DBR *mr)
          "AND VolStatus='%s' "
          "%s "
          "%s "
+         "%s "
          "%s LIMIT %d",
          edit_int64(mr->PoolId, ed1), esc_type,
          esc_status,
          voltype.c_str(),
-         changer.c_str(), order, item);
+         changer.c_str(), exclude.c_str(), order, item);
    }
    Dmsg1(100, "fnextvol=%s\n", cmd);
    if (!QueryDB(jcr, cmd)) {
diff --git a/src/cats/sql_get.c b/src/cats/sql_get.c
index 2414a13..4f60b7f 100644
--- a/src/cats/sql_get.c
+++ b/src/cats/sql_get.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -177,7 +176,6 @@ int BDB::bdb_get_filename_record(JCR *jcr)
 {
    SQL_ROW row;
    int FilenameId = 0;
-   int num_rows;
 
    esc_name = check_pool_memory_size(esc_name, 2*fnl+2);
    bdb_escape_string(jcr, esc_name, fname, fnl);
@@ -185,13 +183,12 @@ int BDB::bdb_get_filename_record(JCR *jcr)
    Mmsg(cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
    if (QueryDB(jcr, cmd)) {
       char ed1[30];
-      num_rows = sql_num_rows();
-      if (num_rows > 1) {
+      if (sql_num_rows() > 1) { 
          Mmsg2(errmsg, _("More than one Filename!: %s for file: %s\n"),
-            edit_uint64(num_rows, ed1), fname);
+            edit_uint64(sql_num_rows(), ed1), fname);
          Jmsg(jcr, M_WARNING, 0, "%s", errmsg);
       }
-      if (num_rows >= 1) {
+      if (sql_num_rows() >= 1) { 
          if ((row = sql_fetch_row()) == NULL) {
             Mmsg1(errmsg, _("error fetching row: %s\n"), sql_strerror());
          } else {
diff --git a/src/cats/sql_list.c b/src/cats/sql_list.c
index 9f237e5..0171eb8 100644
--- a/src/cats/sql_list.c
+++ b/src/cats/sql_list.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -37,6 +36,16 @@
  * -----------------------------------------------------------------------
  */
 
+#define append_filter(buf, sql)  \
+   do {                          \
+      if (*buf) {                \
+         pm_strcat(buf, " AND ");\
+      } else {                   \
+         pm_strcpy(buf, " WHERE ");\
+      }                          \
+      pm_strcat(buf, sql);       \
+   } while (0)
+
 /*
  * Submit general SQL query
  */
@@ -367,94 +376,95 @@ alist *BDB::bdb_list_job_records(JCR *jcr, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
                     void *ctx, e_list_type type)
 {
    char ed1[50];
-   char limit[100];
-   char status[100];
+   char limit[50];
    char esc[MAX_ESCAPE_NAME_LENGTH];
    alist *list = NULL;
+   POOLMEM *where  = get_pool_memory(PM_MESSAGE);
+   POOLMEM *tmp    = get_pool_memory(PM_MESSAGE);
+   const char *order = "ASC";
+   *where = 0;
 
    bdb_lock();
+   if (jr->order == 1) {
+      order = "DESC";
+   }
    if (jr->limit > 0) {
       snprintf(limit, sizeof(limit), " LIMIT %d", jr->limit);
    } else {
       limit[0] = 0;
    }
+   if (jr->Name[0]) {
+      bdb_escape_string(jcr, esc, jr->Name, strlen(jr->Name));
+      Mmsg(tmp, " Name='%s' ", esc);
+      append_filter(where, tmp);
+
+   } else if (jr->JobId != 0) {
+      Mmsg(tmp, " JobId=%s ", edit_int64(jr->JobId, ed1));
+      append_filter(where, tmp);
+
+   } else if (jr->Job[0] != 0) {
+      bdb_escape_string(jcr, esc, jr->Job, strlen(jr->Job));
+      Mmsg(tmp, " Job='%s' ", esc);
+      append_filter(where, tmp);
+   }
+
+   if (type == INCOMPLETE_JOBS && jr->JobStatus == JS_FatalError) {
+      Mmsg(tmp, " JobStatus IN ('E', 'f') ");
+      append_filter(where, tmp);
+
+   } else if (jr->JobStatus) {
+      Mmsg(tmp, " JobStatus='%c' ", jr->JobStatus);
+      append_filter(where, tmp);
+   }
+
+   if (jr->JobType) {
+      Mmsg(tmp, " Type='%c' ", jr->JobType);
+      append_filter(where, tmp);
+   }
+
+   if (jr->JobErrors > 0) {
+      Mmsg(tmp, " JobErrors > 0 ");
+      append_filter(where, tmp);
+   }
+
+   if (jr->ClientId > 0) {
+      Mmsg(tmp, " ClientId=%s ", edit_int64(jr->ClientId, ed1));
+      append_filter(where, tmp);
+   }
+
    switch (type) {
    case VERT_LIST:
-      if (jr->JobId == 0 && jr->Job[0] == 0) {
-         Mmsg(cmd,
-            "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
-            "Job.ClientId,Client.Name as ClientName,JobStatus,SchedTime,"
-            "StartTime,EndTime,RealEndTime,JobTDate,"
-            "VolSessionId,VolSessionTime,JobFiles,JobBytes,ReadBytes,JobErrors,"
-            "JobMissingFiles,Job.PoolId,Pool.Name as PooLname,PriorJobId,"
-            "Job.FileSetId,FileSet.FileSet,Job.HasCache "
-            "FROM Job JOIN Client USING (ClientId) LEFT JOIN Pool USING (PoolId) "
-            "LEFT JOIN FileSet USING (FileSetId) ",
-            "ORDER BY StartTime%s", limit);
-      } else {                           /* single record */
-         Mmsg(cmd,
-            "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
-            "Job.ClientId,Client.Name as ClientName,JobStatus,SchedTime,"
-            "StartTime,EndTime,RealEndTime,JobTDate,"
-            "VolSessionId,VolSessionTime,JobFiles,JobBytes,ReadBytes,JobErrors,"
-            "JobMissingFiles,Job.PoolId,Pool.Name as PooLname,PriorJobId,"
-            "Job.FileSetId,FileSet.FileSet,Job.HasCache "
-            "FROM Job JOIN Client USING (ClientId) LEFT JOIN Pool USING (PoolId) "
-            "LEFT JOIN FileSet USING (FileSetId) WHERE Job.JobId=%s ",
-            edit_int64(jr->JobId, ed1));
-      }
+      Mmsg(cmd,
+           "SELECT JobId,Job,Job.Name,PurgedFiles,Type,Level,"
+           "Job.ClientId,Client.Name as ClientName,JobStatus,SchedTime,"
+           "StartTime,EndTime,RealEndTime,JobTDate,"
+           "VolSessionId,VolSessionTime,JobFiles,JobBytes,ReadBytes,JobErrors,"
+           "JobMissingFiles,Job.PoolId,Pool.Name as PooLname,PriorJobId,"
+           "Job.FileSetId,FileSet.FileSet,Job.HasBase,Job.HasCache,Job.Comment "
+           "FROM Job JOIN Client USING (ClientId) LEFT JOIN Pool USING (PoolId) "
+           "LEFT JOIN FileSet USING (FileSetId) %s "
+           "ORDER BY StartTime %s %s", where, order, limit);
       break;
    case HORZ_LIST:
-      if (jr->Name[0] != 0) {
-         bdb_escape_string(jcr, esc, jr->Name, strlen(jr->Name));
-         Mmsg(cmd,
+      Mmsg(cmd,
            "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-             "FROM Job WHERE Name='%s' ORDER BY StartTime,JobId ASC", esc);
-      } else if (jr->Job[0] != 0) {
-         bdb_escape_string(jcr, esc, jr->Job, strlen(jr->Job));
-         Mmsg(cmd,
-            "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-            "FROM Job WHERE Job='%s' ORDER BY StartTime,JobId ASC", esc);
-      } else if (jr->JobId != 0) {
-         Mmsg(cmd,
-            "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-            "FROM Job WHERE JobId=%s", edit_int64(jr->JobId, ed1));
-      } else {                           /* all records */
-         Mmsg(cmd,
-           "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-           "FROM Job ORDER BY StartTime,JobId ASC%s", limit);
-      }
+           "FROM Job %s ORDER BY StartTime %s,JobId %s %s", where, order, order, limit);
       break;
    case INCOMPLETE_JOBS:
-      if (jr->Name[0] != 0) {
-         bdb_escape_string(jcr, esc, jr->Name, strlen(jr->Name));
-         if (jr->JobStatus == JS_FatalError) {
-            snprintf(status, sizeof(status), "JobStatus IN ('E','f') AND");
-         } else if (jr->JobStatus != 0) {
-            snprintf(status, sizeof(status), "JobStatus='%c' AND", jr->JobStatus);
-         } else {
-            status[0] = 0;
-         }
-         Mmsg(cmd,
-           "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-             "FROM Job WHERE %s Name='%s' ORDER BY StartTime,JobId ASC%s",
-              status, esc, limit);
-         Dmsg1(100, "SQL: %s\n", cmd);
-      } else {                           /* all records */
-         if (jr->JobStatus != 0) {
-            snprintf(status, sizeof(status), "WHERE JobStatus='%c'", jr->JobStatus);
-         } else {
-            status[0] = 0;
-         }
-         Mmsg(cmd,
+      Mmsg(cmd,
            "SELECT JobId,Name,StartTime,Type,Level,JobFiles,JobBytes,JobStatus "
-           "FROM Job %s ORDER BY StartTime,JobId ASC%s", status, limit);
-         Dmsg1(100, "SQL: %s\n", cmd);
-      }
+             "FROM Job %s ORDER BY StartTime %s,JobId %s %s",
+           where, order, order, limit);
       break;
    default:
       break;
    }
+   Dmsg1(100, "SQL: %s\n", cmd);
+
+   free_pool_memory(tmp);
+   free_pool_memory(where);
+
+   Dmsg1(000, "cmd: %s\n", cmd);
    if (!QueryDB(jcr, cmd)) {
       bdb_unlock();
       return NULL;
@@ -568,19 +578,17 @@ void BDB::bdb_list_base_files_for_job(JCR *jcr, JobId_t jobid, DB_LIST_HANDLER *
     * Stupid MySQL is NON-STANDARD !
     */
    if (bdb_get_type_index() == SQL_TYPE_MYSQL) {
-      Mmsg(cmd, "SELECT CONCAT(Path.Path,Filename.Name) AS Filename "
-           "FROM BaseFiles, File, Filename, Path "
+      Mmsg(cmd, "SELECT CONCAT(Path.Path,File.Filename) AS Filename "
+           "FROM BaseFiles, File, Path "
            "WHERE BaseFiles.JobId=%s AND BaseFiles.BaseJobId = File.JobId "
            "AND BaseFiles.FileId = File.FileId "
-           "AND Filename.FilenameId=File.FilenameId "
            "AND Path.PathId=File.PathId",
          edit_int64(jobid, ed1));
    } else {
-      Mmsg(cmd, "SELECT Path.Path||Filename.Name AS Filename "
-           "FROM BaseFiles, File, Filename, Path "
+      Mmsg(cmd, "SELECT Path.Path||File.Filename AS Filename "
+           "FROM BaseFiles, File, Path "
            "WHERE BaseFiles.JobId=%s AND BaseFiles.BaseJobId = File.JobId "
            "AND BaseFiles.FileId = File.FileId "
-           "AND Filename.FilenameId=File.FilenameId "
            "AND Path.PathId=File.PathId",
            edit_int64(jobid, ed1));
    }
@@ -596,16 +604,6 @@ void BDB::bdb_list_base_files_for_job(JCR *jcr, JobId_t jobid, DB_LIST_HANDLER *
    bdb_unlock();
 }
 
-#define append_filter(buf, sql)  \
-   do {                          \
-      if (*buf) {                \
-         pm_strcat(buf, " AND ");\
-      } else {                   \
-         pm_strcpy(buf, " WHERE ");\
-      }                          \
-      pm_strcat(buf, sql);       \
-   } while (0)
-
 void BDB::bdb_list_snapshot_records(JCR *jcr, SNAPSHOT_DBR *sdbr,
               DB_LIST_HANDLER *sendit, void *ctx, e_list_type type)
 {
diff --git a/src/cats/sql_update.c b/src/cats/sql_update.c
index 3c051aa..f4da1e3 100644
--- a/src/cats/sql_update.c
+++ b/src/cats/sql_update.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/cats/sqlite.c b/src/cats/sqlite.c
index c47899c..bed7e62 100644
--- a/src/cats/sqlite.c
+++ b/src/cats/sqlite.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -100,11 +99,11 @@ BDB_SQLITE::~BDB_SQLITE()
  * Initialize database data structure. In principal this should 
  * never have errors, or it is really fatal. 
  */ 
-BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name, 
-                       const char *db_user, const char *db_password, 
-                       const char *db_address, int db_port, 
-                       const char *db_socket, bool mult_db_connections, 
-                       bool disable_batch_insert) 
+BDB *db_init_database(JCR *jcr, const char *db_driver, const char *db_name, const char *db_user, 
+                       const char *db_password, const char *db_address, int db_port, const char *db_socket, 
+                       const char *db_ssl_key, const char *db_ssl_cert, const char *db_ssl_ca,
+                       const char *db_ssl_capath, const char *db_ssl_cipher,
+                       bool mult_db_connections, bool disable_batch_insert) 
 {  
    BDB_SQLITE *mdb = NULL; 
  
diff --git a/src/cats/update_sqlite3_tables.in b/src/cats/update_sqlite3_tables.in
index 0f1f15a..bd468c6 100644
--- a/src/cats/update_sqlite3_tables.in
+++ b/src/cats/update_sqlite3_tables.in
@@ -3,11 +3,11 @@
 # Copyright (C) 2000-2015 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
-# Shell script to update MySQL tables from Bacula Community version 
+# Shell script to update SQLite tables from Bacula Community version 
 #  5.0.x, 5.2.x, 7.0.x
 #
 echo " "
-echo "This script will update a Bacula MySQL database from version 12-14 to 15"
+echo "This script will update a Bacula SQLite database from version 12-14 to 15"
 echo " "
 echo "Depending on the current version of your catalog, you may have to run this script"
 echo "	multiple times"
@@ -76,19 +76,70 @@ fi
 
 if [ "$DBVERSION" = 14 ] ; then
     sqlite3 $* ${db_name}.db  <<END-OF-DATA
+BEGIN;
+
 INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
    ('I', 'Incomplete Job',25);
-ALTER TABLE Media ADD COLUMN VolABytes BIGINT UNSIGNED DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolAPadding BIGINT UNSIGNED DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolHoleBytes BIGINT UNSIGNED DEFAULT 0;
-ALTER TABLE Media ADD COLUMN VolHoles INTEGER UNSIGNED DEFAULT 0;
-ALTER TABLE Media CHANGE VolWrites VolWrites BIGINT UNSIGNED;
+
+CREATE TABLE new_Media (
+   MediaId INTEGER,
+   VolumeName VARCHAR(128) NOT NULL,
+   Slot INTEGER DEFAULT 0,
+   PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   MediaType VARCHAR(128) NOT NULL,
+   MediaTypeId INTEGER UNSIGNED REFERENCES MediaType DEFAULT 0,
+   LabelType TINYINT DEFAULT 0,
+   FirstWritten DATETIME DEFAULT 0,
+   LastWritten DATETIME DEFAULT 0,
+   LabelDate DATETIME DEFAULT 0,
+   VolJobs INTEGER UNSIGNED DEFAULT 0,
+   VolFiles INTEGER UNSIGNED DEFAULT 0,
+   VolBlocks INTEGER UNSIGNED DEFAULT 0,
+   VolMounts INTEGER UNSIGNED DEFAULT 0,
+   VolBytes BIGINT UNSIGNED DEFAULT 0,
+   VolParts INTEGER UNSIGNED DEFAULT 0,
+   VolErrors INTEGER UNSIGNED DEFAULT 0,
+   VolWrites BIGINT UNSIGNED DEFAULT 0,
+   VolCapacityBytes BIGINT UNSIGNED DEFAULT 0,
+   VolStatus VARCHAR(20) NOT NULL,
+   Enabled TINYINT DEFAULT 1,
+   Recycle TINYINT DEFAULT 0,
+   ActionOnPurge     TINYINT    DEFAULT 0,
+   VolRetention BIGINT UNSIGNED DEFAULT 0,
+   VolUseDuration BIGINT UNSIGNED DEFAULT 0,
+   MaxVolJobs INTEGER UNSIGNED DEFAULT 0,
+   MaxVolFiles INTEGER UNSIGNED DEFAULT 0,
+   MaxVolBytes BIGINT UNSIGNED DEFAULT 0,
+   InChanger TINYINT DEFAULT 0,
+   StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0,
+   DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0,
+   MediaAddressing TINYINT DEFAULT 0,
+   VolReadTime BIGINT UNSIGNED DEFAULT 0,
+   VolWriteTime BIGINT UNSIGNED DEFAULT 0,
+   EndFile INTEGER UNSIGNED DEFAULT 0,
+   EndBlock INTEGER UNSIGNED DEFAULT 0,
+   LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0,
+   RecycleCount INTEGER UNSIGNED DEFAULT 0,
+   InitialWrite DATETIME DEFAULT 0,
+   ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0,
+   Comment TEXT,
+   VolABytes BIGINT UNSIGNED DEFAULT 0,
+   VolAPadding BIGINT UNSIGNED DEFAULT 0,
+   VolHoleBytes BIGINT UNSIGNED DEFAULT 0,
+   VolHoles INTEGER UNSIGNED DEFAULT 0,
+   PRIMARY KEY(MediaId)
+   );
+INSERT INTO new_Media (MediaId, VolumeName, Slot, PoolId, MediaType, MediaTypeId, LabelType, FirstWritten, LastWritten, LabelDate, VolJobs, VolFiles, VolBlocks, VolMounts, VolBytes, VolParts, VolErrors, VolWrites, VolCapacityBytes, VolStatus, Enabled, Recycle, ActionOnPurge, VolRetention, VolUseDuration, MaxVolJobs, MaxVolFiles, MaxVolBytes, InChanger, StorageId, DeviceId, MediaAddressing, VolReadTime, VolWriteTime, EndFile, EndBlock, LocationId, RecycleCount, InitialWrite, ScratchPoolId [...]
+DROP TABLE Media;
+ALTER TABLE new_Media RENAME TO Media;
+CREATE INDEX inx8 ON Media (PoolId);
 
 CREATE TABLE Snapshot (
   SnapshotId	  INTEGER UNSIGNED AUTO_INCREMENT,
   Name		  TINYBLOB NOT NULL,
   JobId 	  INTEGER UNSIGNED DEFAULT 0,
-  FileSetId INTEGER UNSIGNED DEFAULT 0;
+  FileSetId INTEGER UNSIGNED DEFAULT 0,
   CreateTDate	  BIGINT   NOT NULL,
   CreateDate	  DATETIME NOT NULL,
   ClientId	  INTEGER DEFAULT 0,
@@ -100,13 +151,13 @@ CREATE TABLE Snapshot (
   primary key (SnapshotId)
 );
 
-CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device(255), Volume(255), Name(255));
+CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device, Volume, Name);
 
 CREATE INDEX jobtdate_idx on JobHisto (JobTDate);
 
 UPDATE Version SET VersionId=15;
+
+COMMIT;
 END-OF-DATA
 DBVERSION=15
 fi
-
-END-OF-DATA
diff --git a/src/console/authenticate.c b/src/console/authenticate.c
index 08116fc..cd50f28 100644
--- a/src/console/authenticate.c
+++ b/src/console/authenticate.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/console/conio.c b/src/console/conio.c
index f2c69f1..03860af 100755
--- a/src/console/conio.c
+++ b/src/console/conio.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 1981-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/console/conio.h b/src/console/conio.h
index c009850..d44ceaf 100644
--- a/src/console/conio.h
+++ b/src/console/conio.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/console/console.c b/src/console/console.c
index b2f0814..1ca30ae 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -75,6 +74,7 @@ static DIRRES *dir = NULL;
 static CONRES *cons = NULL;
 static FILE *output = stdout;
 static bool teeout = false;               /* output to output and stdout */
+static bool teein = false;                /* input to output and stdout */
 static bool stop = false;
 static bool no_conio = false;
 static int timeout = 0;
@@ -91,6 +91,7 @@ static int versioncmd(FILE *input, BSOCK *UA_sock);
 static int inputcmd(FILE *input, BSOCK *UA_sock);
 static int outputcmd(FILE *input, BSOCK *UA_sock);
 static int teecmd(FILE *input, BSOCK *UA_sock);
+static int teeallcmd(FILE *input, BSOCK *UA_sock);
 static int quitcmd(FILE *input, BSOCK *UA_sock);
 static int helpcmd(FILE *input, BSOCK *UA_sock);
 static int echocmd(FILE *input, BSOCK *UA_sock);
@@ -172,6 +173,7 @@ static struct cmdstruct commands[] = {
  { N_("output"),     outputcmd,    _("output to file")},
  { N_("quit"),       quitcmd,      _("quit")},
  { N_("tee"),        teecmd,       _("output to file and terminal")},
+ { N_("tall"),       teeallcmd,    _("output everything to file and terminal (tee all)")},
  { N_("sleep"),      sleepcmd,     _("sleep specified time")},
  { N_("time"),       timecmd,      _("print current time")},
  { N_("version"),    versioncmd,   _("print Console's version")},
@@ -725,6 +727,14 @@ get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
    }
    if (command != line && isatty(fileno(input))) {
       senditf("%s%s\n", prompt, command);
+
+   } else {
+      /* Send the intput to the output file if needed */
+      if (teein && output != stdout) {
+         fputs(prompt, output);
+         fputs(command, output);
+         fputs("\n", output);
+      }
    }
 
    sock->msglen = pm_strcpy(&sock->msg, command);
@@ -841,6 +851,13 @@ again:
    }
    strip_trailing_junk(sock->msg);
    sock->msglen = strlen(sock->msg);
+
+   /* Send input to log file if needed */
+   if (teein && output != stdout) {
+      fputs(sock->msg, output);
+      fputs("\n", output);
+   }
+
    return 1;
 }
 
@@ -1384,11 +1401,21 @@ static int inputcmd(FILE *input, BSOCK *UA_sock)
    return 1;
 }
 
+/* @tall <output-filename> */
+/* Send input/output to both terminal and specified file */
+static int teeallcmd(FILE *input, BSOCK *UA_sock)
+{
+   teeout = true;
+   teein = true;
+   return do_outputcmd(input, UA_sock);
+}
+
 /* @tee <output-filename> */
 /* Send output to both terminal and specified file */
 static int teecmd(FILE *input, BSOCK *UA_sock)
 {
    teeout = true;
+   teein = false;
    return do_outputcmd(input, UA_sock);
 }
 
@@ -1397,6 +1424,7 @@ static int teecmd(FILE *input, BSOCK *UA_sock)
 static int outputcmd(FILE *input, BSOCK *UA_sock)
 {
    teeout = false;
+   teein  = false;
    return do_outputcmd(input, UA_sock);
 }
 
@@ -1415,6 +1443,7 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock)
          fclose(output);
          output = stdout;
          teeout = false;
+         teein = false;
       }
       return 1;
    }
diff --git a/src/console/console_conf.c b/src/console/console_conf.c
index 65c850a..012fb01 100644
--- a/src/console/console_conf.c
+++ b/src/console/console_conf.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/console/console_conf.h b/src/console/console_conf.h
index d54995f..5d0dea2 100644
--- a/src/console/console_conf.h
+++ b/src/console/console_conf.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/console/func.h b/src/console/func.h
index 2a717a1..a527d7a 100755
--- a/src/console/func.h
+++ b/src/console/func.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 1981-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/admin.c b/src/dird/admin.c
index c056bce..0f3505e 100644
--- a/src/dird/admin.c
+++ b/src/dird/admin.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/authenticate.c b/src/dird/authenticate.c
index 6212519..e0eb7ac 100644
--- a/src/dird/authenticate.c
+++ b/src/dird/authenticate.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/autoprune.c b/src/dird/autoprune.c
index 2b8233f..46416f5 100644
--- a/src/dird/autoprune.c
+++ b/src/dird/autoprune.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -201,11 +200,6 @@ void prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
             continue;
          }
 
-         if (has_volume_expired(jcr, &lmr)) {
-            Dmsg1(100, "Vol=%s has expired\n", lmr.VolumeName);
-            continue;                     /* Volume not usable */
-         }
-
          /*
           * If purged and not moved to another Pool,
           *   then we stop pruning and take this volume.
diff --git a/src/dird/backup.c b/src/dird/backup.c
index 9f2f939..932751b 100644
--- a/src/dird/backup.c
+++ b/src/dird/backup.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -255,7 +254,7 @@ bool send_accurate_current_files(JCR *jcr)
       /* On Full mode, if no previous base job, no accurate things */
       if (get_base_jobids(jcr, &jobids)) {
          jcr->HasBase = true;
-         Jmsg(jcr, M_INFO, 0, _("Using BaseJobId(s): %s\n"), jobids.list);
+         Jmsg(jcr, M_INFO, 0, _("Using Base JobId(s): %s\n"), jobids.list);
       } else if (!jcr->rerunning) {
          return true;
       }
diff --git a/src/dird/bacula-dir.conf.in b/src/dird/bacula-dir.conf.in
index 2b469c0..f3a2805 100644
--- a/src/dird/bacula-dir.conf.in
+++ b/src/dird/bacula-dir.conf.in
@@ -11,7 +11,10 @@
 #   from root to your address.  See the "mail" and "operator"
 #   directives in the Messages resource.
 #
-
+# Copyright (C) 2000-2015 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+ 
 Director {                            # define myself
   Name = @basename at -dir
   DIRport = @dir_port@                # where we listen for UA connections
diff --git a/src/dird/bsr.c b/src/dird/bsr.c
index b24a28c..0530ed8 100644
--- a/src/dird/bsr.c
+++ b/src/dird/bsr.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/catreq.c b/src/dird/catreq.c
index 3bb86d0..d7341ad 100644
--- a/src/dird/catreq.c
+++ b/src/dird/catreq.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -577,7 +576,6 @@ static void update_attribute(JCR *jcr, char *msg, int32_t msglen)
       /* Send it */
       if (!db_create_restore_object_record(jcr, jcr->db, &ro)) {
          Jmsg1(jcr, M_FATAL, 0, _("Restore object create error. %s"), db_strerror(jcr->db));
-         jcr->cached_attribute = false;
       }
 
    } else if (crypto_digest_stream_type(Stream) != CRYPTO_DIGEST_NONE) {
diff --git a/src/dird/dir_plugins.c b/src/dird/dir_plugins.c
index c672341..44d6b68 100644
--- a/src/dird/dir_plugins.c
+++ b/src/dird/dir_plugins.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/dird.c b/src/dird/dird.c
index aa1ec18..f74097f 100644
--- a/src/dird/dird.c
+++ b/src/dird/dird.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -68,6 +67,7 @@ static char *runjob = NULL;
 static bool background = true;
 static void init_reload(void);
 static CONFIG *config;
+static bool test_config = false;
 
 /* Globals Exported */
 DIRRES *director;                     /* Director resource */
@@ -163,7 +163,6 @@ int main (int argc, char *argv[])
    int ch;
    JCR *jcr;
    bool no_signals = false;
-   bool test_config = false;
    char *uid = NULL;
    char *gid = NULL;
 
@@ -567,8 +566,10 @@ void terminate_dird(int sig)
    stop_watchdog();
    generate_daemon_event(NULL, "Exit");
    unload_plugins();
-   write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
-   delete_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
+   if (!test_config) {
+      write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
+      delete_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
+   }
    term_scheduler();
    term_job_server();
    if (runjob) {
@@ -959,6 +960,8 @@ static bool check_catalog(cat_op mode)
               catalog->db_user,
               catalog->db_password, catalog->db_address,
               catalog->db_port, catalog->db_socket,
+              catalog->db_ssl_key, catalog->db_ssl_cert, catalog->db_ssl_ca,
+              catalog->db_ssl_capath, catalog->db_ssl_cipher,
               catalog->mult_db_connections,
               catalog->disable_batch_insert);
       if (!db || !db_open_database(NULL, db)) {
diff --git a/src/dird/dird_conf.c b/src/dird/dird_conf.c
index 9e23711..53fb9a1 100644
--- a/src/dird/dird_conf.c
+++ b/src/dird/dird_conf.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -253,6 +252,11 @@ static RES_ITEM cat_items[] = {
    {"DbName",   store_str,      ITEM(res_cat.db_name),     0, ITEM_REQUIRED, 0},
    {"dbdriver", store_str,      ITEM(res_cat.db_driver),   0, 0, 0},
    {"DbSocket", store_str,      ITEM(res_cat.db_socket),   0, 0, 0},
+   {"dbsslkey", store_str,      ITEM(res_cat.db_ssl_key),  0, 0, 0},
+   {"dbsslcert", store_str,     ITEM(res_cat.db_ssl_cert),  0, 0, 0},
+   {"dbsslca", store_str,       ITEM(res_cat.db_ssl_ca),  0, 0, 0},
+   {"dbsslcapath", store_str,   ITEM(res_cat.db_ssl_capath),  0, 0, 0},
+   {"dbsslcipher", store_str,   ITEM(res_cat.db_ssl_cipher),  0, 0, 0},
    /* Turned off for the moment */
    {"MultipleConnections", store_bit, ITEM(res_cat.mult_db_connections), 0, 0, 0},
    {"DisableBatchInsert", store_bool, ITEM(res_cat.disable_batch_insert), 0, ITEM_DEFAULT, false},
@@ -1312,6 +1316,21 @@ void free_resource(RES *rres, int type)
       if (res->res_cat.db_password) {
          free(res->res_cat.db_password);
       }
+      if (res->res_cat.db_ssl_key) {
+         free(res->res_cat.db_ssl_key);
+      }
+      if (res->res_cat.db_ssl_cert) {
+         free(res->res_cat.db_ssl_cert);
+      }
+      if (res->res_cat.db_ssl_ca) {
+         free(res->res_cat.db_ssl_ca);
+      }
+      if (res->res_cat.db_ssl_capath) {
+         free(res->res_cat.db_ssl_capath);
+      }
+      if (res->res_cat.db_ssl_cipher) {
+         free(res->res_cat.db_ssl_cipher);
+      }
       break;
    case R_FILESET:
       if ((num=res->res_fs.num_includes)) {
@@ -2133,7 +2152,7 @@ extern "C" char *job_code_callback_director(JCR *jcr, const char* param)
          }
          break;
       case 'h':
-         if (jcr->client) {
+         if (jcr->client && jcr->client->address) {
             return jcr->client->address;
          }
          break;
diff --git a/src/dird/dird_conf.h b/src/dird/dird_conf.h
index 90700e5..b1101bd 100644
--- a/src/dird/dird_conf.h
+++ b/src/dird/dird_conf.h
@@ -228,6 +228,11 @@ public:
    char *db_user;
    char *db_name;
    char *db_driver;                   /* Select appropriate driver */
+   char *db_ssl_key;                  /* the path name to the key file */
+   char *db_ssl_cert;                 /* the path name to the certificate file */
+   char *db_ssl_ca;                   /* the path name to the certificate authority file */
+   char *db_ssl_capath;               /* the path name to a directory that contains trusted SSL CA certificates in PEM format */
+   char *db_ssl_cipher;               /* a list of permissible ciphers to use for SSL encryption */
    uint32_t mult_db_connections;      /* set for multiple db connections */
    bool disable_batch_insert;         /* set to disable batch inserts */
 
diff --git a/src/dird/expand.c b/src/dird/expand.c
index 00a0577..367f785 100644
--- a/src/dird/expand.c
+++ b/src/dird/expand.c
@@ -1,17 +1,7 @@
 /*
- *
- *   Bacula Director -- expand.c -- does variable expansion
- *    in particular for the LabelFormat specification.
- *
- *     Kern Sibbald, June MMIII
- *
- *   Version $Id$
- */
-/*
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -26,6 +16,14 @@
 
    Bacula(R) is a registered trademark of Kern Sibbald.
 */
+/*
+ *
+ *   Bacula Director -- expand.c -- does variable expansion
+ *    in particular for the LabelFormat specification.
+ *
+ *     Kern Sibbald, June MMIII
+ *
+ */
 
 #include "bacula.h"
 #include "dird.h"
diff --git a/src/dird/fd_cmds.c b/src/dird/fd_cmds.c
index 9d69048..84e198d 100644
--- a/src/dird/fd_cmds.c
+++ b/src/dird/fd_cmds.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -258,16 +257,33 @@ void get_level_since_time(JCR *jcr, char *since, int since_len)
          jcr->setJobLevel(jcr->jr.JobLevel = L_DIFFERENTIAL);
       } else {
          if (jcr->job->rerun_failed_levels) {
-            if (db_find_failed_job_since(jcr, jcr->db, &jcr->jr,
-                                         jcr->stime, JobLevel)) {
-               Jmsg(jcr, M_INFO, 0, _("Prior failed job found in catalog. Upgrading to %s.\n"),
-                  level_to_str(JobLevel));
-               bsnprintf(since, since_len, _(" (upgraded from %s)"),
-                  level_to_str(jcr->getJobLevel()));
-               jcr->setJobLevel(jcr->jr.JobLevel = JobLevel);
-               jcr->jr.JobId = jcr->JobId;
-               break;
+
+            POOLMEM *etime = get_pool_memory(PM_MESSAGE);
+
+            /* Get the end time of our most recent successfull backup for this job */
+            /* This will be used to see if there have been any failures since then */
+	    if (db_find_last_job_end_time(jcr, jcr->db, &jcr->jr, &etime, prev_job)) {
+
+	       /* See if there are any failed Differential/Full backups since the completion */
+               /* of our last successful backup for this job                                 */
+               if (db_find_failed_job_since(jcr, jcr->db, &jcr->jr,
+                                         etime, JobLevel)) {
+                 /* If our job is an Incremental and we have a failed job then upgrade.              */
+                 /* If our job is a Differential and the failed job is a Full then upgrade.          */
+                 /* Otherwise there is no reason to upgrade.                                         */
+		 if ((jcr->getJobLevel() == L_INCREMENTAL) || 
+                     ((jcr->getJobLevel() == L_DIFFERENTIAL) && (JobLevel == L_FULL))) {
+                    Jmsg(jcr, M_INFO, 0, _("Prior failed job found in catalog. Upgrading to %s.\n"),
+                       level_to_str(JobLevel));
+                    bsnprintf(since, since_len, _(" (upgraded from %s)"),
+                             level_to_str(jcr->getJobLevel()));
+                    jcr->setJobLevel(jcr->jr.JobLevel = JobLevel);
+                    jcr->jr.JobId = jcr->JobId;
+                    break;
+                 }
+               }
             }
+            free_pool_memory(etime);
          }
          bstrncpy(since, _(", since="), since_len);
          bstrncat(since, jcr->stime, since_len);
diff --git a/src/dird/getmsg.c b/src/dird/getmsg.c
index 28b2d6e..a9d3084 100644
--- a/src/dird/getmsg.c
+++ b/src/dird/getmsg.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/inc_conf.c b/src/dird/inc_conf.c
index 560fc1a..3f4fbf5 100644
--- a/src/dird/inc_conf.c
+++ b/src/dird/inc_conf.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/job.c b/src/dird/job.c
index 20b0905..2290a2b 100644
--- a/src/dird/job.c
+++ b/src/dird/job.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -119,7 +118,10 @@ bool setup_job(JCR *jcr)
    jcr->db = db_init_database(jcr, jcr->catalog->db_driver, jcr->catalog->db_name,
                 jcr->catalog->db_user, jcr->catalog->db_password,
                 jcr->catalog->db_address, jcr->catalog->db_port,
-                jcr->catalog->db_socket, jcr->catalog->mult_db_connections,
+                jcr->catalog->db_socket, jcr->catalog->db_ssl_key,
+                jcr->catalog->db_ssl_cert, jcr->catalog->db_ssl_ca,
+                jcr->catalog->db_ssl_capath, jcr->catalog->db_ssl_cipher,
+                jcr->catalog->mult_db_connections,
                 jcr->catalog->disable_batch_insert);
    if (!jcr->db || !db_open_database(jcr, jcr->db)) {
       Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
@@ -267,7 +269,10 @@ static bool setup_resume_job(JCR *jcr, JOB_DBR *jr)
    jcr->db = db_init_database(jcr, jcr->catalog->db_driver, jcr->catalog->db_name,
                               jcr->catalog->db_user, jcr->catalog->db_password,
                               jcr->catalog->db_address, jcr->catalog->db_port,
-                              jcr->catalog->db_socket, jcr->catalog->mult_db_connections,
+                              jcr->catalog->db_socket, jcr->catalog->db_ssl_key,
+                              jcr->catalog->db_ssl_cert, jcr->catalog->db_ssl_ca,
+                              jcr->catalog->db_ssl_capath, jcr->catalog->db_ssl_cipher,
+                              jcr->catalog->mult_db_connections,
                               jcr->catalog->disable_batch_insert);
    if (!jcr->db || !db_open_database(jcr, jcr->db)) {
       Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"),
@@ -1434,6 +1439,7 @@ void dird_free_jcr(JCR *jcr)
    free_and_null_pool_memory(jcr->rpool_source);
    free_and_null_pool_memory(jcr->wstore_source);
    free_and_null_pool_memory(jcr->rstore_source);
+   free_and_null_pool_memory(jcr->next_vol_list);
 
    /* Delete lists setup to hold storage pointers */
    free_rwstorage(jcr);
@@ -1496,7 +1502,9 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
       jcr->setJobLevel(job->JobLevel);
       break;
    }
-
+   if (!jcr->next_vol_list) {
+      jcr->next_vol_list = get_pool_memory(PM_FNAME);
+   }
    if (!jcr->fname) {
       jcr->fname = get_pool_memory(PM_FNAME);
    }
diff --git a/src/dird/jobq.c b/src/dird/jobq.c
index 5c95825..11f586f 100644
--- a/src/dird/jobq.c
+++ b/src/dird/jobq.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/mac.c b/src/dird/mac.c
index eb1c17b..134276b 100644
--- a/src/dird/mac.c
+++ b/src/dird/mac.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/mac_sql.c b/src/dird/mac_sql.c
index a7623a7..12e19d3 100644
--- a/src/dird/mac_sql.c
+++ b/src/dird/mac_sql.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/mountreq.c b/src/dird/mountreq.c
index ab101b7..e0727e7 100644
--- a/src/dird/mountreq.c
+++ b/src/dird/mountreq.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/msgchan.c b/src/dird/msgchan.c
index b287f4a..1f227bb 100644
--- a/src/dird/msgchan.c
+++ b/src/dird/msgchan.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/newvol.c b/src/dird/newvol.c
index 46f5b92..8b74dbc 100644
--- a/src/dird/newvol.c
+++ b/src/dird/newvol.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -117,6 +116,7 @@ static bool create_simple_name(JCR *jcr, MEDIA_DBR *mr, POOL_DBR *pr)
    mr->VolumeName[0] = 0;
    bstrncpy(name, pr->LabelFormat, sizeof(name));
    ctx.value = 0;
+   /* TODO: Remove Pool as it is not used in the query */
    Mmsg(query, "SELECT MAX(MediaId) FROM Media,Pool WHERE Pool.PoolId=%s",
         edit_int64(pr->PoolId, ed1));
    if (!db_sql_query(jcr->db, query.c_str(), db_int64_handler, (void *)&ctx)) {
diff --git a/src/dird/next_vol.c b/src/dird/next_vol.c
index 54fa108..522e323 100644
--- a/src/dird/next_vol.c
+++ b/src/dird/next_vol.c
@@ -47,6 +47,29 @@ void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr)
    mr->StorageId = store->StorageId;
 }
 
+static void add_volume_to_exclude_list(JCR *jcr, int index, MEDIA_DBR *mr)
+{
+   char ed1[50];
+   if (index == 1) {
+      *jcr->next_vol_list = 0;
+
+   } else if (*jcr->next_vol_list) {
+      pm_strcat(jcr->next_vol_list, ",");
+   }
+   pm_strcat(jcr->next_vol_list, edit_int64(mr->MediaId, ed1));
+
+   /* The list is valid only in find_next_volume_for_append() */
+   mr->exclude_list = NULL;
+}
+
+static void set_volume_to_exclude_list(JCR *jcr, int index, MEDIA_DBR *mr)
+{
+   if (index == 1) {
+      *jcr->next_vol_list = 0;
+   }
+   mr->exclude_list = jcr->next_vol_list;
+}
+
 /*
  *  Items needed:
  *   mr.PoolId must be set
@@ -75,6 +98,9 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index,
     */
    InChanger = (store->autochanger)? true : false;
 
+   /* Make sure we don't send two times the same volume in the same session */
+   set_volume_to_exclude_list(jcr, index, mr);
+
    /*
     * Find the Next Volume for Append
     */
@@ -197,6 +223,11 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index,
    } /* end for loop */
    db_unlock(jcr->db);
    Dmsg1(dbglvl, "return ok=%d find_next_vol\n", ok);
+
+   /* We keep the record of all previous volumes requested */
+   if (ok) {
+      add_volume_to_exclude_list(jcr, index, mr);;
+   }
    return ok;
 }
 
diff --git a/src/dird/recycle.c b/src/dird/recycle.c
index 6ba990c..a8665f9 100644
--- a/src/dird/recycle.c
+++ b/src/dird/recycle.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/restore.c b/src/dird/restore.c
index 5228390..8a00a0f 100644
--- a/src/dird/restore.c
+++ b/src/dird/restore.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2015 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/run_conf.c b/src/dird/run_conf.c
index 9d21eb9..880e415 100644
--- a/src/dird/run_conf.c
+++ b/src/dird/run_conf.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/scheduler.c b/src/dird/scheduler.c
index eb8dc0b..856fdf8 100644
--- a/src/dird/scheduler.c
+++ b/src/dird/scheduler.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/snapshot.c b/src/dird/snapshot.c
index 3cf9ad2..b6dfcab 100644
--- a/src/dird/snapshot.c
+++ b/src/dird/snapshot.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/ua_acl.c b/src/dird/ua_acl.c
index 23a0ec8..1b271bb 100644
--- a/src/dird/ua_acl.c
+++ b/src/dird/ua_acl.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/ua_cmds.c b/src/dird/ua_cmds.c
index ab8d979..33b93af 100644
--- a/src/dird/ua_cmds.c
+++ b/src/dird/ua_cmds.c
@@ -118,11 +118,14 @@ static struct cmdstruct commands[] = {                                      /* C
 
  { NT_("label"),      label_cmd,     _("Label a tape"), NT_("storage=<storage> volume=<vol> pool=<pool> slot=<slot> barcodes"), false},
  { NT_("list"),       list_cmd,      _("List objects from catalog"),
-   NT_("pools | jobs | jobtotals | volume | media <pool=pool-name> | files jobid=<nn> | copies jobid=<nn> |\n"
-       "\tjoblog jobid=<nn> | snapshot"), false},
+   NT_("jobs [client=<cli>] [jobid=<nn>] [ujobid=<name>] [job=<name>] [joberrors] [jobstatus=<s>] [limit=<n>]|\n"
+       "\tjobtotals | pools | volume | media <pool=pool-name> | files jobid=<nn> | copies jobid=<nn> |\n"
+       "\tjoblog jobid=<nn> | pluginrestoreconf jobid=<nn> restoreobjectid=<nn> | snapshot"), false},
 
  { NT_("llist"),      llist_cmd,     _("Full or long list like list command"),
-   NT_("pools | jobs | joblog jobid=<nn> | jobtotals | media <pool=pool-name> | files jobid=<nn> | copies jobid=<nn> | snapshot"), false},
+   NT_("jobs [client=<cli>] [jobid=<nn>] [ujobid=<name>] [job=<name>] [joberrors] [jobstatus=<s>] [limit=<n>]|\n"
+       "\tjobtotals | pools | volume | media <pool=pool-name> | files jobid=<nn> | copies jobid=<nn> |\n"
+       "\tjoblog jobid=<nn> | pluginrestoreconf jobid=<nn> restoreobjectid=<nn> | snapshot"), false},
 
  { NT_("messages"),   messagescmd,   _("Display pending messages"),   NT_(""),    false},
  { NT_("memory"),     memory_cmd,    _("Print current memory usage"), NT_(""),    true},
@@ -161,7 +164,7 @@ static struct cmdstruct commands[] = {                                      /* C
  { NT_("status"),     status_cmd,    _("Report status"),
    NT_("all | dir=<dir-name> | director | client=<client-name> |\n"
        "\tstorage=<storage-name> slots |\n"
-       "\tschedule [job=<job-name>] [days=<nn>] [limit=<nn>] [toto]\n"
+       "\tschedule [job=<job-name>] [days=<nn>] [limit=<nn>]\n"
        "\t\t[time=<universal-time-specification>]"), true},
 
  { NT_("stop"),       cancel_cmd,    _("Stop a job"), NT_("jobid=<number-list> job=<job-name> ujobid=<unique-jobid> all"), false},
@@ -911,6 +914,14 @@ static int disable_cmd(UAContext *ua, const char *cmd)
    return 1;
 }
 
+static void do_dir_setdebug(UAContext *ua, int64_t level, int trace_flag, char *options, int64_t tags)
+{
+   debug_level = level;
+   debug_level_tags = tags;
+   set_trace(trace_flag);
+   set_debug_flags(options);
+}
+
 static void do_storage_setdebug(UAContext *ua, STORE *store,
                int64_t level, int trace_flag, int hangup, int blowup,
                char *options, char *tags)
@@ -996,9 +1007,11 @@ static void do_all_setdebug(UAContext *ua, int64_t level,
    STORE *store, **unique_store;
    CLIENT *client, **unique_client;
    int i, j, found;
+   int64_t t=0;
 
    /* Director */
-   debug_level = level;
+   debug_parse_tags(tags, &t);
+   do_dir_setdebug(ua, level, trace_flag, options, t);
 
    /* Count Storage items */
    LockRes();
@@ -1146,10 +1159,7 @@ static int setdebug_cmd(UAContext *ua, const char *cmd)
       }
       if (strcasecmp(ua->argk[i], "dir") == 0 ||
           strcasecmp(ua->argk[i], "director") == 0) {
-         debug_level = level;
-         debug_level_tags = tags;
-         set_trace(trace_flag);
-         set_debug_flags(options);
+         do_dir_setdebug(ua, level, trace_flag, options, tags);
          return 1;
       }
       if (strcasecmp(ua->argk[i], "client") == 0 ||
@@ -1202,9 +1212,7 @@ static int setdebug_cmd(UAContext *ua, const char *cmd)
    add_prompt(ua, _("All"));
    switch(do_prompt(ua, "", _("Select daemon type to set debug level"), NULL, 0)) {
    case 0:                         /* Director */
-      debug_level = level;
-      set_trace(trace_flag);
-      set_debug_flags(options);
+      do_dir_setdebug(ua, level, trace_flag, options, tags);
       break;
    case 1:
       store = get_storage_resource(ua, false/*no default*/, true/*unique*/);
@@ -2203,6 +2211,9 @@ bool open_db(UAContext *ua)
                              ua->catalog->db_user,
                              ua->catalog->db_password, ua->catalog->db_address,
                              ua->catalog->db_port, ua->catalog->db_socket,
+                             ua->catalog->db_ssl_key, ua->catalog->db_ssl_cert,
+                             ua->catalog->db_ssl_ca, ua->catalog->db_ssl_capath,
+                             ua->catalog->db_ssl_cipher,
                              mult_db_conn, ua->catalog->disable_batch_insert); 
    if (!ua->db || !db_open_database(ua->jcr, ua->db)) {
       ua->error_msg(_("Could not open catalog database \"%s\".\n"),
diff --git a/src/dird/ua_dotcmds.c b/src/dird/ua_dotcmds.c
index 4aeadfb..eda973a 100644
--- a/src/dird/ua_dotcmds.c
+++ b/src/dird/ua_dotcmds.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -905,20 +904,28 @@ static bool dot_bvfs_get_jobs(UAContext *ua, const char *cmd)
       return true;
    }
 
-   if ((pos = find_arg_with_value(ua, "client")) < 0) {
+   if (((pos = find_arg_with_value(ua, "client")) < 0) ||
+       (strlen(ua->argv[pos]) > MAX_NAME_LENGTH))
+   {
       return true;
    }
 
-   posj = find_arg_with_value(ua, "ujobid");
-
    if (!acl_access_ok(ua, Client_ACL, ua->argv[pos])) {
       return true;
    }
-   
+
+   posj = find_arg_with_value(ua, "ujobid");
+   /* Do a little check on the size of the argument */
+   if (posj >= 0 && strlen(ua->argv[posj]) > MAX_NAME_LENGTH) {
+      return true;
+   }
+
    db_lock(ua->db);
-   db_escape_string(ua->jcr, ua->db, esc_cli, ua->argv[pos], sizeof(esc_cli));
+   db_escape_string(ua->jcr, ua->db, esc_cli,
+                    ua->argv[pos], strlen(ua->argv[pos]));
    if (posj >= 0) {
-      db_escape_string(ua->jcr, ua->db, esc_job, ua->argv[posj], sizeof(esc_job));
+      db_escape_string(ua->jcr, ua->db, esc_job,
+                       ua->argv[posj], strlen(ua->argv[pos]));
       Mmsg(tmp, "AND Job.Job = '%s'", esc_job);
    }
    Mmsg(ua->db->cmd,
diff --git a/src/dird/ua_input.c b/src/dird/ua_input.c
index 7d55aa8..a919723 100644
--- a/src/dird/ua_input.c
+++ b/src/dird/ua_input.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/ua_label.c b/src/dird/ua_label.c
index 1a78c06..e5cc16c 100644
--- a/src/dird/ua_label.c
+++ b/src/dird/ua_label.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -476,7 +475,7 @@ checkName:
          bstrncpy(dev_name, store.store->dev_name(), sizeof(dev_name));
          ua->info_msg(_("Requesting to mount %s ...\n"), dev_name);
          bash_spaces(dev_name);
-         sd->fsend("mount %s drive=%d", dev_name, drive);
+         sd->fsend("mount %s drive=%d slot=%d", dev_name, drive, mr.Slot);
          unbash_spaces(dev_name);
          while (sd->recv() >= 0) {
             ua->send_msg("%s", sd->msg);
diff --git a/src/dird/ua_output.c b/src/dird/ua_output.c
index a0b6c9b..49b578d 100644
--- a/src/dird/ua_output.c
+++ b/src/dird/ua_output.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -350,11 +349,39 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
    if (!ua->db) {
       ua->error_msg(_("Hey! DB is NULL\n"));
    }
-
    /* Apply any limit */
-   j = find_arg_with_value(ua, NT_("limit"));
-   if (j >= 0) {
-      jr.limit = atoi(ua->argv[j]);
+   for (j = 1; j < ua->argc ; j++) {
+      if (strcasecmp(ua->argk[j], NT_("joberrors")) == 0) {
+         jr.JobErrors = 1;
+      } else if (!ua->argv[j]) {
+         /* skip */
+      } else if (strcasecmp(ua->argk[j], NT_("order")) == 0) {
+         if (strcasecmp(ua->argv[j], NT_("desc")) == 0 ||
+             strcasecmp(ua->argv[j], NT_("descending")) == 0) {
+            jr.order = 1;
+         } else if (strcasecmp(ua->argv[j], NT_("asc")) == 0 ||
+                    strcasecmp(ua->argv[j], NT_("ascending")) == 0) {
+            jr.order = 0;
+         } else {
+            ua->error_msg(_("Unknown order type %s\n"), ua->argv[j]);
+            return 1;
+         }
+      } else if (strcasecmp(ua->argk[j], NT_("limit")) == 0) {
+         jr.limit = atoi(ua->argv[j]);
+
+      } else if (strcasecmp(ua->argk[j], NT_("jobstatus")) == 0) {
+         if (B_ISALPHA(ua->argv[j][0])) {
+            jr.JobStatus = ua->argv[j][0];
+         }
+      } else if (strcasecmp(ua->argk[j], NT_("client")) == 0) {
+         if (is_name_valid(ua->argv[j], NULL)) {
+            CLIENT_DBR cr;
+            memset(&cr, 0, sizeof(cr));
+            if(get_client_dbr(ua, &cr)) {
+               jr.ClientId = cr.ClientId;
+            }
+         }
+      }
    }
 
    /* Scan arguments looking for things to do */
@@ -579,7 +606,12 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
          }
          db_list_copies_records(ua->jcr,ua->db,limit,jobids,prtit,ua,llist);
       } else if (strcasecmp(ua->argk[i], NT_("limit")) == 0
-                 || strcasecmp(ua->argk[i], NT_("days")) == 0) {
+                 || strcasecmp(ua->argk[i], NT_("days")) == 0
+                 || strcasecmp(ua->argk[i], NT_("joberrors")) == 0
+                 || strcasecmp(ua->argk[i], NT_("order")) == 0
+                 || strcasecmp(ua->argk[i], NT_("jobstatus")) == 0
+                 || strcasecmp(ua->argk[i], NT_("client")) == 0
+         ) {
          /* Ignore it */
       } else if (strcasecmp(ua->argk[i], NT_("snapshot")) == 0 ||
                  strcasecmp(ua->argk[i], NT_("snapshots")) == 0) 
@@ -785,6 +817,8 @@ bool complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool)
                 jcr->catalog->db_user,
                 jcr->catalog->db_password, jcr->catalog->db_address,
                 jcr->catalog->db_port, jcr->catalog->db_socket,
+                jcr->catalog->db_ssl_key, jcr->catalog->db_ssl_cert, jcr->catalog->db_ssl_ca,
+                jcr->catalog->db_ssl_capath, jcr->catalog->db_ssl_cipher,
                 jcr->catalog->mult_db_connections,
                 jcr->catalog->disable_batch_insert);
    if (!jcr->db || !db_open_database(jcr, jcr->db)) {
diff --git a/src/dird/ua_prune.c b/src/dird/ua_prune.c
index f83b831..53fa0b9 100644
--- a/src/dird/ua_prune.c
+++ b/src/dird/ua_prune.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -652,7 +651,9 @@ static bool prune_expired_volumes(UAContext *ua)
    }
 
    /* We can restrict by MediaType */
-   if ((i = find_arg_with_value(ua, "mediatype")) >= 0) {
+   if (((i = find_arg_with_value(ua, "mediatype")) >= 0) &&
+       (strlen(ua->argv[i]) <= MAX_NAME_LENGTH))
+   {
       char ed1[MAX_ESCAPE_NAME_LENGTH];
       db_escape_string(ua->jcr, ua->db, ed1,
          ua->argv[i], strlen(ua->argv[i]));
diff --git a/src/dird/ua_purge.c b/src/dird/ua_purge.c
index 2507c57..31b4b7e 100644
--- a/src/dird/ua_purge.c
+++ b/src/dird/ua_purge.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -61,6 +60,8 @@ int purge_cmd(UAContext *ua, const char *cmd)
    CLIENT *client;
    MEDIA_DBR mr;
    JOB_DBR  jr;
+   memset(&jr, 0, sizeof(jr));
+
    static const char *keywords[] = {
       NT_("files"),
       NT_("jobs"),
@@ -208,11 +209,11 @@ static int purge_files_from_client(UAContext *ua, CLIENT *client)
 
    purge_files_from_job_list(ua, del);
 
-   if (del.num_ids == 0) {
+   if (del.num_del == 0) {
       ua->warning_msg(_("No Files found for client %s to purge from %s catalog.\n"),
          client->name(), client->catalog->name());
    } else {
-      ua->info_msg(_("Files for %d Jobs for client \"%s\" purged from %s catalog.\n"), del.num_ids,
+      ua->info_msg(_("Files for %d Jobs for client \"%s\" purged from %s catalog.\n"), del.num_del,
          client->name(), client->catalog->name());
    }
 
@@ -258,11 +259,11 @@ static int purge_jobs_from_client(UAContext *ua, CLIENT *client)
 
    purge_job_list_from_catalog(ua, del);
 
-   if (del.num_ids == 0) {
+   if (del.num_del == 0) {
       ua->warning_msg(_("No Files found for client %s to purge from %s catalog.\n"),
          client->name(), client->catalog->name());
    } else {
-      ua->info_msg(_("%d Jobs for client %s purged from %s catalog.\n"), del.num_ids,
+      ua->info_msg(_("%d Jobs for client %s purged from %s catalog.\n"), del.num_del,
          client->name(), client->catalog->name());
    }
 
@@ -705,7 +706,7 @@ int truncate_cmd(UAContext *ua, const char *cmd)
     */
    mr.Recycle = 1;
    mr.Enabled = 1;
-   mr.VolBytes = 10000;
+   mr.VolBytes = 200;
    set_storageid_in_mr(store, &mr);
    bstrncpy(mr.VolStatus, "Purged", sizeof(mr.VolStatus));
    if (!db_get_media_ids(ua->jcr, ua->db, &mr, &nb, &results)) {
diff --git a/src/dird/ua_query.c b/src/dird/ua_query.c
index 1f8449c..e7ba1f0 100644
--- a/src/dird/ua_query.c
+++ b/src/dird/ua_query.c
@@ -1,16 +1,7 @@
 /*
- *
- *   Bacula Director -- User Agent Database Query Commands
- *
- *     Kern Sibbald, December MMI
- *
- *   Version $Id$
- */
-/*
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -25,6 +16,13 @@
 
    Bacula(R) is a registered trademark of Kern Sibbald.
 */
+/*
+ *
+ *   Bacula Director -- User Agent Database Query Commands
+ *
+ *     Kern Sibbald, December MMI
+ *
+ */
 
 #include "bacula.h"
 #include "dird.h"
diff --git a/src/dird/ua_restore.c b/src/dird/ua_restore.c
index 65b069e..6671fb6 100644
--- a/src/dird/ua_restore.c
+++ b/src/dird/ua_restore.c
@@ -1614,12 +1614,13 @@ void find_storage_resource(UAContext *ua, RESTORE_CTX &rx, char *Storage, char *
          ua->info_msg(_("\nWarning Storage is overridden by \"%s\" on the command line.\n"),
             store->name());
          rx.store = store;
-         bstrncpy(rx.RestoreMediaType, MediaType, sizeof(rx.RestoreMediaType));
+         bstrncpy(Storage, store->name(), MAX_NAME_LENGTH); /* Return overridden Storage */
          if (strcmp(MediaType, store->media_type) != 0) {
-            ua->info_msg(_("This may not work because of two different MediaTypes:\n"
-               "  Storage MediaType=\"%s\"\n"
-               "  Volume  MediaType=\"%s\".\n\n"),
+            ua->info_msg(_("Warning MediaType overridden by Storage Media Type:\n"
+               "  New Storage MediaType=\"%s\"\n"
+               "  Old Volume  MediaType=\"%s\".\n\n"),
                store->media_type, MediaType);
+            bstrncpy(MediaType, store->media_type, MAX_NAME_LENGTH); /* Return overridden MediaType */
          }
          Dmsg2(200, "Set store=%s MediaType=%s\n", rx.store->name(), rx.RestoreMediaType);
       }
diff --git a/src/dird/ua_run.c b/src/dird/ua_run.c
index f5756d2..03c3f2f 100644
--- a/src/dird/ua_run.c
+++ b/src/dird/ua_run.c
@@ -311,8 +311,13 @@ static bool get_next_pool(UAContext *ua, run_ctx &rc)
          rc.next_pool = select_pool_resource(ua);
       }
    }
+   /* NextPool can come from Job resource NextPool or Pool resource NextPool */
    if (!rc.next_pool) {
-      rc.next_pool = rc.pool->NextPool;      /* use default */
+      if (rc.job->next_pool) {
+         rc.next_pool = rc.job->next_pool;
+      } else {
+         rc.next_pool = rc.pool->NextPool;      /* use default */
+      }
    }
    if (rc.next_pool && !acl_access_ok(ua, Pool_ACL, rc.next_pool->name())) {
       ua->error_msg(_("No authorization. NextPool \"%s\".\n"), rc.next_pool->name());
@@ -896,6 +901,8 @@ static bool set_run_context_in_jcr(UAContext *ua, JCR *jcr, run_ctx &rc)
    }
    if (rc.next_pool_name) {
       pm_strcpy(jcr->next_pool_source, _("Command input"));
+   } else if (jcr->next_pool == jcr->job->next_pool) {
+      pm_strcpy(jcr->next_pool_source, _("Job resource"));
    } else if (jcr->next_pool != jcr->pool->NextPool) {
       pm_strcpy(jcr->next_pool_source, _("User input"));
    }
@@ -1234,7 +1241,7 @@ static void select_job_level(UAContext *ua, JCR *jcr)
       add_prompt(ua, _("Verify Catalog"));
       add_prompt(ua, _("Verify Volume to Catalog"));
       add_prompt(ua, _("Verify Disk to Catalog"));
-      add_prompt(ua, _("Verify Volume Data (not yet implemented)"));
+      add_prompt(ua, _("Verify Volume Data"));
       switch (do_prompt(ua, "",  _("Select level"), NULL, 0)) {
       case 0:
          jcr->setJobLevel(L_VERIFY_INIT);
diff --git a/src/dird/ua_select.c b/src/dird/ua_select.c
index 343dbbe..d7efcf9 100644
--- a/src/dird/ua_select.c
+++ b/src/dird/ua_select.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -228,6 +227,7 @@ CAT *get_catalog_resource(UAContext *ua)
 {
    char name[MAX_NAME_LENGTH];
    CAT *catalog = NULL;
+   CLIENT *client = NULL;
    int i;
 
    for (i=1; i<ua->argc; i++) {
@@ -237,6 +237,15 @@ CAT *get_catalog_resource(UAContext *ua)
             break;
          }
       }
+      if (strcasecmp(ua->argk[i], NT_("client")) == 0 && ua->argv[i]) {
+         if (acl_access_ok(ua, Client_ACL, ua->argv[i])) {
+            client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+            break;
+         }
+      }
+   }
+   if (!catalog && client) {    /* Try to take the catalog from the client */
+      catalog = client->catalog;
    }
    if (ua->gui && !catalog) {
       LockRes();
@@ -911,7 +920,7 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg,
       if (prompt) {
          bstrncpy(prompt, ua->prompt[1], max_prompt);
       }
-      ua->send_msg(_("Automatically selected %s: %s\n"), automsg, ua->prompt[1]);
+      ua->send_msg(_("Automatically selected %s: %s\n"), NPRTB(automsg), ua->prompt[1]);
       goto done;
    }
    /* If running non-interactive, bail out */
diff --git a/src/dird/ua_server.c b/src/dird/ua_server.c
index eb5c586..eee03bf 100644
--- a/src/dird/ua_server.c
+++ b/src/dird/ua_server.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/ua_status.c b/src/dird/ua_status.c
index 6ac3d66..291de2b 100644
--- a/src/dird/ua_status.c
+++ b/src/dird/ua_status.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -1002,17 +1001,21 @@ static void list_running_jobs(UAContext *ua)
          msg = _("is waiting for an appendable Volume");
          break;
       case JS_WaitFD:
-         if (!pool_mem) {
-            emsg = (char *)get_pool_memory(PM_FNAME);
-            pool_mem = true;
+         /* Special case when JobStatus=JS_WaitFD, we don't have a FD link yet 
+          * we need to stay in WaitFD status See bee mantis #1414 */
+         if (jcr->JobStatus != JS_WaitFD) {
+            if (!pool_mem) {
+               emsg = (char *)get_pool_memory(PM_FNAME);
+               pool_mem = true;
+            }
+            if (!jcr->client || !jcr->wstore) {
+               Mmsg(emsg, _("is waiting for Client to connect to Storage daemon"));
+            } else {
+               Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
+                    jcr->client->name(), jcr->wstore->name());
+            }
+            msg = emsg;
          }
-         if (!jcr->client || !jcr->wstore) {
-            Mmsg(emsg, _("is waiting for Client to connect to Storage daemon"));
-         } else {
-            Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
-                 jcr->client->name(), jcr->wstore->name());
-        }
-        msg = emsg;
         break;
       case JS_DataCommitting:
          msg = _("SD committing Data");
diff --git a/src/dird/ua_tree.c b/src/dird/ua_tree.c
index 8230e0c..d6fb0f7 100644
--- a/src/dird/ua_tree.c
+++ b/src/dird/ua_tree.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/ua_update.c b/src/dird/ua_update.c
index 6362d8c..fdfe7d7 100644
--- a/src/dird/ua_update.c
+++ b/src/dird/ua_update.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/dird/vbackup.c b/src/dird/vbackup.c
index a1af9dc..2152330 100644
--- a/src/dird/vbackup.c
+++ b/src/dird/vbackup.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2008-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -285,6 +284,10 @@ _("This Job is not an Accurate backup so is not equivalent to a Full backup.\n")
    jcr->jr.JobTDate = jcr->start_time;
    jcr->setJobStatus(JS_Running);
 
+   /* Add the following when support for base jobs is added to virtual full */
+   //jcr->HasBase = jcr->job->base != NULL;
+   //jcr->jr.HasBase = jcr->HasBase;
+
    /* Update job start record */
    if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
@@ -577,15 +580,9 @@ static bool create_bootstrap_file(JCR *jcr, char *jobids)
 
    complete_bsr(ua, rx.bsr);
    jcr->ExpectedFiles = write_bsr_file(ua, rx);
-   if (chk_dbglvl(10)) {
-      Pmsg1(000,  "Found %d files to consolidate.\n", jcr->ExpectedFiles);
-   }
-   if (jcr->ExpectedFiles == 0) {
-      free_ua_context(ua);
-      free_bsr(rx.bsr);
-      return false;
-   }
+   Jmsg(jcr, M_INFO, 0, _("Found %d files to consolidate into Virtual Full.\n"),
+        jcr->ExpectedFiles);
    free_ua_context(ua);
    free_bsr(rx.bsr);
-   return true;
+   return jcr->ExpectedFiles==0?false:true;
 }
diff --git a/src/dird/verify.c b/src/dird/verify.c
index a811859..b9f1c4f 100644
--- a/src/dird/verify.c
+++ b/src/dird/verify.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -66,11 +65,10 @@ bool do_verify_init(JCR *jcr)
       free_rstorage(jcr);
       free_wstorage(jcr);
       break;
+   case L_VERIFY_DATA:
    case L_VERIFY_VOLUME_TO_CATALOG:
       free_wstorage(jcr);
       break;
-   case L_VERIFY_DATA:
-      break;
    default:
       Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->getJobLevel(),
          jcr->getJobLevel());
@@ -116,11 +114,13 @@ bool do_verify(JCR *jcr)
     */
    if (jcr->getJobLevel() == L_VERIFY_CATALOG ||
        jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ||
-       jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG) {
+       jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG ||
+       jcr->getJobLevel() == L_VERIFY_DATA) {
       memcpy(&jr, &jcr->jr, sizeof(jr));
       if (jcr->verify_job &&
           (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ||
-           jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG)) {
+           jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG   ||
+           jcr->getJobLevel() == L_VERIFY_DATA)) {
          Name = jcr->verify_job->name();
       } else {
          Name = NULL;
@@ -155,7 +155,8 @@ bool do_verify(JCR *jcr)
     */
    if (jcr->getJobLevel() == L_VERIFY_CATALOG ||
        jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ||
-       jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG) {
+       jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG ||
+       jcr->getJobLevel() == L_VERIFY_DATA) {
       jcr->previous_jr.JobId = verify_jobid;
       if (!db_get_job_record(jcr, jcr->db, &jcr->previous_jr)) {
          Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"),
@@ -178,7 +179,7 @@ bool do_verify(JCR *jcr)
     *   create a dummy authorization key (passed to
     *   File daemon but not used).
     */
-   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
+   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG || jcr->getJobLevel() == L_VERIFY_DATA) {
       int stat;
       /*
        * Note: negative status is an error, zero status, means
@@ -196,10 +197,43 @@ bool do_verify(JCR *jcr)
       jcr->sd_auth_key = bstrdup("dummy");    /* dummy Storage daemon key */
    }
 
+   /* Pass the original fileset to the client */
+   if (jcr->getJobLevel() == L_VERIFY_DATA) {
+      FILESET_DBR fdbr;
+      memset(&fdbr, 0, sizeof(fdbr));
+      fdbr.FileSetId = jcr->previous_jr.FileSetId;
+      if (!db_get_fileset_record(jcr, jcr->db, &fdbr)) {
+         Jmsg(jcr, M_FATAL, 0,
+              _("Could not get fileset record from previous Job. ERR=%s"),
+              db_strerror(jcr->db));
+         return false;
+      }
+
+      jcr->fileset = (FILESET *)GetResWithName(R_FILESET, fdbr.FileSet);
+      if (!jcr->fileset) {
+         if (jcr->verify_job) {
+            jcr->fileset = jcr->verify_job->fileset;
+            Jmsg(jcr, M_WARNING, 0,
+                 _("Could not find FileSet resource \"%s\" from previous Job\n"),
+                 fdbr.FileSet);
+            Jmsg(jcr, M_INFO, 0,
+                 _("Using FileSet \"%\"\n"), jcr->fileset->name());
+
+         } else {
+            Jmsg(jcr, M_FATAL, 0,
+                 _("Could not get FileSet resource for verify Job."));
+            return false;
+         }
+      }
+      Dmsg1(50, "FileSet = %s\n", jcr->fileset->name());
+   }
+
+   /* Pass the current fileset to the client */
    if (jcr->getJobLevel() == L_VERIFY_DISK_TO_CATALOG && jcr->verify_job) {
       jcr->fileset = jcr->verify_job->fileset;
    }
-   Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->previous_jr.ClientId, jcr->getJobLevel());
+   Dmsg2(100, "ClientId=%u JobLevel=%c\n",
+         jcr->previous_jr.ClientId, jcr->getJobLevel());
 
    if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
@@ -210,7 +244,9 @@ bool do_verify(JCR *jcr)
    Jmsg(jcr, M_INFO, 0, _("Start Verify JobId=%s Level=%s Job=%s\n"),
       edit_uint64(jcr->JobId, ed1), level_to_str(jcr->getJobLevel()), jcr->Job);
 
-   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
+   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ||
+       jcr->getJobLevel() == L_VERIFY_DATA)
+   {
       /*
        * Start conversation with Storage daemon
        */
@@ -273,6 +309,7 @@ bool do_verify(JCR *jcr)
    case L_VERIFY_CATALOG:
       level = "catalog";
       break;
+   case L_VERIFY_DATA:
    case L_VERIFY_VOLUME_TO_CATALOG:
       if (jcr->sd_calls_client) {
          if (jcr->FDVersion < 10) {
@@ -309,18 +346,19 @@ bool do_verify(JCR *jcr)
          Jmsg0(jcr, M_FATAL, 0, _("Deprecated feature ... use bootstrap.\n"));
          goto bail_out;
       }
-
-      level = "volume";
-      break;
-   case L_VERIFY_DATA:
-      level = "data";
+      if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
+         level = "volume";
+      } else {
+         level = "data";
+      }
       break;
    case L_VERIFY_DISK_TO_CATALOG:
       level="disk_to_catalog";
       break;
    default:
-      Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->getJobLevel(),
-         jcr->getJobLevel());
+      Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"),
+            jcr->getJobLevel(),
+            jcr->getJobLevel());
       goto bail_out;
    }
 
@@ -372,6 +410,10 @@ bool do_verify(JCR *jcr)
       db_write_batch_file_records(jcr);
       break;
 
+   case L_VERIFY_DATA:
+      /* Nothing special to do */
+      bget_dirmsg(fd);          /* eat EOD */
+      break;
    default:
       Jmsg1(jcr, M_FATAL, 0, _("Unimplemented verify level %d\n"), jcr->getJobLevel());
       goto bail_out;
@@ -403,7 +445,7 @@ void verify_cleanup(JCR *jcr, int TermCode)
 
    Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", jcr->getJobLevel(),
       jcr->ExpectedFiles, jcr->JobFiles);
-   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG &&
+   if ((jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG || jcr->getJobLevel() == L_VERIFY_DATA) &&
        jcr->ExpectedFiles != jcr->JobFiles) {
       TermCode = JS_ErrorTerminated;
    }
@@ -422,7 +464,11 @@ void verify_cleanup(JCR *jcr, int TermCode)
    msg_type = M_INFO;                 /* by default INFO message */
    switch (TermCode) {
    case JS_Terminated:
-      term_msg = _("Verify OK");
+      if (jcr->JobErrors || jcr->SDErrors) {
+         term_msg = _("Verify OK -- with warnings");
+      } else {
+         term_msg = _("Verify OK");
+      }
       break;
    case JS_FatalError:
    case JS_ErrorTerminated:
@@ -453,7 +499,7 @@ void verify_cleanup(JCR *jcr, int TermCode)
    }
 
    jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg));
-   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
+   if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG || jcr->getJobLevel() == L_VERIFY_DATA) {
       jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg));
       Jmsg(jcr, msg_type, 0, _("%s %s %s (%s):\n"
 "  Build OS:               %s %s %s\n"
@@ -469,6 +515,7 @@ void verify_cleanup(JCR *jcr, int TermCode)
 "  Files Expected:         %s\n"
 "  Files Examined:         %s\n"
 "  Non-fatal FD errors:    %d\n"
+"  SD Errors:              %d\n"
 "  FD termination status:  %s\n"
 "  SD termination status:  %s\n"
 "  Termination:            %s\n\n"),
@@ -486,6 +533,7 @@ void verify_cleanup(JCR *jcr, int TermCode)
            edit_uint64_with_commas(jcr->ExpectedFiles, ec1),
            edit_uint64_with_commas(jcr->JobFiles, ec2),
            jcr->JobErrors,
+           jcr->SDErrors,
            fd_term_msg,
            sd_term_msg,
            term_msg);
diff --git a/src/filed/accurate.c b/src/filed/accurate.c
index 62d572b..f996b34 100644
--- a/src/filed/accurate.c
+++ b/src/filed/accurate.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2015 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/authenticate.c b/src/filed/authenticate.c
index e432e06..fe2615d 100644
--- a/src/filed/authenticate.c
+++ b/src/filed/authenticate.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/backup.c b/src/filed/backup.c
index 31ed90a..9d2b58f 100644
--- a/src/filed/backup.c
+++ b/src/filed/backup.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -28,19 +27,19 @@
 #include "bacula.h"
 #include "filed.h"
 #include "backup.h"
-
+ 
 #ifdef HAVE_LZO
 const bool have_lzo = true;
-#else
+#else 
 const bool have_lzo = false;
-#endif
-
+#endif 
+ 
 #ifdef HAVE_LIBZ
 const bool have_libz = true;
-#else
+#else 
 const bool have_libz = false;
-#endif
-
+#endif 
+ 
 /* Forward referenced functions */
 int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
 static int send_data(bctx_t &bctx, int stream);
@@ -166,9 +165,8 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
    memset(jcr->xattr_ctx, 0, sizeof(xattr_ctx_t));
    jcr->xattr_ctx->content = get_pool_memory(PM_MESSAGE);
 #endif
-
-
-   /** Subroutine save_file() is called for each file */
+ 
+   /* Subroutine save_file() is called for each file */
    if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) {
       ok = false;                     /* error */
       jcr->setJobStatus(JS_ErrorTerminated);
@@ -629,7 +627,7 @@ static int send_data(bctx_t &bctx, int stream)
    if ((bctx.ff_pkt->flags & FO_SPARSE) || (bctx.ff_pkt->flags & FO_OFFSETS)) {
       bctx.rbuf += OFFSET_FADDR_SIZE;
       bctx.rsize -= OFFSET_FADDR_SIZE;
-#ifdef HAVE_FREEBSD_OS
+#if defined(HAVE_FREEBSD_OS) || defined(__FreeBSD_kernel__)
       /**
        * To read FreeBSD partitions, the read size must be
        *  a multiple of 512.
diff --git a/src/filed/backup.h b/src/filed/backup.h
index 2cf0223..31090e1 100644
--- a/src/filed/backup.h
+++ b/src/filed/backup.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/crypto.c b/src/filed/crypto.c
index f3eabd5..1c2f675 100644
--- a/src/filed/crypto.c
+++ b/src/filed/crypto.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/estimate.c b/src/filed/estimate.c
index 216b69d..c6b1594 100644
--- a/src/filed/estimate.c
+++ b/src/filed/estimate.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/fd_plugins.c b/src/filed/fd_plugins.c
index 922d1e0..beb6309 100644
--- a/src/filed/fd_plugins.c
+++ b/src/filed/fd_plugins.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/fd_plugins.h b/src/filed/fd_plugins.h
index 63af7d7..f591572 100644
--- a/src/filed/fd_plugins.h
+++ b/src/filed/fd_plugins.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/fd_snapshot.c b/src/filed/fd_snapshot.c
index aac0116..135dca7 100644
--- a/src/filed/fd_snapshot.c
+++ b/src/filed/fd_snapshot.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/fd_snapshot.h b/src/filed/fd_snapshot.h
index 5d670de..2d61fc6 100644
--- a/src/filed/fd_snapshot.h
+++ b/src/filed/fd_snapshot.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/filed.c b/src/filed/filed.c
index 8e273bf..85ab023 100644
--- a/src/filed/filed.c
+++ b/src/filed/filed.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -46,6 +45,7 @@ extern struct s_cmds cmds[];
 #endif
 
 char *configfile = NULL;
+static bool test_config = false;
 static bool foreground = false;
 static workq_t dir_workq;             /* queue of work from Director */
 static pthread_t server_tid;
@@ -85,7 +85,6 @@ static void usage()
 int main (int argc, char *argv[])
 {
    int ch;
-   bool test_config = false;
    bool keep_readall_caps = false;
    char *uid = NULL;
    char *gid = NULL;
@@ -279,8 +278,13 @@ void terminate_filed(int sig)
    bnet_stop_thread_server(server_tid);
    generate_daemon_event(NULL, "Exit");
    unload_plugins();
-   write_state_file(me->working_directory, "bacula-fd", get_first_port_host_order(me->FDaddrs));
-   delete_pid_file(me->pid_directory, "bacula-fd", get_first_port_host_order(me->FDaddrs));
+
+   if (!test_config) {
+      write_state_file(me->working_directory,
+                       "bacula-fd", get_first_port_host_order(me->FDaddrs));
+      delete_pid_file(me->pid_directory,
+                      "bacula-fd", get_first_port_host_order(me->FDaddrs));
+   }
 
    if (configfile != NULL) {
       free(configfile);
diff --git a/src/filed/filed.h b/src/filed/filed.h
index 9eaf2eb..cc15693 100644
--- a/src/filed/filed.h
+++ b/src/filed/filed.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -29,8 +28,7 @@
 #define ERROR_BUFFER_OVERFLOW 1
 #define ERROR_SUCCESS 0
 #endif
-
-
+ 
 /* acl errors to report per job. */
 #define ACL_MAX_ERROR_PRINT_PER_JOB   25
  
diff --git a/src/filed/filed_conf.c b/src/filed/filed_conf.c
index 164786b..cd41ad9 100644
--- a/src/filed/filed_conf.c
+++ b/src/filed/filed_conf.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/filed_conf.h b/src/filed/filed_conf.h
index 7ab4b65..ac04911 100644
--- a/src/filed/filed_conf.h
+++ b/src/filed/filed_conf.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/heartbeat.c b/src/filed/heartbeat.c
index 783bfb2..e3ffdcd 100644
--- a/src/filed/heartbeat.c
+++ b/src/filed/heartbeat.c
@@ -48,6 +48,7 @@ extern "C" void *sd_heartbeat_thread(void *arg)
    time_t last_heartbeat = time(NULL);
    time_t now;
 
+   set_jcr_in_tsd(jcr);
    pthread_detach(pthread_self());
 
    /* Get our own local copy */
diff --git a/src/filed/job.c b/src/filed/job.c
index 1da24a6..bcc72b1 100644
--- a/src/filed/job.c
+++ b/src/filed/job.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -34,8 +33,7 @@ bool no_win32_write_errors = false;
 
 /* Static variables */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-
+ 
 const bool have_win32 = false;
 
 #ifdef HAVE_ACL
@@ -43,7 +41,7 @@ const bool have_acl = true;
 #else 
 const bool have_acl = false; 
 #endif 
-
+ 
 #if HAVE_XATTR
 const bool have_xattr = true; 
 #else 
@@ -341,7 +339,6 @@ static void *handle_director_request(BSOCK *dir)
       dir->fsend(EndJob, jcr->JobStatus, jcr->JobFiles,
               jcr->ReadBytes, jcr->JobBytes, jcr->JobErrors, vss,
               encrypt, 0, 0);
-      //Dmsg0(0/*110*/, dir->msg);
    }
 
    generate_daemon_event(jcr, "JobEnd");
@@ -353,7 +350,6 @@ bail_out:
    /* Inform Director that we are done */
    dir->signal(BNET_TERMINATE);
 
-   free_plugins(jcr);                 /* release instantiated plugins */
    free_and_null_pool_memory(jcr->job_metadata);
 
    /* Clean up fileset */
@@ -2154,6 +2150,7 @@ static int verify_cmd(JCR *jcr)
    case L_VERIFY_CATALOG:
       do_verify(jcr);
       break;
+   case L_VERIFY_DATA:
    case L_VERIFY_VOLUME_TO_CATALOG:
       if (!open_sd_read_session(jcr)) {
          return 0;
@@ -2443,6 +2440,7 @@ static void filed_free_jcr(JCR *jcr)
    if (jcr->last_fname) {
       free_pool_memory(jcr->last_fname);
    }
+   free_plugins(jcr);                 /* release instantiated plugins */
    free_runscripts(jcr->RunScripts);
    delete jcr->RunScripts;
    free_path_list(jcr);
@@ -2462,10 +2460,12 @@ static void filed_free_jcr(JCR *jcr)
  */
 int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd)
 {
+   int ret;
+
    if (sd->errors) {
       return 0;
    }
-   if (bget_msg(sd) > 0) {
+   if ((ret = bget_msg(sd)) > 0) {
       Dmsg0(110, sd->msg);
       if (strcmp(sd->msg, resp) == 0) {
          return 1;
@@ -2479,8 +2479,13 @@ int response(JCR *jcr, BSOCK *sd, char *resp, const char *cmd)
          cmd, sd->bstrerror());
    } else {
       char buf[256];
-      Jmsg4(jcr, M_FATAL, 0, _("Bad response from SD to %s command. Wanted %s, got len=%ld msg=\"%s\"\n"),
-         cmd, resp, sd->msglen, smartdump(sd->msg, sd->msglen, buf, sizeof(buf)));
+      if (ret > 0) {
+         Jmsg4(jcr, M_FATAL, 0, _("Bad response from SD to %s command. Wanted %s, got len=%ld msg=\"%s\"\n"),
+            cmd, resp, sd->msglen, smartdump(sd->msg, sd->msglen, buf, sizeof(buf)));
+      } else {
+         Jmsg3(jcr, M_FATAL, 0, _("Bad response from SD to %s command. Wanted %s, got SIGNAL %s\n"),
+            cmd, resp, bnet_sig_to_ascii(ret));
+      }
    }
    return 0;
 }
diff --git a/src/filed/protos.h b/src/filed/protos.h
index 96a836c..39160be 100644
--- a/src/filed/protos.h
+++ b/src/filed/protos.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -27,6 +26,9 @@ extern void do_verify_volume(JCR *jcr);
 extern void do_restore(JCR *jcr);
 extern int make_estimate(JCR *jcr);
 
+/* From restore.c */
+bool decompress_data(JCR *jcr, int32_t stream, char **data, uint32_t *length);
+
 /* From authenticate.c */
 bool authenticate_director(JCR *jcr);
 bool authenticate_storagedaemon(JCR *jcr);
diff --git a/src/filed/restore.c b/src/filed/restore.c
index 24580bd..b6c2819 100644
--- a/src/filed/restore.c
+++ b/src/filed/restore.c
@@ -1295,9 +1295,7 @@ static bool store_data(r_ctx &rctx, char *data, const int32_t length, bool win32
                jcr->last_fname, be.bstrerror(bfd->berrno));
          return false;
       }
-   }
-
-   if ((wstat=bwrite(bfd, data, length)) != (ssize_t)length) {
+   } else if ((wstat=bwrite(bfd, data, length)) != (ssize_t)length) {
       berrno be;
       int type = M_ERROR;
       int len = strlen(jcr->last_fname);
diff --git a/src/filed/status.c b/src/filed/status.c
index e65cdc0..7980117 100644
--- a/src/filed/status.c
+++ b/src/filed/status.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/verify.c b/src/filed/verify.c
index 1f0717b..427f711 100644
--- a/src/filed/verify.c
+++ b/src/filed/verify.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/filed/verify_vol.c b/src/filed/verify_vol.c
index e29a7dc..69ce3d7 100644
--- a/src/filed/verify_vol.c
+++ b/src/filed/verify_vol.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -27,28 +26,225 @@
 
 #include "bacula.h"
 #include "filed.h"
+#include "findlib/win32filter.h"
+
+#if   defined(HAVE_LIBZ)
+const bool have_libz = true;
+#else
+const bool have_libz = false;
+#endif
+
+#ifdef HAVE_LZO
+const bool have_lzo = true;
+#else
+const bool have_lzo = false;
+#endif
+
+/* Context used during Verify Data job. We use it in the
+ * verify loop to compute checksums and check attributes.
+ */
+class v_ctx {
+public:
+   JCR *jcr;
+   int32_t stream;              /* stream less new bits */
+   int32_t prev_stream;         /* previous stream */
+   int32_t full_stream;         /* full stream including new bits */
+   int32_t type;                /* file type FT_ */
+   int64_t size;                /* current file size */
+   ATTR *attr;                  /* Pointer to attributes */
+
+   bool check_size;             /* Check or not the size attribute */
+   bool check_chksum;           /* Check the checksum */
+
+   crypto_digest_t digesttype;
+   Win32Filter win32filter;
+   char digest[BASE64_SIZE(CRYPTO_DIGEST_MAX_SIZE)]; /* current digest */
+
+   v_ctx(JCR *ajcr) :
+      jcr(ajcr), stream(0), prev_stream(0), full_stream(0), type(0), size(-1),
+      attr(new_attr(jcr)), check_size(false), check_chksum(false),
+      digesttype(CRYPTO_DIGEST_NONE), win32filter()
+   {
+      *digest = 0;
+      scan_fileset();
+   };
+   ~v_ctx() {
+      free_attr(attr);
+   };
+   /* Call this function when we change the file
+    * We check the st_size and we compute the digest
+    */
+   bool close_previous_stream();
+
+   /* Call when we have a sparse record */
+   void skip_sparse_header(char **data, uint32_t *length);
+
+   /* Scan the fileset to know if we want to check checksums or st_size */
+   void scan_fileset();
+
+   /* In cleanup, we reset the current file size to -1 */
+   void reset_size() {
+      size = -1;
+   };
+
+   /* Used for sparse files */
+   void set_size(int64_t val) {
+      size = MAX(size, val);
+   };
+
+   void update_size(int64_t val) {
+      if (size == -1) {
+         size = 0;
+      }
+      size += val;
+   };
+
+   void update_checksum(char *wbuf, int32_t wsize) {
+      if (wsize > 0 && check_chksum) {
+         if (!jcr->crypto.digest) {
+            jcr->crypto.digest = crypto_digest_new(jcr, digesttype);
+         }
+         crypto_digest_update(jcr->crypto.digest, (uint8_t *)wbuf, wsize);
+      }
+   };
+};
 
 /* Data received from Storage Daemon */
 static char rec_header[] = "rechdr %ld %ld %ld %ld %ld";
 
 /* Forward referenced functions */
 
+/* We don't know in advance which digest mode is needed, we do not
+ * want to store files on disk either to check afterward. So, we read
+ * the fileset definition and we try to guess the digest that will be
+ * used. If the FileSet uses multiple digests, it will not work.
+ */
+void v_ctx::scan_fileset()
+{
+   findFILESET *fileset;
+
+   check_size = check_chksum = false;
+   digesttype = CRYPTO_DIGEST_NONE;
+
+   if (!jcr->ff || !jcr->ff->fileset) {
+      return;
+   }
+
+   fileset = jcr->ff->fileset;
+
+   for (int i=0; i<fileset->include_list.size(); i++) {
+      findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
+
+      for (int j=0; j<incexe->opts_list.size(); j++) {
+         findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
+         check_size = (strchr(fo->VerifyOpts, 's') != NULL);
+         if ((strchr(fo->VerifyOpts, '1') != NULL) ||
+             (strchr(fo->VerifyOpts, '5') != NULL))
+         {
+            check_chksum = true;
+         } 
+
+         if (fo->flags & FO_MD5) {
+            digesttype = CRYPTO_DIGEST_MD5;
+            return;
+         }
+         if (fo->flags & FO_SHA1) {
+            digesttype = CRYPTO_DIGEST_SHA1;
+            return;
+         }
+         if (fo->flags & FO_SHA256) {
+            digesttype = CRYPTO_DIGEST_SHA256;
+            return;
+         }
+         if (fo->flags & FO_SHA512) {
+            digesttype = CRYPTO_DIGEST_SHA512;
+            return;
+         }
+      }
+   }
+   digesttype = CRYPTO_DIGEST_NONE;
+   if (check_chksum) {
+      Jmsg(jcr, M_WARNING, 0, _("Checksum verification required in Verify FileSet option, but no Signature found in the FileSet\n"));
+      check_chksum = false;
+   }
+}
+
+/* Compute the file size for sparse records and adjust the data */
+void v_ctx::skip_sparse_header(char **data, uint32_t *length)
+{
+   unser_declare;
+   uint64_t faddr;
+   unser_begin(*data, OFFSET_FADDR_SIZE);
+   unser_uint64(faddr);
+
+   /* For sparse, we assume that the file is at least big as faddr */
+   set_size(faddr);
+   
+   *data += OFFSET_FADDR_SIZE;
+   *length -= OFFSET_FADDR_SIZE;
+}
+
+/*
+ * If extracting, close any previous stream
+ */
+bool v_ctx::close_previous_stream()
+{
+   bool rtn = true;
+   uint8_t buf[CRYPTO_DIGEST_MAX_SIZE];
+   uint32_t len = CRYPTO_DIGEST_MAX_SIZE;
+   char ed1[50], ed2[50];
+
+   /* Reset the win32 filter that strips header stream out of the file */
+   win32filter.init();
+
+   /* Check the size if possible */
+   if (check_size && size >= 0) {
+      if (attr->type == FT_REG && size != attr->statp.st_size) {
+         Dmsg1(50, "Size comparison failed for %s\n", jcr->last_fname);
+         Jmsg(jcr, M_INFO, 0,
+              _("   st_size  differs on \"%s\". Vol: %s File: %s\n"),
+              jcr->last_fname,
+              edit_int64(size, ed1),
+              edit_int64((int64_t)attr->statp.st_size, ed2));
+         jcr->setJobStatus(JS_Differences);
+      }
+      reset_size();
+   }
+
+   /* Compute the digest and store it */
+   *digest = 0;
+   if (jcr->crypto.digest) {
+      if (!crypto_digest_finalize(jcr->crypto.digest, buf, &len)) {
+         Dmsg1(50, "Unable to finalize digest for %s\n", jcr->last_fname);
+         rtn = false;
+
+      } else {
+         bin_to_base64(digest, sizeof(digest), (char *)buf, len, true);
+      }
+      crypto_digest_free(jcr->crypto.digest);
+      jcr->crypto.digest = NULL;
+   }
+   return rtn;
+}
 
 /*
- * Verify attributes of the requested files on the Volume
+ * Verify attributes or data of the requested files on the Volume
  *
  */
 void do_verify_volume(JCR *jcr)
 {
    BSOCK *sd, *dir;
-   POOLMEM *fname;                    /* original file name */
-   POOLMEM *lname;                    /* link name */
-   int32_t stream, full_stream;
    uint32_t size;
    uint32_t VolSessionId, VolSessionTime, file_index;
-   uint32_t record_file_index;
    char digest[BASE64_SIZE(CRYPTO_DIGEST_MAX_SIZE)];
-   int type, stat;
+   int stat;
+   char *wbuf;                        /* write buffer */
+   uint32_t wsize;                    /* write size */
+   uint32_t rsize;                    /* read size */
+   bool msg_encrypt = false;
+   bool do_chksum;
+   v_ctx vctx(jcr);
+   ATTR *attr = vctx.attr;
 
    sd = jcr->store_bsock;
    if (!sd) {
@@ -74,8 +270,12 @@ void do_verify_volume(JCR *jcr)
    }
    jcr->buf_size = sd->msglen;
 
-   fname = get_pool_memory(PM_FNAME);
-   lname = get_pool_memory(PM_FNAME);
+   /* use the same buffer size to decompress both gzip and lzo */
+   if (have_libz || have_lzo) {
+      uint32_t compress_buf_size = jcr->buf_size + 12 + ((jcr->buf_size+999) / 1000) + 100;
+      jcr->compress_buf = get_memory(compress_buf_size);
+      jcr->compress_buf_size = compress_buf_size;
+   }
 
    GetMsg *fdmsg = New(GetMsg(jcr, sd, rec_header, GETMSG_MAX_MSG_SIZE));
    fdmsg->start_read_sock();
@@ -85,16 +285,20 @@ void do_verify_volume(JCR *jcr)
     * Get a record from the Storage daemon
     */
    while (fdmsg->bget_msg(&bmsg) >= 0 && !job_canceled(jcr)) {
+      /* Remember previous stream type */
+      vctx.prev_stream = vctx.stream;
+
       /*
        * First we expect a Stream Record Header
        */
       if (sscanf(bmsg->rbuf, rec_header, &VolSessionId, &VolSessionTime, &file_index,
-          &full_stream, &size) != 5) {
+          &vctx.full_stream, &size) != 5) {
          Jmsg1(jcr, M_FATAL, 0, _("Record header scan error: %s\n"), bmsg->rbuf);
          goto bail_out;
       }
-      stream = full_stream & STREAMMASK_TYPE;
-      Dmsg4(30, "Got hdr: FilInx=%d FullStream=%d Stream=%d size=%d.\n", file_index, full_stream, stream, size);
+      vctx.stream = vctx.full_stream & STREAMMASK_TYPE;
+      Dmsg4(30, "Got hdr: FilInx=%d FullStream=%d Stream=%d size=%d.\n",
+            file_index, vctx.full_stream, vctx.stream, size);
 
       /*
        * Now we expect the Stream Data
@@ -107,152 +311,239 @@ void do_verify_volume(JCR *jcr)
          Jmsg2(jcr, M_FATAL, 0, _("Actual data size %d not same as header %d\n"), bmsg->origlen, size);
          goto bail_out;
       }
-      Dmsg2(30, "Got stream data %s, len=%d\n", stream_to_ascii(stream), bmsg->rbuflen);
+      Dmsg2(30, "Got stream data %s, len=%d\n", stream_to_ascii(vctx.stream), bmsg->rbuflen);
 
       /* File Attributes stream */
-      switch (stream) {
+      switch (vctx.stream) {
       case STREAM_UNIX_ATTRIBUTES:
       case STREAM_UNIX_ATTRIBUTES_EX:
-         char *ap, *lp, *fp;
-
          Dmsg0(400, "Stream=Unix Attributes.\n");
-
-         if ((int)sizeof_pool_memory(fname) < bmsg->rbuflen) {
-            fname = realloc_pool_memory(fname, bmsg->rbuflen + 1);
-         }
-
-         if ((int)sizeof_pool_memory(lname) < bmsg->rbuflen) {
-            lname = realloc_pool_memory(lname, bmsg->rbuflen + 1);
+         if (!vctx.close_previous_stream()) {
+            goto bail_out;
          }
-         *fname = 0;
-         *lname = 0;
-
          /*
-          * An Attributes record consists of:
-          *    File_index
-          *    Type   (FT_types)
-          *    Filename
-          *    Attributes
-          *    Link name (if file linked i.e. FT_LNK)
-          *    Extended Attributes (if Win32)
+          * Unpack attributes and do sanity check them
           */
-         if (sscanf(bmsg->rbuf, "%d %d", &record_file_index, &type) != 2) {
-            Jmsg(jcr, M_FATAL, 0, _("Error scanning record header: %s\n"), bmsg->rbuf);
-            Dmsg0(0, "\nError scanning header\n");
+         if (!unpack_attributes_record(jcr, vctx.stream,
+                                       bmsg->rbuf, bmsg->rbuflen, attr)) {
             goto bail_out;
          }
-         Dmsg2(30, "Got Attr: FilInx=%d type=%d\n", record_file_index, type);
-         ap = bmsg->rbuf;
-         while (*ap++ != ' ')         /* skip record file index */
-            ;
-         while (*ap++ != ' ')         /* skip type */
-            ;
-         /* Save filename and position to attributes */
-         fp = fname;
-         while (*ap != 0) {
-            *fp++  = *ap++;           /* copy filename to fname */
-         }
-         *fp = *ap++;                 /* terminate filename & point to attribs */
-
-         Dmsg2(100, "File=%s Attr=%s\n", fname, ap);
-         /* Skip to Link name */
-         if (type == FT_LNK || type == FT_LNKSAVED) {
-            lp = ap;
-            while (*lp++ != 0) {
-               ;
-            }
-            pm_strcat(lname, lp);        /* "save" link name */
-         } else {
-            *lname = 0;
-         }
+
+         attr->data_stream = decode_stat(attr->attr, &attr->statp,
+                                         sizeof(attr->statp), &attr->LinkFI);
+
          jcr->lock();
          jcr->JobFiles++;
          jcr->num_files_examined++;
-         pm_strcpy(jcr->last_fname, fname); /* last file examined */
+         pm_strcpy(jcr->last_fname, attr->fname); /* last file examined */
          jcr->unlock();
 
+         if (jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
+            /*
+             * Send file attributes to Director
+             *   File_index
+             *   Stream
+             *   Verify Options
+             *   Filename (full path)
+             *   Encoded attributes
+             *   Link name (if type==FT_LNK)
+             * For a directory, link is the same as fname, but with trailing
+             * slash. For a linked file, link is the link.
+             */
+            /* Send file attributes to Director */
+            Dmsg2(200, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, attr->fname);
+            if (attr->type == FT_LNK || attr->type == FT_LNKSAVED) {
+               stat = dir->fsend("%d %d %s %s%c%s%c%s%c", jcr->JobFiles,
+                                 STREAM_UNIX_ATTRIBUTES, "pinsug5", attr->fname,
+                                 0, attr->attr, 0, attr->lname, 0);
+               /* for a deleted record, we set fileindex=0 */
+            } else if (attr->type == FT_DELETED)  {
+               stat = dir->fsend("%d %d %s %s%c%s%c%c", 0,
+                                 STREAM_UNIX_ATTRIBUTES, "pinsug5", attr->fname,
+                                 0, attr->attr, 0, 0);
+            } else {
+               stat = dir->fsend("%d %d %s %s%c%s%c%c", jcr->JobFiles,
+                                 STREAM_UNIX_ATTRIBUTES, "pinsug5", attr->fname,
+                                 0, attr->attr, 0, 0);
+            }
+            Dmsg2(200, "bfiled>bdird: attribs len=%d: msg=%s\n", dir->msglen, dir->msg);
+            if (!stat) {
+               Jmsg(jcr, M_FATAL, 0, _("Network error in send to Director: ERR=%s\n"), dir->bstrerror());
+               goto bail_out;
+            }
+         }
+         break;
+
          /*
-          * Send file attributes to Director
-          *   File_index
-          *   Stream
-          *   Verify Options
-          *   Filename (full path)
-          *   Encoded attributes
-          *   Link name (if type==FT_LNK)
-          * For a directory, link is the same as fname, but with trailing
-          * slash. For a linked file, link is the link.
+          * Restore stream object is counted, but not restored here
           */
-         /* Send file attributes to Director */
-         Dmsg2(200, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, fname);
-         if (type == FT_LNK || type == FT_LNKSAVED) {
-            stat = dir->fsend("%d %d %s %s%c%s%c%s%c", jcr->JobFiles,
-                          STREAM_UNIX_ATTRIBUTES, "pinsug5", fname,
-                          0, ap, 0, lname, 0);
-         /* for a deleted record, we set fileindex=0 */
-         } else if (type == FT_DELETED)  {
-            stat = dir->fsend("%d %d %s %s%c%s%c%c", 0,
-                          STREAM_UNIX_ATTRIBUTES, "pinsug5", fname,
-                          0, ap, 0, 0);
-         } else {
-            stat = dir->fsend("%d %d %s %s%c%s%c%c", jcr->JobFiles,
-                          STREAM_UNIX_ATTRIBUTES, "pinsug5", fname,
-                          0, ap, 0, 0);
-         }
-         Dmsg2(200, "bfiled>bdird: attribs len=%d: msg=%s\n", dir->msglen, dir->msg);
-         if (!stat) {
-            Jmsg(jcr, M_FATAL, 0, _("Network error in send to Director: ERR=%s\n"), dir->bstrerror());
-            goto bail_out;
-         }
+      case STREAM_RESTORE_OBJECT:
+         jcr->lock();
+         jcr->JobFiles++;
+         jcr->num_files_examined++;
+         jcr->unlock();
          break;
 
+      default:
+         break;
+      }
+
+      const char *digest_code = NULL;
+
+      switch(vctx.stream) {
       case STREAM_MD5_DIGEST:
          bin_to_base64(digest, sizeof(digest), (char *)bmsg->rbuf, CRYPTO_DIGEST_MD5_SIZE, true);
-         Dmsg2(400, "send inx=%d MD5=%s\n", jcr->JobFiles, digest);
-         dir->fsend("%d %d %s *MD5-%d*", jcr->JobFiles, STREAM_MD5_DIGEST, digest,
-                    jcr->JobFiles);
-         Dmsg2(20, "bfiled>bdird: MD5 len=%d: msg=%s\n", dir->msglen, dir->msg);
+         digest_code = "MD5";
          break;
 
       case STREAM_SHA1_DIGEST:
          bin_to_base64(digest, sizeof(digest), (char *)bmsg->rbuf, CRYPTO_DIGEST_SHA1_SIZE, true);
-         Dmsg2(400, "send inx=%d SHA1=%s\n", jcr->JobFiles, digest);
-         dir->fsend("%d %d %s *SHA1-%d*", jcr->JobFiles, STREAM_SHA1_DIGEST,
-                    digest, jcr->JobFiles);
-         Dmsg2(20, "bfiled>bdird: SHA1 len=%d: msg=%s\n", dir->msglen, dir->msg);
+         digest_code = "SHA1";
          break;
 
       case STREAM_SHA256_DIGEST:
          bin_to_base64(digest, sizeof(digest), (char *)bmsg->rbuf, CRYPTO_DIGEST_SHA256_SIZE, true);
-         Dmsg2(400, "send inx=%d SHA256=%s\n", jcr->JobFiles, digest);
-         dir->fsend("%d %d %s *SHA256-%d*", jcr->JobFiles, STREAM_SHA256_DIGEST,
-                    digest, jcr->JobFiles);
-         Dmsg2(20, "bfiled>bdird: SHA256 len=%d: msg=%s\n", dir->msglen, dir->msg);
+         digest_code = "SHA256";
          break;
 
       case STREAM_SHA512_DIGEST:
          bin_to_base64(digest, sizeof(digest), (char *)bmsg->rbuf, CRYPTO_DIGEST_SHA512_SIZE, true);
-         Dmsg2(400, "send inx=%d SHA512=%s\n", jcr->JobFiles, digest);
-         dir->fsend("%d %d %s *SHA512-%d*", jcr->JobFiles, STREAM_SHA512_DIGEST,
-                    digest, jcr->JobFiles);
-         Dmsg2(20, "bfiled>bdird: SHA512 len=%d: msg=%s\n", dir->msglen, dir->msg);
+         digest_code = "SHA512";
          break;
 
-      /*
-       * Restore stream object is counted, but not restored here
-       */
-      case STREAM_RESTORE_OBJECT:
-         jcr->lock();
-         jcr->JobFiles++;
-         jcr->num_files_examined++;
-         jcr->unlock();
-         break;
-
-      /* Ignore everything else */
       default:
+         *digest = 0;
          break;
+      }
+
+      if (digest_code && jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG) {
+         dir->fsend("%d %d %s *%s-%d*", jcr->JobFiles, vctx.stream,
+                    digest, digest_code, jcr->JobFiles);
+
+      } else if (jcr->getJobLevel() == L_VERIFY_DATA) {
+
+         /* Compare digest */
+         if (vctx.check_chksum && *digest) {
+            /* probably an empty file, we can create an empty crypto session */
+            if (!jcr->crypto.digest) {
+               jcr->crypto.digest = crypto_digest_new(jcr, vctx.digesttype);
+            }
+            vctx.close_previous_stream();
+            if (strncmp(digest, vctx.digest,
+                        MIN(sizeof(digest), sizeof(vctx.digest))) != 0)
+            {
+               Jmsg(jcr, M_INFO, 0,
+                    _("   %s differs on \"%s\". File=%s Vol=%s\n"),
+                    stream_to_ascii(vctx.stream), jcr->last_fname,
+                    vctx.digest, digest);
+               jcr->setJobStatus(JS_Differences);
+               Dmsg3(50, "Signature verification failed for %s %s != %s\n",
+                     jcr->last_fname, digest, vctx.digest);
+            }
+         }
+
+         /* Compute size and checksum for level=Data */
+         switch (vctx.stream) {
+         case STREAM_ENCRYPTED_FILE_DATA:
+         case STREAM_ENCRYPTED_WIN32_DATA:
+         case STREAM_ENCRYPTED_FILE_GZIP_DATA:
+         case STREAM_ENCRYPTED_WIN32_GZIP_DATA:
+         case STREAM_ENCRYPTED_FILE_COMPRESSED_DATA:
+         case STREAM_ENCRYPTED_WIN32_COMPRESSED_DATA:
+            if (!msg_encrypt) {
+               Jmsg(jcr, M_WARNING, 0,
+                  _("Verification of encrypted file data is not supported.\n"));
+               msg_encrypt = true;
+            }
+            break;
+
+         case STREAM_PLUGIN_DATA:
+         case STREAM_FILE_DATA:
+         case STREAM_SPARSE_DATA:
+         case STREAM_WIN32_DATA:
+         case STREAM_GZIP_DATA:
+         case STREAM_SPARSE_GZIP_DATA:
+         case STREAM_WIN32_GZIP_DATA:
+         case STREAM_COMPRESSED_DATA:
+         case STREAM_SPARSE_COMPRESSED_DATA:
+         case STREAM_WIN32_COMPRESSED_DATA:
+            do_chksum=true;
+            if (!(attr->type ==  FT_RAW || attr->type == FT_FIFO || attr->type == FT_REG)) {
+               break;
+            }
 
+            wbuf = bmsg->rbuf;
+            rsize = bmsg->rbuflen;
+            jcr->ReadBytes += rsize;
+            wsize = rsize;
+
+            if (vctx.stream == STREAM_SPARSE_DATA
+                || vctx.stream == STREAM_SPARSE_COMPRESSED_DATA
+                || vctx.stream == STREAM_SPARSE_GZIP_DATA) {
+               vctx.skip_sparse_header(&wbuf, &wsize);
+            }
+
+            /* On Windows, the checksum is computed after the compression
+             * On Unix, the checksum is computed before the compression
+             */
+            if (vctx.stream == STREAM_WIN32_GZIP_DATA
+                || vctx.stream == STREAM_WIN32_DATA
+                || vctx.stream == STREAM_WIN32_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_WIN32_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_WIN32_GZIP_DATA)
+            {
+               do_chksum = false;
+               vctx.update_checksum(wbuf, wsize);
+            }
+
+            if (vctx.stream == STREAM_GZIP_DATA
+                || vctx.stream == STREAM_SPARSE_GZIP_DATA
+                || vctx.stream == STREAM_WIN32_GZIP_DATA
+                || vctx.stream == STREAM_ENCRYPTED_FILE_GZIP_DATA
+                || vctx.stream == STREAM_COMPRESSED_DATA
+                || vctx.stream == STREAM_SPARSE_COMPRESSED_DATA
+                || vctx.stream == STREAM_WIN32_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_FILE_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_WIN32_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_WIN32_GZIP_DATA) {
+
+               if (!decompress_data(jcr, vctx.stream, &wbuf, &wsize)) {
+                  dequeue_messages(jcr);
+                  goto bail_out;
+               }
+            }
+
+            /* Unix way to deal with checksums */
+            if (do_chksum) {
+               vctx.update_checksum(wbuf, wsize);
+            }
+
+            if (vctx.stream == STREAM_WIN32_GZIP_DATA
+                || vctx.stream == STREAM_WIN32_DATA
+                || vctx.stream == STREAM_WIN32_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_WIN32_COMPRESSED_DATA
+                || vctx.stream == STREAM_ENCRYPTED_WIN32_GZIP_DATA) {
+
+               int64_t wbuf_len = wsize;
+               int64_t wsize64 = 0;
+               if (vctx.win32filter.have_data(&wbuf, &wbuf_len, &wsize64)) {
+                  wsize = wsize64;
+               }
+            }
+            jcr->JobBytes += wsize;
+            vctx.update_size(wsize);
+            break;
+
+            /* TODO: Handle data to compute checksums */
+            /* Ignore everything else */
+         default:
+            break;
+         }
       } /* end switch */
    } /* end while bnet_get */
+   if (!vctx.close_previous_stream()) {
+      goto bail_out;
+   }
    jcr->setJobStatus(JS_Terminated);
    goto ok_out;
 
@@ -264,13 +555,11 @@ ok_out:
    fdmsg->wait_read_sock();
    delete bmsg;
    free_GetMsg(fdmsg);
-
    if (jcr->compress_buf) {
-      free(jcr->compress_buf);
+      free_pool_memory(jcr->compress_buf);
       jcr->compress_buf = NULL;
    }
-   free_pool_memory(fname);
-   free_pool_memory(lname);
-   Dmsg2(050, "End Verify-Vol. Files=%d Bytes=%" lld "\n", jcr->JobFiles,
+   /* TODO: We probably want to mark the job as failed if we have errors */
+   Dmsg2(50, "End Verify-Vol. Files=%d Bytes=%" lld "\n", jcr->JobFiles,
       jcr->JobBytes);
 }
diff --git a/src/filed/xattr.c b/src/filed/xattr.c
index 9240544..6762348 100644
--- a/src/filed/xattr.c
+++ b/src/filed/xattr.c
@@ -559,11 +559,11 @@ static bxattr_rtn_code aix_restore_xattr_streams(JCR *jcr, int stream, char *con
              * change from one filesystem to an other.
              */
             jcr->xattr_ctx->flags &= ~BXATTR_FLAG_RESTORE_NATIVE;
-            break;
+            /* Failback wanted */
          default:
-            Mmsg2(jcr->errmsg, _("XATTR lsetea error on file \"%s\": ERR=%s\n"),
-                  jcr->last_fname, be.bstrerror());
-            Dmsg1(100, "%s", jcr->errmsg);
+            MmsgD2(100, jcr->errmsg,
+                   _("XATTR lsetea error on file \"%s\": ERR=%s\n"),
+                   jcr->last_fname, be.bstrerror());
             break;
          }
          goto get_out;
@@ -1298,11 +1298,10 @@ static bxattr_rtn_code generic_restore_xattr_streams(JCR *jcr, int stream,
              * change from one filesystem to an other.
              */
             jcr->xattr_ctx->flags &= ~BXATTR_FLAG_RESTORE_NATIVE;
-         } else {
-            Mmsg2(jcr->errmsg, _("lsetxattr error on file \"%s\": ERR=%s\n"),
-                  jcr->last_fname, be.bstrerror());
-            Dmsg1(100, "%s", jcr->errmsg);
          }
+         MmsgD2(100, jcr->errmsg,
+                _("lsetxattr error on file \"%s\": ERR=%s\n"),
+                jcr->last_fname, be.bstrerror());
          goto get_out;
       }
    }
diff --git a/src/findlib/Makefile.in b/src/findlib/Makefile.in
index 7370881..1b47d90 100644
--- a/src/findlib/Makefile.in
+++ b/src/findlib/Makefile.in
@@ -25,12 +25,12 @@ dummy:
 #
 # include files installed when using libtool
 #
-INCLUDE_FILES = bfile.h find.h protos.h
+INCLUDE_FILES = bfile.h find.h protos.h win32filter.h
 
 #
 LIBBACFIND_SRCS = find.c match.c find_one.c attribs.c create_file.c \
 		  bfile.c drivetype.c enable_priv.c fstype.c mkpath.c \
-		  savecwd.c
+		  savecwd.c win32filter.c
 LIBBACFIND_OBJS = $(LIBBACFIND_SRCS:.c=.o)
 LIBBACFIND_LOBJS = $(LIBBACFIND_SRCS:.c=.lo)
 
diff --git a/src/findlib/attribs.c b/src/findlib/attribs.c
index 5c8f518..9d249b1 100644
--- a/src/findlib/attribs.c
+++ b/src/findlib/attribs.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2002-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -657,4 +656,3 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 }
 
 #endif
-
diff --git a/src/findlib/bfile.c b/src/findlib/bfile.c
index 99b3a5f..f0de4fa 100644
--- a/src/findlib/bfile.c
+++ b/src/findlib/bfile.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/bfile.h b/src/findlib/bfile.h
index d0797ae..eba4082 100644
--- a/src/findlib/bfile.h
+++ b/src/findlib/bfile.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/create_file.c b/src/findlib/create_file.c
index 0641b69..9488dbc 100644
--- a/src/findlib/create_file.c
+++ b/src/findlib/create_file.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/drivetype.c b/src/findlib/drivetype.c
index 1f68fa0..cc55901 100644
--- a/src/findlib/drivetype.c
+++ b/src/findlib/drivetype.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2006-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -22,7 +21,6 @@
  *
  *   Written by Robert Nelson, June 2006
  *
- *   Version $Id$
  */
 
 #ifndef TEST_PROGRAM
diff --git a/src/findlib/enable_priv.c b/src/findlib/enable_priv.c
index 884ed41..9d5be01 100644
--- a/src/findlib/enable_priv.c
+++ b/src/findlib/enable_priv.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/find.c b/src/findlib/find.c
index a9f2d6e..573a37e 100644
--- a/src/findlib/find.c
+++ b/src/findlib/find.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/find.h b/src/findlib/find.h
index a12bf03..3cd77a1 100644
--- a/src/findlib/find.h
+++ b/src/findlib/find.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2001-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -212,7 +211,7 @@ struct FF_PKT {
    bool opt_plugin;                   /* set if we have an option plugin */
    rblist *mtab_list;                 /* List of mtab entries */
    uint64_t last_fstype;              /* cache last file system type */
-   char *last_fstypename;             /* cache last file system type name */
+   char last_fstypename[32];          /* cache last file system type name */
    alist fstypes;                     /* allowed file system types */
    alist drivetypes;                  /* allowed drive types */
    alist mount_points;                /* Possible mount points to be snapshotted */
diff --git a/src/findlib/find_one.c b/src/findlib/find_one.c
index d0c1fbf..98ed813 100644
--- a/src/findlib/find_one.c
+++ b/src/findlib/find_one.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -765,7 +764,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt,
     *  a block device, we do a raw backup of it or if it is
     *  a fifo, we simply read it.
     */
-#ifdef HAVE_FREEBSD_OS
+#if defined(HAVE_FREEBSD_OS) || defined(__FreeBSD_kernel__)
    /*
     * On FreeBSD, all block devices are character devices, so
     *   to be able to read a raw disk, we need the check for
diff --git a/src/findlib/fstype.c b/src/findlib/fstype.c
index c2bc83d..dc4f65d 100644
--- a/src/findlib/fstype.c
+++ b/src/findlib/fstype.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -103,6 +102,7 @@ bool fstype_cmp(FF_PKT *ff_pkt, const char *fsname)
  */
 #if defined(HAVE_DARWIN_OS) \
    || defined(HAVE_FREEBSD_OS ) \
+   || defined(HAVE_KFREEBSD_OS ) \
    || defined(HAVE_OPENBSD_OS)
 
 #include <sys/param.h>
@@ -176,7 +176,7 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
 
    if (statfs(fname, &st) == 0) {
       mtab_item *item, search_item;
-      if (ff_pkt->last_fstypename && ff_pkt->last_fstype == (uint64_t)st.f_type) {
+      if (*ff_pkt->last_fstypename && ff_pkt->last_fstype == (uint64_t)st.f_type) {
          bstrncpy(fs, ff_pkt->last_fstypename, fslen);
          return true; 
       }
@@ -188,9 +188,9 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
       item = (mtab_item *)ff_pkt->mtab_list->search((void *)&search_item, compare_mtab_items);
       if (item) {
          ff_pkt->last_fstype = st.f_type;
-         bstrncpy(ff_pkt->last_fstypename, item->fstype, sizeof(ff_pkt->last_fstype));
+         bstrncpy(ff_pkt->last_fstypename, item->fstype, sizeof(ff_pkt->last_fstypename));
          bstrncpy(fs, ff_pkt->last_fstypename, fslen);
-         return true;
+         return true; 
       }
       /*
        * Values obtained from statfs(2), testing and
@@ -237,13 +237,13 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
       case 0x7275:         fstype = "romfs"; break;          /* QNX4_SUPER_MAGIC */
       case 0x012ff7b6:     fstype = "sysv2"; break;
       case 0x012ff7b5:     fstype = "sysv4"; break;
-      case 0x01021994:     fstype = "tempfs"; break;
+      case 0x01021994:     fstype = "tmpfs"; break;
       case 0x15013346:     fstype = "udf"; break;
       case 0x00011954:     fstype = "ufs"; break;
       case 0xa501FCF5:     fstype = "vxfs"; break;
       case 0x012FF7B4:     fstype = "xenix"; break;
       case 0x012FD16D:     fstype = "xiafs"; break;
-
+      case 0x9123683e:     fstype = "btrfs"; break;
 
 #if 0       /* These need confirmation */
       case 0x6B414653:     fstype = "afs"; break;           /* AFS_FS_MAGIC */
@@ -272,7 +272,7 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
       case 0x858458f6:     fstype = "tmpfs"; break;         /* RAMFS_MAGIC */
       case 0x01021994:     fstype = "tmpfs"; break;         /* TMPFS_MAGIC */
 #endif
-
+ 
       default:
          Dmsg2(10, "Unknown file system type \"0x%x\" for \"%s\".\n", st.f_type,
                fname);
@@ -303,7 +303,7 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
 /* Tru64 */
 #include <sys/stat.h>
 #include <sys/mount.h>
-
+ 
 bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
 {
    char *fname = ff_pkt->fname;
@@ -419,12 +419,12 @@ bool read_mtab(mtab_handler_t *mtab_handler, void *user_ctx)
             mntinfo->f_mntonname, mntinfo->f_fstypename, NULL);
          mntinfo++;
       }
-   }
+   } 
    V(mutex);
 #endif /* HAVE_GETMNTINFO */
    return true;
 } 
-
+ 
 #ifdef TEST_PROGRAM
 int main(int argc, char **argv)
 {
diff --git a/src/findlib/match.c b/src/findlib/match.c
index 69a19a8..a6cd72c 100644
--- a/src/findlib/match.c
+++ b/src/findlib/match.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/mkpath.c b/src/findlib/mkpath.c
index f1c4fee..6b5cbff 100644
--- a/src/findlib/mkpath.c
+++ b/src/findlib/mkpath.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/protos.h b/src/findlib/protos.h
index 12514ad..b0ee972 100644
--- a/src/findlib/protos.h
+++ b/src/findlib/protos.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/savecwd.c b/src/findlib/savecwd.c
index 2c64cc7..236e4d0 100644
--- a/src/findlib/savecwd.c
+++ b/src/findlib/savecwd.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/savecwd.h b/src/findlib/savecwd.h
index d88eeac..aa763e9 100644
--- a/src/findlib/savecwd.h
+++ b/src/findlib/savecwd.h
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/findlib/win32filter.c b/src/findlib/win32filter.c
new file mode 100644
index 0000000..f6533f3
--- /dev/null
+++ b/src/findlib/win32filter.c
@@ -0,0 +1,96 @@
+/*
+   Bacula(R) - The Network Backup Solution
+
+   Copyright (C) 2000-2015 Kern Sibbald
+
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
+
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
+*/
+
+#include "win32filter.h"
+
+#define WIN32_STREAM_HEADER_SIZE 20 /* the size of the WIN32_STREAM_ID header without the name */
+
+/* search in a record of a STREAM_WIN32_DATA for the true data
+ * when found: return true, '*raw' is set at the beginning of the data
+ * and *use_len is the length of data to read.
+ * *raw_len is decremented and contains the amount of data that as not
+ * been filtered yet.
+ * For this STREAM_WIN32_DATA, you can call have_data() only one
+ * per record.
+ * If the stream where the data is can be spread all around the stream
+ * you must call have_data() until *raw_len is zero and increment
+ * *data before the next call.
+ */
+bool Win32Filter::have_data(char **raw, int64_t *raw_len, int64_t *use_len)
+{
+   int64_t size;
+   char *orig=*raw;
+   Dmsg1(100, "have_data(%lld)\n", *raw_len);
+   while (*raw_len > 0) {
+      /* In this rec, we could have multiple streams of data and headers
+       * to handle before to reach the data, then we must iterate
+       */
+
+      Dmsg4(100, "s off=%lld len=%lld skip_size=%lld data_size=%lld\n", *raw-orig, *raw_len, skip_size, data_size);
+      if (skip_size > 0) {
+         /* skip what the previous header told us to skip */
+         size = *raw_len < skip_size ? *raw_len : skip_size;
+         skip_size -= size;
+         *raw_len -= size;
+         *raw += size;
+      }
+
+      Dmsg4(100, "h off=%lld len=%lld skip_size=%lld data_size=%lld\n", *raw-orig, *raw_len, skip_size, data_size);
+      if (data_size == 0 && skip_size == 0 && *raw_len > 0) {
+         /* read a WIN32_STREAM header, merge it with the part that was read
+          * from the previous record, if any, if the header was split across
+          * 2 records.
+          */
+         size = WIN32_STREAM_HEADER_SIZE - header_pos;
+         if (*raw_len < size) {
+            size = *raw_len;
+         }
+         memcpy((char *)&header + header_pos, *raw, size);
+         header_pos += size;
+         *raw_len -= size;
+         *raw += size;
+         if (header_pos == WIN32_STREAM_HEADER_SIZE) {
+            Dmsg5(100, "header pos=%d size=%lld name_size=%d len=%lld StreamId=0x%x\n", header_pos, size,
+                  header.dwStreamNameSize, header.Size, header.dwStreamId);
+            header_pos = 0;
+            skip_size = header.dwStreamNameSize; /* skip the name of the stream */
+            if (header.dwStreamId == WIN32_BACKUP_DATA) {
+               data_size = header.Size;
+            } else {
+               skip_size += header.Size; /* skip the all stream */
+            }
+         }
+         Dmsg4(100, "H off=%lld len=%lld skip_size=%lld data_size=%lld\n", *raw-orig, *raw_len, skip_size, data_size);
+      }
+
+      Dmsg4(100, "d off=%lld len=%lld skip_size=%lld data_size=%lld\n", *raw - orig, *raw_len, skip_size, data_size);
+      if (data_size > 0 && skip_size == 0 && *raw_len > 0) {
+         /* some data to read */
+         size = *raw_len < data_size ? *raw_len : data_size;
+         data_size -= size;
+         *raw_len -= size;
+         *use_len = size;
+         Dmsg5(100, "D off=%lld len=%lld use_len=%lld skip_size=%lld data_size=%lld\n", *raw-orig, *raw_len,
+               *use_len, skip_size, data_size);
+         return true;
+      }
+   }
+
+   return false;
+}
diff --git a/src/findlib/win32filter.h b/src/findlib/win32filter.h
new file mode 100644
index 0000000..048ce94
--- /dev/null
+++ b/src/findlib/win32filter.h
@@ -0,0 +1,59 @@
+/*
+   Bacula(R) - The Network Backup Solution
+
+   Copyright (C) 2000-2015 Kern Sibbald
+
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
+
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
+*/
+
+#ifndef WIN32FILTER_H
+#define WIN32FILTER_H
+
+#include "bacula.h"
+#include "bfile.h"      /* for BWIN32_STREAM_ID */
+
+class Win32Filter
+{
+public:
+   int64_t skip_size;   /* how many bytes we have to skip before next header */
+   int64_t data_size;   /* how many data are expected in the stream */
+   int     header_pos;  /* the part of the header that was filled in by previous record */
+
+   BWIN32_STREAM_ID header;
+
+   Win32Filter() {
+      init();
+   };
+   
+   void init() {
+      skip_size = 0;
+      data_size = 0;
+      header_pos = 0;
+   };
+
+   void copy(Win32Filter *f)
+   {
+      skip_size = f->skip_size;
+      data_size = f->data_size;
+      header_pos = f->header_pos;
+      header = f->header;
+   };
+
+   /* If the stream is HHHDDDDD, you can call  have_data("HHHDDDDD", 8, <not used>)
+    * and it will return  "DDDDD", 0, 5
+    */
+   bool have_data(char **raw, int64_t *raw_len, int64_t *data_len);
+};
+
+#endif
diff --git a/src/jcr.h b/src/jcr.h
index e9fc371..154b62c 100644
--- a/src/jcr.h
+++ b/src/jcr.h
@@ -366,6 +366,7 @@ public:
    POOLMEM *rstore_source;            /* Where read storage came from */
    POOLMEM *wstore_source;            /* Where write storage came from */
    POOLMEM *catalog_source;           /* Where catalog came from */
+   POOLMEM *next_vol_list;            /* Volumes previously requested */
    uint32_t replace;                  /* Replace option */
    int32_t NumVols;                   /* Number of Volume used in pool */
    int32_t reschedule_count;          /* Number of times rescheduled */
diff --git a/src/lib/bpipe.c b/src/lib/bpipe.c
index 81d673f..c0ef83a 100644
--- a/src/lib/bpipe.c
+++ b/src/lib/bpipe.c
@@ -74,6 +74,12 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode, char *envp[])
    BPIPE *bpipe;
    int save_errno;
 
+   if (!prog || !*prog) {
+      /* execve(3) A component of the file does not name an existing file or file is an empty string. */
+      errno = ENOENT; 
+      return NULL;
+   }
+   
    bpipe = (BPIPE *)malloc(sizeof(BPIPE));
    memset(bpipe, 0, sizeof(BPIPE));
    mode_read = (mode[0] == 'r');
diff --git a/src/lib/parse_conf.h b/src/lib/parse_conf.h
index 2eaf51c..59931a3 100644
--- a/src/lib/parse_conf.h
+++ b/src/lib/parse_conf.h
@@ -29,7 +29,7 @@ struct s_kw {
    uint32_t token;
 };
 
-struct RES_ITEM;                    /* Declare forward referenced structure */
+struct RES_ITEM;                   /* Declare forward referenced structure */
 struct RES_ITEM2;                  /* Declare forward referenced structure */
 class RES;                         /* Declare forware referenced structure */
 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
diff --git a/src/plugins/fd/bpipe-fd.c b/src/plugins/fd/bpipe-fd.c
index fe58a2d..6f17444 100644
--- a/src/plugins/fd/bpipe-fd.c
+++ b/src/plugins/fd/bpipe-fd.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -378,7 +377,7 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
       }
       io->status = fread(io->buf, 1, io->count, p_ctx->pfd->rfd);
 //    bfuncs->DebugMessage(ctx, fi, li, dbglvl, "bpipe-fd: IO_READ buf=%p len=%d\n", io->buf, io->status);
-      if (io->status == 0 && ferror(p_ctx->pfd->rfd)) {
+      if (!feof(p_ctx->pfd->rfd) && io->status == 0 && ferror(p_ctx->pfd->rfd)) {
          bfuncs->JobMessage(ctx, fi, li, M_FATAL, 0, 
             "Pipe read error: ERR=%s\n", strerror(errno));
          bfuncs->DebugMessage(ctx, fi, li, dbglvl, 
@@ -395,11 +394,11 @@ static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
 //    printf("bpipe-fd: IO_WRITE fd=%p buf=%p len=%d\n", p_ctx->fd, io->buf, io->count);
       io->status = fwrite(io->buf, 1, io->count, p_ctx->pfd->wfd);
 //    printf("bpipe-fd: IO_WRITE buf=%p len=%d\n", io->buf, io->status);
-      if (io->status == 0 && ferror(p_ctx->pfd->wfd)) {
+      if (!feof(p_ctx->pfd->wfd) && io->status == 0 && ferror(p_ctx->pfd->wfd)) {
          bfuncs->JobMessage(ctx, fi, li, M_FATAL, 0, 
             "Pipe write error\n");
          bfuncs->DebugMessage(ctx, fi, li, dbglvl, 
-            "Pipe read error: ERR=%s\n", strerror(errno));
+            "Pipe write error: ERR=%s\n", strerror(errno));
          return bRC_Error;
       }
       break;
diff --git a/src/plugins/fd/example-plugin-fd.c b/src/plugins/fd/example-plugin-fd.c
index 1f16ea8..b3f2dfd 100644
--- a/src/plugins/fd/example-plugin-fd.c
+++ b/src/plugins/fd/example-plugin-fd.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2010-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/plugins/fd/test-deltaseq-fd.c b/src/plugins/fd/test-deltaseq-fd.c
index c5ab173..bc0734a 100644
--- a/src/plugins/fd/test-deltaseq-fd.c
+++ b/src/plugins/fd/test-deltaseq-fd.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/plugins/fd/test-plugin-fd.c b/src/plugins/fd/test-plugin-fd.c
index 634fe2a..cb2a123 100644
--- a/src/plugins/fd/test-plugin-fd.c
+++ b/src/plugins/fd/test-plugin-fd.c
@@ -2,7 +2,6 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2015 Kern Sibbald
-   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
diff --git a/src/stored/acquire.c b/src/stored/acquire.c
index b6faaf1..153843c 100644
--- a/src/stored/acquire.c
+++ b/src/stored/acquire.c
@@ -451,8 +451,7 @@ DCR *acquire_device_for_append(DCR *dcr)
    Dmsg4(100, "=== nwriters=%d nres=%d vcatjob=%d dev=%s\n",
       dev->num_writers, dev->num_reserved(), dev->VolCatInfo.VolCatJobs,
       dev->print_name());
-   dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
-   ok = true;
+   ok = dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
 
 get_out:
    /* Don't plugin close here, we might have multiple writers */
diff --git a/src/stored/askdir.c b/src/stored/askdir.c
index a3cb80e..b7e9ba4 100644
--- a/src/stored/askdir.c
+++ b/src/stored/askdir.c
@@ -428,6 +428,9 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten)
       }
       Dmsg1(100, "get_volume_info() %s", dir->msg);
       /* Update dev Volume info in case something changed (e.g. expired) */
+      vol->Slot = dev->VolCatInfo.Slot;
+      bstrncpy(vol->VolCatStatus, dcr->VolCatInfo.VolCatStatus, sizeof(vol->VolCatStatus));
+
       dcr->VolCatInfo.VolCatAdataBytes = dev->VolCatInfo.VolCatAdataBytes;
       dcr->VolCatInfo.VolCatAmetaBytes = dev->VolCatInfo.VolCatAmetaBytes;
       dcr->VolCatInfo.VolCatHoleBytes = dev->VolCatInfo.VolCatHoleBytes;
@@ -436,8 +439,13 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten)
       dcr->VolCatInfo.VolCatAmetaPadding = dev->VolCatInfo.VolCatAmetaPadding;
       dcr->VolCatInfo.VolCatAdataPadding = dev->VolCatInfo.VolCatAdataPadding;
       dcr->VolCatInfo.VolCatFiles = dev->VolCatInfo.VolCatFiles;
-      bstrncpy(vol->VolCatStatus, dcr->VolCatInfo.VolCatStatus, sizeof(vol->VolCatStatus));
-      /* ***FIXME***  copy other fields that can change, if any */
+      dcr->VolCatInfo.VolCatBytes = dev->VolCatInfo.VolCatBytes;
+      dcr->VolCatInfo.VolCatMounts = dev->VolCatInfo.VolCatMounts;
+      dcr->VolCatInfo.VolCatJobs = dev->VolCatInfo.VolCatJobs;
+      dcr->VolCatInfo.VolCatFiles = dev->VolCatInfo.VolCatFiles;
+      dcr->VolCatInfo.VolCatRecycles = dev->VolCatInfo.VolCatRecycles;
+      dcr->VolCatInfo.VolCatWrites = dev->VolCatInfo.VolCatWrites;
+      dcr->VolCatInfo.VolCatReads = dev->VolCatInfo.VolCatReads;
       ok = true;
    }
 
diff --git a/src/stored/bextract.c b/src/stored/bextract.c
index baeb42e..b0b16df 100644
--- a/src/stored/bextract.c
+++ b/src/stored/bextract.c
@@ -86,7 +86,7 @@ PROG_COPYRIGHT
 "       -c <file>       specify a Storage configuration file\n"
 "       -d <nn>         set debug level to <nn>\n"
 "       -dt             print timestamp in debug output\n"
-"       -T              send debug traces to trace file\n"
+"       -T              send debug traces to trace file (stored in /tmp)\n"
 "       -e <file>       exclude list\n"
 "       -i <file>       include list\n"
 "       -p              proceed inspite of I/O errors\n"
@@ -162,6 +162,9 @@ int main (int argc, char *argv[])
          }
          while (fgets(line, sizeof(line), fd) != NULL) {
             strip_trailing_junk(line);
+            if (line[0] == 0) { /* skip blank lines */
+               continue;
+            }
             Dmsg1(900, "add_exclude %s\n", line);
             add_fname_to_exclude_list(ff, line);
          }
@@ -177,6 +180,9 @@ int main (int argc, char *argv[])
          }
          while (fgets(line, sizeof(line), fd) != NULL) {
             strip_trailing_junk(line);
+            if (line[0] == 0) { /* skip blank lines */
+               continue;
+            }
             Dmsg1(900, "add_include %s\n", line);
             add_fname_to_include_list(ff, 0, line);
          }
@@ -359,7 +365,8 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
       if (verbose != 1 && (num_records % 200000) == 0L) {
          fprintf(stderr, "\rfiles=%d records=%s\n", num_files, edit_uint64(num_records, ed1));
       }
-      return true;
+      ret = true;
+      goto bail_out;
    }
 
    /* File Attributes stream */
diff --git a/src/stored/block.c b/src/stored/block.c
index 75ec5bf..b74027b 100644
--- a/src/stored/block.c
+++ b/src/stored/block.c
@@ -230,7 +230,7 @@ bool DCR::write_block_to_dev()
    if (debug_block_checksum) {
       uint32_t achecksum = ser_block_header(block, dev->do_checksum());
       if (checksum != achecksum) {
-         Jmsg2(jcr, M_ERROR, 0, _("Block checksum changed during write: before=%ud after=%ud\n"),
+         Jmsg2(jcr, M_ERROR, 0, _("Block checksum changed during write: before=%u after=%u\n"),
             checksum, achecksum);
          dump_block(block, "with checksum error");
       }
@@ -314,7 +314,7 @@ bool DCR::write_block_to_dev()
       uint64_t addr = dev->file_addr + wlen - 1;
       if (dcr->EndFile == (uint32_t)(addr >> 32) &&
           (uint32_t)addr < dcr->EndBlock) {
-         Pmsg4(000, "Possible incorrect EndBlock oldEndBlock=%d newEndBlock=%d oldEndFile=%d newEndFile=%d\n",
+         Pmsg4(000, "Possible incorrect EndBlock oldEndBlock=%u newEndBlock=%u oldEndFile=%u newEndFile=%u\n",
             dcr->EndBlock, (uint32_t)addr, dcr->EndFile, (uint32_t)(addr >> 32));
       } else {
          dcr->EndBlock = (uint32_t)addr;
diff --git a/src/stored/block_util.c b/src/stored/block_util.c
index 86e097d..11f3cf2 100644
--- a/src/stored/block_util.c
+++ b/src/stored/block_util.c
@@ -82,8 +82,11 @@ void dump_block(DEV_BLOCK *b, const char *msg)
       rhl = RECHDR1_LENGTH;
    }
 
-   if (block_len > 4000000) {
-      Dmsg3(20, "!!!Dump block %s 0x%x blocksize too big %u\n", msg, b, block_len);
+   if (block_len > 4000000 || block_len < BLKHDR_CS_LENGTH) {
+      Dmsg4(20, "!!!Dump block %s %p blocksize too %s %lu\n",
+            msg, b,
+            (block_len < BLKHDR_CS_LENGTH)?"small":"big",
+            block_len);
       return;
    }
 
@@ -183,7 +186,7 @@ void DCR::free_blocks()
  */
 void free_block(DEV_BLOCK *block)
 {
-   if (block) {
+   if (block && block->buf) {
       Dmsg1(999, "free_block buffer %x\n", block->buf);
       free_memory(block->buf);
       Dmsg1(999, "free_block block %x\n", block);
@@ -271,8 +274,8 @@ bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    unser_uint32(BlockNumber);
    unser_bytes(Id, BLKHDR_ID_LENGTH);
    ASSERT(unser_length(block->buf) == BLKHDR1_LENGTH);
-
    Id[BLKHDR_ID_LENGTH] = 0;
+
    if (Id[3] == '1') {
       bhl = BLKHDR1_LENGTH;
       block->BlockVer = 1;
diff --git a/src/stored/bscan.c b/src/stored/bscan.c
index 3702b88..4757fb0 100644
--- a/src/stored/bscan.c
+++ b/src/stored/bscan.c
@@ -76,6 +76,11 @@ static const char *db_name = "bacula";
 static const char *db_user = "bacula";
 static const char *db_password = "";
 static const char *db_host = NULL;
+static const char *db_ssl_key = NULL;
+static const char *db_ssl_cert = NULL;
+static const char *db_ssl_ca = NULL;
+static const char *db_ssl_capath = NULL;
+static const char *db_ssl_cipher = NULL;
 static int db_port = 0;
 static const char *wd = NULL;
 static bool update_db = false;
@@ -117,6 +122,9 @@ PROG_COPYRIGHT
 "       -u <user>         specify database user name (default bacula)\n"
 "       -P <password>     specify database password (default none)\n"
 "       -h <host>         specify database host (default NULL)\n"
+"       -k <sslkey>       path name to the key file (default NULL)\n"
+"       -e <sslcert>      path name to the certificate file (default NULL)\n"
+"       -a <sslca>        path name to the CA certificate file (default NULL)\n"
 "       -t <port>         specify database port (default 0)\n"
 "       -p                proceed inspite of I/O errors\n"
 "       -r                list records\n"
@@ -147,7 +155,7 @@ int main (int argc, char *argv[])
 
    OSDependentInit();
 
-   while ((ch = getopt(argc, argv, "b:c:d:D:h:p:mn:pP:rsSt:u:vV:w:?")) != -1) {
+   while ((ch = getopt(argc, argv, "b:c:d:D:h:k:e:a:p:mn:pP:rsSt:u:vV:w:?")) != -1) {
       switch (ch) {
       case 'S' :
          showProgress = true;
@@ -182,6 +190,18 @@ int main (int argc, char *argv[])
          db_host = optarg;
          break;
 
+      case 'k':
+         db_ssl_key = optarg;
+         break;
+
+      case 'e':
+         db_ssl_cert = optarg;
+         break;
+
+      case 'a':
+         db_ssl_ca = optarg;
+         break;
+
       case 't':
          db_port = atoi(optarg);
          break;
@@ -284,7 +304,10 @@ int main (int argc, char *argv[])
    }
 
    db = db_init_database(NULL, db_driver, db_name, db_user, db_password,
-                            db_host, db_port, NULL, false, false);
+                         db_host, db_port, NULL, 
+                         db_ssl_key, db_ssl_cert, db_ssl_ca,
+                         db_ssl_capath, db_ssl_cipher,
+                         false, false);
    if (!db || !db_open_database(NULL, db)) {
       Pmsg2(000, _("Could not open Catalog \"%s\", database \"%s\".\n"),
            db_driver, db_name);
diff --git a/src/stored/device.c b/src/stored/device.c
index 90a11cf..e2b31f5 100644
--- a/src/stored/device.c
+++ b/src/stored/device.c
@@ -138,7 +138,9 @@ bool fixup_device_block_write_error(DCR *dcr, int retries)
    dev->Lock();                    /* lock again */
 
    dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs on vol */
-   dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
+   if (!dir_update_volume_info(dcr, false, false)) { /* send Volume info to Director */
+      goto bail_out;
+   }
 
    Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
       dcr->VolumeName, dev->print_name(), bstrftime(dt, sizeof(dt), time(NULL)));
diff --git a/src/stored/dircmd.c b/src/stored/dircmd.c
index dee3a03..abf9f1a 100644
--- a/src/stored/dircmd.c
+++ b/src/stored/dircmd.c
@@ -541,7 +541,7 @@ static bool do_label(JCR *jcr, int relabel)
    POOLMEM *newname, *oldname, *poolname, *mtype;
    POOL_MEM dev_name;
    BSOCK *dir = jcr->dir_bsock;
-   DCR *dcr;
+   DCR *dcr = NULL;;
    DEVICE *dev;
    bool ok = false;
    int32_t slot, drive;
@@ -572,8 +572,28 @@ static bool do_label(JCR *jcr, int relabel)
       unbash_spaces(mtype);
       dcr = find_device(jcr, dev_name, mtype, drive);
       if (dcr) {
+         uint32_t max_jobs;
          dev = dcr->dev;
+         ok = true;
          dev->Lock();                 /* Use P to avoid indefinite block */
+         max_jobs = dev->max_concurrent_jobs;
+         dev->max_concurrent_jobs = 1;
+         bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
+         if (dcr->can_i_write_volume()) {
+            if (reserve_volume(dcr, newname) == NULL) {
+               ok = false;
+            }
+            Dmsg1(000, "Reserved volume \"%s\"\n", newname);
+         } else {
+            ok = false;
+         }
+         if (!ok) {
+            Dmsg2(000, "Reserve error on volume \"%s\": ERR=%s\n", newname, jcr->errmsg);
+            dir->fsend(_("3908 Error reserving volume: %s\n"), jcr->errmsg);
+            dev->max_concurrent_jobs = max_jobs;
+            dev->Unlock();
+            goto bail_out;
+         }
          if (!dev->is_open() && !dev->is_busy()) {
             Dmsg1(400, "Can %slabel. Device is not open\n", relabel?"re":"");
             label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel);
@@ -588,8 +608,9 @@ static bool do_label(JCR *jcr, int relabel)
             Dmsg0(400, "Can relabel. device not used\n");
             label_volume_if_ok(dcr, oldname, newname, poolname, slot, relabel);
          }
+         dev->max_concurrent_jobs = max_jobs;
+         volume_unused(dcr);
          dev->Unlock();
-         free_dcr(dcr);
       } else {
          dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
       }
@@ -598,6 +619,10 @@ static bool do_label(JCR *jcr, int relabel)
       pm_strcpy(jcr->errmsg, dir->msg);
       dir->fsend(_("3903 Error scanning label command: %s\n"), jcr->errmsg);
    }
+bail_out:
+   if (dcr) {
+      free_dcr(dcr);
+   }
    free_memory(oldname);
    free_memory(newname);
    free_memory(poolname);
@@ -680,7 +705,7 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    case VOL_NO_LABEL:
       if (!write_new_volume_label_to_dev(dcr, newname, poolname,
               relabel, true /* write dvd now */)) {
-         dir->fsend(_("3912 Failed to label Volume: ERR=%s\n"), dev->bstrerror());
+         dir->fsend(_("3912 Failed to label Volume: ERR=%s\n"), dcr->jcr->errmsg);
          break;
       }
       bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
@@ -696,10 +721,10 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
                  type, newname, dev->print_name());
       break;
    case VOL_TYPE_ERROR:
-      dir->fsend(_("3915 Failed to label Volume: ERR=%s\n"), dev->errmsg);
+      dir->fsend(_("3912 Failed to label Volume: ERR=%s\n"), dcr->jcr->errmsg);
       break;
    case VOL_NO_MEDIA:
-      dir->fsend(_("3914 Failed to label Volume (no media): ERR=%s\n"), dev->bstrerror());
+      dir->fsend(_("3914 Failed to label Volume (no media): ERR=%s\n"), dcr->jcr->errmsg);
       break;
    default:
       dir->fsend(_("3913 Cannot label Volume. "
diff --git a/src/stored/file_dev.c b/src/stored/file_dev.c
index d7166e7..09cee35 100644
--- a/src/stored/file_dev.c
+++ b/src/stored/file_dev.c
@@ -155,6 +155,9 @@ void DEVICE::open_file_device(DCR *dcr, int omode)
       if (VolCatInfo.VolCatName[0] == 0) {
          Mmsg(errmsg, _("Could not open file device %s. No Volume name given.\n"),
             print_name());
+         if (dcr->jcr) {
+            pm_strcpy(dcr->jcr->errmsg, errmsg);
+         }
          clear_opened();
          return;
       }
@@ -194,6 +197,10 @@ void DEVICE::open_file_device(DCR *dcr, int omode)
       if (fstat(m_fd, &sp) == 0) {
          devno = sp.st_dev;
       }
+   } else {
+      if (dcr->jcr) {
+         pm_strcpy(dcr->jcr->errmsg, errmsg);
+      }
    }
    Dmsg1(100, "open dev: disk fd=%d opened\n", m_fd);
 }
diff --git a/src/stored/label.c b/src/stored/label.c
index cbab189..00112f3 100644
--- a/src/stored/label.c
+++ b/src/stored/label.c
@@ -236,7 +236,7 @@ int read_dev_volume_label(DCR *dcr)
          Mmsg3(jcr->errmsg, _("Could not reserve volume %s on %s device %s\n"),
               dev->VolHdr.VolumeName, dev->print_type(), dev->print_name());
       }
-      Dmsg2(150, "Could not reserve volume %s on %s\n", dev->VolHdr.VolumeName, dev->print_name());
+      Dmsg2(100, "Could not reserve volume %s on %s\n", dev->VolHdr.VolumeName, dev->print_name());
       stat = VOL_NAME_ERROR;
       goto bail_out;
    }
@@ -338,6 +338,9 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
 
    Dmsg0(150, "write_volume_label()\n");
    if (*VolName == 0) {
+      if (dcr->jcr) {
+         Mmsg(dcr->jcr->errmsg, "ERROR: new_volume_label_to_dev called with NULL VolName\n");
+      }
       Pmsg0(0, "=== ERROR: write_new_volume_label_to_dev called with NULL VolName\n");
       goto bail_out;
    }
@@ -485,7 +488,7 @@ bool DCR::rewrite_volume_label(bool recycle)
    DCR *dcr = this;
 
    Enter(100);
-   ASSERT(dcr->VolumeName[0]);
+   ASSERT2(dcr->VolumeName[0], "Empty Volume name");
    if (!dev->open(dcr, OPEN_READ_WRITE)) {
        Jmsg4(jcr, M_WARNING, 0, _("Open %s device %s Volume \"%s\" failed: ERR=%s\n"),
              dev->print_type(), dev->print_name(), dcr->VolumeName, dev->bstrerror());
@@ -531,7 +534,7 @@ bool DCR::rewrite_volume_label(bool recycle)
    }
    Dmsg1(100, "wrote vol label to block. Vol=%s\n", dcr->VolumeName);
 
-   ASSERT(dcr->VolumeName[0]);
+   ASSERT2(dcr->VolumeName[0], "Empty Volume name");
    dev->setVolCatInfo(false);
 
    /*
@@ -588,9 +591,9 @@ bool DCR::rewrite_volume_label(bool recycle)
    Dmsg1(100, "dir_update_vol_info. Set Append vol=%s\n", dcr->VolumeName);
    dev->VolCatInfo.VolFirstWritten = time(NULL);
    dev->setVolCatStatus("Append");
-   ASSERT(dcr->VolumeName[0]);
+   ASSERT2(dcr->VolumeName[0], "Empty Volume name");
    dev->setVolCatName(dcr->VolumeName);
-   if (!dir_update_volume_info(dcr, true, true)) {  /* indicate doing relabel */
+   if (!dir_update_volume_info(dcr, true, true)) {  /* indicate relabel */
       Leave(100);
       return false;
    }
@@ -665,7 +668,7 @@ static void create_volume_label_record(DCR *dcr, DEVICE *dev,
 
    ser_end(rec->data, SER_LENGTH_Volume_Label);
    bstrncpy(dcr->VolumeName, dev->VolHdr.VolumeName, sizeof(dcr->VolumeName));
-   ASSERT(dcr->VolumeName[0]);
+   ASSERT2(dcr->VolumeName[0], "Empty Volume name");
    rec->data_len = ser_length(rec->data);
    rec->FileIndex = dev->VolHdr.LabelType;
    Dmsg1(100, "LabelType=%d\n", dev->VolHdr.LabelType);
@@ -847,7 +850,7 @@ bool write_session_label(DCR *dcr, int label)
       rec->remainder);
 
    free_record(rec);
-   Dmsg2(150, "Leave write_session_label Block=%ud File=%ud\n",
+   Dmsg2(150, "Leave write_session_label Block=%u File=%u\n",
       dev->get_block_num(), dev->get_file());
    Leave(100);
    return true;
diff --git a/src/stored/reserve.c b/src/stored/reserve.c
index cad831a..c5b3af4 100644
--- a/src/stored/reserve.c
+++ b/src/stored/reserve.c
@@ -608,8 +608,12 @@ static bool is_vol_in_autochanger(RCTX &rctx, VOLRES *vol)
 {
    AUTOCHANGER *changer = vol->dev->device->changer_res;
 
+   if (!changer) {
+      return false;
+   }
+
    /* Find resource, and make sure we were able to open it */
-   if (changer && strcmp(rctx.device_name, changer->hdr.name) == 0) {
+   if (strcmp(rctx.device_name, changer->hdr.name) == 0) {
       Dmsg1(dbglvl, "Found changer device %s\n", vol->dev->device->hdr.name);
       return true;
    }
diff --git a/src/stored/status.c b/src/stored/status.c
index e3612b5..2a8b7e6 100644
--- a/src/stored/status.c
+++ b/src/stored/status.c
@@ -517,8 +517,7 @@ static void list_running_jobs(STATUS_PKT *sp)
                    rdcr->dev?rdcr->dev->print_name():
                             rdcr->device->device_name);
             sendit(msg, len, sp);
-         }
-         if (dcr && dcr->device && dcr != rdcr) {
+         } else if (dcr && dcr->device) {
             len = Mmsg(msg, _("Writing: %s %s job %s JobId=%d Volume=\"%s\"\n"
                             "    pool=\"%s\" device=%s\n"),
                    job_level_to_str(jcr->getJobLevel()),
diff --git a/src/stored/stored.c b/src/stored/stored.c
index 5782088..abf0d4f 100644
--- a/src/stored/stored.c
+++ b/src/stored/stored.c
@@ -59,6 +59,7 @@ bool forge_on = false;                /* proceed inspite of I/O errors */
 pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER;
 void *start_heap;
+static bool test_config = false;
 
 
 static uint32_t VolSessionId = 0;
@@ -111,7 +112,6 @@ int main (int argc, char *argv[])
 {
    int ch;
    bool no_signals = false;
-   bool test_config = false;
    pthread_t thid;
    char *uid = NULL;
    char *gid = NULL;
@@ -691,8 +691,12 @@ void terminate_stored(int sig)
       bmicrosleep(0, 500000);         /* give them 1/2 sec to clean up */
    }
 
-   write_state_file(me->working_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs));
-   delete_pid_file(me->pid_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs));
+   if (!test_config) {
+      write_state_file(me->working_directory,
+                       "bacula-sd", get_first_port_host_order(me->sdaddrs));
+      delete_pid_file(me->pid_directory,
+                      "bacula-sd", get_first_port_host_order(me->sdaddrs));
+   }
 
    Dmsg1(200, "In terminate_stored() sig=%d\n", sig);
 
diff --git a/src/stored/tape_dev.c b/src/stored/tape_dev.c
index 0119ee0..4afdd8b 100644
--- a/src/stored/tape_dev.c
+++ b/src/stored/tape_dev.c
@@ -163,6 +163,9 @@ void DEVICE::open_tape_device(DCR *dcr, int omode)
       berrno be;
       Mmsg2(errmsg, _("Unable to open device %s: ERR=%s\n"),
             print_name(), be.bstrerror(dev_errno));
+      if (dcr->jcr) {
+         pm_strcpy(dcr->jcr->errmsg, errmsg);
+      }
       Dmsg1(100, "%s", errmsg);
    }
 
diff --git a/src/tools/bbatch.c b/src/tools/bbatch.c
index 9542648..1d4ac8d 100644
--- a/src/tools/bbatch.c
+++ b/src/tools/bbatch.c
@@ -58,6 +58,11 @@ static const char *db_name = "bacula";
 static const char *db_user = "bacula";
 static const char *db_password = "";
 static const char *db_host = NULL;
+static const char *db_ssl_key= NULL;
+static const char *db_ssl_cert= NULL;
+static const char *db_ssl_ca= NULL;
+static const char *db_ssl_capath= NULL;
+static const char *db_ssl_cipher= NULL;
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -78,6 +83,9 @@ PROG_COPYRIGHT
 "       -u <user>         specify database user name (default bacula)\n"
 "       -P <password      specify database password (default none)\n"
 "       -h <host>         specify database host (default NULL)\n"
+"       -k <sslkey>       path name to the key file (default NULL)\n"
+"       -e <sslcert>      path name to the certificate file (default NULL)\n"
+"       -a <sslca>        path name to the CA certificate file (default NULL)\n"
 "       -w <working>      specify working directory\n"
 "       -r <jobids>       call restore code with given jobids\n"
 "       -v                verbose\n"
@@ -114,7 +122,7 @@ int main (int argc, char *argv[])
 
    OSDependentInit();
 
-   while ((ch = getopt(argc, argv, "bBh:c:d:n:P:Su:vf:w:r:?")) != -1) {
+   while ((ch = getopt(argc, argv, "bBh:k:e:a:c:d:n:P:Su:vf:w:r:?")) != -1) {
       switch (ch) {
       case 'r':
          restore_list=bstrdup(optarg);
@@ -140,6 +148,18 @@ int main (int argc, char *argv[])
          db_host = optarg;
          break;
 
+      case 'k':
+         db_ssl_key = optarg;
+         break;
+
+      case 'e':
+         db_ssl_cert = optarg;
+         break;
+
+      case 'a':
+         db_ssl_ca = optarg;
+         break;
+
       case 'n':
          db_name = optarg;
          break;
@@ -186,7 +206,9 @@ int main (int argc, char *argv[])
       /* To use the -r option, the catalog should already contains records */
       
       if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password,
-                                 db_host, 0, NULL, false, disable_batch)) == NULL) {
+                                 db_host, 0, NULL, db_ssl_key, db_ssl_cert,
+                                 db_ssl_ca, db_ssl_capath, db_ssl_cipher,
+                                 false, disable_batch)) == NULL) {
          Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
       }
       if (!db_open_database(NULL, db)) {
@@ -235,7 +257,9 @@ int main (int argc, char *argv[])
       pm_strcpy(bjcr->fileset_md5, "Dummy.fileset.md5");
       
       if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password,
-                                 db_host, 0, NULL, false, false)) == NULL) {
+                                 db_host, 0, NULL, db_ssl_key, db_ssl_cert,
+                                 db_ssl_ca, db_ssl_capath, db_ssl_cipher,
+                                 false, false)) == NULL) {
          Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
       }
       if (!db_open_database(NULL, db)) {
diff --git a/src/tools/bpluginfo.c b/src/tools/bpluginfo.c
index 1655bd5..15318f1 100644
--- a/src/tools/bpluginfo.c
+++ b/src/tools/bpluginfo.c
@@ -25,6 +25,8 @@
    Bacula® is a registered trademark of Kern Sibbald.
 */
 
+#ifdef working /* currently will not compile KES 21 Nov 2015 */
+
 #include <stdio.h>
 #include <unistd.h>
 #include <limits.h>
@@ -623,3 +625,5 @@ int main(int argc, char *argv[])
 
    return 0;
 }
+
+#endif /* working */
diff --git a/src/tools/bvfs_test.c b/src/tools/bvfs_test.c
index b2a7ed0..3ac3253 100644
--- a/src/tools/bvfs_test.c
+++ b/src/tools/bvfs_test.c
@@ -39,6 +39,11 @@ static const char *db_name = "regress";
 static const char *db_user = "regress";
 static const char *db_password = "";
 static const char *db_host = NULL;
+static const char *db_ssl_key = NULL;
+static const char *db_ssl_cert = NULL;
+static const char *db_ssl_ca = NULL;
+static const char *db_ssl_capath = NULL;
+static const char *db_ssl_cipher = NULL;
 
 static void usage()
 {
@@ -51,6 +56,9 @@ PROG_COPYRIGHT
 "       -u <user>         specify database user name (default bacula)\n"
 "       -P <password      specify database password (default none)\n"
 "       -h <host>         specify database host (default NULL)\n"
+"       -k <sslkey>       path name to the key file (default NULL)\n"
+"       -e <sslcert>      path name to the certificate file (default NULL)\n"
+"       -a <sslca>        path name to the CA certificate file (default NULL)\n"
 "       -w <working>      specify working directory\n"
 "       -j <jobids>       specify jobids\n"
 "       -p <path>         specify path\n"
@@ -119,7 +127,7 @@ int main (int argc, char *argv[])
 
    OSDependentInit();
 
-   while ((ch = getopt(argc, argv, "h:c:l:d:n:P:Su:vf:w:?j:p:f:T")) != -1) {
+   while ((ch = getopt(argc, argv, "h:k:e:a:c:l:d:n:P:Su:vf:w:?j:p:f:T")) != -1) {
       switch (ch) {
       case 'd':                    /* debug level */
          if (*optarg == 't') {
@@ -143,6 +151,18 @@ int main (int argc, char *argv[])
          db_host = optarg;
          break;
 
+      case 'k':
+         db_ssl_key= optarg;
+         break;
+
+      case 'e':
+         db_ssl_cert= optarg;
+         break;
+
+      case 'a':
+         db_ssl_ca= optarg;
+         break;
+
       case 'n':
          db_name = optarg;
          break;
@@ -202,7 +222,10 @@ int main (int argc, char *argv[])
    bstrncpy(bjcr->Job, "bvfs_test", sizeof(bjcr->Job));
    
    if ((db = db_init_database(NULL, NULL, db_name, db_user, db_password,
-                              db_host, 0, NULL, false, false)) == NULL) {
+                              db_host, 0, NULL,
+                              db_ssl_key, db_ssl_cert, db_ssl_ca,
+                              db_ssl_capath, db_ssl_cipher,
+                              false, false)) == NULL) {
       Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
    }
    Dmsg1(0, "db_type=%s\n", db_get_engine_name(db));
diff --git a/src/tools/cats_test.c b/src/tools/cats_test.c
index f204aa0..c51f21f 100644
--- a/src/tools/cats_test.c
+++ b/src/tools/cats_test.c
@@ -340,6 +340,8 @@ int main (int argc, char *argv[])
                    NULL /* dbi driver */,
                    db_name, db_user, db_password, db_address, db_port + 100,
                    NULL /* db_socket */,
+                   db_ssl_key, db_ssl_cert, db_ssl_ca,
+                   db_ssl_capath, db_ssl_cipher,
                    0 /* mult_db_connections */, false);
       ok(db != NULL, "Test bad connection");
       if (!db) {
@@ -354,6 +356,8 @@ int main (int argc, char *argv[])
                 NULL /* dbi driver */,
                 db_name, db_user, db_password, db_address, db_port,
                 NULL /* db_socket */,
+                db_ssl_key, db_ssl_cert, db_ssl_ca,
+                db_ssl_capath, db_ssl_cipher,
                 false /* mult_db_connections */, false);
 
    ok(db != NULL, "Test db connection");
diff --git a/src/tools/dbcheck.c b/src/tools/dbcheck.c
index 5d50e2e..73ea992 100644
--- a/src/tools/dbcheck.c
+++ b/src/tools/dbcheck.c
@@ -100,7 +100,7 @@ static void usage()
    fprintf(stderr,
 PROG_COPYRIGHT
 "\n%sVersion: %s (%s)\n\n"
-"Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>]\n"
+"Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>] [<dbport>] [<dbsslkey>] [<dbsslcert>] [<dbsslca>]\n"
 "       -b              batch mode\n"
 "       -C              catalog name in the director conf file\n"
 "       -c              Director conf filename\n"
@@ -120,6 +120,8 @@ int main (int argc, char *argv[])
 {
    int ch;
    const char *user, *password, *db_name, *dbhost;
+   const char *dbsslkey = NULL, *dbsslcert = NULL, *dbsslca = NULL;
+   const char *dbsslcapath = NULL, *dbsslcipher = NULL;
    int dbport = 0;
    bool print_catalog=false;
    char *configfile = NULL;
@@ -230,9 +232,14 @@ int main (int argc, char *argv[])
             dbhost = NULL;
          }
          dbport = catalog->db_port;
+         dbsslkey = catalog->db_ssl_key;
+         dbsslcert = catalog->db_ssl_cert;
+         dbsslca = catalog->db_ssl_ca;
+         dbsslcapath = catalog->db_ssl_capath;
+         dbsslcipher = catalog->db_ssl_cipher;
       }
    } else {
-      if (argc > 6) {
+      if (argc > 9) {
          Pmsg0(0, _("Wrong number of arguments.\n"));
          usage();
       }
@@ -251,42 +258,43 @@ int main (int argc, char *argv[])
       password = "";
       dbhost = NULL;
 
-      if (argc == 2) {
+      if (argc >= 2) {
          db_name = argv[1];
          user = db_name;
-      } else if (argc == 3) {
-         db_name = argv[1];
-         user = argv[2];
-      } else if (argc == 4) {
-         db_name = argv[1];
-         user = argv[2];
-         password = argv[3];
-      } else if (argc == 5) {
-         db_name = argv[1];
-         user = argv[2];
-         password = argv[3];
-         dbhost = argv[4];
-      } else if (argc == 6) {
-         db_name = argv[1];
-         user = argv[2];
-         password = argv[3];
-         dbhost = argv[4];
-         errno = 0;
-         dbport = strtol(argv[5], &endptr, 10);
-         if (*endptr != '\0') {
-            Pmsg0(0, _("Database port must be a numeric value.\n"));
-            exit(1);
-         } else if (errno == ERANGE) {
-            Pmsg0(0, _("Database port must be a int value.\n"));
-            exit(1);
-         }
-      }
+         if (argc >= 3) {
+            user = argv[2];
+            if (argc >= 4) {
+               password = argv[3];
+               if (argc >= 5) {
+                  dbhost = argv[4];
+                  if (argc >= 6) {
+                     errno = 0;
+                     dbport = strtol(argv[5], &endptr, 10);
+                     if (*endptr != '\0') {
+                        Pmsg0(0, _("Database port must be a numeric value.\n"));
+                        exit(1);
+                     } else if (errno == ERANGE) {
+                        Pmsg0(0, _("Database port must be a int value.\n"));
+                        exit(1);
+                     }
+                     if (argc >= 7) {
+                        dbsslkey = argv[6];
+                        dbsslcert = argv[7];
+                        if (argc == 9) {
+                           dbsslca = argv[8];
+                        } /* if (argc == 9) */
+                     } /* if (argc >= 7) */
+                  } /* if (argc >= 6) */
+               } /* if (argc >= 5) */
+            } /* if (argc >= 4) */
+         } /* if (argc >= 3) */
+      } /* if (argc >= 2) */
    }
 
    /*
     * Open database
     */
-   db = db_init_database(NULL, NULL, db_name, user, password, dbhost, dbport, NULL, false, false);
+   db = db_init_database(NULL, NULL, db_name, user, password, dbhost, dbport, NULL, dbsslkey, dbsslcert, dbsslca, dbsslcapath, dbsslcipher, false, false);
    if (!db || !db_open_database(NULL, db)) {
       Emsg1(M_FATAL, 0, "%s", db_strerror(db));
           return 1;
@@ -337,6 +345,8 @@ static void print_catalog_details(CAT *catalog, const char *working_dir)
    db = db_init_database(NULL, catalog->db_driver, catalog->db_name, catalog->db_user,
                          catalog->db_password, catalog->db_address,
                          catalog->db_port, catalog->db_socket,
+                         catalog->db_ssl_key, catalog->db_ssl_cert, catalog->db_ssl_ca,
+                         catalog->db_ssl_capath, catalog->db_ssl_cipher,
                          catalog->mult_db_connections,
                          catalog->disable_batch_insert);
    if (db) {
diff --git a/src/version.h b/src/version.h
index 677a81f..229e2fb 100644
--- a/src/version.h
+++ b/src/version.h
@@ -5,9 +5,9 @@
 #define COMMUNITY 1      /* Define to create a Windows community binary */
 
 /* Note: there can be only *one* VERSION in this file */
-#define VERSION "7.2.0"
-#define BDATE   "17 November 2015"
-#define LSMDATE "17Nov15"
+#define VERSION "7.2.1"
+#define BDATE   "23 December 2015"
+#define LSMDATE "23Dec15"
 
 #define RELEASE 1   /* Use ONLY in rpms */
 
@@ -95,7 +95,7 @@
  */
 /* #define USE_LOCKMGR_SAFEKILL */
 
-#if !HAVE_LINUX_OS && !HAVE_SUN_OS && !HAVE_DARWIN_OS && !HAVE_FREEBSD_OS
+#if !HAVE_LINUX_OS && !HAVE_SUN_OS && !HAVE_DARWIN_OS && !HAVE_FREEBSD_OS && !HAVE_KFREEBSD_OS
 # undef _USE_LOCKMGR
 #endif
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bacula/bacula.git



More information about the pkg-bacula-commits mailing list