From 3b86d4272600d60fe40f55460847c51b8389c7d6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 3 Oct 2007 11:36:47 +0000 Subject: [PATCH] Backport almost 4000 lines of 2.3 code that fixes a number of bugs. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@5713 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/COPYRIGHT | 2 + bacula/autoconf/configure.in | 9 + bacula/configure | 24 +- bacula/kernstodo | 18 ++ bacula/projects | 9 +- bacula/src/cats/bdb.c | 2 +- bacula/src/cats/mysql.c | 57 +---- bacula/src/cats/postgresql.c | 18 +- bacula/src/cats/protos.h | 2 +- bacula/src/cats/sql_create.c | 12 +- bacula/src/cats/sql_get.c | 4 +- bacula/src/cats/sqlite.c | 2 +- bacula/src/dird/backup.c | 10 +- bacula/src/dird/catreq.c | 32 +-- bacula/src/dird/dird_conf.h | 2 + bacula/src/dird/fd_cmds.c | 30 +-- bacula/src/dird/getmsg.c | 2 +- bacula/src/dird/job.c | 24 +- bacula/src/dird/migrate.c | 1 - bacula/src/dird/newvol.c | 42 ++-- bacula/src/dird/restore.c | 12 +- bacula/src/dird/ua_output.c | 14 +- bacula/src/dird/ua_query.c | 5 +- bacula/src/dird/ua_restore.c | 12 +- bacula/src/dird/ua_run.c | 12 +- bacula/src/dird/ua_tree.c | 25 ++- bacula/src/dird/verify.c | 4 +- bacula/src/filed/authenticate.c | 34 +-- bacula/src/filed/job.c | 14 +- bacula/src/filed/restore.c | 2 +- bacula/src/filed/status.c | 2 +- bacula/src/jcr.h | 3 + bacula/src/lib/Makefile.in | 6 +- bacula/src/lib/attr.c | 31 ++- bacula/src/lib/attr.h | 7 + bacula/src/lib/breg.c | 10 +- bacula/src/lib/breg.h | 20 +- bacula/src/lib/bsnprintf.c | 4 +- bacula/src/lib/bsock.h | 4 +- bacula/src/lib/btimers.h | 1 + bacula/src/lib/cram-md5.c | 30 +-- bacula/src/lib/edit.c | 2 +- bacula/src/lib/guid_to_name.c | 205 ++++++++++++++++++ bacula/src/lib/guid_to_name.h | 48 ++++ bacula/src/lib/jcr.c | 7 +- bacula/src/lib/lib.h | 1 + bacula/src/lib/message.c | 53 +++-- bacula/src/lib/message.h | 3 +- bacula/src/lib/parse_conf.h | 2 +- bacula/src/lib/protos.h | 8 +- bacula/src/lib/res.c | 2 +- bacula/src/qt-console/console/console.cpp | 7 + bacula/src/qt-console/medialist/medialist.cpp | 8 + bacula/src/qt-console/medialist/medialist.h | 1 + bacula/src/qt-console/medialist/medialist.ui | 17 ++ bacula/src/qt-console/restore/prerestore.cpp | 8 +- bacula/src/qt-console/restore/restoretree.cpp | 4 +- bacula/src/stored/ansi_label.c | 29 ++- bacula/src/stored/authenticate.c | 43 ++-- bacula/src/stored/autochanger.c | 14 +- bacula/src/stored/bacula-sd.conf.in | 2 +- bacula/src/stored/bextract.c | 2 +- bacula/src/stored/block.c | 14 +- bacula/src/stored/bls.c | 28 +-- bacula/src/stored/bscan.c | 2 +- bacula/src/stored/dircmd.c | 165 +++++++------- bacula/src/stored/fd_cmds.c | 3 +- bacula/src/stored/label.c | 5 - bacula/src/stored/lock.c | 19 +- bacula/src/stored/mac.c | 11 +- bacula/src/stored/stored.c | 6 +- bacula/src/tools/bsmtp.c | 34 ++- bacula/src/tools/dbcheck.c | 8 +- bacula/src/tools/testfind.c | 4 +- bacula/src/win32/README.vc8 | 52 +++-- bacula/src/win32/cats/bacula_cats.def | 5 +- bacula/src/win32/cats/make_def | 6 +- bacula/src/win32/dll/bacula.def | 31 +-- bacula/src/win32/dll/make_def | 17 +- bacula/src/win32/libwin32/wintray.h | 92 -------- bacula/technotes-2.1 | 41 ++++ 81 files changed, 964 insertions(+), 599 deletions(-) create mode 100644 bacula/COPYRIGHT create mode 100644 bacula/src/lib/guid_to_name.c create mode 100644 bacula/src/lib/guid_to_name.h delete mode 100644 bacula/src/win32/libwin32/wintray.h diff --git a/bacula/COPYRIGHT b/bacula/COPYRIGHT new file mode 100644 index 0000000000..062c2fbb48 --- /dev/null +++ b/bacula/COPYRIGHT @@ -0,0 +1,2 @@ +Please see the file LICENSE concerning the terms of the license, +copying and such. diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 554e05bd64..ccbb0dd419 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -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} diff --git a/bacula/configure b/bacula/configure index 6bfcbfdc74..3ef7c73edc 100755 --- a/bacula/configure +++ b/bacula/configure @@ -309,7 +309,7 @@ ac_includes_default="\ # include #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} diff --git a/bacula/kernstodo b/bacula/kernstodo index eadfb5770c..d840d86f2d 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -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. diff --git a/bacula/projects b/bacula/projects index 3653905742..6b99f5fc6a 100644 --- a/bacula/projects +++ b/bacula/projects @@ -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 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 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. diff --git a/bacula/src/cats/bdb.c b/bacula/src/cats/bdb.c index 60f57849ea..d9862abab1 100644 --- a/bacula/src/cats/bdb.c +++ b/bacula/src/cats/bdb.c @@ -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); diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index cb5b76783a..c0068b1b1d 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -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); } /* diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 6f901403e7..5f3d5bcb88 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -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"); + } } /* diff --git a/bacula/src/cats/protos.h b/bacula/src/cats/protos.h index c554a22744..43f1d98427 100644 --- a/bacula/src/cats/protos.h +++ b/bacula/src/cats/protos.h @@ -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); diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index be89406b81..8ea820b36a 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -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)) { diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 438e3f788f..981f10ab78 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -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) { diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 66cc74c47b..b4331dd815 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -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; diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index ba1bdfe00d..8c7a3cef46 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -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); } diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 41f705bc38..cc1903615f 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -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); + } } diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 03d50eb706..61e4a32cdb 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -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 */ diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 2e9e3e5014..7479a73056 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -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); } diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index ae4a190bf6..16e88291c4 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -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); diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 406a43e3bb..ac0fb26166 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -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); diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index c0f183d05a..e239197e35 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -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"); diff --git a/bacula/src/dird/newvol.c b/bacula/src/dird/newvol.c index 2a345ce8d3..c66b813325 100644 --- a/bacula/src/dird/newvol.c +++ b/bacula/src/dird/newvol.c @@ -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: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); diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 978f81476a..2c3b213bae 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -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 = ∅ /* 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 = ∅ /* use default */ + cmd = restorecmd; + } jcr->prefix_links = jcr->job->PrefixLinks; diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 299847fee3..66dc23d51b 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -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); diff --git a/bacula/src/dird/ua_query.c b/bacula/src/dird/ua_query.c index bd3202e300..231e41700b 100644 --- a/bacula/src/dird/ua_query.c +++ b/bacula/src/dird/ua_query.c @@ -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); diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 0320456e86..9b0dc9090d 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -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; diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 5baf9d9c6a..4f5f86a66b 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -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) { diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 576049f023..616c052dc7 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -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; } diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 71dc8b48ef..8562add9db 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -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) { diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index 4ed53cdffc..12de1816ce 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -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: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()); } } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index d8f0d00780..03c971d8e8 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -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); } diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index c505971de8..7c094462ef 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -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); diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index c3c2da632d..afff50db84 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -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 "; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 89e2095cdb..ad28b3485c 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -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 */ diff --git a/bacula/src/lib/Makefile.in b/bacula/src/lib/Makefile.in index b9ca9acaa6..c32085f460 100644 --- a/bacula/src/lib/Makefile.in +++ b/bacula/src/lib/Makefile.in @@ -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 \ diff --git a/bacula/src/lib/attr.c b/bacula/src/lib/attr.c index d3f59bffb0..b916f801f5 100644 --- a/bacula/src/lib/attr.c +++ b/bacula/src/lib/attr.c @@ -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. @@ -32,18 +25,28 @@ (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++ = ' '; diff --git a/bacula/src/lib/attr.h b/bacula/src/lib/attr.h index 4167ef1548..4b3cbe65e0 100644 --- a/bacula/src/lib/attr.h +++ b/bacula/src/lib/attr.h @@ -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_ */ diff --git a/bacula/src/lib/breg.c b/bacula/src/lib/breg.c index 0f742d6665..6a3d33c7ae 100644 --- a/bacula/src/lib/breg.c +++ b/bacula/src/lib/breg.c @@ -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, diff --git a/bacula/src/lib/breg.h b/bacula/src/lib/breg.h index 33be5397d1..27ddfbbd1f 100644 --- a/bacula/src/lib/breg.h +++ b/bacula/src/lib/breg.h @@ -61,18 +61,18 @@ */ 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_ */ diff --git a/bacula/src/lib/bsnprintf.c b/bacula/src/lib/bsnprintf.c index f8f88aea6b..920fdb1b24 100644 --- a/bacula/src/lib/bsnprintf.c +++ b/bacula/src/lib/bsnprintf.c @@ -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; diff --git a/bacula/src/lib/bsock.h b/bacula/src/lib/bsock.h index 06247da0dc..f4a90085dc 100644 --- a/bacula/src/lib/bsock.h +++ b/bacula/src/lib/bsock.h @@ -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 */ diff --git a/bacula/src/lib/btimers.h b/bacula/src/lib/btimers.h index 33e3ed5994..7d9eca00cd 100644 --- a/bacula/src/lib/btimers.h +++ b/bacula/src/lib/btimers.h @@ -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_ */ diff --git a/bacula/src/lib/cram-md5.c b/bacula/src/lib/cram-md5.c index 80b7b13d41..036dc4ed34 100644 --- a/bacula/src/lib/cram-md5.c +++ b/bacula/src/lib/cram-md5.c @@ -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; } diff --git a/bacula/src/lib/edit.c b/bacula/src/lib/edit.c index 5c3bfdbb00..89768f5d94 100644 --- a/bacula/src/lib/edit.c +++ b/bacula/src/lib/edit.c @@ -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 index 0000000000..73eeb6edb1 --- /dev/null +++ b/bacula/src/lib/guid_to_name.c @@ -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 index 0000000000..fd10155b2b --- /dev/null +++ b/bacula/src/lib/guid_to_name.h @@ -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); + diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 882bf9c07f..3032fc037e 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -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) diff --git a/bacula/src/lib/lib.h b/bacula/src/lib/lib.h index 0397bd9521..7ecc0858a6 100644 --- a/bacula/src/lib/lib.h +++ b/bacula/src/lib/lib.h @@ -67,5 +67,6 @@ #include "attr.h" #include "var.h" #include "address_conf.h" +#include "guid_to_name.h" #include "protos.h" diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 915c3d9007..00ec1e97b6 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -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 */ diff --git a/bacula/src/lib/message.h b/bacula/src/lib/message.h index 191e02c42b..476d3611a9 100644 --- a/bacula/src/lib/message.h +++ b/bacula/src/lib/message.h @@ -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; diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index a7a5d59e10..470ac52818 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -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); diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index e3b9340bdc..c1ed9ead16 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -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, diff --git a/bacula/src/lib/res.c b/bacula/src/lib/res.c index 59a41e8d8c..886f1a220b 100644 --- a/bacula/src/lib/res.c +++ b/bacula/src/lib/res.c @@ -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; diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 0c50f13579..fd4273b3b6 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -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 */ diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 6cda1e5a1b..ee8a9d3321 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -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! */ diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index 823d87137c..c8cb0a5f53 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -60,6 +60,7 @@ private slots: void pruneVolume(); void relabelVolume(); void allVolumesFromPool(); + void allVolumes(); void volumeFromPool(); private: diff --git a/bacula/src/qt-console/medialist/medialist.ui b/bacula/src/qt-console/medialist/medialist.ui index b4117bb5f4..058a4f8251 100644 --- a/bacula/src/qt-console/medialist/medialist.ui +++ b/bacula/src/qt-console/medialist/medialist.ui @@ -99,6 +99,23 @@ Update all Volumes From Pool + + + :/images/cartridge-edit.png + + + Update all Volumes from all Pools + + + Update all Volumes from all Pools + + + Update all Volumes from all Pools + + + Update all Volumes from all Pools + + :/images/cartridge-edit.png diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index cc13480ac3..379bf483fb 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -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); } diff --git a/bacula/src/qt-console/restore/restoretree.cpp b/bacula/src/qt-console/restore/restoretree.cpp index 6d22c70fe4..e1594a39b9 100644 --- a/bacula/src/qt-console/restore/restoretree.cpp +++ b/bacula/src/qt-console/restore/restoretree.cpp @@ -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; diff --git a/bacula/src/stored/ansi_label.c b/bacula/src/stored/ansi_label.c index 1414868491..e8978ec7bc 100644 --- a/bacula/src/stored/ansi_label.c +++ b/bacula/src/stored/ansi_label.c @@ -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. @@ -36,6 +25,17 @@ (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; } } diff --git a/bacula/src/stored/authenticate.c b/bacula/src/stored/authenticate.c index f2c4485c30..49f6551fc5 100644 --- a/bacula/src/stored/authenticate.c +++ b/bacula/src/stored/authenticate.c @@ -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. @@ -33,10 +25,21 @@ (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) { diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index 3776f92e2e..1d9cad0eba 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -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, "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; diff --git a/bacula/src/stored/bacula-sd.conf.in b/bacula/src/stored/bacula-sd.conf.in index 247eb01e41..c161f30d38 100644 --- a/bacula/src/stored/bacula-sd.conf.in +++ b/bacula/src/stored/bacula-sd.conf.in @@ -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 diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 6d6cba94f9..53f40d9738 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -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); diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index d23182a7ee..e5b95b624d 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -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 */ diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index d556cb4091..92d6fbcc95 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -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. @@ -33,6 +25,14 @@ (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"), diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index c8e38ad0fd..71254e5bbf 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -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)); diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 396e68a6e4..95a05e075a 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -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, "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, "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); } } diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index e6e35a0953..66a2301489 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -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"); diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 8f926bb7cc..e56e32c39b 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -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; } diff --git a/bacula/src/stored/lock.c b/bacula/src/stored/lock.c index 9b2a4ca1f8..28200047b9 100644 --- a/bacula/src/stored/lock.c +++ b/bacula/src/stored/lock.c @@ -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 diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index 16640f4e92..11528ad84c 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -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(); } } diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 070e788d8f..74c69e08c1 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -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) { diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index d58d032b3c..83b0e552dc 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -28,14 +28,42 @@ /* 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$ */ diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index 1963931e64..dafff136af 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -611,7 +611,7 @@ static void eliminate_duplicate_filenames() /* Loop through list of duplicate names */ for (int i=0; i 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 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) { diff --git a/bacula/src/tools/testfind.c b/bacula/src/tools/testfind.c index a14799a9a6..184580604b 100644 --- a/bacula/src/tools/testfind.c +++ b/bacula/src/tools/testfind.c @@ -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(); diff --git a/bacula/src/win32/README.vc8 b/bacula/src/win32/README.vc8 index c804f0afd6..838c0c781f 100644 --- a/bacula/src/win32/README.vc8 +++ b/bacula/src/win32/README.vc8 @@ -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 " @@ -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\include;\VC\PlatformSDK\Include; + + %LIB% (echo %LIB%) must contain + \VC\lib;\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 diff --git a/bacula/src/win32/cats/bacula_cats.def b/bacula/src/win32/cats/bacula_cats.def index 04f56127a7..9d75a1dadb 100644 --- a/bacula/src/win32/cats/bacula_cats.def +++ b/bacula/src/win32/cats/bacula_cats.def @@ -23,9 +23,6 @@ _ZN9dbid_listD1Ev _ZN9dbid_listD2Ev ; sql_create.o -_Z12my_batch_endP3JCRP4B_DBPKc -_Z14my_batch_startP3JCRP4B_DB -_Z15my_batch_insertP3JCRP4B_DBP8ATTR_DBR _Z20db_create_job_recordP3JCRP4B_DBP7JOB_DBR _Z21db_create_pool_recordP3JCRP4B_DBP8POOL_DBR _Z22db_create_media_recordP3JCRP4B_DBP9MEDIA_DBR @@ -93,7 +90,7 @@ _Z28db_add_digest_to_file_recordP3JCRP4B_DBjPci _Z11db_get_typev _Z12db_sql_queryP4B_DBPKcPFiPviPPcES3_ _Z13db_next_indexP3JCRP4B_DBPcS3_ -_Z16db_escape_stringPcS_i +_Z16db_escape_stringP3JCRP4B_DBPcS3_i _Z16db_init_databaseP3JCRPKcS2_S2_S2_iS2_i _Z16db_open_databaseP3JCRP4B_DB _Z17db_close_databaseP3JCRP4B_DB diff --git a/bacula/src/win32/cats/make_def b/bacula/src/win32/cats/make_def index aee776ecf3..945f86a9b6 100755 --- a/bacula/src/win32/cats/make_def +++ b/bacula/src/win32/cats/make_def @@ -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"; \ diff --git a/bacula/src/win32/dll/bacula.def b/bacula/src/win32/dll/bacula.def index f5bbdacbe6..264e7edcd1 100644 --- a/bacula/src/win32/dll/bacula.def +++ b/bacula/src/win32/dll/bacula.def @@ -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 diff --git a/bacula/src/win32/dll/make_def b/bacula/src/win32/dll/make_def index 6b754c924a..89b036e058 100755 --- a/bacula/src/win32/dll/make_def +++ b/bacula/src/win32/dll/make_def @@ -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 index 59b5568033..0000000000 --- a/bacula/src/win32/libwin32/wintray.h +++ /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 diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 85794f8407..f5d4aac55d 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -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. -- 2.39.5