]> git.sur5r.net Git - bacula/bacula/commitdiff
Backport almost 4000 lines of 2.3 code that fixes a number of bugs.
authorKern Sibbald <kern@sibbald.com>
Wed, 3 Oct 2007 11:36:47 +0000 (11:36 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 3 Oct 2007 11:36:47 +0000 (11:36 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@5713 91ce42f0-d328-0410-95d8-f526ca767f89

81 files changed:
bacula/COPYRIGHT [new file with mode: 0644]
bacula/autoconf/configure.in
bacula/configure
bacula/kernstodo
bacula/projects
bacula/src/cats/bdb.c
bacula/src/cats/mysql.c
bacula/src/cats/postgresql.c
bacula/src/cats/protos.h
bacula/src/cats/sql_create.c
bacula/src/cats/sql_get.c
bacula/src/cats/sqlite.c
bacula/src/dird/backup.c
bacula/src/dird/catreq.c
bacula/src/dird/dird_conf.h
bacula/src/dird/fd_cmds.c
bacula/src/dird/getmsg.c
bacula/src/dird/job.c
bacula/src/dird/migrate.c
bacula/src/dird/newvol.c
bacula/src/dird/restore.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_query.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_run.c
bacula/src/dird/ua_tree.c
bacula/src/dird/verify.c
bacula/src/filed/authenticate.c
bacula/src/filed/job.c
bacula/src/filed/restore.c
bacula/src/filed/status.c
bacula/src/jcr.h
bacula/src/lib/Makefile.in
bacula/src/lib/attr.c
bacula/src/lib/attr.h
bacula/src/lib/breg.c
bacula/src/lib/breg.h
bacula/src/lib/bsnprintf.c
bacula/src/lib/bsock.h
bacula/src/lib/btimers.h
bacula/src/lib/cram-md5.c
bacula/src/lib/edit.c
bacula/src/lib/guid_to_name.c [new file with mode: 0644]
bacula/src/lib/guid_to_name.h [new file with mode: 0644]
bacula/src/lib/jcr.c
bacula/src/lib/lib.h
bacula/src/lib/message.c
bacula/src/lib/message.h
bacula/src/lib/parse_conf.h
bacula/src/lib/protos.h
bacula/src/lib/res.c
bacula/src/qt-console/console/console.cpp
bacula/src/qt-console/medialist/medialist.cpp
bacula/src/qt-console/medialist/medialist.h
bacula/src/qt-console/medialist/medialist.ui
bacula/src/qt-console/restore/prerestore.cpp
bacula/src/qt-console/restore/restoretree.cpp
bacula/src/stored/ansi_label.c
bacula/src/stored/authenticate.c
bacula/src/stored/autochanger.c
bacula/src/stored/bacula-sd.conf.in
bacula/src/stored/bextract.c
bacula/src/stored/block.c
bacula/src/stored/bls.c
bacula/src/stored/bscan.c
bacula/src/stored/dircmd.c
bacula/src/stored/fd_cmds.c
bacula/src/stored/label.c
bacula/src/stored/lock.c
bacula/src/stored/mac.c
bacula/src/stored/stored.c
bacula/src/tools/bsmtp.c
bacula/src/tools/dbcheck.c
bacula/src/tools/testfind.c
bacula/src/win32/README.vc8
bacula/src/win32/cats/bacula_cats.def
bacula/src/win32/cats/make_def
bacula/src/win32/dll/bacula.def
bacula/src/win32/dll/make_def
bacula/src/win32/libwin32/wintray.h [deleted file]
bacula/technotes-2.1

diff --git a/bacula/COPYRIGHT b/bacula/COPYRIGHT
new file mode 100644 (file)
index 0000000..062c2fb
--- /dev/null
@@ -0,0 +1,2 @@
+Please see the file LICENSE concerning the terms of the license,
+copying and such.
index 554e05bd64b21efa0a091597949a7f42feb8f55b..ccbb0dd41909a72cd2b1ad7e266c39bec013b2b1 100644 (file)
@@ -163,6 +163,14 @@ if test x$sbindir = x'${exec_prefix}/sbin' ; then
 fi
 sbindir=`eval echo ${sbindir}`
 
+# ------------------------------------------------------------------
+# If the user has not set --archivedir, we set our default as /tmp
+# ------------------------------------------------------------------
+if test x$archivedir = x'${archivedir}' ; then
+    archivedir=${archivedir}
+fi
+archivedir=`eval echo ${archivedir}`
+
 # -------------------------------------------------------------------------
 #  If the user has not set --mandir, we default to /usr/share/man
 # -------------------------------------------------------------------------
@@ -2318,6 +2326,7 @@ Configuration on `date`:
   Install binaries:          ${sbindir}
   Install config files:       ${sysconfdir}
   Scripts directory:         ${scriptdir}
+  Archive directory:         ${archivedir}
   Working directory:         ${working_dir}
   PID directory:             ${piddir}
   Subsys directory:          ${subsysdir}
index 6bfcbfdc747bf2753f2b81bf5202171cdb92d77d..3ef7c73edc1054d67c165dfa98e688ec30c4792a 100755 (executable)
@@ -309,7 +309,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_DIR TOP_DIR TRUEPRG FALSEPRG VERSION DATE LSMDATE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB MV RM CP SED ECHO CMP TBL AR OPENSSL MTX DD MKISOFS PYTHON GROWISOFS DVDRWMEDIAINFO DVDRWFORMAT PKGCONFIG WXCONFIG WXFLAGS CDRECORD PIDOF AWK ARFLAGS MAKE_SHELL LOCAL_LIBS LOCAL_CFLAGS LOCAL_LDFLAGS LOCAL_DEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os HAVE_SUN_OS_TRUE HAVE_SUN_OS_FALSE HAVE_OSF1_OS_TRUE HAVE_OSF1_OS_FALSE HAVE_AIX_OS_TRUE HAVE_AIX_OS_FALSE HAVE_HPUX_OS_TRUE HAVE_HPUX_OS_FALSE HAVE_LINUX_OS_TRUE HAVE_LINUX_OS_FALSE HAVE_FREEBSD_OS_TRUE HAVE_FREEBSD_OS_FALSE HAVE_NETBSD_OS_TRUE HAVE_NETBSD_OS_FALSE HAVE_OPENBSD_OS_TRUE HAVE_OPENBSD_OS_FALSE HAVE_BSDI_OS_TRUE HAVE_BSDI_OS_FALSE HAVE_SGI_OS_TRUE HAVE_SGI_OS_FALSE HAVE_IRIX_OS_TRUE HAVE_IRIX_OS_FALSE HAVE_DARWIN_OS_TRUE HAVE_DARWIN_OS_FALSE SET_MAKE MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE INTL_MACOSX_LIBS LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB GLIBC2 ALLOCA GLIBC21 HAVE_POSIX_PRINTF HAVE_ASPRINTF HAVE_SNPRINTF HAVE_WPRINTF INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX GNOME_INCLUDEDIR GNOMEUI_LIBS GNOME_LIBDIR GNOME_LIBS GNOME_DIR BAT_DIR QWT_INC QWT_LDFLAGS WXCONS_CPPFLAGS WXCONS_LDFLAGS WX_DIR TRAY_MONITOR_CPPFLAGS TRAY_MONITOR_LDFLAGS TRAY_MONITOR_DIR TTOOL_LDFLAGS STATIC_FD STATIC_SD STATIC_DIR STATIC_CONS STATIC_GNOME_CONS STATIC_WX_CONS ALL_DIRS DIRD_DIR DIR_TOOLS STORED_DIR CONS_INC CONS_OBJ CONS_SRC CONS_LIBS CONS_LDFLAGS READLINE_SRC PYTHON_LIBS PYTHON_INCDIR OPENSSL_LIBS OPENSSL_INC working_dir scriptdir dump_email job_email smtp_host piddir subsysdir baseport dir_port fd_port sd_port dir_password fd_password sd_password mon_dir_password mon_fd_password mon_sd_password db_name db_user dir_user dir_group sd_user sd_group fd_user fd_group SBINPERM SQL_LFLAGS SQL_INCLUDE SQL_BINDIR cats DB_TYPE GETCONF ac_ct_GETCONF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBOBJS FDLIBS DEBUG DINCLUDE DLIB DB_LIBS WCFLAGS WLDFLAGS WRAPLIBS OBJLIST hostname TAPEDRIVE PSCMD WIN32 MACOSX DISTNAME DISTVER LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir archivedir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_DIR TOP_DIR TRUEPRG FALSEPRG VERSION DATE LSMDATE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB MV RM CP SED ECHO CMP TBL AR OPENSSL MTX DD MKISOFS PYTHON GROWISOFS DVDRWMEDIAINFO DVDRWFORMAT PKGCONFIG WXCONFIG WXFLAGS CDRECORD PIDOF AWK ARFLAGS MAKE_SHELL LOCAL_LIBS LOCAL_CFLAGS LOCAL_LDFLAGS LOCAL_DEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os HAVE_SUN_OS_TRUE HAVE_SUN_OS_FALSE HAVE_OSF1_OS_TRUE HAVE_OSF1_OS_FALSE HAVE_AIX_OS_TRUE HAVE_AIX_OS_FALSE HAVE_HPUX_OS_TRUE HAVE_HPUX_OS_FALSE HAVE_LINUX_OS_TRUE HAVE_LINUX_OS_FALSE HAVE_FREEBSD_OS_TRUE HAVE_FREEBSD_OS_FALSE HAVE_NETBSD_OS_TRUE HAVE_NETBSD_OS_FALSE HAVE_OPENBSD_OS_TRUE HAVE_OPENBSD_OS_FALSE HAVE_BSDI_OS_TRUE HAVE_BSDI_OS_FALSE HAVE_SGI_OS_TRUE HAVE_SGI_OS_FALSE HAVE_IRIX_OS_TRUE HAVE_IRIX_OS_FALSE HAVE_DARWIN_OS_TRUE HAVE_DARWIN_OS_FALSE SET_MAKE MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE INTL_MACOSX_LIBS LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB GLIBC2 ALLOCA GLIBC21 HAVE_POSIX_PRINTF HAVE_ASPRINTF HAVE_SNPRINTF HAVE_WPRINTF INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX GNOME_INCLUDEDIR GNOMEUI_LIBS GNOME_LIBDIR GNOME_LIBS GNOME_DIR BAT_DIR QWT_INC QWT_LDFLAGS WXCONS_CPPFLAGS WXCONS_LDFLAGS WX_DIR TRAY_MONITOR_CPPFLAGS TRAY_MONITOR_LDFLAGS TRAY_MONITOR_DIR TTOOL_LDFLAGS STATIC_FD STATIC_SD STATIC_DIR STATIC_CONS STATIC_GNOME_CONS STATIC_WX_CONS ALL_DIRS DIRD_DIR DIR_TOOLS STORED_DIR CONS_INC CONS_OBJ CONS_SRC CONS_LIBS CONS_LDFLAGS READLINE_SRC PYTHON_LIBS PYTHON_INCDIR OPENSSL_LIBS OPENSSL_INC working_dir scriptdir dump_email job_email smtp_host piddir subsysdir baseport dir_port fd_port sd_port dir_password fd_password sd_password mon_dir_password mon_fd_password mon_sd_password db_name db_user dir_user dir_group sd_user sd_group fd_user fd_group SBINPERM SQL_LFLAGS SQL_INCLUDE SQL_BINDIR cats DB_TYPE GETCONF ac_ct_GETCONF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBOBJS FDLIBS DEBUG DINCLUDE DLIB DB_LIBS WCFLAGS WLDFLAGS WRAPLIBS OBJLIST hostname TAPEDRIVE PSCMD WIN32 MACOSX DISTNAME DISTVER LTLIBOBJS'
 ac_subst_files='MCOMMON'
 
 # Initialize some variables set by options.
@@ -350,6 +350,8 @@ oldincludedir='/usr/include'
 infodir='${prefix}/info'
 mandir='${prefix}/man'
 
+archivedir='/tmp'
+
 ac_prev=
 for ac_option
 do
@@ -544,6 +546,13 @@ do
   | --sbi=* | --sb=*)
     sbindir=$ac_optarg ;;
 
+  -archivedir | --archivedir | --archivedi | --archived | --archive | --archiv \
+  | --archi | --arch | --arc | --ar | --a)
+    ac_prev=archivedir ;;
+  -archivedir=* | --archivedir=* | --archivedi=* | --archived=* | --archive=* \
+  | --archiv=* | --archi=* | --arch=* | --arc=* | --ar=* | --a=*)
+    archivedir=$ac_optarg ;;
+
   -sharedstatedir | --sharedstatedir | --sharedstatedi \
   | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
   | --sharedst | --shareds | --shared | --share | --shar \
@@ -667,7 +676,7 @@ do
 done
 
 # Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir archivedir \
              localstatedir libdir includedir oldincludedir infodir mandir
 do
   eval ac_val=$`echo $ac_var`
@@ -843,6 +852,7 @@ Fine tuning of the installation directories:
   --oldincludedir=DIR    C header files for non-gcc [/usr/include]
   --infodir=DIR          info documentation [PREFIX/info]
   --mandir=DIR           man documentation [PREFIX/man]
+  --archivedir=DIR       archive destination for disk-based backups [/tmp]
 _ACEOF
 
   cat <<\_ACEOF
@@ -6763,6 +6773,14 @@ if test x$sbindir = x'${exec_prefix}/sbin' ; then
 fi
 sbindir=`eval echo ${sbindir}`
 
+# ------------------------------------------------------------------
+# If the user has not set --archivedir, we set our default as /tmp
+# ------------------------------------------------------------------
+if test x$archivedir = x'/tmp' ; then
+    archivedir=/tmp
+fi
+archivedir=`eval echo ${archivedir}`
+
 # -------------------------------------------------------------------------
 #  If the user has not set --mandir, we default to /usr/share/man
 # -------------------------------------------------------------------------
@@ -31155,6 +31173,7 @@ s,@prefix@,$prefix,;t t
 s,@program_transform_name@,$program_transform_name,;t t
 s,@bindir@,$bindir,;t t
 s,@sbindir@,$sbindir,;t t
+s,@archivedir@,$archivedir,;t t
 s,@libexecdir@,$libexecdir,;t t
 s,@datadir@,$datadir,;t t
 s,@sysconfdir@,$sysconfdir,;t t
@@ -32199,6 +32218,7 @@ Configuration on `date`:
   Install binaries:          ${sbindir}
   Install config files:       ${sysconfdir}
   Scripts directory:         ${scriptdir}
+  Archive directory:         ${archivedir}
   Working directory:         ${working_dir}
   PID directory:             ${piddir}
   Subsys directory:          ${subsysdir}
index eadfb5770cf2954472d82a8ec6cc865888900768..d840d86f2d585399e05a105642a9fa999553eaca 100644 (file)
@@ -56,10 +56,27 @@ Professional Needs:
 - How to sync remote offices.
 - Exchange backup:
   http://www.microsoft.com/technet/itshowcase/content/exchbkup.mspx
+- David's priorities
+   Copypools
+   Extract capability (#25)
+   Continued enhancement of bweb
+   Threshold triggered migration jobs (not currently in list, but will be
+    needed ASAP)
+   Client triggered backups
+   Complete rework of the scheduling system (not in list)
+   Performance and usage instrumentation (not in list)
+   See email of 21Aug2007 for details.
 
 Priority:
+- Erabt if min_block_size > max_block_size
+- KIWI
+- Implement wait on multiple objects
+   - Multiple max times
+   - pthread signal
+   - socket input ready
 - Implement SDErrors (must return from SD)
 - Implement USB keyboard support in rescue CD.
+- Implement continue spooling while despooling.
 - Remove all install temp files in Win32 PLUGINSDIR.
 - Audit retention periods to make sure everything is 64 bit.
 - Use E'xxx' to escape PostgreSQL strings.
@@ -170,6 +187,7 @@ Projects:
 
 
 For next release:
+- Try to fix bscan not working with multiple DVD volumes bug #912.
 - Look at mondo/mindi
 - Don't restore Solaris Door files:
    #define   S_IFDOOR   in st_mode.
index 3653905742db006563ec0853c4f8542b04d3f8fd..6b99f5fc6a5f38f63658549139c3214f03e3a0ea 100644 (file)
@@ -497,7 +497,7 @@ Item 12:  Add Plug-ins to the FileSet Include statements.
 Item 13:  Restore only file attributes (permissions, ACL, owner, group...)
   Origin: Eric Bollengier
   Date:   30/12/2006
-  Status:
+  Status: Implemented by Eric, see project-restore-attributes-only.patch
 
   What:   The goal of this project is to be able to restore only rights
           and attributes of files without crushing them.
@@ -513,7 +513,8 @@ Item 13:  Restore only file attributes (permissions, ACL, owner, group...)
           If the file isn't here, we can create an empty one and apply
           rights or do nothing.
 
-
+          This will not work with win32 stream, because it seems that we 
+          can't split the WriteBackup stream to get only ACL and ownerchip.
 
 Item 14:  Add an override in Schedule for Pools based on backup types
 Date:     19 Jan 2005
@@ -679,7 +680,7 @@ Item 19:  Automatic disabling of devices
 Item 20:  An option to operate on all pools with update vol parameters
   Origin: Dmitriy Pinchukov <absh@bossdev.kiev.ua>
    Date:  16 August 2006
-  Status:
+  Status: Patch made by  Nigel Stepp
 
    What:  When I do update -> Volume parameters -> All Volumes
           from Pool, then I have to select pools one by one.  I'd like
@@ -1163,7 +1164,7 @@ Item  n:  make changing "spooldata=yes|no" possible for
           manual/interactive jobs
   Origin: Marc Schiffbauer <marc@schiffbauer.net>
   Date:   12 April 2007)
-  Status: Already implemented by Eric
+  Status: 
 
   What:   Make it possible to modify the spooldata option
           for a job when being run from within the console.
index 60f57849ea8df70df7fbd1440a102eda22f16e45..d9862abab11eddc97f8c3ebe8bb488705c25882c 100644 (file)
@@ -307,7 +307,7 @@ void db_thread_cleanup()
 { }
 
 
-void db_escape_string(char *snew, char *old, int len)
+void db_escape_string(JCR *jcr, B_DB *db, char *snew, char *old, int len)
 {
    memset(snew, 0, len);
    bstrncpy(snew, old, len);
index cb5b76783ae134a3f1b6b8e7b6e34ec09cc889c2..c0068b1b1dc815a4414de3cc7e2b0ab20b6cce57 100644 (file)
@@ -296,62 +296,9 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
  *         the escaped output.
  */
 void
-db_escape_string(char *snew, char *old, int len)
+db_escape_string(JCR *jcr, B_DB *mdb, char *snew, char *old, int len)
 {
-   mysql_escape_string(snew, old, len);
-
-#ifdef xDO_IT_MYSELF
-
-/* Should use mysql_real_escape_string ! */
-unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned long length);
-
-   char *n, *o;
-
-   n = snew;
-   o = old;
-   while (len--) {
-      switch (*o) {
-      case 0:
-         *n++= '\\';
-         *n++= '0';
-         o++;
-         break;
-      case '\n':
-         *n++= '\\';
-         *n++= 'n';
-         o++;
-         break;
-      case '\r':
-         *n++= '\\';
-         *n++= 'r';
-         o++;
-         break;
-      case '\\':
-         *n++= '\\';
-         *n++= '\\';
-         o++;
-         break;
-      case '\'':
-         *n++= '\\';
-         *n++= '\'';
-         o++;
-         break;
-      case '"':
-         *n++= '\\';
-         *n++= '"';
-         o++;
-         break;
-      case '\032':
-         *n++= '\\';
-         *n++= 'Z';
-         o++;
-         break;
-      default:
-         *n++= *o++;
-      }
-   }
-   *n = 0;
-#endif
+   mysql_real_escape_string(mdb->db, snew, old, len);
 }
 
 /*
index 6f901403e7de108fcfcba7bd262bbdf06808445a..5f3d5bcb882869a2b392673cab803fb82b61b55b 100644 (file)
@@ -211,6 +211,12 @@ db_open_database(JCR *jcr, B_DB *mdb)
    }
 
    sql_query(mdb, "SET datestyle TO 'ISO, YMD'");
+   
+   /* tell PostgreSQL we are using standard conforming strings
+      and avoid warnings such as:
+       WARNING:  nonstandard use of \\ in a string literal
+   */
+   sql_query(mdb, "set standard_conforming_strings=on");
 
    V(mutex);
    return 1;
