From: <ke...@us...> - 2007-10-03 11:36:43
|
Revision: 5713 http://bacula.svn.sourceforge.net/bacula/?rev=5713&view=rev Author: kerns Date: 2007-10-03 04:36:47 -0700 (Wed, 03 Oct 2007) Log Message: ----------- Backport almost 4000 lines of 2.3 code that fixes a number of bugs. Modified Paths: -------------- branches/Branch-2.2/bacula/autoconf/configure.in branches/Branch-2.2/bacula/configure branches/Branch-2.2/bacula/kernstodo branches/Branch-2.2/bacula/projects branches/Branch-2.2/bacula/src/cats/bdb.c branches/Branch-2.2/bacula/src/cats/mysql.c branches/Branch-2.2/bacula/src/cats/postgresql.c branches/Branch-2.2/bacula/src/cats/protos.h branches/Branch-2.2/bacula/src/cats/sql_create.c branches/Branch-2.2/bacula/src/cats/sql_get.c branches/Branch-2.2/bacula/src/cats/sqlite.c branches/Branch-2.2/bacula/src/dird/backup.c branches/Branch-2.2/bacula/src/dird/catreq.c branches/Branch-2.2/bacula/src/dird/dird_conf.h branches/Branch-2.2/bacula/src/dird/fd_cmds.c branches/Branch-2.2/bacula/src/dird/getmsg.c branches/Branch-2.2/bacula/src/dird/job.c branches/Branch-2.2/bacula/src/dird/migrate.c branches/Branch-2.2/bacula/src/dird/newvol.c branches/Branch-2.2/bacula/src/dird/restore.c branches/Branch-2.2/bacula/src/dird/ua_output.c branches/Branch-2.2/bacula/src/dird/ua_query.c branches/Branch-2.2/bacula/src/dird/ua_restore.c branches/Branch-2.2/bacula/src/dird/ua_run.c branches/Branch-2.2/bacula/src/dird/ua_tree.c branches/Branch-2.2/bacula/src/dird/verify.c branches/Branch-2.2/bacula/src/filed/authenticate.c branches/Branch-2.2/bacula/src/filed/job.c branches/Branch-2.2/bacula/src/filed/restore.c branches/Branch-2.2/bacula/src/filed/status.c branches/Branch-2.2/bacula/src/jcr.h branches/Branch-2.2/bacula/src/lib/Makefile.in branches/Branch-2.2/bacula/src/lib/attr.c branches/Branch-2.2/bacula/src/lib/attr.h branches/Branch-2.2/bacula/src/lib/breg.c branches/Branch-2.2/bacula/src/lib/breg.h branches/Branch-2.2/bacula/src/lib/bsnprintf.c branches/Branch-2.2/bacula/src/lib/bsock.h branches/Branch-2.2/bacula/src/lib/btimers.h branches/Branch-2.2/bacula/src/lib/cram-md5.c branches/Branch-2.2/bacula/src/lib/edit.c branches/Branch-2.2/bacula/src/lib/jcr.c branches/Branch-2.2/bacula/src/lib/lib.h branches/Branch-2.2/bacula/src/lib/message.c branches/Branch-2.2/bacula/src/lib/message.h branches/Branch-2.2/bacula/src/lib/parse_conf.h branches/Branch-2.2/bacula/src/lib/protos.h branches/Branch-2.2/bacula/src/lib/res.c branches/Branch-2.2/bacula/src/qt-console/console/console.cpp branches/Branch-2.2/bacula/src/qt-console/medialist/medialist.cpp branches/Branch-2.2/bacula/src/qt-console/medialist/medialist.h branches/Branch-2.2/bacula/src/qt-console/medialist/medialist.ui branches/Branch-2.2/bacula/src/qt-console/restore/prerestore.cpp branches/Branch-2.2/bacula/src/qt-console/restore/restoretree.cpp branches/Branch-2.2/bacula/src/stored/ansi_label.c branches/Branch-2.2/bacula/src/stored/authenticate.c branches/Branch-2.2/bacula/src/stored/autochanger.c branches/Branch-2.2/bacula/src/stored/bacula-sd.conf.in branches/Branch-2.2/bacula/src/stored/bextract.c branches/Branch-2.2/bacula/src/stored/block.c branches/Branch-2.2/bacula/src/stored/bls.c branches/Branch-2.2/bacula/src/stored/bscan.c branches/Branch-2.2/bacula/src/stored/dircmd.c branches/Branch-2.2/bacula/src/stored/fd_cmds.c branches/Branch-2.2/bacula/src/stored/label.c branches/Branch-2.2/bacula/src/stored/lock.c branches/Branch-2.2/bacula/src/stored/mac.c branches/Branch-2.2/bacula/src/stored/stored.c branches/Branch-2.2/bacula/src/tools/bsmtp.c branches/Branch-2.2/bacula/src/tools/dbcheck.c branches/Branch-2.2/bacula/src/tools/testfind.c branches/Branch-2.2/bacula/src/win32/README.vc8 branches/Branch-2.2/bacula/src/win32/cats/bacula_cats.def branches/Branch-2.2/bacula/src/win32/cats/make_def branches/Branch-2.2/bacula/src/win32/dll/bacula.def branches/Branch-2.2/bacula/src/win32/dll/make_def branches/Branch-2.2/bacula/technotes-2.1 Added Paths: ----------- branches/Branch-2.2/bacula/COPYRIGHT branches/Branch-2.2/bacula/src/lib/guid_to_name.c branches/Branch-2.2/bacula/src/lib/guid_to_name.h Removed Paths: ------------- branches/Branch-2.2/bacula/src/win32/libwin32/wintray.h Added: branches/Branch-2.2/bacula/COPYRIGHT =================================================================== --- branches/Branch-2.2/bacula/COPYRIGHT (rev 0) +++ branches/Branch-2.2/bacula/COPYRIGHT 2007-10-03 11:36:47 UTC (rev 5713) @@ -0,0 +1,2 @@ +Please see the file LICENSE concerning the terms of the license, +copying and such. Modified: branches/Branch-2.2/bacula/autoconf/configure.in =================================================================== --- branches/Branch-2.2/bacula/autoconf/configure.in 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/autoconf/configure.in 2007-10-03 11:36:47 UTC (rev 5713) @@ -163,6 +163,14 @@ 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 @@ Install binaries: ${sbindir} Install config files: ${sysconfdir} Scripts directory: ${scriptdir} + Archive directory: ${archivedir} Working directory: ${working_dir} PID directory: ${piddir} Subsys directory: ${subsysdir} Modified: branches/Branch-2.2/bacula/configure =================================================================== --- branches/Branch-2.2/bacula/configure 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/configure 2007-10-03 11:36:47 UTC (rev 5713) @@ -309,7 +309,7 @@ # 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 @@ infodir='${prefix}/info' mandir='${prefix}/man' +archivedir='/tmp' + ac_prev= for ac_option do @@ -544,6 +546,13 @@ | --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 @@ 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 @@ --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 @@ 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,@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 @@ Install binaries: ${sbindir} Install config files: ${sysconfdir} Scripts directory: ${scriptdir} + Archive directory: ${archivedir} Working directory: ${working_dir} PID directory: ${piddir} Subsys directory: ${subsysdir} Modified: branches/Branch-2.2/bacula/kernstodo =================================================================== --- branches/Branch-2.2/bacula/kernstodo 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/kernstodo 2007-10-03 11:36:47 UTC (rev 5713) @@ -56,10 +56,27 @@ - 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 @@ 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. Modified: branches/Branch-2.2/bacula/projects =================================================================== --- branches/Branch-2.2/bacula/projects 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/projects 2007-10-03 11:36:47 UTC (rev 5713) @@ -497,7 +497,7 @@ 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,8 +513,9 @@ 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 Origin: Chad Slater <cha...@cl...> @@ -679,7 +680,7 @@ Item 20: An option to operate on all pools with update vol parameters Origin: Dmitriy Pinchukov <ab...@bo...> 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 @@ manual/interactive jobs Origin: Marc Schiffbauer <ma...@sc...> 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. Modified: branches/Branch-2.2/bacula/src/cats/bdb.c =================================================================== --- branches/Branch-2.2/bacula/src/cats/bdb.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/bdb.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -307,7 +307,7 @@ { } -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); Modified: branches/Branch-2.2/bacula/src/cats/mysql.c =================================================================== --- branches/Branch-2.2/bacula/src/cats/mysql.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/mysql.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -296,62 +296,9 @@ * 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); } /* Modified: branches/Branch-2.2/bacula/src/cats/postgresql.c =================================================================== --- branches/Branch-2.2/bacula/src/cats/postgresql.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/postgresql.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -211,6 +211,12 @@ } 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 @@ * 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"); + } } /* Modified: branches/Branch-2.2/bacula/src/cats/protos.h =================================================================== --- branches/Branch-2.2/bacula/src/cats/protos.h 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/protos.h 2007-10-03 11:36:47 UTC (rev 5713) @@ -46,7 +46,7 @@ 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); Modified: branches/Branch-2.2/bacula/src/cats/sql_create.c =================================================================== --- branches/Branch-2.2/bacula/src/cats/sql_create.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/sql_create.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -710,14 +710,14 @@ 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 @@ 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 @@ 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)) { Modified: branches/Branch-2.2/bacula/src/cats/sql_get.c =================================================================== --- branches/Branch-2.2/bacula/src/cats/sql_get.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/sql_get.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -169,7 +169,7 @@ 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 @@ 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) { Modified: branches/Branch-2.2/bacula/src/cats/sqlite.c =================================================================== --- branches/Branch-2.2/bacula/src/cats/sqlite.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/cats/sqlite.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -290,7 +290,7 @@ * 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; Modified: branches/Branch-2.2/bacula/src/dird/backup.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/backup.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/backup.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -200,7 +200,7 @@ } } - 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 @@ } /* 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 @@ 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 @@ 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 @@ 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); } Modified: branches/Branch-2.2/bacula/src/dird/catreq.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/catreq.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/catreq.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -126,7 +126,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } } +bail_out: + if (job_canceled(jcr)) { + cancel_storage_daemon_job(jcr); + } } Modified: branches/Branch-2.2/bacula/src/dird/dird_conf.h =================================================================== --- branches/Branch-2.2/bacula/src/dird/dird_conf.h 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/dird_conf.h 2007-10-03 11:36:47 UTC (rev 5713) @@ -380,6 +380,7 @@ 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 @@ 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 */ Modified: branches/Branch-2.2/bacula/src/dird/fd_cmds.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/fd_cmds.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/fd_cmds.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -90,9 +90,11 @@ } 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 @@ /* * 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 @@ { 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 @@ 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 @@ 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 @@ /* 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 @@ } 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); } Modified: branches/Branch-2.2/bacula/src/dird/getmsg.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/getmsg.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/getmsg.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -213,7 +213,7 @@ 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); Modified: branches/Branch-2.2/bacula/src/dird/job.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/job.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/job.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -237,8 +237,7 @@ { 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 @@ * 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 @@ /* 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 @@ */ 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 @@ /* 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 @@ 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); Modified: branches/Branch-2.2/bacula/src/dird/migrate.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/migrate.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/migrate.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -1147,7 +1147,6 @@ /* 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"); Modified: branches/Branch-2.2/bacula/src/dird/newvol.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/newvol.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/newvol.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -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. @@ -39,6 +25,20 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ft...@fs.... */ +/* + * + * 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 @@ { 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); Modified: branches/Branch-2.2/bacula/src/dird/restore.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/restore.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/restore.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -173,7 +173,7 @@ } /* Send restore command */ - char replace, *where, *cmd=NULL; + char replace, *where, *cmd; char empty = '\0'; if (jcr->replace != 0) { @@ -184,13 +184,11 @@ replace = REPLACE_ALWAYS; /* always replace */ } - where = ∅ /* 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 @@ } else if (jcr->job->RestoreWhere) { where = jcr->job->RestoreWhere; /* no override take from job */ cmd = restorecmd; - } + + } else { /* nothing was specified */ + where = ∅ /* use default */ + cmd = restorecmd; + } jcr->prefix_links = jcr->job->PrefixLinks; Modified: branches/Branch-2.2/bacula/src/dird/ua_output.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/ua_output.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/ua_output.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -557,12 +557,12 @@ 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 @@ } } 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); Modified: branches/Branch-2.2/bacula/src/dird/ua_query.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/ua_query.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/ua_query.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -69,8 +69,9 @@ 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 @@ } 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); Modified: branches/Branch-2.2/bacula/src/dird/ua_restore.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/ua_restore.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/ua_restore.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -58,7 +58,7 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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; Modified: branches/Branch-2.2/bacula/src/dird/ua_run.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/ua_run.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/ua_run.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -46,7 +46,7 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ /* 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) { Modified: branches/Branch-2.2/bacula/src/dird/ua_tree.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/ua_tree.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/ua_tree.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -111,6 +111,7 @@ "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 @@ 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 @@ 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 @@ *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 @@ } 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 @@ 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 @@ /* 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; } Modified: branches/Branch-2.2/bacula/src/dird/verify.c =================================================================== --- branches/Branch-2.2/bacula/src/dird/verify.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/dird/verify.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -193,7 +193,7 @@ 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 @@ 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) { Modified: branches/Branch-2.2/bacula/src/filed/authenticate.c =================================================================== --- branches/Branch-2.2/bacula/src/filed/authenticate.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/filed/authenticate.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -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. @@ -33,10 +25,20 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ft...@fs.... */ +/* + * 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 @@ 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 @@ 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 @@ 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 @@ 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()); } } Modified: branches/Branch-2.2/bacula/src/filed/job.c =================================================================== --- branches/Branch-2.2/bacula/src/filed/job.c 2007-10-03 07:48:04 UTC (rev 5712) +++ branches/Branch-2.2/bacula/src/filed/job.c 2007-10-03 11:36:47 UTC (rev 5713) @@ -406,7 +406,7 @@ } debug_level = level; set_trace(trace_flag); - return bnet_fsend(dir, OKsetdebug, level); + return dir->fsend(OKsetdebug, level); } @@ -418,11 +418,11 @@ 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 @@ 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 @@ 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 @@ 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 @@ Dmsg0(110, "Authenticated with SD.\n"); /* Send OK to Director */ - return bnet_fsend(dir, OKstore); + return dir->fsend(OKstore); } Modified: branches/Branch-2.2/bacula/src/filed/restore.c ==================... [truncated message content] |