@@ -284,9 +290,17 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
  *         the escaped output.
  */
 void
-db_escape_string(char *snew, char *old, int len)
+db_escape_string(JCR *jcr, B_DB *mdb, char *snew, char *old, int len)
 {
-   PQescapeString(snew, old, len);
+   int error;
+  
+   PQescapeStringConn(mdb->db, snew, old, len, &error);
+   if (error) {
+      Jmsg(jcr, M_FATAL, 0, _("PQescapeStringConn returned non-zero.\n"));
+      /* error on encoding, probably invalid multibyte encoding in the source string
+        see PQescapeStringConn documentation for details. */
+      Dmsg0(500, "PQescapeStringConn failed\n");
+   }
 }
 
 /*
index c554a227442396134c56846c99525ce2c2d28e7f..43f1d984271561ea886fe6b03aeeb9a7717b02ba 100644 (file)
@@ -46,7 +46,7 @@ B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const
                        int mult_db_connections);
 int  db_open_database(JCR *jcr, B_DB *db);
 void db_close_database(JCR *jcr, B_DB *db);
-void db_escape_string(char *snew, char *old, int len);
+void db_escape_string(JCR *jcr, B_DB *db, char *snew, char *old, int len);
 char *db_strerror(B_DB *mdb);
 int  db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index);
 int  db_sql_query(B_DB *mdb, const char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
index be89406b812bbea2f4d224eac3069200375ab27c..8ea820b36afa4689ebc743893099f6159cb0aa26 100644 (file)
@@ -710,14 +710,14 @@ bool my_batch_start(JCR *jcr, B_DB *mdb)
 bool my_batch_insert(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
 {
    size_t len;
-   char *digest;
+   const char *digest;
    char ed1[50];
 
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, mdb->fnl*2+1);
-   db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl);
+   db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl);
 
    mdb->esc_path = check_pool_memory_size(mdb->esc_path, mdb->pnl*2+1);
-   db_escape_string(mdb->esc_path, mdb->path, mdb->pnl);
+   db_escape_string(jcr, mdb, mdb->esc_path, mdb->path, mdb->pnl);
 
    if (ar->Digest == NULL || ar->Digest[0] == 0) {
       digest = "0";
@@ -1000,7 +1000,7 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    int stat;
 
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->pnl+2);
-   db_escape_string(mdb->esc_name, mdb->path, mdb->pnl);
+   db_escape_string(jcr, mdb, mdb->esc_name, mdb->path, mdb->pnl);
 
    if (mdb->cached_path_id != 0 && mdb->cached_path_len == mdb->pnl &&
        strcmp(mdb->cached_path, mdb->path) == 0) {
@@ -1070,8 +1070,8 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
    SQL_ROW row;
 
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
-   db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl);
-
+   db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl);
+   
    Mmsg(mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
index 438e3f788f9ae2c276dbd9831806729cf0b3d63f..981f10ab789af3d22aa99133de4f2ba420291346 100644 (file)
@@ -169,7 +169,7 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb)
    int FilenameId = 0;
 
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->fnl+2);
-   db_escape_string(mdb->esc_name, mdb->fname, mdb->fnl);
+   db_escape_string(jcr, mdb, mdb->esc_name, mdb->fname, mdb->fnl);
 
    Mmsg(mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
@@ -213,7 +213,7 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
    uint32_t PathId = 0;
 
    mdb->esc_name = check_pool_memory_size(mdb->esc_name, 2*mdb->pnl+2);
-   db_escape_string(mdb->esc_name, mdb->path, mdb->pnl);
+   db_escape_string(jcr, mdb, mdb->esc_name, mdb->path, mdb->pnl);
 
    if (mdb->cached_path_id != 0 && mdb->cached_path_len == mdb->pnl &&
        strcmp(mdb->cached_path, mdb->path) == 0) {
index 66cc74c47b5b6be86e07c47532ae8a48a43f2685..b4331dd81595fb578632c25c250b8b8a51d1e566 100644 (file)
@@ -290,7 +290,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
  *         the escaped output.
  */
 void
-db_escape_string(char *snew, char *old, int len)
+db_escape_string(JCR *jcr, B_DB *db, char *snew, char *old, int len)
 {
    char *n, *o;
 
index ba1bdfe00d76a4c7037340b1ba3ec551d3e8b5d1..8c7a3cef46981e498abe855c8042422366fcf203 100644 (file)
@@ -200,7 +200,7 @@ bool do_backup(JCR *jcr)
       }
    }
 
-   bnet_fsend(fd, storaddr, store->address, store->SDDport, tls_need);
+   fd->fsend(storaddr, store->address, store->SDDport, tls_need);
    if (!response(jcr, fd, OKstore, "Storage", DISPLAY_ERROR)) {
       goto bail_out;
    }
@@ -226,7 +226,7 @@ bool do_backup(JCR *jcr)
    }
 
    /* Send backup command */
-   bnet_fsend(fd, backupcmd);
+   fd->fsend(backupcmd);
    if (!response(jcr, fd, OKbackup, "backup", DISPLAY_ERROR)) {
       goto bail_out;
    }
@@ -293,7 +293,7 @@ int wait_for_job_termination(JCR *jcr)
       Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"),
           job_type_to_str(jcr->JobType), fd->bstrerror());
    }
-   bnet_sig(fd, BNET_TERMINATE);   /* tell Client we are terminating */
+   fd->signal(BNET_TERMINATE);   /* tell Client we are terminating */
 
    /* Force cancel in SD if failing */
    if (job_canceled(jcr) || !fd_ok) {
@@ -388,7 +388,7 @@ void backup_cleanup(JCR *jcr, int TermCode)
          term_msg = _("*** Backup Error ***");
          msg_type = M_ERROR;          /* Generate error message */
          if (jcr->store_bsock) {
-            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
+            jcr->store_bsock->signal(BNET_TERMINATE);
             if (jcr->SD_msg_chan) {
                pthread_cancel(jcr->SD_msg_chan);
             }
@@ -397,7 +397,7 @@ void backup_cleanup(JCR *jcr, int TermCode)
       case JS_Canceled:
          term_msg = _("Backup Canceled");
          if (jcr->store_bsock) {
-            bnet_sig(jcr->store_bsock, BNET_TERMINATE);
+            jcr->store_bsock->signal(BNET_TERMINATE);
             if (jcr->SD_msg_chan) {
                pthread_cancel(jcr->SD_msg_chan);
             }
index 41f705bc38ef012c1818bcf60cd2d2944630d851..cc1903615f8ea585503b65f9d0e8d53060a7150b 100644 (file)
@@ -126,7 +126,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
    if (!jcr->db) {
       omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
-      bnet_fsend(bs, _("1990 Invalid Catalog Request: %s"), omsg);    
+      bs->fsend(_("1990 Invalid Catalog Request: %s"), omsg);    
       Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog request; DB not open: %s"), omsg);
       free_memory(omsg);
       return;
@@ -151,7 +151,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       if (ok) {
          send_volume_info_to_storage_daemon(jcr, bs, &mr);
       } else {
-         bnet_fsend(bs, _("1901 No Media.\n"));
+         bs->fsend(_("1901 No Media.\n"));
          Dmsg0(500, "1901 No Media.\n");
       }
 
@@ -200,12 +200,12 @@ void catalog_request(JCR *jcr, BSOCK *bs)
             send_volume_info_to_storage_daemon(jcr, bs, &mr);
          } else {
             /* Not suitable volume */
-            bnet_fsend(bs, _("1998 Volume \"%s\" status is %s, %s.\n"), mr.VolumeName,
+            bs->fsend(_("1998 Volume \"%s\" status is %s, %s.\n"), mr.VolumeName,
                mr.VolStatus, reason);
          }
 
       } else {
-         bnet_fsend(bs, _("1997 Volume \"%s\" not in catalog.\n"), mr.VolumeName);
+         bs->fsend(_("1997 Volume \"%s\" not in catalog.\n"), mr.VolumeName);
          Dmsg1(100, "1997 Volume \"%s\" not in catalog.\n", mr.VolumeName);
       }
 
@@ -229,7 +229,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       if (!db_get_media_record(jcr, jcr->db, &mr)) {
          Jmsg(jcr, M_ERROR, 0, _("Unable to get Media record for Volume %s: ERR=%s\n"),
               mr.VolumeName, db_strerror(jcr->db));
-         bnet_fsend(bs, _("1991 Catalog Request for vol=%s failed: %s"),
+         bs->fsend(_("1991 Catalog Request for vol=%s failed: %s"),
             mr.VolumeName, db_strerror(jcr->db));
          db_unlock(jcr->db);
          return;
@@ -259,7 +259,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
             Jmsg(jcr, M_FATAL, 0, _("Volume Files at %u being set to %u"
                  " for Volume \"%s\". This is incorrect.\n"),
                mr.VolFiles, sdmr.VolFiles, mr.VolumeName);
-            bnet_fsend(bs, _("1992 Update Media error. VolFiles=%u, CatFiles=%u\n"),
+            bs->fsend(_("1992 Update Media error. VolFiles=%u, CatFiles=%u\n"),
                sdmr.VolFiles, mr.VolFiles);
             db_unlock(jcr->db);
             return;
@@ -293,7 +293,7 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       if (!db_update_media_record(jcr, jcr->db, &mr)) {
          Jmsg(jcr, M_FATAL, 0, _("Catalog error updating Media record. %s"),
             db_strerror(jcr->db));
-         bnet_fsend(bs, _("1993 Update Media error\n"));
+         bs->fsend(_("1993 Update Media error\n"));
          Dmsg0(400, "send error\n");
       } else {
          (void)has_volume_expired(jcr, &mr);
@@ -319,16 +319,16 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) {
          Jmsg(jcr, M_FATAL, 0, _("Catalog error creating JobMedia record. %s"),
             db_strerror(jcr->db));
-         bnet_fsend(bs, _("1991 Update JobMedia error\n"));
+         bs->fsend(_("1991 Update JobMedia error\n"));
       } else {
          Dmsg0(400, "JobMedia record created\n");
-         bnet_fsend(bs, OK_create);
+         bs->fsend(OK_create);
       }
 
    } else {
       omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
-      bnet_fsend(bs, _("1990 Invalid Catalog Request: %s"), omsg);
+      bs->fsend(_("1990 Invalid Catalog Request: %s"), omsg);
       Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog request: %s"), omsg);
       free_memory(omsg);
    }
@@ -358,16 +358,16 @@ void catalog_update(JCR *jcr, BSOCK *bs)
    POOLMEM *omsg;
 
    Dsm_check(1);
-   if (!jcr->pool->catalog_files) {
-      return;                         /* user disabled cataloging */
+   if (job_canceled(jcr) || !jcr->pool->catalog_files) {
+      goto bail_out;                  /* user disabled cataloging */
    }
    if (!jcr->db) {
       omsg = get_memory(bs->msglen+1);
       pm_strcpy(omsg, bs->msg);
-      bnet_fsend(bs, _("1991 Invalid Catalog Update: %s"), omsg);    
+      bs->fsend(_("1991 Invalid Catalog Update: %s"), omsg);    
       Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog Update; DB not open: %s"), omsg);
       free_memory(omsg);
-      return;
+      goto bail_out;
    }
 
    /* Start transaction allocates jcr->attr and jcr->ar if needed */
@@ -486,4 +486,8 @@ void catalog_update(JCR *jcr, BSOCK *bs)
          }
       }
    }
+bail_out:
+   if (job_canceled(jcr)) {
+      cancel_storage_daemon_job(jcr);
+   }
 }
index 03d50eb7062941c4fbe8eabcb07beff97317fa21..61e4a32cdbeb45f9151b7b5e6d5a6c6f26f98048 100644 (file)
@@ -380,6 +380,7 @@ public:
    utime_t RescheduleInterval;        /* Reschedule interval */
    utime_t JobRetention;              /* job retention period in seconds */
    uint32_t MaxConcurrentJobs;        /* Maximum concurrent jobs */
+   int64_t spool_size;                /* Size of spool file for this job */
    int RescheduleTimes;               /* Number of times to reschedule job */
    bool RescheduleOnError;            /* Set to reschedule on error */
    bool PrefixLinks;                  /* prefix soft links with Where path */
@@ -392,6 +393,7 @@ public:
    bool PreferMountedVolumes;         /* Prefer vols mounted rather than new one */
    bool write_part_after_job;         /* Set to write part after job in SD */
    bool enabled;                      /* Set if job enabled */
+   bool OptimizeJobScheduling;        /* Set if we should optimize Job scheduling */
    
    MSGS      *messages;               /* How and where to send messages */
    SCHED     *schedule;               /* When -- Automatic schedule */
index 2e9e3e50148f4e4cd2c78b4dfdf15b71fa829020..7479a7305635a28a7b386d7a21aaac8ab5e94ac0 100644 (file)
@@ -90,9 +90,11 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
    }
 
    if (!jcr->file_bsock) {
+      char name[MAX_NAME_LENGTH + 100];
+      bstrncpy(name, _("Client: "), sizeof(name));
+      bstrncat(name, jcr->client->name(), sizeof(name));
       fd = bnet_connect(jcr, retry_interval, max_retry_time, heart_beat,
-           _("File daemon"), jcr->client->address,
-           NULL, jcr->client->FDport, verbose);
+           name, jcr->client->address, NULL, jcr->client->FDport, verbose);
       if (fd == NULL) {
          set_jcr_job_status(jcr, JS_ErrorTerminated);
          return 0;
@@ -113,7 +115,7 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time,
    /*
     * Now send JobId and authorization key
     */
-   bnet_fsend(fd, jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId,
+   fd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId,
       jcr->VolSessionTime, jcr->sd_auth_key);
    if (strcmp(jcr->sd_auth_key, "dummy") != 0) {
       memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
@@ -437,7 +439,7 @@ bool send_include_list(JCR *jcr)
 {
    BSOCK *fd = jcr->file_bsock;
    if (jcr->fileset->new_include) {
-      bnet_fsend(fd, filesetcmd, jcr->fileset->enable_vss ? " vss=1" : "");
+      fd->fsend(filesetcmd, jcr->fileset->enable_vss ? " vss=1" : "");
       return send_fileset(jcr);
    }
    return true;
@@ -479,11 +481,11 @@ bool send_bootstrap_file(JCR *jcr, BSOCK *sock)
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       return false;
    }
-   bnet_fsend(sock, bootstrap);
+   sock->fsend(bootstrap);
    while (fgets(buf, sizeof(buf), bs)) {
-      bnet_fsend(sock, "%s", buf);
+      sock->fsend("%s", buf);
    }
-   bnet_sig(sock, BNET_EOD);
+   sock->signal(BNET_EOD);
    fclose(bs);
    if (jcr->unlink_bsr) {
       unlink(jcr->RestoreBootstrap);
@@ -545,11 +547,11 @@ int send_runscripts_commands(JCR *jcr)
                result = send_runscript_with_old_proto(jcr, cmd->when, msg);
 
             } else {
-               bnet_fsend(fd, runscript, cmd->on_success, 
-                                         cmd->on_failure,
-                                         cmd->fail_on_error,
-                                         cmd->when,
-                                         msg);
+               fd->fsend(runscript, cmd->on_success, 
+                                    cmd->on_failure,
+                                    cmd->fail_on_error,
+                                    cmd->when,
+                                    msg);
 
                result = response(jcr, fd, OKRunScript, "RunScript", DISPLAY_ERROR);
                launch_before_cmd = true;
@@ -570,7 +572,7 @@ int send_runscripts_commands(JCR *jcr)
 
    /* Tell the FD to execute the ClientRunBeforeJob */
    if (launch_before_cmd) {
-      bnet_fsend(fd, runbeforenow);
+      fd->fsend(runbeforenow);
       if (!response(jcr, fd, OKRunBeforeNow, "RunBeforeNow", DISPLAY_ERROR)) {
         goto bail_out;
       }
@@ -677,7 +679,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr)
          }
          ar->Digest = digest;
          ar->DigestType = crypto_digest_stream_type(stream);
-         db_escape_string(digest, Digest, strlen(Digest));
+         db_escape_string(jcr, jcr->db, digest, Digest, strlen(Digest));
          Dmsg4(dbglvl, "stream=%d DigestLen=%d Digest=%s type=%d\n", stream,
                strlen(digest), digest, ar->DigestType);
       }
index ae4a190bf6dc30f94bc35896a7f479eba16c4666..16e88291c42f0b7ce73d77be820db3521f3fe4b1 100644 (file)
@@ -213,7 +213,7 @@ int bget_dirmsg(BSOCK *bs)
          free_jcr(jcr);
          continue;
       }
-      if (bs->msg[0] == 'U') {        /* Catalog update */
+      if (bs->msg[0] == 'U') {        /* SD sending attributes */
          Dmsg2(900, "Catalog upd jcr 0x%x: %s", jcr, bs->msg);
          catalog_update(jcr, bs);
          Dmsg1(900, "Calling freejcr 0x%x\n", jcr);
index 406a43e3bb054e0107e15e56c547e224dd7c6250..ac0fb2616624e86f869fea11bc19a5f74c60decd 100644 (file)
@@ -237,8 +237,7 @@ static void *job_thread(void *arg)
 {
    JCR *jcr = (JCR *)arg;
 
-   jcr->my_thread_id = pthread_self();
-   pthread_detach(jcr->my_thread_id);
+   pthread_detach(pthread_self());
    Dsm_check(1);
 
    Dmsg0(200, "=====Start Job=========\n");
@@ -745,6 +744,10 @@ void update_job_end_record(JCR *jcr)
  * Takes base_name and appends (unique) current
  *   date and time to form unique job name.
  *
+ *  Note, the seconds are actually a sequence number. This
+ *   permits us to start a maximum fo 59 unique jobs a second, which
+ *   should be sufficient.
+ *
  *  Returns: unique job name in jcr->Job
  *    date/time in jcr->start_time
  */
@@ -753,6 +756,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
    /* Job start mutex */
    static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
    static time_t last_start_time = 0;
+   static int seq = 0;
    time_t now;
    struct tm tm;
    char dt[MAX_TIME_LENGTH];
@@ -764,9 +768,13 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
     */
    P(mutex);                          /* lock creation of jobs */
    now = time(NULL);
-   while (now == last_start_time) {
-      bmicrosleep(0, 500000);
-      now = time(NULL);
+   seq++;
+   if (seq > 59) {                    /* wrap as if it is seconds */
+      seq = 0;
+      while (now == last_start_time) {
+         bmicrosleep(0, 500000);
+         now = time(NULL);
+      }
    }
    last_start_time = now;
    V(mutex);                          /* allow creation of jobs */
@@ -774,10 +782,10 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
    /* Form Unique JobName */
    (void)localtime_r(&now, &tm);
    /* Use only characters that are permitted in Windows filenames */
-   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
+   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M", &tm);
    bstrncpy(name, base_name, sizeof(name));
    name[sizeof(name)-22] = 0;          /* truncate if too long */
-   bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s", name, dt); /* add date & time */
+   bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s.%02d", name, dt, seq); /* add date & time */
    /* Convert spaces into underscores */
    for (p=jcr->Job; *p; p++) {
       if (*p == ' ') {
@@ -1203,7 +1211,7 @@ bool create_restore_bootstrap_file(JCR *jcr)
    UAContext *ua;
    memset(&rx, 0, sizeof(rx));
    rx.bsr = new_bsr();
-   rx.JobIds = "";                       
+   rx.JobIds = (char *)"";                       
    rx.bsr->JobId = jcr->previous_jr.JobId;
    ua = new_ua_context(jcr);
    complete_bsr(ua, rx.bsr);
index c0f183d05a4a856ccacf9b6ea8a6540953d60ea4..e239197e352f22d21c2c7377b7fa36ca50afd881 100644 (file)
@@ -1147,7 +1147,6 @@ void migration_cleanup(JCR *jcr, int TermCode)
         /* Mark previous job as migrated */
         Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1));
-        Dmsg1(000, "Mark: %s\n", query.c_str());
         db_sql_query(jcr->db, query.c_str(), NULL, NULL);
      }
      term_msg = _("%s -- no files to migrate");
index 2a345ce8d35ed14f7e9dee4aeda87cd7bb0c37e8..c66b8133258fb70711a16d4c9af125535cf243af 100644 (file)
@@ -1,21 +1,7 @@
-/*
- *
- *   Bacula Director -- newvol.c -- creates new Volumes in
- *    catalog Media table from the LabelFormat specification.
- *
- *     Kern Sibbald, May MMI
- *
- *    This routine runs as a thread and must be thread reentrant.
- *
- *  Basic tasks done here:
- *      If possible create a new Media entry
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ *   Bacula Director -- newvol.c -- creates new Volumes in
+ *    catalog Media table from the LabelFormat specification.
+ *
+ *     Kern Sibbald, May MMI
+ *
+ *    This routine runs as a thread and must be thread reentrant.
+ *
+ *  Basic tasks done here:
+ *      If possible create a new Media entry
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"
 #include "dird.h"
@@ -116,11 +116,21 @@ static bool create_simple_name(JCR *jcr, MEDIA_DBR *mr, POOL_DBR *pr)
 {
    char name[MAXSTRING];
    char num[20];
+   db_int64_ctx ctx;
+   POOL_MEM query(PM_MESSAGE);
+   char ed1[50];
 
    /* See if volume already exists */
    mr->VolumeName[0] = 0;
    bstrncpy(name, pr->LabelFormat, sizeof(name));
-   for (int i=pr->NumVols+1; i<(int)pr->NumVols+100; i++) {
+   ctx.value = 0;
+   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)) {
+      Jmsg(jcr, M_WARNING, 0, _("SQL failed, but ignored. ERR=%s\n"), db_strerror(jcr->db));
+      ctx.value = pr->NumVols+1;
+   }
+   for (int i=(int)ctx.value+1; i<(int)ctx.value+100; i++) {
       MEDIA_DBR tmr;
       memset(&tmr, 0, sizeof(tmr));
       sprintf(num, "%04d", i);
index 978f81476a985f3d8d31760b8cd6940719c0015c..2c3b213baeecd35153aaa90fa38bed7ac867c9fd 100644 (file)
@@ -173,7 +173,7 @@ bool do_restore(JCR *jcr)
    }
 
    /* Send restore command */
-   char replace, *where, *cmd=NULL;
+   char replace, *where, *cmd;
    char empty = '\0';
 
    if (jcr->replace != 0) {
@@ -184,13 +184,11 @@ bool do_restore(JCR *jcr)
       replace = REPLACE_ALWAYS;       /* always replace */
    }
    
-   where = &empty;                    /* default */
-
    if (jcr->RegexWhere) {
       where = jcr->RegexWhere;             /* override */
       cmd = restorecmdR;
    } else if (jcr->job->RegexWhere) {
-      where = jcr->job->RegexWhere; /* no override take from job */
+      where = jcr->job->RegexWhere;   /* no override take from job */
       cmd = restorecmdR;
 
    } else if (jcr->where) {
@@ -199,7 +197,11 @@ bool do_restore(JCR *jcr)
    } else if (jcr->job->RestoreWhere) {
       where = jcr->job->RestoreWhere; /* no override take from job */
       cmd = restorecmd;
-   } 
+
+   } else {                          /* nothing was specified */
+      where = &empty;                /* use default */
+      cmd   = restorecmd;                   
+   }
    
    jcr->prefix_links = jcr->job->PrefixLinks;
 
index 299847fee37668352c911861533133c77909eb8e..66dc23d51bc69e768d21681ff7fae7ba9a67a988 100644 (file)
@@ -557,12 +557,12 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays)
             bit_is_set(woy, run->woy);
  
 #ifdef xxx
-         Dmsg2(000, "day=%d is_scheduled=%d\n", day, is_scheduled);
-         Dmsg1(000, "bit_set_mday=%d\n", bit_is_set(mday, run->mday));
-         Dmsg1(000, "bit_set_wday=%d\n", bit_is_set(wday, run->wday));
-         Dmsg1(000, "bit_set_month=%d\n", bit_is_set(month, run->month));
-         Dmsg1(000, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
-         Dmsg1(000, "bit_set_woy=%d\n", bit_is_set(woy, run->woy));
+         Pmsg2(000, "day=%d is_scheduled=%d\n", day, is_scheduled);
+         Pmsg1(000, "bit_set_mday=%d\n", bit_is_set(mday, run->mday));
+         Pmsg1(000, "bit_set_wday=%d\n", bit_is_set(wday, run->wday));
+         Pmsg1(000, "bit_set_month=%d\n", bit_is_set(month, run->month));
+         Pmsg1(000, "bit_set_wom=%d\n", bit_is_set(wom, run->wom));
+         Pmsg1(000, "bit_set_woy=%d\n", bit_is_set(woy, run->woy));
 #endif
 
          if (is_scheduled) { /* Jobs scheduled on that day */
@@ -576,7 +576,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays)
                }
             }
             bstrncat(buf, "\n", sizeof(buf));
-            Dmsg1(000, "%s", buf);
+            Pmsg1(000, "%s", buf);
 #endif
             /* find time (time_t) job is to be run */
             (void)localtime_r(&future, &runtm);
index bd3202e300f76b2b3824306a5dcf1a1f679a465b..231e41700b6f7411b3f2b51253f104422f8cfc1b 100644 (file)
@@ -69,8 +69,9 @@ int querycmd(UAContext *ua, const char *cmd)
       goto bail_out;
    }
    if ((fd=fopen(query_file, "rb")) == NULL) {
+      berrno be;
       ua->error_msg(_("Could not open %s: ERR=%s\n"), query_file,
-         strerror(errno));
+         be.bstrerror());
       goto bail_out;
    }
 
@@ -207,7 +208,7 @@ static POOLMEM *substitute_prompts(UAContext *ua,
                }
                len = strlen(ua->cmd);
                p = (char *)malloc(len * 2 + 1);
-               db_escape_string(p, ua->cmd, len);
+               db_escape_string(ua->jcr, ua->db, p, ua->cmd, len);
                subst[n] = p;
                olen = o - new_query;
                new_query = check_pool_memory_size(new_query, olen + strlen(p) + 10);
index 0320456e868db1d313cd9185d342ed18b1c360cc..9b0dc9090ddd01405d2e54a088e6336e5e9a28be 100644 (file)
@@ -58,7 +58,7 @@ static void free_name_list(NAME_LIST *name_list);
 static bool select_backups_before_date(UAContext *ua, RESTORE_CTX *rx, char *date);
 static bool build_directory_tree(UAContext *ua, RESTORE_CTX *rx);
 static void free_rx(RESTORE_CTX *rx);
-static void split_path_and_filename(RESTORE_CTX *rx, char *fname);
+static void split_path_and_filename(UAContext *ua, RESTORE_CTX *rx, char *fname);
 static int jobid_fileindex_handler(void *ctx, int num_fields, char **row);
 static bool insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *file,
                                          char *date);
@@ -581,7 +581,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
          }
          len = strlen(ua->cmd);
          fname = (char *)malloc(len * 2 + 1);
-         db_escape_string(fname, ua->cmd, len);
+         db_escape_string(ua->jcr, ua->db, fname, ua->cmd, len);
          Mmsg(rx->query, uar_file, rx->ClientName, fname);
          free(fname);
          gui_save = ua->jcr->gui;
@@ -868,7 +868,7 @@ static bool insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *f
                                         char *date)
 {
    strip_trailing_newline(file);
-   split_path_and_filename(rx, file);
+   split_path_and_filename(ua, rx, file);
    if (*rx->JobIds == 0) {
       Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, 
            rx->ClientName);
@@ -939,7 +939,7 @@ static bool insert_table_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *
    return true;
 }
 
-static void split_path_and_filename(RESTORE_CTX *rx, char *name)
+static void split_path_and_filename(UAContext *ua, RESTORE_CTX *rx, char *name)
 {
    char *p, *f;
 
@@ -968,7 +968,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name)
    rx->fnl = p - f;
    if (rx->fnl > 0) {
       rx->fname = check_pool_memory_size(rx->fname, 2*(rx->fnl)+1);
-      db_escape_string(rx->fname, f, rx->fnl);
+      db_escape_string(ua->jcr, ua->db, rx->fname, f, rx->fnl);
    } else {
       rx->fname[0] = 0;
       rx->fnl = 0;
@@ -977,7 +977,7 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name)
    rx->pnl = f - name;
    if (rx->pnl > 0) {
       rx->path = check_pool_memory_size(rx->path, 2*(rx->pnl)+1);
-      db_escape_string(rx->path, name, rx->pnl);
+      db_escape_string(ua->jcr, ua->db, rx->path, name, rx->pnl);
    } else {
       rx->path[0] = 0;
       rx->pnl = 0;
index 5baf9d9c6a03e182defef81187f8da33c5b9726d..4f5f86a66bfd5581593fd2d8df423340b924a16c 100644 (file)
@@ -46,7 +46,7 @@ public:
    char *when, *verify_job_name, *catalog_name;
    char *previous_job_name;
    char *since;
-   char *verify_list;
+   const char *verify_list;
    JOB *job;
    JOB *verify_job;
    JOB *previous_job;
@@ -69,7 +69,7 @@ public:
 /* Forward referenced subroutines */
 static void select_job_level(UAContext *ua, JCR *jcr);
 static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, 
-                char *verify_list, char *jid, const char *replace,
+                const char *verify_list, char *jid, const char *replace,
                 char *client_name);
 static void select_where_regexp(UAContext *ua, JCR *jcr);
 static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc);
@@ -245,7 +245,6 @@ try_again:
 
    if (strncasecmp(ua->cmd, ".mod ", 5) == 0 || 
        (strncasecmp(ua->cmd, "mod ", 4) == 0 && strlen(ua->cmd) > 6)) {
-      Dmsg1(000, "got: %s\n", ua->cmd);
       parse_ua_args(ua);
       rc.mod = true;
       if (!scan_command_line_arguments(ua, rc)) {
@@ -377,8 +376,9 @@ try_again:
             jcr->RestoreBootstrap = bstrdup(ua->cmd);
             fd = fopen(jcr->RestoreBootstrap, "rb");
             if (!fd) {
+               berrno be;
                ua->send_msg(_("Warning cannot open %s: ERR=%s\n"),
-                  jcr->RestoreBootstrap, strerror(errno));
+                  jcr->RestoreBootstrap, be.bstrerror());
                free(jcr->RestoreBootstrap);
                jcr->RestoreBootstrap = NULL;
             } else {
@@ -659,7 +659,7 @@ static void select_job_level(UAContext *ua, JCR *jcr)
    return;
 }
 
-static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, char *verify_list,
+static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char *verify_list,
    char *jid, const char *replace, char *client_name) 
 {
    Dmsg1(800, "JobType=%c\n", jcr->JobType);
@@ -933,7 +933,7 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
             /* Note, yes and run have no value, so do not fail */
             if (!ua->argv[i] && j != YES_POS /*yes*/) {
                ua->send_msg(_("Value missing for keyword %s\n"), ua->argk[i]);
-               return true;
+               return false;
             }
             Dmsg1(800, "Got keyword=%s\n", NPRT(kw[j]));
             switch (j) {
index 576049f023f4c29891019c5d3a9cb4d496ecfab2..616c052dc7e71cd1780431374c98d235e5277eb1 100644 (file)
@@ -111,6 +111,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
       "remove (unmark) files to be restored. No files are initially added, unless\n"
       "you used the \"all\" keyword on the command line.\n"
       "Enter \"done\" to leave this mode.\n\n"));
+   if (ua->api) user->signal(BNET_START_RTREE);
    /*
     * Enter interactive command handler allowing selection
     *  of individual files.
@@ -150,6 +151,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
          break;
       }
    }
+   if (ua->api) user->signal(BNET_END_RTREE);
    ua->UA_sock = NULL;                /* don't release restore socket */
    stat = !ua->quit;
    ua->quit = false;
@@ -490,17 +492,11 @@ static int lsmarkcmd(UAContext *ua, TREE_CTX *tree)
    return 1;
 }
 
-
-
-extern char *getuser(uid_t uid, char *name, int len);
-extern char *getgroup(gid_t gid, char *name, int len);
-
 /*
  * This is actually the long form used for "dir"
  */
-static void ls_output(char *buf, const char *fname, const char *tag, 
+static void ls_output(guid_list *guid, char *buf, const char *fname, const char *tag, 
                       struct stat *statp, bool dot_cmd) 
-                    
 {
    char *p;
    const char *f;
@@ -514,8 +510,9 @@ static void ls_output(char *buf, const char *fname, const char *tag,
       *p++ = ',';
       n = sprintf(p, "%d,", (uint32_t)statp->st_nlink);
       p += n;
-      n = sprintf(p, "%s,%s,", getuser(statp->st_uid, en1, sizeof(en1)),
-                  getgroup(statp->st_gid, en2, sizeof(en2)));
+      n = sprintf(p, "%s,%s,", 
+                  guid->uid_to_name(statp->st_uid, en1, sizeof(en1)),
+                  guid->gid_to_name(statp->st_gid, en2, sizeof(en2)));
       p += n;
       n = sprintf(p, "%s,", edit_uint64(statp->st_size, ec1));
       p += n;
@@ -526,8 +523,9 @@ static void ls_output(char *buf, const char *fname, const char *tag,
    } else {
       n = sprintf(p, "  %2d ", (uint32_t)statp->st_nlink);
       p += n;
-      n = sprintf(p, "%-8.8s %-8.8s", getuser(statp->st_uid, en1, sizeof(en1)),
-                  getgroup(statp->st_gid, en2, sizeof(en2)));
+      n = sprintf(p, "%-8.8s %-8.8s", 
+                  guid->uid_to_name(statp->st_uid, en1, sizeof(en1)),
+                  guid->gid_to_name(statp->st_gid, en2, sizeof(en2)));
       p += n;
       n = sprintf(p, "%10.10s  ", edit_uint64(statp->st_size, ec1));
       p += n;
@@ -557,12 +555,14 @@ static int do_dircmd(UAContext *ua, TREE_CTX *tree, bool dot_cmd)
    struct stat statp;
    char buf[1100];
    char cwd[1100], *pcwd;
+   guid_list *guid;
 
    if (!tree_node_has_child(tree->node)) {
       ua->send_msg(_("Node %s has no children.\n"), tree->node->fname);
       return 1;
    }
 
+   guid = new_guid_list();
    foreach_child(node, tree->node) {
       const char *tag;
       if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
@@ -600,10 +600,11 @@ static int do_dircmd(UAContext *ua, TREE_CTX *tree, bool dot_cmd)
             /* Something went wrong getting attributes -- print name */
             memset(&statp, 0, sizeof(statp));
          }
-         ls_output(buf, cwd, tag, &statp, dot_cmd);
+         ls_output(guid, buf, cwd, tag, &statp, dot_cmd);
          ua->send_msg("%s\n", buf);
       }
    }
+   free_guid_list(guid);
    return 1;
 }
 
index 71dc8b48ef02fc1f447fbf233865c6d0060bcbab..8562add9dbac565703d48c362e3699f8f9042c2d 100644 (file)
@@ -193,7 +193,7 @@ bool do_verify(JCR *jcr)
       if (!start_storage_daemon_job(jcr, jcr->rstorage, NULL)) {
          return false;
       }
-      if (!bnet_fsend(jcr->store_bsock, "run")) {
+      if (!jcr->store_bsock->fsend("run")) {
          return false;
       }
       /*
@@ -707,7 +707,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId)
             return false;
          }
          if (do_Digest != CRYPTO_DIGEST_NONE) {
-            db_escape_string(buf, Opts_Digest, strlen(Opts_Digest));
+            db_escape_string(jcr, jcr->db, buf, Opts_Digest, strlen(Opts_Digest));
             if (strcmp(buf, fdbr.Digest) != 0) {
                prt_fname(jcr);
                if (debug_level >= 10) {
index 4ed53cdffce04e21cb49ca410173287f3a7747e5..12de1816ceac6d6ae9276cf293e1b255eafc8bb9 100644 (file)
@@ -1,15 +1,7 @@
-/*
- * Authenticate Director who is attempting to connect.
- *
- *   Kern Sibbald, October 2000
- *
- *   Version $Id$
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Authenticate Director who is attempting to connect.
+ *
+ *   Kern Sibbald, October 2000
+ *
+ *   Version $Id$
+ *
+ */
 
 #include "bacula.h"
 #include "filed.h"
 
+const int dbglvl = 50;
+
 static char OK_hello[]  = "2000 OK Hello\n";
 static char Dir_sorry[] = "2999 No go\n";
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -56,12 +58,12 @@ static bool authenticate(int rcode, BSOCK *bs, JCR* jcr)
    btimer_t *tid = NULL;
 
    if (rcode != R_DIRECTOR) {
-      Dmsg1(50, "I only authenticate directors, not %d\n", rcode);
+      Dmsg1(dbglvl, "I only authenticate directors, not %d\n", rcode);
       Emsg1(M_FATAL, 0, _("I only authenticate directors, not %d\n"), rcode);
       goto auth_fatal;
    }
    if (bs->msglen < 25 || bs->msglen > 500) {
-      Dmsg2(50, "Bad Hello command from Director at %s. Len=%d.\n",
+      Dmsg2(dbglvl, "Bad Hello command from Director at %s. Len=%d.\n",
             bs->who(), bs->msglen);
       char addr[64];
       char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who() : addr;
@@ -75,7 +77,7 @@ static bool authenticate(int rcode, BSOCK *bs, JCR* jcr)
       char addr[64];
       char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who() : addr;
       bs->msg[100] = 0;
-      Dmsg2(50, "Bad Hello command from Director at %s: %s\n",
+      Dmsg2(dbglvl, "Bad Hello command from Director at %s: %s\n",
             bs->who(), bs->msg);
       Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"),
             who, bs->msg);
@@ -121,12 +123,12 @@ static bool authenticate(int rcode, BSOCK *bs, JCR* jcr)
       if (!auth_success) {
           char addr[64];
           char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who() : addr;
-          Dmsg1(50, "cram_get_auth failed for %s\n", who);
+          Dmsg1(dbglvl, "cram_get_auth failed for %s\n", who);
       }
    } else {
        char addr[64];
        char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who() : addr;
-       Dmsg1(50, "cram_auth failed for %s\n", who);
+       Dmsg1(dbglvl, "cram_auth failed for %s\n", who);
    }
    if (!auth_success) {
        Emsg1(M_FATAL, 0, _("Incorrect password given by Director at %s.\n"),
@@ -231,12 +233,12 @@ int authenticate_storagedaemon(JCR *jcr)
       goto auth_fatal;
    }
    if (!auth_success) {
-      Dmsg1(50, "cram_respond failed for %s\n", sd->who());
+      Dmsg1(dbglvl, "cram_respond failed for %s\n", sd->who());
    } else {
       /* Now challenge him */
       auth_success = cram_md5_challenge(sd, jcr->sd_auth_key, tls_local_need, compatible);
       if (!auth_success) {
-         Dmsg1(50, "cram_challenge failed for %s\n", sd->who());
+         Dmsg1(dbglvl, "cram_challenge failed for %s\n", sd->who());
       }
    }
 
index d8f0d007804d3441c3c6e69d6e999e746ff987f2..03c971d8e8e6836282ba75ce4d3425d8b124f64b 100644 (file)
@@ -406,7 +406,7 @@ static int setdebug_cmd(JCR *jcr)
    }
    debug_level = level;
    set_trace(trace_flag);
-   return bnet_fsend(dir, OKsetdebug, level);
+   return dir->fsend(OKsetdebug, level);
 }
 
 
@@ -418,11 +418,11 @@ static int estimate_cmd(JCR *jcr)
    if (sscanf(dir->msg, estimatecmd, &jcr->listing) != 1) {
       pm_strcpy(jcr->errmsg, dir->msg);
       Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg);
-      bnet_fsend(dir, _("2992 Bad estimate command.\n"));
+      dir->fsend(_("2992 Bad estimate command.\n"));
       return 0;
    }
    make_estimate(jcr);
-   bnet_fsend(dir, OKest, jcr->num_files_examined,
+   dir->fsend(OKest, jcr->num_files_examined,
       edit_uint64_with_commas(jcr->JobBytes, ed2));
    bnet_sig(dir, BNET_EOD);
    return 1;
@@ -449,7 +449,7 @@ static int job_cmd(JCR *jcr)
    jcr->sd_auth_key = bstrdup(sd_auth_key);
    free_pool_memory(sd_auth_key);
    Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key);
-   return bnet_fsend(dir, OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER);
+   return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER);
 }
 
 static int runbefore_cmd(JCR *jcr)
@@ -463,7 +463,7 @@ static int runbefore_cmd(JCR *jcr)
    if (sscanf(dir->msg, runbefore, cmd) != 1) {
       pm_strcpy(jcr->errmsg, dir->msg);
       Jmsg1(jcr, M_FATAL, 0, _("Bad RunBeforeJob command: %s\n"), jcr->errmsg);
-      bnet_fsend(dir, _("2905 Bad RunBeforeJob command.\n"));
+      dir->fsend(_("2905 Bad RunBeforeJob command.\n"));
       free_memory(cmd);
       return 0;
    }
@@ -1310,7 +1310,7 @@ static int storage_cmd(JCR *jcr)
 
    jcr->store_bsock = sd;
 
-   bnet_fsend(sd, "Hello Start Job %s\n", jcr->Job);
+   sd->fsend("Hello Start Job %s\n", jcr->Job);
    if (!authenticate_storagedaemon(jcr)) {
       Jmsg(jcr, M_FATAL, 0, _("Failed to authenticate Storage daemon.\n"));
       return 0;
@@ -1318,7 +1318,7 @@ static int storage_cmd(JCR *jcr)
    Dmsg0(110, "Authenticated with SD.\n");
 
    /* Send OK to Director */
-   return bnet_fsend(dir, OKstore);
+   return dir->fsend(OKstore);
 }
 
 
index c505971de867124164067428a853a9b451c2528e..7c094462ef7cba3ed5f0636b1873aca08e2352ef 100644 (file)
@@ -240,7 +240,7 @@ void do_restore(JCR *jcr)
     */
    binit(&rctx.bfd);
    binit(&rctx.forkbfd);
-   attr = new_attr();
+   attr = new_attr(jcr);
    jcr->acl_text = get_pool_memory(PM_MESSAGE);
 
    
index c3c2da632d4e2c3854f06c67b55a17871f1c89ed..afff50db84270404c433a4da9843b33b87c149db 100644 (file)
@@ -143,7 +143,7 @@ void output_status(void sendit(const char *msg, int len, void *sarg), void *arg)
    Dmsg0(1000, "Begin status jcr loop.\n");
    len = Mmsg(msg, _("\nRunning Jobs:\n"));
    sendit(msg.c_str(), len, arg);
-   char *vss = "";
+   const char *vss = "";
 #ifdef WIN32_VSS
    if (g_pVSSClient && g_pVSSClient->IsInitialized()) {
       vss = "VSS ";
index 89e2095cdbc2308cdf4e1c4413eee8f1bfe1c685..ad28b3485cdb63f760a1b06483053d0e8199469f 100644 (file)
@@ -188,6 +188,7 @@ public:
    B_DB *db;                          /* database pointer */
    B_DB *db_batch;                    /* database pointer for batch insert */
    ATTR_DBR *ar;                      /* DB attribute record */
+   guid_list *id_list;                /* User/group id to name list */
 
    /* Daemon specific part of JCR */
    /* This should be empty in the library */
@@ -246,6 +247,7 @@ public:
    int replace;                       /* Replace option */
    int NumVols;                       /* Number of Volume used in pool */
    int reschedule_count;              /* Number of times rescheduled */
+   int64_t spool_size;                /* Spool size for this job */
    bool spool_data;                   /* Spool data in SD */
    bool acquired_resource_locks;      /* set if resource locks acquired */
    bool term_wait_inited;             /* Set when cond var inited */
@@ -322,6 +324,7 @@ public:
    bool ignore_label_errors;          /* ignore Volume label errors */
    bool spool_attributes;             /* set if spooling attributes */
    bool no_attributes;                /* set if no attributes wanted */
+   int64_t spool_size;                /* Spool size for this job */
    bool spool_data;                   /* set to spool data */
    int CurVol;                        /* Current Volume count */
    DIRRES* director;                  /* Director resource */
index b9ca9acaa6ba840dd42127686c9030bc97ffb51f..c32085f46045bbdd69db204be21f3ac3cea6746a 100644 (file)
@@ -23,7 +23,7 @@ LIBSRCS = attr.c base64.c berrno.c bsys.c bget_msg.c \
          bnet.c bnet_server.c runscript.c \
          bsock.c bpipe.c bsnprintf.c btime.c \
          cram-md5.c crc32.c crypto.c daemon.c edit.c fnmatch.c \
-         hmac.c idcache.c jcr.c lex.c alist.c dlist.c \
+         guid_to_name.c hmac.c jcr.c lex.c alist.c dlist.c \
          md5.c message.c mem_pool.c openssl.c parse_conf.c \
          queue.c bregex.c \
          res.c rwlock.c scan.c serial.c sha1.c \
@@ -35,8 +35,8 @@ LIBSRCS = attr.c base64.c berrno.c bsys.c bget_msg.c \
 LIBOBJS = attr.o base64.o berrno.o bsys.o bget_msg.o \
          bnet.o bnet_server.o runscript.o \
          bsock.o bpipe.o bsnprintf.o btime.o \
-         cram-md5.o crc32.o crypto.o daemon.o edit.o enh_fnmatch.o fnmatch.o \
-         hmac.o idcache.o jcr.o lex.o alist.o dlist.o \
+         cram-md5.o crc32.o crypto.o daemon.o edit.o fnmatch.o \
+         guid_to_name.o hmac.o jcr.o lex.o alist.o dlist.o \
          md5.o message.o mem_pool.o openssl.o parse_conf.o \
          queue.o bregex.o \
          res.o rwlock.o scan.o serial.o sha1.o \
index d3f59bffb041b8ee24afca39f6c529a93a4e6752..b916f801f518efead4e23cd7f9be59974bde3910 100644 (file)
@@ -1,14 +1,7 @@
-/*
- *   attr.c  Unpack an Attribute record returned from the tape
- *
- *    Kern Sibbald, June MMIII  (code pulled from filed/restore.c and updated)
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2003-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *   attr.c  Unpack an Attribute record returned from the tape
+ *
+ *    Kern Sibbald, June MMIII  (code pulled from filed/restore.c and updated)
+ *
+ *   Version $Id$
+ */
+
 
 #include "bacula.h"
 #include "jcr.h"
 #include "lib/breg.h"
 
-ATTR *new_attr()
+ATTR *new_attr(JCR *jcr)
 {
    ATTR *attr = (ATTR *)malloc(sizeof(ATTR));
    memset(attr, 0, sizeof(ATTR));
    attr->ofname = get_pool_memory(PM_FNAME);
    attr->olname = get_pool_memory(PM_FNAME);
    attr->attrEx = get_pool_memory(PM_FNAME);
+   attr->jcr = jcr;
+   attr->uid = getuid();
    return attr;
 }
 
@@ -237,11 +240,17 @@ void print_ls_output(JCR *jcr, ATTR *attr)
    char ec1[30];
    char en1[30], en2[30];
    char *p, *f;
+   guid_list *guid;
 
+   if (!jcr->id_list) {
+      jcr->id_list = new_guid_list();
+   }
+   guid = jcr->id_list;
    p = encode_mode(attr->statp.st_mode, buf);
    p += sprintf(p, "  %2d ", (uint32_t)attr->statp.st_nlink);
-   p += sprintf(p, "%-8.8s %-8.8s", getuser(attr->statp.st_uid, en1, sizeof(en1)),
-                getgroup(attr->statp.st_gid, en2, sizeof(en2)));
+   p += sprintf(p, "%-8.8s %-8.8s", 
+                guid->uid_to_name(attr->statp.st_uid, en1, sizeof(en1)),
+                guid->gid_to_name(attr->statp.st_gid, en2, sizeof(en2)));
    p += sprintf(p, "%10.10s ", edit_uint64(attr->statp.st_size, ec1));
    p = encode_time(attr->statp.st_ctime, p);
    *p++ = ' ';
index 4167ef154829b4174eafd18190380707fc136bb6..4b3cbe65e005f1324d15824b2ce23e87c63c0ede 100644 (file)
@@ -33,6 +33,9 @@
  *   Version $Id$
  */
 
+#ifndef __ATTR_H_
+#define __ATTR_H_ 1
+
 
 struct ATTR {
    int32_t stream;                    /* attribute stream id */
@@ -40,6 +43,7 @@ struct ATTR {
    int32_t type;                      /* file type FT */
    int32_t file_index;                /* file index */
    int32_t LinkFI;                    /* file index to data if hard link */
+   uid_t uid;                         /* userid */
    struct stat statp;                 /* decoded stat packet */
    POOLMEM *attrEx;                   /* extended attributes if any */
    POOLMEM *ofname;                   /* output filename */
@@ -52,4 +56,7 @@ struct ATTR {
    char *attr;                        /* attributes position */
    char *fname;                       /* filename */
    char *lname;                       /* link name if any */
+   JCR *jcr;                          /* jcr pointer */
 };
+
+#endif /* __ATTR_H_ */
index 0f742d66650743e5d477fad9027dee64b2c1f1d4..6a3d33c7ae83160488197455e084652a2fe6596a 100644 (file)
@@ -340,7 +340,7 @@ char *BREGEXP::edit_subst(const char *fname, regmatch_t regs[])
 /* escape sep char and \
  * dest must be long enough (src*2+1)
  * return end of the string */
-char *bregexp_escape_string(char *dest, char *src, char sep)
+char *bregexp_escape_string(char *dest, const char *src, const char sep)
 {
    char *ret = dest;
    while (*src)
@@ -357,10 +357,10 @@ char *bregexp_escape_string(char *dest, char *src, char sep)
    return ret; 
 }
 
-static char regexp_sep = '!';
-static char *str_strip_prefix = "!%s!!i";
-static char *str_add_prefix   = "!^!%s!";
-static char *str_add_suffix   = "!([^/])$!$1%s!";
+static const char regexp_sep = '!';
+static const char *str_strip_prefix = "!%s!!i";
+static const char *str_add_prefix   = "!^!%s!";
+static const char *str_add_suffix   = "!([^/])$!$1%s!";
 
 int bregexp_get_build_where_size(char *strip_prefix, 
                                  char *add_prefix, 
index 33be5397d1a730fed4c5db2df4c978d424a35cb9..27ddfbbd1fe1dc59fdcdccd86a8d9ab544d4cec1 100644 (file)
  */
 class BREGEXP {
 public:
-   POOLMEM *result;            /* match result */
-   bool success;               /* match is ok */
+   POOLMEM *result;             /* match result */
+   bool success;                /* match is ok */
 
    char *replace(const char *fname); /* return this.result */
    void debug();
 
    /* private */
-   POOLMEM *expr;              /* search epression */
-   POOLMEM *subst;             /* substitution */
-   regex_t preg;               /* regex_t result of regcomp() */
+   POOLMEM *expr;               /* search epression */
+   POOLMEM *subst;              /* substitution */
+   regex_t preg;                /* regex_t result of regcomp() */
    regmatch_t regs[BREG_NREGS]; /* contains match */
-   char *eor;                  /* end of regexp in expr */
+   char *eor;                   /* end of regexp in expr */
 
    char *return_fname(const char *fname, int len); /* return fname as result */
    char *edit_subst(const char *fname, regmatch_t regs[]);
@@ -100,20 +100,20 @@ void free_bregexps(alist *bregexps); /* you have to free alist */
 
 /* get regexp size */
 int bregexp_get_build_where_size(char *strip_prefix, 
-                                char *add_prefix, 
-                                char *add_suffix);
+                                 char *add_prefix, 
+                                 char *add_suffix);
 
 /* get a bregexp string from user arguments 
  * you must allocate it with bregexp_get_build_where_size();
  */
 char *bregexp_build_where(char *dest, int str_size,
-                         char *strip_prefix, 
+                          char *strip_prefix, 
                           char *add_prefix, 
                           char *add_suffix);
 
 /* escape a string to regexp format (sep and \) 
  * dest must be long enough (dest = 2*src + 1)
  */
-char *bregexp_escape_string(char *dest, char *src, char sep);
+char *bregexp_escape_string(char *dest, const char *src, const char sep);
 
 #endif /* __BREG_H_ */
index f8f88aea6b78cea65bb43154d16281e93ff0f3b3..920fdb1b240c9204cf9720bdca5698a963426b55 100644 (file)
@@ -63,7 +63,7 @@
 
 int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args);
 static int32_t fmtstr(char *buffer, int32_t currlen, int32_t maxlen,
-                   char *value, int flags, int min, int max);
+                   const char *value, int flags, int min, int max);
 static int32_t fmtint(char *buffer, int32_t currlen, int32_t maxlen,
                    int64_t value, int base, int min, int max, int flags);
 
@@ -396,7 +396,7 @@ int bvsnprintf(char *buffer, int32_t maxlen, const char *format, va_list args)
 }
 
 static int32_t fmtstr(char *buffer, int32_t currlen, int32_t maxlen,
-                   char *value, int flags, int min, int max)
+                   const char *value, int flags, int min, int max)
 {
    int padlen, strln;              /* amount to pad */
    int cnt = 0;
index 06247da0dcce536bfed75caccae163ee96e01a9c..f4a90085dc9fd950b32b0fcf4d81faee53a97349 100644 (file)
@@ -167,7 +167,9 @@ enum {
    BNET_ERROR_MSG      = -21,         /* Error message -- command failed */
    BNET_INFO_MSG       = -22,         /* Info message -- status line */
    BNET_RUN_CMD        = -23,         /* Run command follows */
-   BNET_YESNO          = -24          /* Request yes no response */
+   BNET_YESNO          = -24,         /* Request yes no response */
+   BNET_START_RTREE    = -25,         /* Start restore tree mode */
+   BNET_END_RTREE      = -26          /* End restore tree mode */ 
 };
 
 #define BNET_SETBUF_READ  1           /* Arg for bnet_set_buffer_size */
index 33e3ed59947005474938fb7d2db4cf93e70c25d6..7d9eca00cd6ac0a064601918d17c8022f42992c9 100644 (file)
@@ -42,6 +42,7 @@ struct btimer_t {
    pid_t pid;                         /* process id if TYPE_CHILD */
    pthread_t tid;                     /* thread id if TYPE_PTHREAD */
    BSOCK *bsock;                      /* Pointer to BSOCK */
+   JCR *jcr;                          /* Pointer to job control record */
 };
 
 #endif /* __BTIMERS_H_ */
index 80b7b13d4152d51cf2d474c5271d0a4a05c27e09..036dc4ed34c8c34ff799a05994438e4e80343902 100644 (file)
@@ -37,6 +37,8 @@
 
 #include "bacula.h"
 
+const int dbglvl = 50;
+
 /* Authorize other end
  * Codes that tls_local_need and tls_remote_need can take:
  *   BNET_TLS_NONE     I cannot do tls
@@ -68,23 +70,23 @@ bool cram_md5_challenge(BSOCK *bs, const char *password, int tls_local_need, int
    /* Send challenge -- no hashing yet */
    bsnprintf(chal, sizeof(chal), "<%u.%u@%s>", (uint32_t)random(), (uint32_t)time(NULL), host);
    if (compatible) {
-      Dmsg2(50, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
+      Dmsg2(dbglvl, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
       if (!bs->fsend("auth cram-md5 %s ssl=%d\n", chal, tls_local_need)) {
-         Dmsg1(50, "Bnet send challenge error.\n", bs->bstrerror());
+         Dmsg1(dbglvl, "Bnet send challenge error.\n", bs->bstrerror());
          return false;
       }
    } else {
       /* Old non-compatible system */
-      Dmsg2(50, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
+      Dmsg2(dbglvl, "send: auth cram-md5 %s ssl=%d\n", chal, tls_local_need);
       if (!bs->fsend("auth cram-md5 %s ssl=%d\n", chal, tls_local_need)) {
-         Dmsg1(50, "Bnet send challenge error.\n", bs->bstrerror());
+         Dmsg1(dbglvl, "Bnet send challenge error.\n", bs->bstrerror());
          return false;
       }
    }
 
    /* Read hashed response to challenge */
    if (bs->wait_data(180) <= 0 || bs->recv() <= 0) {
-      Dmsg1(50, "Bnet receive challenge response error.\n", bs->bstrerror());
+      Dmsg1(dbglvl, "Bnet receive challenge response error.\n", bs->bstrerror());
       bmicrosleep(5, 0);
       return false;
    }
@@ -94,18 +96,18 @@ bool cram_md5_challenge(BSOCK *bs, const char *password, int tls_local_need, int
    bin_to_base64(host, sizeof(host), (char *)hmac, 16, compatible);
    ok = strcmp(bs->msg, host) == 0;
    if (ok) {
-      Dmsg1(50, "Authenticate OK %s\n", host);
+      Dmsg1(dbglvl, "Authenticate OK %s\n", host);
    } else {
       bin_to_base64(host, sizeof(host), (char *)hmac, 16, false);     
       ok = strcmp(bs->msg, host) == 0;
       if (!ok) {
-         Dmsg2(50, "Authenticate NOT OK: wanted %s, got %s\n", host, bs->msg);
+         Dmsg2(dbglvl, "Authenticate NOT OK: wanted %s, got %s\n", host, bs->msg);
       }
    }
    if (ok) {
       bs->fsend("1000 OK auth\n");
    } else {
-      Dmsg1(50, "Auth failed PW: %s\n", password);
+      Dmsg1(dbglvl, "Auth failed PW: %s\n", password);
       bs->fsend(_("1999 Authorization failed.\n"));
       bmicrosleep(5, 0);
    }
@@ -124,16 +126,16 @@ bool cram_md5_respond(BSOCK *bs, const char *password, int *tls_remote_need, int
       return false;
    }
    if (bs->msglen >= MAXSTRING) {
-      Dmsg1(50, "Msg too long wanted auth cram... Got: %s", bs->msg);
+      Dmsg1(dbglvl, "Msg too long wanted auth cram... Got: %s", bs->msg);
       bmicrosleep(5, 0);
       return false;
    }
-   Dmsg1(100, "cram-get: %s", bs->msg);
+   Dmsg1(100, "cram-get received: %s", bs->msg);
    if (sscanf(bs->msg, "auth cram-md5c %s ssl=%d", chal, tls_remote_need) == 2) {
       *compatible = true;
    } else if (sscanf(bs->msg, "auth cram-md5 %s ssl=%d", chal, tls_remote_need) != 2) {
       if (sscanf(bs->msg, "auth cram-md5 %s\n", chal) != 1) {
-         Dmsg1(50, "Cannot scan challenge: %s", bs->msg);
+         Dmsg1(dbglvl, "Cannot scan challenge: %s", bs->msg);
          bs->fsend(_("1999 Authorization failed.\n"));
          bmicrosleep(5, 0);
          return false;
@@ -144,19 +146,19 @@ bool cram_md5_respond(BSOCK *bs, const char *password, int *tls_remote_need, int
    bs->msglen = bin_to_base64(bs->msg, 50, (char *)hmac, 16, *compatible) + 1;
 // Dmsg3(100, "get_auth: chal=%s pw=%s hmac=%s\n", chal, password, bs->msg);
    if (!bs->send()) {
-      Dmsg1(50, "Send challenge failed. ERR=%s\n", bs->bstrerror());
+      Dmsg1(dbglvl, "Send challenge failed. ERR=%s\n", bs->bstrerror());
       return false;
    }
    Dmsg1(99, "sending resp to challenge: %s\n", bs->msg);
    if (bs->wait_data(180) <= 0 || bs->recv() <= 0) {
-      Dmsg1(50, "Receive chanllenge response failed. ERR=%s\n", bs->bstrerror());
+      Dmsg1(dbglvl, "Receive chanllenge response failed. ERR=%s\n", bs->bstrerror());
       bmicrosleep(5, 0);
       return false;
    }
    if (strcmp(bs->msg, "1000 OK auth\n") == 0) {
       return true;
    }
-   Dmsg1(50, "Bad auth response: %s\n", bs->msg);
+   Dmsg1(dbglvl, "Received bad response: %s\n", bs->msg);
    bmicrosleep(5, 0);
    return false;
 }
index 5c3bfdbb006c11378489d9db038987feeb617fb8..89768f5d941d6d0f38d8dec7d197734b6e7140dd 100644 (file)
@@ -120,7 +120,7 @@ char *edit_uint64_with_suffix(uint64_t val, char *buf)
 {
   int commas = 0;
   char *c, mbuf[50];
-  char *suffix[] =
+  const char *suffix[] =
     { "", "K", "M", "G", "T", "P", "E", "Z", "Y", "FIX ME" };
   int suffixes = sizeof(suffix) / sizeof(*suffix);
 
diff --git a/bacula/src/lib/guid_to_name.c b/bacula/src/lib/guid_to_name.c
new file mode 100644 (file)
index 0000000..73eeb6e
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007 Kern Sibbald
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation, which is 
+   listed in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ * Written by Kern Sibbald, July 2007 to replace idcache.c
+ * 
+ *  Program to convert uid and gid into names, and cache the results
+ *   for preformance reasons.
+ *
+ *  Version $Id: guid_to_name.c 5502 2007-09-09 08:00:09Z kerns $
+ */
+
+#include "bacula.h"
+
+#ifndef WIN32
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+struct guitem {
+   dlink link;
+   char *name;
+   union {
+      uid_t uid;
+      gid_t gid;
+   };
+};
+
+
+guid_list *new_guid_list()
+{
+   guid_list *list;
+   guitem *item = NULL;
+   list = (guid_list *)malloc(sizeof(guid_list));
+   list->uid_list = New(dlist(item, &item->link));
+   list->gid_list = New(dlist(item, &item->link));
+   return list;
+}
+
+void free_guid_list(guid_list *list)
+{
+   guitem *item;
+   foreach_dlist(item, list->uid_list) {
+      free(item->name);
+   }
+   foreach_dlist(item, list->gid_list) {
+      free(item->name);
+   }
+   delete list->uid_list;
+   delete list->gid_list;
+   free(list);
+}
+
+static int uid_compare(void *item1, void *item2)
+{
+   guitem *i1 = (guitem *)item1;
+   guitem *i2 = (guitem *)item2;
+   if (i1->uid < i2->uid) {
+      return -1;
+   } else if (i1->uid > i2->uid) {
+      return 1;
+   } else {
+      return 0;
+   }
+}
+
+static int gid_compare(void *item1, void *item2)
+{
+   guitem *i1 = (guitem *)item1;
+   guitem *i2 = (guitem *)item2;
+   if (i1->gid < i2->gid) {
+      return -1;
+   } else if (i1->gid > i2->gid) {
+      return 1;
+   } else {
+      return 0;
+   }
+}
+
+
+static void get_uidname(uid_t uid, guitem *item)
+{
+#ifndef HAVE_WIN32
+   struct passwd *pwbuf;
+   P(mutex);
+   pwbuf = getpwuid(uid);
+   if (pwbuf != NULL && strcmp(pwbuf->pw_name, "????????") != 0) {
+      item->name = bstrdup(pwbuf->pw_name);
+   }
+   V(mutex);
+#endif
+}
+
+static void get_gidname(gid_t gid, guitem *item)
+{
+#ifndef HAVE_WIN32
+   struct group *grbuf;
+   P(mutex);
+   grbuf = getgrgid(gid);
+   if (grbuf != NULL && strcmp(grbuf->gr_name, "????????") != 0) {
+      item->name = bstrdup(grbuf->gr_name);
+   }
+   V(mutex);
+#endif
+}
+
+
+char *guid_list::uid_to_name(uid_t uid, char *name, int maxlen)
+{
+   guitem sitem, *item, *fitem;
+   sitem.uid = uid;
+   char buf[50];
+
+   item = (guitem *)uid_list->binary_search(&sitem, uid_compare);
+   Dmsg2(900, "uid=%d item=%p\n", uid, item);
+   if (!item) {
+      item = (guitem *)malloc(sizeof(guitem));
+      item->uid = uid;
+      item->name = NULL;
+      get_uidname(uid, item);
+      if (!item->name) {
+         item->name = bstrdup(edit_int64(uid, buf));
+         Dmsg2(900, "set uid=%d name=%s\n", uid, item->name);
+      }
+      fitem = (guitem *)uid_list->binary_insert(item, uid_compare);
+      if (fitem != item) {               /* item already there this shouldn't happen */
+         free(item);
+         item = fitem;   
+      }
+   }
+   bstrncpy(name, item->name, maxlen);
+   return name;
+}
+
+char *guid_list::gid_to_name(gid_t gid, char *name, int maxlen)
+{
+   guitem sitem, *item, *fitem;
+   sitem.gid = gid;
+   char buf[50];
+
+   item = (guitem *)gid_list->binary_search(&sitem, gid_compare);
+   if (!item) {
+      item = (guitem *)malloc(sizeof(guitem));
+      item->gid = gid;
+      item->name = NULL;
+      get_gidname(gid, item);
+      if (!item->name) {
+         item->name = bstrdup(edit_int64(gid, buf));
+      }
+      fitem = (guitem *)gid_list->binary_insert(item, gid_compare);
+      if (fitem != item) {               /* item already there this shouldn't happen */
+         free(item);
+         item = fitem;   
+      }
+   }
+
+   bstrncpy(name, item->name, maxlen);
+   return name;
+}
+
+#ifdef TEST_PROGRAM
+
+int main()
+{
+   int i;
+   guid_list *list;
+   char ed1[50], ed2[50];
+   list = new_guid_list();
+   for (i=0; i<1001; i++) {
+      printf("uid=%d name=%s  gid=%d name=%s\n", i, list->uid_to_name(i, ed1, sizeof(ed1)),
+         i, list->gid_to_name(i, ed2, sizeof(ed2)));
+      printf("uid=%d name=%s  gid=%d name=%s\n", i, list->uid_to_name(i, ed1, sizeof(ed1)),
+         i, list->gid_to_name(i, ed2, sizeof(ed2)));
+   }
+    
+   free_guid_list(list);
+   sm_dump(false);
+
+   return 0;
+}
+#endif
diff --git a/bacula/src/lib/guid_to_name.h b/bacula/src/lib/guid_to_name.h
new file mode 100644 (file)
index 0000000..fd10155
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007 Kern Sibbald
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation, which is 
+   listed in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ * Written by Kern Sibbald, July 2007 to replace idcache.c
+ * 
+ *  Program to convert uid and gid into names, and cache the results
+ *   for preformance reasons.
+ *
+ *  Version $Id: guid_to_name.h 5460 2007-09-05 11:13:57Z kerns $
+ */
+
+class guid_list {
+public:
+   dlist *uid_list;
+   dlist *gid_list;
+
+   char *uid_to_name(uid_t uid, char *name, int maxlen);
+   char *gid_to_name(gid_t gid, char *name, int maxlen);
+};
+
+guid_list *new_guid_list();
+void free_guid_list(guid_list *list);
+
index 882bf9c07f82b9ab8fa284d6ffa5e6c60fd76b1a..3032fc037e8699efbe6cc1282f0f6111e63daadf 100644 (file)
@@ -401,8 +401,10 @@ static void free_common_jcr(JCR *jcr)
       jcr->cached_path = NULL;
       jcr->cached_pnl = 0;
    }
-   free_getuser_cache();
-   free_getgroup_cache();
+   if (jcr->id_list) {
+      free_guid_list(jcr->id_list);
+      jcr->id_list = NULL;
+   }
    free(jcr);
 }
 
@@ -413,7 +415,6 @@ static void free_common_jcr(JCR *jcr)
 void b_free_jcr(const char *file, int line, JCR *jcr)
 {
    Dmsg3(3400, "Enter free_jcr 0x%x from %s:%d\n", jcr, file, line);
-
 #else
 
 void free_jcr(JCR *jcr)
index 0397bd952123f041133f769ac777e91ff5bda8b4..7ecc0858a64fd4133f35a003dd9ba6e84ffffc89 100644 (file)
@@ -67,5 +67,6 @@
 #include "attr.h"
 #include "var.h"
 #include "address_conf.h"
+#include "guid_to_name.h"
 
 #include "protos.h"
index 915c3d900704afc55e9fe21fb52c469481f906bc..00ec1e97b6b0ff14a4f44c840be1738b47af629d 100644 (file)
@@ -38,6 +38,9 @@
 #include "bacula.h"
 #include "jcr.h"
 
+#define get_jcr_from_tsd() NULL
+#define get_jobid_from_tsd() 0
+
 sql_query p_sql_query = NULL;
 sql_escape p_sql_escape = NULL;
 
@@ -60,19 +63,6 @@ char con_fname[500];                  /* Console filename */
 FILE *con_fd = NULL;                  /* Console file descriptor */
 brwlock_t con_lock;                   /* Console lock structure */
 
-static char *catalog_db = NULL;       /* database type */
-static void (*message_callback)(int type, char *msg) = NULL;
-
-const char *host_os = HOST_OS;
-const char *distname = DISTNAME;
-const char *distver = DISTVER;
-static FILE *trace_fd = NULL;
-#if defined(HAVE_WIN32)
-static bool trace = true;
-#else
-static bool trace = false;
-#endif
-
 /* Forward referenced functions */
 
 /* Imported functions */
@@ -83,6 +73,20 @@ static bool trace = false;
 /* Used to allow only one thread close the daemon messages at a time */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 static MSGS *daemon_msgs;              /* global messages */
+static char *catalog_db = NULL;       /* database type */
+static void (*message_callback)(int type, char *msg) = NULL;
+static FILE *trace_fd = NULL;
+#if defined(HAVE_WIN32)
+static bool trace = true;
+#else
+static bool trace = false;
+#endif
+
+/* Constants */
+const char *host_os = HOST_OS;
+const char *distname = DISTNAME;
+const char *distver = DISTVER;
+
 
 void register_message_callback(void msg_callback(int type, char *msg))
 {
@@ -581,8 +585,7 @@ static bool open_dest_file(JCR *jcr, DEST *d, const char *mode)
    if (!d->fd) {
       berrno be;
       d->fd = stdout;
-      Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), d->where,
-            be.bstrerror());
+      Qmsg2(jcr, M_ERROR, 0, _("fopen %s failed: ERR=%s\n"), d->where, be.bstrerror());
       d->fd = NULL;
       return false;
    }
@@ -600,7 +603,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
     int len, dtlen;
     MSGS *msgs;
     BPIPE *bpipe;
-    char *mode;
+    const char *mode;
 
     Dmsg2(850, "Enter dispatch_msg type=%d msg=%s", type, msg);
 
@@ -638,6 +641,9 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
 
     /* Now figure out where to send the message */
     msgs = NULL;
+    if (!jcr) {
+       jcr = get_jcr_from_tsd();
+    }
     if (jcr) {
        msgs = jcr->jcr_msgs;
     }
@@ -658,7 +664,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                    
                    int len = strlen(msg) + 1;
                    esc_msg = check_pool_memory_size(esc_msg, len*2+1);
-                   p_sql_escape(esc_msg, msg, len);
+                   p_sql_escape(jcr, jcr->db, esc_msg, msg, len);
 
                    bstrutime(dt, sizeof(dt), mtime);
                    Mmsg(cmd, "INSERT INTO Log (JobId, Time, LogText) VALUES (%s,'%s','%s')",
@@ -849,7 +855,8 @@ d_msg(const char *file, int line, int level, const char *fmt,...)
     if (level <= debug_level) {
 #ifdef FULL_LOCATION
        if (details) {
-          len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, get_basename(file), line);
+          len = bsnprintf(buf, sizeof(buf), "%s: %s:%d-%u ", 
+                my_name, get_basename(file), line, get_jobid_from_tsd());
        } else {
           len = 0;
        }
@@ -1084,12 +1091,15 @@ Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
        dir->msglen = bvsnprintf(dir->msg, sizeof_pool_memory(dir->msg),
                                 fmt, arg_ptr);
        va_end(arg_ptr);
-       bnet_send(jcr->dir_bsock);
+       jcr->dir_bsock->send();
        return;
     }
 
     msgs = NULL;
     job = NULL;
+    if (!jcr) {
+       jcr = get_jcr_from_tsd();
+    }
     if (jcr) {
        msgs = jcr->jcr_msgs;
        job = jcr->Job;
@@ -1327,10 +1337,13 @@ void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...)
    item->type = type;
    item->mtime = time(NULL);
    strcpy(item->msg, pool_buf);
+   if (!jcr) {
+      jcr = get_jcr_from_tsd();
+   }
    /* If no jcr or dequeuing send to daemon to avoid recursion */
    if (!jcr || jcr->dequeuing) {
       /* jcr==NULL => daemon message, safe to send now */
-      Jmsg(NULL, item->type, item->mtime, "%s", item->msg);
+      Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
       free(item);
    } else {
       /* Queue message for later sending */
index 191e02c42b6e51dfb8dfa0b84c0e1a2b4a52784c..476d3611a9b9e6b506978e195b630cfd8f6aa015 100644 (file)
@@ -146,8 +146,9 @@ void Jmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
 void Qmsg(JCR *jcr, int type, time_t mtime, const char *fmt,...);
 bool get_trace(void);
 
+struct B_DB;
 typedef void (*sql_query)(JCR *jcr, const char *cmd);
-typedef void (*sql_escape)(char *snew, char *old, int len);
+typedef void (*sql_escape)(JCR *jcr, B_DB* db, char *snew, char *old, int len);
 
 extern DLL_IMP_EXP sql_query     p_sql_query;
 extern DLL_IMP_EXP sql_escape    p_sql_escape;
index a7a5d59e105fb947e896e7faeba40ce73cb1fab6..470ac528184c3120a2eae3a30fbaa0b231eb165c 100644 (file)
@@ -134,7 +134,7 @@ RES   **new_res_head();
 
 
 /* Resource routines */
-RES *GetResWithName(int rcode, char *name);
+RES *GetResWithName(int rcode, const char *name);
 RES *GetNextRes(int rcode, RES *res);
 void b_LockRes(const char *file, int line);
 void b_UnlockRes(const char *file, int line);
index e3b9340bdc1928cc474193d2947f5f3d1b1b47e6..c1ed9ead163e4361ffd3c980ab43afd914d989c5 100644 (file)
@@ -34,7 +34,7 @@
 class JCR;
 
 /* attr.c */
-ATTR     *new_attr();
+ATTR     *new_attr(JCR *jcr);
 void      free_attr(ATTR *attr);
 int       unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr);
 void      build_attr_output_fnames(JCR *jcr, ATTR *attr);
@@ -240,12 +240,6 @@ int              net_connect             (int port);
 BSOCK *          bnet_bind               (int port);
 BSOCK *          bnet_accept             (BSOCK *bsock, char *who);
 
-/* idcache.c */
-char *getuser(uid_t uid);
-void free_getuser_cache();
-char *getgroup (gid_t gid);
-void free_getgroup_cache();
-
 /* python.c */
 typedef int (EVENT_HANDLER)(JCR *jcr, const char *event);
 void init_python_interpreter(const char *progname, const char *scripts,
index 59a41e8d8c96a4c736d74c8b123556d84c0f7f05..886f1a220b79119eafe5a63391fa26a20581b105 100644 (file)
@@ -87,7 +87,7 @@ void b_UnlockRes(const char *file, int line)
  * Return resource of type rcode that matches name
  */
 RES *
-GetResWithName(int rcode, char *name)
+GetResWithName(int rcode, const char *name)
 {
    RES *res;
    int rindex = rcode - r_first;
index 0c50f13579af3d8b7680168b53a1b461a53c253c..fd4273b3b67003b13d30be28acd559b09b538b72 100644 (file)
@@ -689,6 +689,13 @@ int Console::read()
          if (mainWin->m_commDebug) Pmsg0(000, "RUN CMD\n");
          new runCmdPage();
          break;
+      case BNET_START_RTREE:
+         if (mainWin->m_commDebug) Pmsg0(000, "START RTREE CMD\n");
+         new restorePage();
+         break;
+      case BNET_END_RTREE:
+         if (mainWin->m_commDebug) Pmsg0(000, "END RTREE CMD\n");
+         break;
       case BNET_ERROR_MSG:
          if (mainWin->m_commDebug) Pmsg0(000, "ERROR MSG\n");
          m_sock->recv();              /* get the message */
index 6cda1e5a1b2c3719be1b79f6e573330a40ad3984..ee8a9d3321c50c2ba091354431282a82b1934671 100644 (file)
@@ -251,6 +251,7 @@ void MediaList::createContextMenu()
    /* connect to the action specific to this pages class */
    connect(actionRefreshMediaList, SIGNAL(triggered()), this,
                 SLOT(populateTree()));
+   connect(actionAllVolumes, SIGNAL(triggered()), this, SLOT(allVolumes()));
    connect(actionAllVolumesFromPool, SIGNAL(triggered()), this, SLOT(allVolumesFromPool()));
    connect(actionVolumeFromPool, SIGNAL(triggered()), this, SLOT(volumeFromPool()));
 }
@@ -340,6 +341,13 @@ void MediaList::allVolumesFromPool()
    populateTree();
 }
 
+void MediaList::allVolumes()
+{
+   QString cmd = "update volume allfrompools";
+   consoleCommand(cmd);
+   populateTree();
+}
+
 /*
  * Called from the signal of the context sensitive menu to purge!
  */
index 823d87137c7c74e14a9750188b9c1c52019c2112..c8cb0a5f535706abdd7ff9e84e213dc50868b6e6 100644 (file)
@@ -60,6 +60,7 @@ private slots:
    void pruneVolume();
    void relabelVolume();
    void allVolumesFromPool();
+   void allVolumes();
    void volumeFromPool();
 
 private:
index b4117bb5f419cdd2503b0da0f1fe894f281ded66..058a4f825151f2682b258b5e8c0fe94df625e311 100644 (file)
     <string>Update all Volumes From Pool</string>
    </property>
   </action>
+  <action name="actionAllVolumes" >
+   <property name="icon" >
+    <iconset resource="../main.qrc" >:/images/cartridge-edit.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Update all Volumes from all Pools</string>
+   </property>
+   <property name="iconText" >
+    <string>Update all Volumes from all Pools</string>
+   </property>
+   <property name="toolTip" >
+    <string>Update all Volumes from all Pools</string>
+   </property>
+   <property name="statusTip" >
+    <string>Update all Volumes from all Pools</string>
+   </property>
+  </action>
   <action name="actionVolumeFromPool" >
    <property name="icon" >
     <iconset resource="../main.qrc" >:/images/cartridge-edit.png</iconset>
index cc13480ac3011eb3855cebe9720ad4c65dcb4c6a..379bf483fbe34bae0017893e60365e7cb8c15d54 100644 (file)
@@ -170,17 +170,19 @@ void prerestorePage::okButtonPushed()
    if (mainWin->m_commandDebug) {
       Pmsg1(000, "preRestore command \'%s\'\n", cmd.toUtf8().data());
    }
-   consoleCommand(cmd);
+   m_console->write_dir(cmd.toUtf8().data());
+// consoleCommand(cmd);
+
    /* Note, do not turn notifier back on here ... */
    if (selectFilesRadio->isChecked()) {
       setConsoleCurrent();
-      new restorePage();
+//    new restorePage();
       closeStackPage();
    } else {
-      m_console->notify(true);
       closeStackPage();
       mainWin->resetFocus();
    }
+   m_console->notify(true);
 }
 
 
index 6d22c70fe4508b3e454da83dfaa39e1802938d63..e1594a39b9bec92a936fff99a66bf28733108e50 100644 (file)
@@ -51,8 +51,8 @@ restoreTree::restoreTree()
    m_populated = false;
 
    dockPage();
-   m_winRegExpDrive.setPattern("^[a-z]:/$");
-   m_winRegExpPath.setPattern("^[a-z]:/");
+   m_winRegExpDrive.setPattern("^[a-zA-Z]:/$");
+   m_winRegExpPath.setPattern("^[a-zA-Z]:/");
    m_slashregex.setPattern("/");
    m_debugCnt = 0;
    m_debugTrap = true;
index 1414868491401cdc33175b2db16858e0dffd7a2a..e8978ec7bce2b05e616fd4306f6a512ecac9472f 100644 (file)
@@ -1,18 +1,7 @@
-/*
- *
- *  ansi_label.c routines to handle ANSI (and perhaps one day IBM)
- *   tape labels.
- *
- *   Kern Sibbald, MMV
- *
- *
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2005-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ *  ansi_label.c routines to handle ANSI (and perhaps one day IBM)
+ *   tape labels.
+ *
+ *   Kern Sibbald, MMV
+ *
+ *
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"                   /* pull in global headers */
 #include "stored.h"                   /* pull in Storage Deamon headers */
@@ -115,6 +115,7 @@ int read_ansi_ibm_label(DCR *dcr)
             if (strncmp("VOL1", label, 4) == 0) {
                ok = true;
                dev->label_type = B_ANSI_LABEL;
+               Dmsg0(100, "Got ANSI VOL1 label\n");
             } else {
                /* Try EBCDIC */
                ebcdic_to_ascii(label, label, sizeof(label));
@@ -122,6 +123,7 @@ int read_ansi_ibm_label(DCR *dcr)
                   ok = true;;
                   dev->label_type = B_IBM_LABEL;
                   Dmsg0(100, "Found IBM label.\n");
+                  Dmsg0(100, "Got IBM VOL1 label\n");
                }
             }       
          }
@@ -168,6 +170,7 @@ int read_ansi_ibm_label(DCR *dcr)
                dev->VolHdr.VolumeName);
             return VOL_NAME_ERROR;     /* Not a Bacula label */
          }
+         Dmsg0(100, "Got HDR1 label\n");
          break;
       case 2:
          if (dev->label_type == B_IBM_LABEL) {
@@ -178,6 +181,7 @@ int read_ansi_ibm_label(DCR *dcr)
             Mmsg0(jcr->errmsg, _("No HDR2 label while reading ANSI/IBM label.\n"));
             return VOL_LABEL_ERROR;
          }
+         Dmsg0(100, "Got ANSI HDR2 label\n");
          break;
       default:
          if (stat == 0) {
@@ -192,6 +196,7 @@ int read_ansi_ibm_label(DCR *dcr)
             Mmsg0(jcr->errmsg, _("Unknown or bad ANSI/IBM label record.\n"));
             return VOL_LABEL_ERROR;
          }
+         Dmsg0(100, "Got HDR label\n");
          break;
       }
    }
index f2c4485c303d309ec543d883da7f4a953150a631..49f6551fc54a719ea13dc57fcca3043620736c58 100644 (file)
@@ -1,15 +1,7 @@
-/*
- * Authenticate caller
- *
- *   Kern Sibbald, October 2000
- *
- *   Version $Id$
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * Authenticate caller
+ *
+ *   Kern Sibbald, October 2000
+ *
+ *   Version $Id$
+ *
+ */
+
 
 #include "bacula.h"
 #include "stored.h"
 
+const int dbglvl = 50;
+
 static char Dir_sorry[] = "3999 No go\n";
 static char OK_hello[]  = "3000 OK Hello\n";
 
@@ -56,12 +59,12 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    alist *verify_list = NULL;
 
    if (rcode != R_DIRECTOR) {
-      Dmsg1(50, "I only authenticate Directors, not %d\n", rcode);
+      Dmsg1(dbglvl, "I only authenticate Directors, not %d\n", rcode);
       Emsg1(M_FATAL, 0, _("I only authenticate Directors, not %d\n"), rcode);
       return 0;
    }
    if (bs->msglen < 25 || bs->msglen > 500) {
-      Dmsg2(50, "Bad Hello command from Director at %s. Len=%d.\n",
+      Dmsg2(dbglvl, "Bad Hello command from Director at %s. Len=%d.\n",
             bs->who(), bs->msglen);
       Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"),
             bs->who(), bs->msglen);
@@ -72,7 +75,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
 
    if (sscanf(bs->msg, "Hello Director %127s calling", dirname) != 1) {
       bs->msg[100] = 0;
-      Dmsg2(50, "Bad Hello command from Director at %s: %s\n",
+      Dmsg2(dbglvl, "Bad Hello command from Director at %s: %s\n",
             bs->who(), bs->msg);
       Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"),
             bs->who(), bs->msg);
@@ -85,7 +88,7 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
          break;
    }
    if (!director) {
-      Dmsg2(50, "Connection from unknown Director %s at %s rejected.\n",
+      Dmsg2(dbglvl, "Connection from unknown Director %s at %s rejected.\n",
             dirname, bs->who());
       Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"
        "Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"),
@@ -113,10 +116,10 @@ static int authenticate(int rcode, BSOCK *bs, JCR* jcr)
    if (auth_success) {
       auth_success = cram_md5_respond(bs, director->password, &tls_remote_need, &compatible);
       if (!auth_success) {
-         Dmsg1(50, "cram_get_auth failed with %s\n", bs->who());
+         Dmsg1(dbglvl, "cram_get_auth failed with %s\n", bs->who());
       }
    } else {
-      Dmsg1(50, "cram_auth failed with %s\n", bs->who());
+      Dmsg1(dbglvl, "cram_auth failed with %s\n", bs->who());
    }
 
    if (!auth_success) {
@@ -174,13 +177,13 @@ int authenticate_director(JCR *jcr)
    BSOCK *dir = jcr->dir_bsock;
 
    if (!authenticate(R_DIRECTOR, dir, jcr)) {
-      bnet_fsend(dir, "%s", Dir_sorry);
-      Dmsg1(50, "Unable to authenticate Director at %s.\n", dir->who());
+      dir->fsend("%s", Dir_sorry);
+      Dmsg1(dbglvl, "Unable to authenticate Director at %s.\n", dir->who());
       Emsg1(M_ERROR, 0, _("Unable to authenticate Director at %s.\n"), dir->who());
       bmicrosleep(5, 0);
       return 0;
    }
-   return bnet_fsend(dir, "%s", OK_hello);
+   return dir->fsend("%s", OK_hello);
 }
 
 int authenticate_filed(JCR *jcr)
@@ -213,10 +216,10 @@ int authenticate_filed(JCR *jcr)
        /* Respond to his challenge */
        auth_success = cram_md5_respond(fd, jcr->sd_auth_key, &tls_remote_need, &compatible);
        if (!auth_success) {
-          Dmsg1(50, "cram-get-auth failed with %s\n", fd->who());
+          Dmsg1(dbglvl, "cram-get-auth failed with %s\n", fd->who());
        }
    } else {
-      Dmsg1(50, "cram-auth failed with %s\n", fd->who());
+      Dmsg1(dbglvl, "cram-auth failed with %s\n", fd->who());
    }
 
    if (!auth_success) {
index 3776f92e2edf4286967e3db0ec1576f2eddc88bf..1d9cad0eba5c89b1ef0b4e12f2cf23d535c11771 100644 (file)
@@ -493,9 +493,9 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd)
    if (!dev->is_autochanger() || !dcr->device->changer_name ||
        !dcr->device->changer_command) {
       if (strcmp(cmd, "drives") == 0) {
-         bnet_fsend(dir, "drives=1\n");
+         dir->fsend("drives=1\n");
       }
-      bnet_fsend(dir, _("3993 Device %s not an autochanger device.\n"),
+      dir->fsend(_("3993 Device %s not an autochanger device.\n"),
          dev->print_name());
       return false;
    }
@@ -506,7 +506,7 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd)
       if (changer_res) {
          drives = changer_res->device->size();
       }
-      bnet_fsend(dir, "drives=%d\n", drives);
+      dir->fsend("drives=%d\n", drives);
       Dmsg1(100, "drives=%d\n", drives);
       return true;
    }
@@ -516,10 +516,10 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd)
    /* Now issue the command */
    changer = edit_device_codes(dcr, changer, 
                  dcr->device->changer_command, cmd);
-   bnet_fsend(dir, _("3306 Issuing autochanger \"%s\" command.\n"), cmd);
+   dir->fsend(_("3306 Issuing autochanger \"%s\" command.\n"), cmd);
    bpipe = open_bpipe(changer, timeout, "r");
    if (!bpipe) {
-      bnet_fsend(dir, _("3996 Open bpipe failed.\n"));
+      dir->fsend(_("3996 Open bpipe failed.\n"));
       goto bail_out;
    }
    if (strcmp(cmd, "list") == 0) {
@@ -538,7 +538,7 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd)
       /* Strip any leading space in front of # of slots */
       for (p=buf; B_ISSPACE(*p); p++)
         { }
-      bnet_fsend(dir, "slots=%s", p);
+      dir->fsend("slots=%s", p);
       Dmsg1(100, "<stored: %s", dir->msg);
    } 
                  
@@ -546,7 +546,7 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd)
    if (stat != 0) {
       berrno be;
       be.set_errno(stat);
-      bnet_fsend(dir, _("Autochanger error: ERR=%s\n"), be.bstrerror());
+      dir->fsend(_("Autochanger error: ERR=%s\n"), be.bstrerror());
    }
    bnet_sig(dir, BNET_EOD);
    ok = true;
index 247eb01e41c42947af1416aa4626e8f8ddbb9f6a..c161f30d381eb857bf2822fb4e05c85b16ec358a 100644 (file)
@@ -45,7 +45,7 @@ Director {
 Device {
   Name = FileStorage
   Media Type = File
-  Archive Device = /tmp
+  Archive Device = @archivedir@
   LabelMedia = yes;                   # lets Bacula label unlabeled media
   Random Access = Yes;
   AutomaticMount = yes;               # when device opened, read it
index 6d6cba94f95c31ae6fd024310764112c8d02006c..53f40d9738efcc6516fd7ad59c244c72425a6989 100644 (file)
@@ -245,7 +245,7 @@ static void do_extract(char *devname)
 
    free(jcr->where);
    jcr->where = bstrdup(where);
-   attr = new_attr();
+   attr = new_attr(jcr);
 
    compress_buf = get_memory(compress_buf_size);
 
index d23182a7eed9ed00022e6668fdce554fa55130e7..e5b95b624db4a98acd1838415a184553ddbcde48 100644 (file)
@@ -576,9 +576,12 @@ bool write_block_to_dev(DCR *dcr)
             dev->VolCatInfo.VolCatName,
             dev->file, dev->block_num, dev->print_name(), wlen, stat);
       }
-      Dmsg7(100, "=== Write error. fd=%d size=%u rtn=%d dev_blk=%d blk_blk=%d errno=%d: ERR=%s\n",
-         dev->fd(), wlen, stat, dev->block_num, block->BlockNumber, 
-         dev->dev_errno, strerror(dev->dev_errno));
+      if (debug_level >= 100) {
+         berrno be;
+         Dmsg7(100, "=== Write error. fd=%d size=%u rtn=%d dev_blk=%d blk_blk=%d errno=%d: ERR=%s\n",
+            dev->fd(), wlen, stat, dev->block_num, block->BlockNumber, 
+            dev->dev_errno, be.bstrerror(dev->dev_errno));
+      }
 
       ok = terminate_writing_volume(dcr);
       if (!ok && !forge_on) {
@@ -767,9 +770,10 @@ static bool terminate_writing_volume(DCR *dcr)
       /* This may not be fatal since we already wrote an EOF */
       Jmsg(dcr->jcr, M_ERROR, 0, "%s", dev->errmsg);
    }
+
 bail_out:
    dev->set_ateot();                  /* no more writing this tape */
-   Dmsg1(100, "Leave terminate_writing_volume -- %s\n", ok?"OK":"ERROR");
+   Dmsg1(50, "*** Leave terminate_writing_volume -- %s\n", ok?"OK":"ERROR");
    return ok;
 }
 
@@ -1013,7 +1017,7 @@ reread:
    /* Continue here for successful read */
 
    block->read_len = stat;      /* save length read */
-   if (dev->at_eof() && block->read_len == 80 && 
+   if (block->read_len == 80 && 
         (dcr->VolCatInfo.LabelType != B_BACULA_LABEL ||
          dcr->device->label_type != B_BACULA_LABEL)) {
       /* ***FIXME*** should check label */
index d556cb40913102bac80b975d8c28f54795e2ff9a..92d6fbcc95682d55a8735a5bab602deda575da35 100644 (file)
@@ -1,15 +1,7 @@
-/*
- *
- *  Dumb program to do an "ls" of a Bacula 1.0 mortal file.
- * 
- *  Kern Sibbald, MM
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ *  Dumb program to do an "ls" of a Bacula 1.0 mortal file.
+ * 
+ *  Kern Sibbald, MM
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"
 #include "stored.h"
@@ -137,8 +137,9 @@ int main (int argc, char *argv[])
 
       case 'e':                    /* exclude list */
          if ((fd = fopen(optarg, "rb")) == NULL) {
+            berrno be;
             Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
-               optarg, strerror(errno));
+               optarg, be.bstrerror());
             exit(1);
          }
          while (fgets(line, sizeof(line), fd) != NULL) {
@@ -151,8 +152,9 @@ int main (int argc, char *argv[])
 
       case 'i':                    /* include list */
          if ((fd = fopen(optarg, "rb")) == NULL) {
+            berrno be;
             Pmsg2(0, _("Could not open include file: %s, ERR=%s\n"),
-               optarg, strerror(errno));
+               optarg, be.bstrerror());
             exit(1);
          }
          while (fgets(line, sizeof(line), fd) != NULL) {
@@ -227,7 +229,7 @@ int main (int argc, char *argv[])
       }
       dcr = jcr->dcr;
       rec = new_record();
-      attr = new_attr();
+      attr = new_attr(jcr);
       /*
        * Assume that we have already read the volume label.
        * If on second or subsequent volume, adjust buffer pointer
@@ -273,7 +275,7 @@ static void do_blocks(char *infname)
    char buf1[100], buf2[100];
    for ( ;; ) {
       if (!read_block_from_device(dcr, NO_BLOCK_NUMBER_CHECK)) {
-         Dmsg1(100, "!read_block(): ERR=%s\n", dev->strerror());
+         Dmsg1(100, "!read_block(): ERR=%s\n", dev->bstrerror());
          if (dev->at_eot()) {
             if (!mount_next_read_volume(dcr)) {
                Jmsg(jcr, M_INFO, 0, _("Got EOM at file %u on device %s, Volume \"%s\"\n"),
index c8e38ad0fdad9fbc939b0a14e16c1cdeaccab08f..71254e5bbf8035d618740a511a4b5bacb1d440c3 100644 (file)
@@ -355,7 +355,7 @@ static bool bscan_mount_next_read_volume(DCR *dcr)
 
 static void do_scan()
 {
-   attr = new_attr();
+   attr = new_attr(bjcr);
 
    memset(&ar, 0, sizeof(ar));
    memset(&pr, 0, sizeof(pr));
index 396e68a6e4cd86b8877f78858609868f36e4341b..95a05e075abd295baa0db0702fcedf11c9656cf1 100644 (file)
@@ -152,7 +152,7 @@ void *handle_connection_request(void *arg)
 
    if (bs->recv() <= 0) {
       Emsg0(M_ERROR, 0, _("Connection request failed.\n"));
-      bnet_close(bs);
+      bs->close();
       return NULL;
    }
 
@@ -160,8 +160,9 @@ void *handle_connection_request(void *arg)
     * Do a sanity check on the message received
     */
    if (bs->msglen < 25 || bs->msglen > (int)sizeof(name)) {
+      Dmsg1(000, "<filed: %s", bs->msg);
       Emsg1(M_ERROR, 0, _("Invalid connection. Len=%d\n"), bs->msglen);
-      bnet_close(bs);
+      bs->close();
       return NULL;
    }
    /*
@@ -169,6 +170,9 @@ void *handle_connection_request(void *arg)
     *   call FD handler.
     */
    Dmsg1(110, "Conn: %s", bs->msg);
+   if (debug_level == 3) {
+      Dmsg1(000, "<filed: %s", bs->msg);
+   }
    if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
       Dmsg0(110, "Got a FD connection\n");
       handle_filed_connection(bs, name);
@@ -186,7 +190,8 @@ void *handle_connection_request(void *arg)
    /* Initialize FD start condition variable */
    int errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
    if (errstat != 0) {
-      Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), strerror(errstat));
+      berrno be;
+      Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat));
       goto bail_out;
    }
 
@@ -216,7 +221,7 @@ void *handle_connection_request(void *arg)
         if (strncmp(cmds[i].cmd, bs->msg, strlen(cmds[i].cmd)) == 0) {
            if ((!cmds[i].monitoraccess) && (jcr->director->monitor)) {
               Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd);
-              bnet_fsend(bs, invalid_cmd);
+              bs->fsend(invalid_cmd);
               bs->signal(BNET_EOD);
               break;
            }
@@ -230,14 +235,14 @@ void *handle_connection_request(void *arg)
         }
       }
       if (!found) {                   /* command not found */
-        bnet_fsend(bs, derrmsg);
+        bs->fsend(derrmsg);
         break;
       }
    }
 bail_out:
    generate_daemon_event(jcr, "JobEnd");
    dequeue_messages(jcr);             /* send any queued messages */
-   bnet_sig(bs, BNET_TERMINATE);
+   bs->signal(BNET_TERMINATE);
    free_jcr(jcr);
    return NULL;
 }
@@ -271,12 +276,12 @@ static bool setdebug_cmd(JCR *jcr)
 
    Dmsg1(10, "setdebug_cmd: %s", dir->msg);
    if (sscanf(dir->msg, "setdebug=%d trace=%d", &level, &trace_flag) != 2 || level < 0) {
-      bnet_fsend(dir, _("3991 Bad setdebug command: %s\n"), dir->msg);
+      dir->fsend(_("3991 Bad setdebug command: %s\n"), dir->msg);
       return 0;
    }
    debug_level = level;
    set_trace(trace_flag);
-   return bnet_fsend(dir, OKsetdebug, level);
+   return dir->fsend(OKsetdebug, level);
 }
 
 
@@ -292,7 +297,7 @@ static bool cancel_cmd(JCR *cjcr)
 
    if (sscanf(dir->msg, "cancel Job=%127s", Job) == 1) {
       if (!(jcr=get_jcr_by_full_name(Job))) {
-         bnet_fsend(dir, _("3904 Job %s not found.\n"), Job);
+         dir->fsend(_("3904 Job %s not found.\n"), Job);
       } else {
          oldStatus = jcr->JobStatus;
          set_jcr_job_status(jcr, JS_Canceled);
@@ -317,13 +322,13 @@ static bool cancel_cmd(JCR *cjcr)
             pthread_cond_broadcast(&wait_device_release);
          }
          Jmsg(jcr, M_INFO, 0, _("Job %s marked to be canceled.\n"), jcr->Job);
-         bnet_fsend(dir, _("3000 Job %s marked to be canceled.\n"), jcr->Job);
+         dir->fsend(_("3000 Job %s marked to be canceled.\n"), jcr->Job);
          free_jcr(jcr);
       }
    } else {
-      bnet_fsend(dir, _("3903 Error scanning cancel command.\n"));
+      dir->fsend(_("3903 Error scanning cancel command.\n"));
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return 1;
 }
 
@@ -397,18 +402,18 @@ static bool do_label(JCR *jcr, int relabel)
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3903 Error scanning label command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3903 Error scanning label command: %s\n"), jcr->errmsg);
    }
    free_memory(oldname);
    free_memory(newname);
    free_memory(poolname);
    free_memory(mtype);
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -452,8 +457,8 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    /* Set old volume name for open if relabeling */
    bstrncpy(dcr->VolCatInfo.VolCatName, volname, sizeof(dcr->VolCatInfo.VolCatName));
    if (dev->open(dcr, mode) < 0) {
-      bnet_fsend(dir, _("3910 Unable to open device %s: ERR=%s\n"),
-         dev->print_name(), dev->strerror());
+      dir->fsend(_("3910 Unable to open device %s: ERR=%s\n"),
+         dev->print_name(), dev->bstrerror());
       goto bail_out;      
    }
 
@@ -468,7 +473,7 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
    case VOL_LABEL_ERROR:
    case VOL_OK:
       if (!relabel) {
-         bnet_fsend(dir, _(
+         dir->fsend(_(
             "3920 Cannot label Volume because it is already labeled: \"%s\"\n"),
              dev->VolHdr.VolumeName);
          break;
@@ -476,11 +481,11 @@ static void label_volume_if_ok(DCR *dcr, char *oldname,
 
       /* Relabel request. If oldname matches, continue */
       if (strcmp(oldname, dev->VolHdr.VolumeName) != 0) {
-         bnet_fsend(dir, _("3921 Wrong volume mounted.\n"));
+         dir->fsend(_("3921 Wrong volume mounted.\n"));
          break;
       }
       if (dev->label_type != B_BACULA_LABEL) {
-         bnet_fsend(dir, _("3922 Cannot relabel an ANSI/IBM labeled Volume.\n"));
+         dir->fsend(_("3922 Cannot relabel an ANSI/IBM labeled Volume.\n"));
          break;
       }
       /* Fall through wanted! */
@@ -488,20 +493,20 @@ 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 */)) {
-         bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), dev->bstrerror());
+         dir->fsend(_("3912 Failed to label Volume: ERR=%s\n"), dev->bstrerror());
          break;
       }
       bstrncpy(dcr->VolumeName, newname, sizeof(dcr->VolumeName));
       /* The following 3000 OK label. string is scanned in ua_label.c */
-      bnet_fsend(dir, "3000 OK label. VolBytes=%s DVD=%d Volume=\"%s\" Device=%s\n",
+      dir->fsend("3000 OK label. VolBytes=%s DVD=%d Volume=\"%s\" Device=%s\n",
                  edit_uint64(dev->VolCatInfo.VolCatBytes, ed1),
                  dev->is_dvd()?1:0, newname, dev->print_name());
       break;
    case VOL_NO_MEDIA:
-      bnet_fsend(dir, _("3914 Failed to label Volume (no media): ERR=%s\n"), dev->bstrerror());
+      dir->fsend(_("3914 Failed to label Volume (no media): ERR=%s\n"), dev->bstrerror());
       break;
    default:
-      bnet_fsend(dir, _("3913 Cannot label Volume. "
+      dir->fsend(_("3913 Cannot label Volume. "
 "Unknown status %d from read_volume_label()\n"), label_status);
       break;
    }
@@ -534,11 +539,11 @@ static bool read_label(DCR *dcr)
    dev->clear_labeled();              /* force read of label */
    switch (read_dev_volume_label(dcr)) {
    case VOL_OK:
-      bnet_fsend(dir, _("3001 Mounted Volume: %s\n"), dev->VolHdr.VolumeName);
+      dir->fsend(_("3001 Mounted Volume: %s\n"), dev->VolHdr.VolumeName);
       ok = true;
       break;
    default:
-      bnet_fsend(dir, _("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
+      dir->fsend(_("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
          dev->print_name(), jcr->errmsg);
       ok = false;
       break;
@@ -648,7 +653,7 @@ static bool mount_cmd(JCR *jcr)
             /* Someone is waiting, wake him */
             Dmsg0(100, "Waiting for mount. Attempting to wake thread\n");
             dev->set_blocked(BST_MOUNT);
-            bnet_fsend(dir, "3001 OK mount. Device=%s\n", 
+            dir->fsend("3001 OK mount. Device=%s\n", 
                dev->print_name());
             pthread_cond_broadcast(&dev->wait_next_vol);
             Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)dcr->jcr->JobId);
@@ -663,7 +668,7 @@ static bool mount_cmd(JCR *jcr)
             }
             /* We freed the device, so reopen it and wake any waiting threads */
             if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
-               bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
+               dir->fsend(_("3901 open device failed: ERR=%s\n"),
                   dev->bstrerror());
                if (dev->blocked() == BST_UNMOUNTED) {
                   /* We blocked the device, so unblock it */
@@ -683,10 +688,10 @@ static bool mount_cmd(JCR *jcr)
                dev->set_blocked(BST_MOUNT);
             }
             if (dev->is_labeled()) {
-               bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
+               dir->fsend(_("3001 Device %s is mounted with Volume \"%s\"\n"),
                   dev->print_name(), dev->VolHdr.VolumeName);
             } else {
-               bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+               dir->fsend(_("3905 Device %s open but no Bacula volume is mounted.\n"
                                  "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                           dev->print_name());
             }
@@ -696,12 +701,12 @@ static bool mount_cmd(JCR *jcr)
             break;
 
          case BST_DOING_ACQUIRE:
-            bnet_fsend(dir, _("3001 Device %s is doing acquire.\n"),
+            dir->fsend(_("3001 Device %s is doing acquire.\n"),
                        dev->print_name());
             break;
 
          case BST_WRITING_LABEL:
-            bnet_fsend(dir, _("3903 Device %s is being labeled.\n"), 
+            dir->fsend(_("3903 Device %s is being labeled.\n"), 
                dev->print_name());
             break;
 
@@ -711,55 +716,55 @@ static bool mount_cmd(JCR *jcr)
             }
             if (dev->is_open()) {
                if (dev->is_labeled()) {
-                  bnet_fsend(dir, _("3001 Device %s is mounted with Volume \"%s\"\n"),
+                  dir->fsend(_("3001 Device %s is mounted with Volume \"%s\"\n"),
                      dev->print_name(), dev->VolHdr.VolumeName);
                } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                  dir->fsend(_("3905 Device %s open but no Bacula volume is mounted.\n"
                                  "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                              dev->print_name());
                }
             } else if (dev->is_tape()) {
                if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
-                  bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"),
+                  dir->fsend(_("3901 open device failed: ERR=%s\n"),
                      dev->bstrerror());
                   break;
                }
                read_label(dcr);
                if (dev->is_labeled()) {
-                  bnet_fsend(dir, _("3001 Device %s is already mounted with Volume \"%s\"\n"),
+                  dir->fsend(_("3001 Device %s is already mounted with Volume \"%s\"\n"),
                      dev->print_name(), dev->VolHdr.VolumeName);
                } else {
-                  bnet_fsend(dir, _("3905 Device %s open but no Bacula volume is mounted.\n"
+                  dir->fsend(_("3905 Device %s open but no Bacula volume is mounted.\n"
                                     "If this is not a blank tape, try unmounting and remounting the Volume.\n"),
                              dev->print_name());
                }
             } else if (dev->is_unmountable()) {
                if (dev->mount(1)) {
-                  bnet_fsend(dir, _("3002 Device %s is mounted.\n"), 
+                  dir->fsend(_("3002 Device %s is mounted.\n"), 
                      dev->print_name());
                } else {
-                  bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+                  dir->fsend(_("3907 %s"), dev->bstrerror());
                } 
             } else { /* must be file */
-               bnet_fsend(dir, _("3906 File device %s is always mounted.\n"),
+               dir->fsend(_("3906 File device %s is always mounted.\n"),
                   dev->print_name());
             }
             break;
 
          default:
-            bnet_fsend(dir, _("3905 Bizarre wait state %d\n"), dev->blocked());
+            dir->fsend(_("3905 Bizarre wait state %d\n"), dev->blocked());
             break;
          }
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3909 Error scanning mount command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3909 Error scanning mount command: %s\n"), jcr->errmsg);
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -785,14 +790,14 @@ static bool unmount_cmd(JCR *jcr)
             }
             if (dev->is_unmountable()) {
                if (dev->unmount(0)) {
-                  bnet_fsend(dir, _("3002 Device %s unmounted.\n"), 
+                  dir->fsend(_("3002 Device %s unmounted.\n"), 
                      dev->print_name());
                } else {
-                  bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+                  dir->fsend(_("3907 %s"), dev->bstrerror());
                } 
             } else {
                Dmsg0(90, "Device already unmounted\n");
-               bnet_fsend(dir, _("3901 Device %s is already unmounted.\n"), 
+               dir->fsend(_("3901 Device %s is already unmounted.\n"), 
                   dev->print_name());
             }
          } else if (dev->blocked() == BST_WAITING_FOR_SYSOP) {
@@ -803,19 +808,19 @@ static bool unmount_cmd(JCR *jcr)
                dev->close();
             }
             if (dev->is_unmountable() && !dev->unmount(0)) {
-               bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+               dir->fsend(_("3907 %s"), dev->bstrerror());
             } else {
                dev->set_blocked(BST_UNMOUNTED_WAITING_FOR_SYSOP);
-               bnet_fsend(dir, _("3001 Device %s unmounted.\n"), 
+               dir->fsend(_("3001 Device %s unmounted.\n"), 
                   dev->print_name());
             }
 
          } else if (dev->blocked() == BST_DOING_ACQUIRE) {
-            bnet_fsend(dir, _("3902 Device %s is busy in acquire.\n"), 
+            dir->fsend(_("3902 Device %s is busy in acquire.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_WRITING_LABEL) {
-            bnet_fsend(dir, _("3903 Device %s is being labeled.\n"), 
+            dir->fsend(_("3903 Device %s is being labeled.\n"), 
                dev->print_name());
 
          } else if (dev->is_busy()) {
@@ -834,23 +839,23 @@ static bool unmount_cmd(JCR *jcr)
                dev->close();
             }
             if (dev->is_unmountable() && !dev->unmount(0)) {
-               bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
+               dir->fsend(_("3907 %s"), dev->bstrerror());
             } else {
-               bnet_fsend(dir, _("3002 Device %s unmounted.\n"), 
+               dir->fsend(_("3002 Device %s unmounted.\n"), 
                   dev->print_name());
             }
          }
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3907 Error scanning unmount command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3907 Error scanning unmount command: %s\n"), jcr->errmsg);
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -879,28 +884,28 @@ static bool release_cmd(JCR *jcr)
                unload_autochanger(dcr, -1);
             }
             Dmsg0(90, "Device already released\n");
-            bnet_fsend(dir, _("3921 Device %s already released.\n"), 
+            dir->fsend(_("3921 Device %s already released.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_WAITING_FOR_SYSOP) {
             Dmsg2(90, "%d waiter dev_block=%d.\n", dev->num_waiting,
                dev->blocked());
             unload_autochanger(dcr, -1);
-            bnet_fsend(dir, _("3922 Device %s waiting for sysop.\n"), 
+            dir->fsend(_("3922 Device %s waiting for sysop.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_UNMOUNTED_WAITING_FOR_SYSOP) {
             Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
                dev->blocked());
-            bnet_fsend(dir, _("3922 Device %s waiting for mount.\n"), 
+            dir->fsend(_("3922 Device %s waiting for mount.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_DOING_ACQUIRE) {
-            bnet_fsend(dir, _("3923 Device %s is busy in acquire.\n"), 
+            dir->fsend(_("3923 Device %s is busy in acquire.\n"), 
                dev->print_name());
 
          } else if (dev->blocked() == BST_WRITING_LABEL) {
-            bnet_fsend(dir, _("3914 Device %s is being labeled.\n"), 
+            dir->fsend(_("3914 Device %s is being labeled.\n"), 
                dev->print_name());
 
          } else if (dev->is_busy()) {
@@ -909,20 +914,20 @@ static bool release_cmd(JCR *jcr)
             Dmsg0(90, "Device not in use, releaseing\n");
             unload_autochanger(dcr, -1);
             release_volume(dcr);
-            bnet_fsend(dir, _("3022 Device %s released.\n"), 
+            dir->fsend(_("3022 Device %s released.\n"), 
                dev->print_name());
          }
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       /* NB dir->msg gets clobbered in bnet_fsend, so save command */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3927 Error scanning release command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3927 Error scanning release command: %s\n"), jcr->errmsg);
    }
-   bnet_sig(dir, BNET_EOD);
+   dir->signal(BNET_EOD);
    return true;
 }
 
@@ -965,7 +970,7 @@ static bool changer_cmd(JCR *jcr)
          dev = dcr->dev;
          dev->dlock();                 /* Use P to avoid indefinite block */
          if (!dev->device->changer_res) {
-            bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"), 
+            dir->fsend(_("3995 Device %s is not an autochanger.\n"), 
                dev->print_name());
          /* Under certain "safe" conditions, we can steal the lock */
          } else if (safe_cmd || !dev->is_open() || dev->can_steal_lock()) {
@@ -978,11 +983,11 @@ static bool changer_cmd(JCR *jcr)
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {  /* error on scanf */
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3908 Error scanning autocharger drives/list/slots command: %s\n"),
+      dir->fsend(_("3908 Error scanning autocharger drives/list/slots command: %s\n"),
          jcr->errmsg);
    }
    dir->signal(BNET_EOD);
@@ -1021,11 +1026,11 @@ static bool readlabel_cmd(JCR *jcr)
          dev->dunlock();
          free_dcr(dcr);
       } else {
-         bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
+         dir->fsend(_("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
       }
    } else {
       pm_strcpy(jcr->errmsg, dir->msg);
-      bnet_fsend(dir, _("3909 Error scanning readlabel command: %s\n"), jcr->errmsg);
+      dir->fsend(_("3909 Error scanning readlabel command: %s\n"), jcr->errmsg);
    }
    dir->signal(BNET_EOD);
    return true;
@@ -1053,11 +1058,11 @@ static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot)
    switch (read_dev_volume_label(dcr)) {
    case VOL_OK:
       /* DO NOT add quotes around the Volume name. It is scanned in the DIR */
-      bnet_fsend(dir, _("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
+      dir->fsend(_("3001 Volume=%s Slot=%d\n"), dev->VolHdr.VolumeName, Slot);
       Dmsg1(100, "Volume: %s\n", dev->VolHdr.VolumeName);
       break;
    default:
-      bnet_fsend(dir, _("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
+      dir->fsend(_("3902 Cannot mount Volume on Storage Device %s because:\n%s"),
                  dev->print_name(), jcr->errmsg);
       break;
    }
@@ -1085,35 +1090,35 @@ static void send_dir_busy_message(BSOCK *dir, DEVICE *dev)
    if (dev->is_blocked()) {
       switch (dev->blocked()) {
       case BST_UNMOUNTED:
-         bnet_fsend(dir, _("3931 Device %s is BLOCKED. user unmounted.\n"),
+         dir->fsend(_("3931 Device %s is BLOCKED. user unmounted.\n"),
             dev->print_name());
          break;
       case BST_UNMOUNTED_WAITING_FOR_SYSOP:
-         bnet_fsend(dir, _("3932 Device %s is BLOCKED. user unmounted during wait for media/mount.\n"),
+         dir->fsend(_("3932 Device %s is BLOCKED. user unmounted during wait for media/mount.\n"),
              dev->print_name());
          break;
       case BST_WAITING_FOR_SYSOP:
-         bnet_fsend(dir, _("3933 Device %s is BLOCKED waiting for media.\n"),
+         dir->fsend(_("3933 Device %s is BLOCKED waiting for media.\n"),
             dev->print_name());
          break;
       case BST_DOING_ACQUIRE:
-         bnet_fsend(dir, _("3934 Device %s is being initialized.\n"),
+         dir->fsend(_("3934 Device %s is being initialized.\n"),
             dev->print_name());
          break;
       case BST_WRITING_LABEL:
-         bnet_fsend(dir, _("3935 Device %s is blocked labeling a Volume.\n"),
+         dir->fsend(_("3935 Device %s is blocked labeling a Volume.\n"),
             dev->print_name());
          break;
       default:
-         bnet_fsend(dir, _("3935 Device %s is blocked for unknown reason.\n"),
+         dir->fsend(_("3935 Device %s is blocked for unknown reason.\n"),
             dev->print_name());
          break;
       }
    } else if (dev->can_read()) {
-       bnet_fsend(dir, _("3936 Device %s is busy reading.\n"),
+       dir->fsend(_("3936 Device %s is busy reading.\n"),
                    dev->print_name());;
    } else {
-       bnet_fsend(dir, _("3937 Device %s is busy with %d writer(s).\n"),
+       dir->fsend(_("3937 Device %s is busy with %d writer(s).\n"),
           dev->print_name(), dev->num_writers);
    }
 }
index e6e35a09535d8ad3d85568ac1c76609a455ee26f..66a2301489cceb4bf603c1593119fd3c87174e3f 100644 (file)
@@ -352,8 +352,9 @@ bool get_bootstrap_file(JCR *jcr, BSOCK *sock)
    jcr->RestoreBootstrap = fname;
    bs = fopen(fname, "a+b");           /* create file */
    if (!bs) {
+      berrno be;
       Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"),
-         jcr->RestoreBootstrap, strerror(errno));
+         jcr->RestoreBootstrap, be.bstrerror());
       goto bail_out;
    }
    Dmsg0(10, "=== Bootstrap file ===\n");
index 8f926bb7cc86bee4f04f429d956c0922296e0c17..e56e32c39be11f77e852d77a5c677d6ac8fbd988 100644 (file)
@@ -733,16 +733,11 @@ bool write_session_label(DCR *dcr, int label)
       Dmsg0(150, "Cannot write session label to block.\n");
       if (!write_block_to_device(dcr)) {
          Dmsg0(130, "Got session label write_block_to_dev error.\n");
-         /* ****FIXME***** errno is not set here */
-         Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"),
-                           dev_vol_name(dev), strerror(errno));
          free_record(rec);
          return false;
       }
    }
    if (!write_record_to_block(block, rec)) {
-      Jmsg(jcr, M_FATAL, 0, _("Error writing Session label to %s: %s\n"),
-                        dev_vol_name(dev), strerror(errno));
       free_record(rec);
       return false;
    }
index 9b2a4ca1f8a80b4e97a0afaa7e53083275f1d75a..28200047b9ec30b8316523750fb0e7f1b36d6de3 100644 (file)
@@ -88,6 +88,16 @@ const int dbglvl = 500;
  *   DEVICE::dlock()   does P(m_mutex)     (in dev.h)
  *   DEVICE::dunlock() does V(m_mutex)
  *
+ *   DEVICE::r_dlock() allows locking the device when this thread
+                         already has the device blocked.
+ *                    dlock()
+ *                    if blocked and not same thread that locked
+ *                       pthread_cond_wait
+ *                    leaves device locked 
+ *
+ *   DEVICE::r_dunlock() unlocks but does not unblock
+ *                    same as dunlock();
+ *
  *   DEVICE::dblock(why)  does 
  *                    r_dlock();         (recursive device lock)
  *                    block_device(this, why) 
@@ -98,15 +108,6 @@ const int dbglvl = 500;
  *                    unblock_device()
  *                    dunlock()
  *
- *   DEVICE::r_dlock() does recursive locking
- *                    dlock()
- *                    if blocked and not same thread that locked
- *                       pthread_cond_wait
- *                    leaves device locked 
- *
- *   DEVICE::r_dunlock()
- *                    same as dunlock();
- *
  *   block_device() does  (must be locked and not blocked at entry)  
  *                    set blocked status
  *                    set our pid
index 16640f4e92259926734d2b46f5201658ba375baa..11528ad84cbe60ed8da97868dfa0604cdf3807f8 100644 (file)
@@ -167,7 +167,7 @@ ok_out:
       set_jcr_job_status(jcr, JS_Terminated);
    }
    generate_daemon_event(jcr, "JobEnd");
-   bnet_fsend(dir, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
+   dir->fsend(Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles,
       edit_uint64(jcr->JobBytes, ec1));
    Dmsg4(200, Job_end, jcr->Job, jcr->JobStatus, jcr->JobFiles, ec1); 
        
@@ -239,17 +239,18 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec)
    if (stream == STREAM_UNIX_ATTRIBUTES || stream == STREAM_UNIX_ATTRIBUTES_EX ||
        crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) {
       if (!jcr->no_attributes) {
+         BSOCK *dir = jcr->dir_bsock;
          if (are_attributes_spooled(jcr)) {
-            jcr->dir_bsock->set_spooling();
+            dir->set_spooling();
          }
          Dmsg0(850, "Send attributes to dir.\n");
          if (!dir_update_file_attributes(jcr->dcr, rec)) {
-            jcr->dir_bsock->clear_spooling();
+            dir->clear_spooling();
             Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"),
-               bnet_strerror(jcr->dir_bsock));
+               dir->bstrerror());
             return false;
          }
-         jcr->dir_bsock->clear_spooling();
+         dir->clear_spooling();
       }
    }
 
index 070e788d8f6ba53859efbe80498e6e9ffe2e5a14..74c69e08c15fa120359fef2fc75146f6deefe6b9 100644 (file)
@@ -253,7 +253,8 @@ int main (int argc, char *argv[])
      */
    create_volume_list();              /* do before device_init */
    if (pthread_create(&thid, NULL, device_initialization, NULL) != 0) {
-      Emsg1(M_ABORT, 0, _("Unable to create thread. ERR=%s\n"), strerror(errno));
+      berrno be;
+      Emsg1(M_ABORT, 0, _("Unable to create thread. ERR=%s\n"), be.bstrerror());
    }
 
    start_watchdog();                  /* start watchdog thread */
@@ -471,7 +472,8 @@ void *device_initialization(void *arg)
    /* Initialize FD start condition variable */
    int errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
    if (errstat != 0) {
-      Jmsg1(jcr, M_ABORT, 0, _("Unable to init job cond variable: ERR=%s\n"), strerror(errstat));
+      berrno be;
+      Jmsg1(jcr, M_ABORT, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat));
    }
 
    foreach_res(device, R_DEVICE) {
index d58d032b3cb8d6dcc214c6fc050433fc0c9e96ef..83b0e552dc9c55bc81b874420342ddc24f9ccef4 100644 (file)
 /*
    Derived from a SMTPclient:
 
+  ======== Original copyrights ==========  
+
        SMTPclient -- simple SMTP client
 
-       Copyright (C) 1997 Ralf S. Engelschall, All Rights Reserved.
-       rse@engelschall.com
-       www.engelschall.com
+       Copyright (c) 1997 Ralf S. Engelschall, All rights reserved.
+
+       This program is free software; it may be redistributed and/or modified
+       only under the terms of either the Artistic License or the GNU General
+       Public License, which may be found in the SMTP source distribution.
+       Look at the file COPYING.
+
+       This program is distributed in the hope that it will be useful, but
+       WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       GNU General Public License for more details.
+
+       ======================================================================
+
+       smtpclient_main.c -- program source
+
+       Based on smtp.c as of August 11, 1995 from
+           W.Z. Venema,
+           Eindhoven University of Technology,
+           Department of Mathematics and Computer Science,
+           Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands.
+
+   =========
+
 
    Kern Sibbald, July 2001
 
+     Note, the original W.Z. Venema smtp.c had no license and no
+     copyright.  See:
+        http://archives.neohapsis.com/archives/postfix/2000-05/1520.html
+
    Version $Id$
 
  */
index 1963931e64efa15aa34ea67c379744c0ebc07b1d..dafff136af50cf0e188131fb7e07e7999bacf05a 100644 (file)
@@ -611,7 +611,7 @@ static void eliminate_duplicate_filenames()
       /* Loop through list of duplicate names */
       for (int i=0; i<name_list.num_ids; i++) {
          /* Get all the Ids of each name */
-         db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+         db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i]));
          bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
          if (verbose > 1) {
             printf("%s\n", buf);
@@ -669,7 +669,7 @@ static void eliminate_duplicate_paths()
       /* Loop through list of duplicate names */
       for (int i=0; i<name_list.num_ids; i++) {
          /* Get all the Ids of each name */
-         db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+         db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i]));
          bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
          if (verbose > 1) {
             printf("%s\n", buf);
@@ -1103,7 +1103,7 @@ static void repair_bad_filenames()
             esc_name[1] = 0;
          } else {
             name[len-1] = 0;
-            db_escape_string(esc_name, name, len);
+            db_escape_string(NULL, db, esc_name, name, len);
          }
          bsnprintf(buf, sizeof(buf),
             "UPDATE Filename SET Name='%s' WHERE FilenameId=%s",
@@ -1162,7 +1162,7 @@ static void repair_bad_paths()
          }
          /* Add trailing slash */
          len = pm_strcat(&name, "/");
-         db_escape_string(esc_name, name, len);
+         db_escape_string(NULL, db, esc_name, name, len);
          bsnprintf(buf, sizeof(buf), "UPDATE Path SET Path='%s' WHERE PathId=%s",
             esc_name, edit_int64(id_list.Id[i], ed1));
          if (verbose > 1) {
index a14799a9a6c026fc2c6c29dcb1d618403a35c2a9..184580604b70fc6c7bbc1c825d629e23ed0bedb8 100644 (file)
@@ -87,8 +87,8 @@ int
 main (int argc, char *const *argv)
 {
    FF_PKT *ff;
-   char *configfile = "bacula-dir.conf";
-   char *fileset_name = "Windows-Full-Set";
+   const char *configfile = "bacula-dir.conf";
+   const char *fileset_name = "Windows-Full-Set";
    int ch, hard_links;
 
    OSDependentInit();
index c804f0afd60ad8c614c7fbf8d3fdafdd6172ab40..838c0c781f411719920d5e5ea22b3ca4ac685b4a 100644 (file)
@@ -10,8 +10,15 @@ Using the Express Edition (free version)
       instead of the web installer, as Microsoft will
       start to charge for VC++ one year after the product launch
       (launch was in November 2005, see VC++ FAQ).
+      NOTE: last modifications in order to compile have been tested with 
+      Visual C++ Standard Edition, not with Express Edition, but this shouldn't change anything.
 
-    - Windows® Server 2003 SP1 Platform SDK Full Download (385MB)
+       - Microsoft VSS SDK.  You can find it on Microsoft's web-site at:
+      http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en
+      If that link doesn't work then go to http://www.microsoft.com and search for
+      "download volume shadow copy service sdk"
+
+    - Windows Server 2003 SP1 Platform SDK Full Download (385MB)
       http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en
       NOTE: choose "Full Download" version on the bottom of that page.
 
@@ -22,7 +29,7 @@ Using the Express Edition (free version)
         (MSDN Library is NOT needed).
       + Remember where you install it (e.g. E:\Microsoft Visual Studio 8\)
 
-    - Windows® Server 2003 SP1 Platform SDK Full Download
+    - Windows Server 2003 SP1 Platform SDK Full Download
       + Run psdk-full.exe, type the directory where you downloaded the cab
         files.
       + In a command prompt, run "PSDK-full.bat <temp directory>"
@@ -34,6 +41,20 @@ Using the Express Edition (free version)
       + When asked for components, you can safely remove documentation,
         samples, and all 64-bit tools and libs if you want to save disk
         space.
+      NOTE: Just after having installed "Windows® Server 2003 SP1 Platform SDK Full Download", 
+      my XP was no more considered as "genuine". You are warned.
+      That's why it is recommended to download "volume shadow copy service sdk" before installing SDK
+
+    - Microsoft VSS SDK
+      + Normally the files will be installed in:  C:\Program Files\Microsoft\VSSSDK72
+      + You only need to copy everything under the C:\Program Files\Microsoft\VSSSDK72\inc
+        directory into .../depkgs-msvc/vss/inc.
+
+    - Verify what you've got in your system variables :
+      + %INCLUDE% (echo %INCLUDE%) must contain 
+        <vc++ install dir>\VC\include;<vc++ install dir>\VC\PlatformSDK\Include;
+      + %LIB% (echo %LIB%) must contain 
+        <vc++ install dir>\VC\lib;<vc++ install dir>\VC\PlatformSDK\Lib
 
 One-time Setup
 ==============
@@ -103,27 +124,12 @@ whenever the dependencies change.
    build-depkgs-msvc
 
 At this point all of the dependencies should have been downloaded and
-built.  You need the header files from the Microsoft VSS SDK.  You can
-find it on Microsoft's web-site at:
-
-http://www.microsoft.com/downloads/details.aspx?FamilyID=0b4f56e4-0ccc-4626-826a-ed2c4c95c871&DisplayLang=en
-
-If that link doesn't work then go to http://www.microsoft.com and search
-for
-
-   "download volume shadow copy service sdk"
-
-Normally the files will be installed in:
-
-   C:\Program Files\Microsoft\VSSSDK72
-
-You only need to copy everything under the C:\Program Files\Microsoft\VSSSDK72\inc
-directory into .../depkgs-msvc/vss/inc.
-
+built.  
 The above only needs to be done once unless we change the cross-tools or
 the dependencies versions.  In general, you can run the script multiple
 times with no problem.
 
+
 Building
 ========
 
@@ -200,6 +206,10 @@ C++ mangled name of the new function.  Fortunately it is displayed in
 parentheses in the linker error message.  Place it in the
 .../bacula/src/win32/libbac/bacula.def file.
 
+In .../bacula/src/win32/libbac/msvc there is a shell "make_def_msvc" that creates 
+a def file (not really clean way). 
+In cygwin,  one has to type ./make_def_msvc > bacula.def 
+
 bacula_cats.dll
 ---------------
 
@@ -221,3 +231,7 @@ name in the file .../bacula/src/win32/cats/bacula_cats/bacula_cats.def.
 
 The mangled name is printed, surrounded by parentheses, in the Linker
 error message.
+
+In .../bacula/src/win32/bacula_cats/ there is a shell "make_def_msvc" that creates 
+a def file (not really clean way). 
+In cygwin,  one has to type ./make_def_msvc > bacula_cats.def 
index 04f56127a7954f1411aedb72c63034e151c0b586..9d75a1dadba6f0ff0de7553fa069be2bc5c62ee8 100644 (file)
@@ -23,9 +23,6 @@ _ZN9dbid_listD1Ev
 _ZN9dbid_listD2Ev\r
  \r
 ; sql_create.o\r
-_Z12my_batch_endP3JCRP4B_DBPKc\r
-_Z14my_batch_startP3JCRP4B_DB\r
-_Z15my_batch_insertP3JCRP4B_DBP8ATTR_DBR\r
 _Z20db_create_job_recordP3JCRP4B_DBP7JOB_DBR\r
 _Z21db_create_pool_recordP3JCRP4B_DBP8POOL_DBR\r
 _Z22db_create_media_recordP3JCRP4B_DBP9MEDIA_DBR\r
@@ -93,7 +90,7 @@ _Z28db_add_digest_to_file_recordP3JCRP4B_DBjPci
 _Z11db_get_typev\r
 _Z12db_sql_queryP4B_DBPKcPFiPviPPcES3_\r
 _Z13db_next_indexP3JCRP4B_DBPcS3_\r
-_Z16db_escape_stringPcS_i\r
+_Z16db_escape_stringP3JCRP4B_DBPcS3_i\r
 _Z16db_init_databaseP3JCRPKcS2_S2_S2_iS2_i\r
 _Z16db_open_databaseP3JCRP4B_DB\r
 _Z17db_close_databaseP3JCRP4B_DB\r
index aee776ecf39d39852c9cb1b543adf702dd0602fc..945f86a9b6f3b6b731fd6a104952f37d3e6ffd20 100755 (executable)
@@ -10,6 +10,8 @@ echo "LIBRARY bacula_cats.dll"
 echo "EXPORTS"
 echo " "
 
+NM=../../../../../cross-tools/mingw32/mingw32/bin/nm
+
 OBJS="sql.o sql_create.o sql_delete.o sql_find.o sql_get.o \
       sql_list.o sql_update.o"
 
@@ -64,11 +66,11 @@ DATA="\
 cd cats_mysql
 for i in ${OBJS}; do \
    echo "; $i"; \
-   nm $i | grep "^[0-9a-f]* T _" | cut -c21-; \
+   ${NM} $i | grep "^[0-9a-f]* T _" | cut -c13-; \
    echo " "; \
 done
 
-nm mysql.o | grep "^[0-9a-f]* T _" | cut -c21- | grep -v "my_mysql"
+${NM} mysql.o | grep "^[0-9a-f]* T _" | cut -c13- | grep -v "my_mysql"
 
 for i in ${DATA}; do \
    echo "$i DATA"; \
index f5bbdacbe6573a217ad8248ad70592746a981d07..264e7edcd17263e518ba65d99c03d6bc82cbc2fe 100644 (file)
@@ -192,7 +192,7 @@ _ZN5alist9grow_listEv
 _Z15print_ls_outputP3JCRP4ATTR
 _Z24build_attr_output_fnamesP3JCRP4ATTR
 _Z24unpack_attributes_recordP3JCRiPcP4ATTR
-_Z8new_attrv
+_Z8new_attrP3JCR
 _Z9free_attrP4ATTR
  
 ; base64.o
@@ -251,7 +251,7 @@ _Z12get_bregexpsPKc
 _Z13free_bregexpsP5alist
 _Z14apply_bregexpsPKcP5alistPPc
 _Z19bregexp_build_wherePciS_S_S_
-_Z21bregexp_escape_stringPcS_c
+_Z21bregexp_escape_stringPcPKcc
 _Z28bregexp_get_build_where_sizePcS_S_
 _ZN7BREGEXP10edit_substEPKcP12b_regmatch_t
 _ZN7BREGEXP12return_fnameEPKci
@@ -352,10 +352,10 @@ _Z9tm_encodeP9date_timeP2tm
 _Z16stop_bsock_timerP8btimer_t
 _Z16stop_child_timerP8btimer_t
 _Z17start_bsock_timerP5BSOCKj
-_Z17start_child_timerij
+_Z17start_child_timerP3JCRij
 _Z17stop_thread_timerP8btimer_t
-_Z18start_thread_timerP10pthread_t_j
+_Z18start_thread_timerP3JCRP10pthread_t_j
+
 ; cram-md5.o
 _Z16cram_md5_respondP5BSOCKPKcPiS3_
 _Z18cram_md5_challengeP5BSOCKPKcii
@@ -451,12 +451,12 @@ _Z23edit_uint64_with_suffixyPc
  
 ; fnmatch.o
 fnmatch
-; idcache.o
-_Z18free_getuser_cachev
-_Z19free_getgroup_cachev
-_Z7getuserjPci
-_Z8getgroupjPci
+
+; guid_to_name.o
+_ZN9guid_list11uid_to_nameEjPci
+_ZN9guid_list11gid_to_nameEjPci
+_Z14free_guid_listP9guid_list
+_Z13new_guid_listv
  
 ; jcr.o
 _Z10b_free_jcrPKciP3JCR
@@ -466,11 +466,10 @@ _Z12job_end_pushP3JCRPFvS0_PvES1_
 _Z13get_jcr_by_idj
 _Z13jcr_walk_nextP3JCR
 _Z14jcr_walk_startv
-_Z16get_jcr_from_tidP10pthread_t_
-_Z16get_jcr_from_tidv
+_Z14set_jcr_in_tsdP3JCR
+_Z16get_jcr_from_tsdv
+_Z18get_jobid_from_tsdv
 _Z18get_jcr_by_sessionjj
-_Z18get_jobid_from_tidP10pthread_t_
-_Z18get_jobid_from_tidv
 _Z18init_jcr_subsystemv
 _Z18set_jcr_job_statusP3JCRi
 _Z19init_last_jobs_listv
@@ -484,6 +483,8 @@ _Z23get_jcr_by_partial_namePc
 _Z7new_jcriPFvP3JCRE
 _Z9lock_jobsv
 timeout_handler
+
+
  
 ; lex.o
 _Z11scan_to_eolP13s_lex_context
index 6b754c924a72cd3c0bade7da38c84f131584fd23..89b036e0580d9adfabd07f309819ebe4869219e0 100755 (executable)
@@ -5,24 +5,15 @@
 #
 #  Kern Sibbald, June 2007
 #
+
+NM=../../../../cross-tools/mingw32/mingw32/bin/nm
  
 echo "LIBRARY bacula.dll"
 echo "EXPORTS"
 echo " "
 
-OBJS="compat.o print.o winapi.o attribs.o bfile.o create_file.o \
-      drivetype.o enable_priv.o find.o find_one.o fstype.o match.o \
-      address_conf.o alist.o attr.o base64.o berrno.o bget_msg.o \
-      bnet.o bnet_server.o bpipe.o breg.o bregex.o bsnprintf.o \
-      bsock.o bsys.o btime.o btimers.o cram-md5.o crc32.o crypto.o \
-      daemon.o dlist.o edit.o fnmatch.o idcache.o jcr.o lex.o md5.o \
-      mem_pool.o message.o pythonlib.o queue.o rblist.o runscript.o \
-      rwlock.o scan.o serial.o smartall.o tls.o tree.o util.o var.o \
-      watchdog.o"
-
-
-for i in ${OBJS}; do \
+for i in *.o ; do \
    echo "; $i"; \
-   nm $i | grep "^[0-9a-f]* T _" | cut -c21-; \
+   ${NM} $i | grep "^[0-9a-f]* T _" | cut -c13- ; \
    echo " "; \
 done
diff --git a/bacula/src/win32/libwin32/wintray.h b/bacula/src/win32/libwin32/wintray.h
deleted file mode 100644 (file)
index 59b5568..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-//  Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
-//
-//  This file was part of the VNC system.
-//
-//  The VNC system is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
-//  USA.
-//
-// If the source code for the VNC system is not available from the place
-// whence you received this file, check http://www.uk.research.att.com/vnc or contact
-// the authors on vnc@uk.research.att.com for information on obtaining it.
-//
-// This file has been adapted to the Win32 version of Bacula
-// by Kern E. Sibbald.  Many thanks to ATT and James Weatherall,
-// the original author, for providing an excellent template.
-//
-// Copyright (2000) Kern E. Sibbald
-//
-
-
-
-// winMenu
-
-// This class handles creation of a system-tray icon & menu
-
-
-
-class bacMenu;
-
-#if (!defined(_win_bacMENU))
-#define _win_bacMENU
-
-#include "aboutDialog.h"
-#include "statusDialog.h"
-
-// Message used for system tray notifications
-#define WM_TRAYNOTIFY  WM_USER+1
-
-// Constants
-extern const UINT MENU_ABOUTBOX_SHOW;
-extern const UINT MENU_STATUS_SHOW;
-extern const char *MENU_CLASS_NAME;
-
-// The tray menu class itself
-class bacMenu
-{
-public:
-   bacMenu();
-   ~bacMenu();
-protected:
-   // Tray icon handling
-   void AddTrayIcon();
-   void DelTrayIcon();
-   void UpdateTrayIcon(int battstat);
-   void SendTrayMsg(DWORD msg, int battstat);
-
-   // Message handler for the tray window
-   static LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
-
-   // Fields
-protected:
-
-   // About dialog for this server
-   aboutDialog  m_about;
-
-   // Status dialog for this server
-   statusDialog m_status;
-
-   HWND  m_hwnd;
-   HMENU m_hmenu;
-   NOTIFYICONDATA m_nid;
-
-   // The icon handles
-   HICON m_idle_icon;
-   HICON m_running_icon;
-   HICON m_error_icon;
-   HICON m_warn_icon;
-};
-
-
-#endif
index 85794f8407d0848a8da8a58b442e6f8f5b953a79..f5d4aac55d54dd2bce4c684fd793d88b77f6654e 100644 (file)
@@ -1,6 +1,9 @@
               Technical notes on version 2.2
 
 General:
+03Oct07
+kes  Backport almost 4000 lines of 2.3 code that fixes a number of bugs.
+     The details are included in the notes in this file.
 28Sep07
 kes  Backport 2.3 code that fixes: it fixes incorrect or incomplete error
      messages; it fixes a problem opening the SQLite3 database when multiple
@@ -15,6 +18,44 @@ kes  Fix race condition that drops final block written to volume.
 kes  Fix FD->SD authorization failure, which was due to spurious
      wakeups from a pthread_cond_timedwait().  Simply check the
      predicate before continuing.  This fixes bug #953
+dvl  Add new configuration item --archivedir
+dvl  Adjust regression tests to use tmp not /tmp.  This will allow
+     multiple concurrent runs of the regression tests.
+28Sep07
+kes  Fix race condition that drops final block written to volume.
+     This happens in rare cases with multiple simultaneous jobs 
+     when the Volume fills.  This fixes bug #964.  May be related
+     to bug #935 and possibly #903.
+kes  Eliminate more strerror() and replace with bstrerror().
+kes  Remove BSD getopt and replace with unrestricted IBM version.
+kes  Fix Win32 build for changed calling sequences.
+27Sep07 
+kes  Fix FD->SD authorization failure, which was due to spurious
+     wakeups from a pthread_cond_timedwait().  Simply check the
+     predicate before continuing.  This fixes bug #953.
+kes  Add const char where needed (more to do).
+26Sep07
+kes  Setup SQLite busy handler before doing queries. Fixes bug #967.
+kes  Don't overwrite error message in check_tables_version.
+     Fixes bug #966.
+kes  Unlock batch insert tables with same calls used elsewhere.
+kes  Allow starting 59 jobs a second.
+kes  Make SD session key more random.
+kes  Add retry for SQLite opening db if it fails. Probably helps
+     for bug #967.
+kes  Suppress extra error messages during batch insert failure.
+     Fixes bug #966.
+kes  Put some FD auth code on dbglvl rather than fixed.
+kes  Return insert attributes error message in db msg buffer to avoid
+     false error messages. Helps fix bug #966.
+kes  Separate batch init error messages. Probably helps fix bug #966.
+kes  If Dir gets an error during inserting attributes, cancel SD.  
+     This reduces unnecessary error messages.
+24Sep07 
+ebl  Cleanup batch insert code. Probably fixes bug #965.
+23Sep07 
+kes  Turn off some code when batch insert not enabled.
+kes  Edit FD name in connect error messages.
 22Sep07
 kes  Add code to handle tray monitor separated from Win32 FD.
 kes  Fix display of Win32 tray monitor after reboot. Fixes bug #952.