--- /dev/null
+Please see the file LICENSE concerning the terms of the license,
+copying and such.
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
# -------------------------------------------------------------------------
Install binaries: ${sbindir}
Install config files: ${sysconfdir}
Scripts directory: ${scriptdir}
+ Archive directory: ${archivedir}
Working directory: ${working_dir}
PID directory: ${piddir}
Subsys directory: ${subsysdir}
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_DIR TOP_DIR TRUEPRG FALSEPRG VERSION DATE LSMDATE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB MV RM CP SED ECHO CMP TBL AR OPENSSL MTX DD MKISOFS PYTHON GROWISOFS DVDRWMEDIAINFO DVDRWFORMAT PKGCONFIG WXCONFIG WXFLAGS CDRECORD PIDOF AWK ARFLAGS MAKE_SHELL LOCAL_LIBS LOCAL_CFLAGS LOCAL_LDFLAGS LOCAL_DEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os HAVE_SUN_OS_TRUE HAVE_SUN_OS_FALSE HAVE_OSF1_OS_TRUE HAVE_OSF1_OS_FALSE HAVE_AIX_OS_TRUE HAVE_AIX_OS_FALSE HAVE_HPUX_OS_TRUE HAVE_HPUX_OS_FALSE HAVE_LINUX_OS_TRUE HAVE_LINUX_OS_FALSE HAVE_FREEBSD_OS_TRUE HAVE_FREEBSD_OS_FALSE HAVE_NETBSD_OS_TRUE HAVE_NETBSD_OS_FALSE HAVE_OPENBSD_OS_TRUE HAVE_OPENBSD_OS_FALSE HAVE_BSDI_OS_TRUE HAVE_BSDI_OS_FALSE HAVE_SGI_OS_TRUE HAVE_SGI_OS_FALSE HAVE_IRIX_OS_TRUE HAVE_IRIX_OS_FALSE HAVE_DARWIN_OS_TRUE HAVE_DARWIN_OS_FALSE SET_MAKE MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE INTL_MACOSX_LIBS LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB GLIBC2 ALLOCA GLIBC21 HAVE_POSIX_PRINTF HAVE_ASPRINTF HAVE_SNPRINTF HAVE_WPRINTF INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX GNOME_INCLUDEDIR GNOMEUI_LIBS GNOME_LIBDIR GNOME_LIBS GNOME_DIR BAT_DIR QWT_INC QWT_LDFLAGS WXCONS_CPPFLAGS WXCONS_LDFLAGS WX_DIR TRAY_MONITOR_CPPFLAGS TRAY_MONITOR_LDFLAGS TRAY_MONITOR_DIR TTOOL_LDFLAGS STATIC_FD STATIC_SD STATIC_DIR STATIC_CONS STATIC_GNOME_CONS STATIC_WX_CONS ALL_DIRS DIRD_DIR DIR_TOOLS STORED_DIR CONS_INC CONS_OBJ CONS_SRC CONS_LIBS CONS_LDFLAGS READLINE_SRC PYTHON_LIBS PYTHON_INCDIR OPENSSL_LIBS OPENSSL_INC working_dir scriptdir dump_email job_email smtp_host piddir subsysdir baseport dir_port fd_port sd_port dir_password fd_password sd_password mon_dir_password mon_fd_password mon_sd_password db_name db_user dir_user dir_group sd_user sd_group fd_user fd_group SBINPERM SQL_LFLAGS SQL_INCLUDE SQL_BINDIR cats DB_TYPE GETCONF ac_ct_GETCONF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBOBJS FDLIBS DEBUG DINCLUDE DLIB DB_LIBS WCFLAGS WLDFLAGS WRAPLIBS OBJLIST hostname TAPEDRIVE PSCMD WIN32 MACOSX DISTNAME DISTVER LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir archivedir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_DIR TOP_DIR TRUEPRG FALSEPRG VERSION DATE LSMDATE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB MV RM CP SED ECHO CMP TBL AR OPENSSL MTX DD MKISOFS PYTHON GROWISOFS DVDRWMEDIAINFO DVDRWFORMAT PKGCONFIG WXCONFIG WXFLAGS CDRECORD PIDOF AWK ARFLAGS MAKE_SHELL LOCAL_LIBS LOCAL_CFLAGS LOCAL_LDFLAGS LOCAL_DEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os HAVE_SUN_OS_TRUE HAVE_SUN_OS_FALSE HAVE_OSF1_OS_TRUE HAVE_OSF1_OS_FALSE HAVE_AIX_OS_TRUE HAVE_AIX_OS_FALSE HAVE_HPUX_OS_TRUE HAVE_HPUX_OS_FALSE HAVE_LINUX_OS_TRUE HAVE_LINUX_OS_FALSE HAVE_FREEBSD_OS_TRUE HAVE_FREEBSD_OS_FALSE HAVE_NETBSD_OS_TRUE HAVE_NETBSD_OS_FALSE HAVE_OPENBSD_OS_TRUE HAVE_OPENBSD_OS_FALSE HAVE_BSDI_OS_TRUE HAVE_BSDI_OS_FALSE HAVE_SGI_OS_TRUE HAVE_SGI_OS_FALSE HAVE_IRIX_OS_TRUE HAVE_IRIX_OS_FALSE HAVE_DARWIN_OS_TRUE HAVE_DARWIN_OS_FALSE SET_MAKE MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE INTL_MACOSX_LIBS LIBICONV LTLIBICONV INTLLIBS LIBINTL LTLIBINTL POSUB GLIBC2 ALLOCA GLIBC21 HAVE_POSIX_PRINTF HAVE_ASPRINTF HAVE_SNPRINTF HAVE_WPRINTF INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX GNOME_INCLUDEDIR GNOMEUI_LIBS GNOME_LIBDIR GNOME_LIBS GNOME_DIR BAT_DIR QWT_INC QWT_LDFLAGS WXCONS_CPPFLAGS WXCONS_LDFLAGS WX_DIR TRAY_MONITOR_CPPFLAGS TRAY_MONITOR_LDFLAGS TRAY_MONITOR_DIR TTOOL_LDFLAGS STATIC_FD STATIC_SD STATIC_DIR STATIC_CONS STATIC_GNOME_CONS STATIC_WX_CONS ALL_DIRS DIRD_DIR DIR_TOOLS STORED_DIR CONS_INC CONS_OBJ CONS_SRC CONS_LIBS CONS_LDFLAGS READLINE_SRC PYTHON_LIBS PYTHON_INCDIR OPENSSL_LIBS OPENSSL_INC working_dir scriptdir dump_email job_email smtp_host piddir subsysdir baseport dir_port fd_port sd_port dir_password fd_password sd_password mon_dir_password mon_fd_password mon_sd_password db_name db_user dir_user dir_group sd_user sd_group fd_user fd_group SBINPERM SQL_LFLAGS SQL_INCLUDE SQL_BINDIR cats DB_TYPE GETCONF ac_ct_GETCONF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LIBOBJS FDLIBS DEBUG DINCLUDE DLIB DB_LIBS WCFLAGS WLDFLAGS WRAPLIBS OBJLIST hostname TAPEDRIVE PSCMD WIN32 MACOSX DISTNAME DISTVER LTLIBOBJS'
ac_subst_files='MCOMMON'
# Initialize some variables set by options.
infodir='${prefix}/info'
mandir='${prefix}/man'
+archivedir='/tmp'
+
ac_prev=
for ac_option
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 \
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`
--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
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
# -------------------------------------------------------------------------
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
Install binaries: ${sbindir}
Install config files: ${sysconfdir}
Scripts directory: ${scriptdir}
+ Archive directory: ${archivedir}
Working directory: ${working_dir}
PID directory: ${piddir}
Subsys directory: ${subsysdir}
- 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.
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.
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.
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
Item 20: An option to operate on all pools with update vol parameters
Origin: Dmitriy Pinchukov <absh@bossdev.kiev.ua>
Date: 16 August 2006
- Status:
+ Status: Patch made by Nigel Stepp
What: When I do update -> Volume parameters -> All Volumes
from Pool, then I have to select pools one by one. I'd like
manual/interactive jobs
Origin: Marc Schiffbauer <marc@schiffbauer.net>
Date: 12 April 2007)
- Status: Already implemented by Eric
+ Status:
What: Make it possible to modify the spooldata option
for a job when being run from within the console.
{ }
-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);
* 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);
}
/*
}
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;
* 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");
+ }
}
/*
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);
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";
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) {
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)) {
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)) {
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) {
* 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;
}
}
- 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;
}
}
/* Send backup command */
- bnet_fsend(fd, backupcmd);
+ fd->fsend(backupcmd);
if (!response(jcr, fd, OKbackup, "backup", DISPLAY_ERROR)) {
goto bail_out;
}
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) {
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);
}
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);
}
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;
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");
}
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);
}
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;
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;
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);
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);
}
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 */
}
}
}
+bail_out:
+ if (job_canceled(jcr)) {
+ cancel_storage_daemon_job(jcr);
+ }
}
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 */
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 */
}
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;
/*
* 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));
{
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;
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);
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;
/* 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;
}
}
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);
}
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);
{
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");
* 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
*/
/* 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];
*/
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 */
/* 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 == ' ') {
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);
/* 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");
-/*
- *
- * Bacula Director -- newvol.c -- creates new Volumes in
- * catalog Media table from the LabelFormat specification.
- *
- * Kern Sibbald, May MMI
- *
- * This routine runs as a thread and must be thread reentrant.
- *
- * Basic tasks done here:
- * If possible create a new Media entry
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula Director -- newvol.c -- creates new Volumes in
+ * catalog Media table from the LabelFormat specification.
+ *
+ * Kern Sibbald, May MMI
+ *
+ * This routine runs as a thread and must be thread reentrant.
+ *
+ * Basic tasks done here:
+ * If possible create a new Media entry
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "dird.h"
{
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);
}
/* Send restore command */
- char replace, *where, *cmd=NULL;
+ char replace, *where, *cmd;
char empty = '\0';
if (jcr->replace != 0) {
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) {
} 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;
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 */
}
}
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);
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;
}
}
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);
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);
}
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;
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);
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;
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;
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;
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;
/* 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);
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)) {
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 {
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);
/* 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) {
"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.
break;
}
}
+ if (ua->api) user->signal(BNET_END_RTREE);
ua->UA_sock = NULL; /* don't release restore socket */
stat = !ua->quit;
ua->quit = false;
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;
*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;
} 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;
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) {
/* 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;
}
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;
}
/*
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) {
-/*
- * Authenticate Director who is attempting to connect.
- *
- * Kern Sibbald, October 2000
- *
- * Version $Id$
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Authenticate Director who is attempting to connect.
+ *
+ * Kern Sibbald, October 2000
+ *
+ * Version $Id$
+ *
+ */
#include "bacula.h"
#include "filed.h"
+const int dbglvl = 50;
+
static char OK_hello[] = "2000 OK Hello\n";
static char Dir_sorry[] = "2999 No go\n";
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
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;
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);
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"),
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());
}
}
}
debug_level = level;
set_trace(trace_flag);
- return bnet_fsend(dir, OKsetdebug, level);
+ return dir->fsend(OKsetdebug, level);
}
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;
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)
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;
}
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;
Dmsg0(110, "Authenticated with SD.\n");
/* Send OK to Director */
- return bnet_fsend(dir, OKstore);
+ return dir->fsend(OKstore);
}
*/
binit(&rctx.bfd);
binit(&rctx.forkbfd);
- attr = new_attr();
+ attr = new_attr(jcr);
jcr->acl_text = get_pool_memory(PM_MESSAGE);
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 ";
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 */
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 */
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 */
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 \
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 \
-/*
- * attr.c Unpack an Attribute record returned from the tape
- *
- * Kern Sibbald, June MMIII (code pulled from filed/restore.c and updated)
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2003-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * attr.c Unpack an Attribute record returned from the tape
+ *
+ * Kern Sibbald, June MMIII (code pulled from filed/restore.c and updated)
+ *
+ * Version $Id$
+ */
+
#include "bacula.h"
#include "jcr.h"
#include "lib/breg.h"
-ATTR *new_attr()
+ATTR *new_attr(JCR *jcr)
{
ATTR *attr = (ATTR *)malloc(sizeof(ATTR));
memset(attr, 0, sizeof(ATTR));
attr->ofname = get_pool_memory(PM_FNAME);
attr->olname = get_pool_memory(PM_FNAME);
attr->attrEx = get_pool_memory(PM_FNAME);
+ attr->jcr = jcr;
+ attr->uid = getuid();
return attr;
}
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++ = ' ';
* Version $Id$
*/
+#ifndef __ATTR_H_
+#define __ATTR_H_ 1
+
struct ATTR {
int32_t stream; /* attribute stream id */
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 */
char *attr; /* attributes position */
char *fname; /* filename */
char *lname; /* link name if any */
+ JCR *jcr; /* jcr pointer */
};
+
+#endif /* __ATTR_H_ */
/* 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)
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,
*/
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[]);
/* 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_ */
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);
}
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;
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 */
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_ */
#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
/* 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;
}
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);
}
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;
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;
}
{
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);
--- /dev/null
+/*
+ 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
--- /dev/null
+/*
+ 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);
+
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);
}
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)
#include "attr.h"
#include "var.h"
#include "address_conf.h"
+#include "guid_to_name.h"
#include "protos.h"
#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;
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 */
/* 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))
{
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;
}
int len, dtlen;
MSGS *msgs;
BPIPE *bpipe;
- char *mode;
+ const char *mode;
Dmsg2(850, "Enter dispatch_msg type=%d msg=%s", type, msg);
/* Now figure out where to send the message */
msgs = NULL;
+ if (!jcr) {
+ jcr = get_jcr_from_tsd();
+ }
if (jcr) {
msgs = jcr->jcr_msgs;
}
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')",
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;
}
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;
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 */
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;
/* 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);
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);
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,
* 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;
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 */
/* 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()));
}
populateTree();
}
+void MediaList::allVolumes()
+{
+ QString cmd = "update volume allfrompools";
+ consoleCommand(cmd);
+ populateTree();
+}
+
/*
* Called from the signal of the context sensitive menu to purge!
*/
void pruneVolume();
void relabelVolume();
void allVolumesFromPool();
+ void allVolumes();
void volumeFromPool();
private:
<string>Update all Volumes From Pool</string>
</property>
</action>
+ <action name="actionAllVolumes" >
+ <property name="icon" >
+ <iconset resource="../main.qrc" >:/images/cartridge-edit.png</iconset>
+ </property>
+ <property name="text" >
+ <string>Update all Volumes from all Pools</string>
+ </property>
+ <property name="iconText" >
+ <string>Update all Volumes from all Pools</string>
+ </property>
+ <property name="toolTip" >
+ <string>Update all Volumes from all Pools</string>
+ </property>
+ <property name="statusTip" >
+ <string>Update all Volumes from all Pools</string>
+ </property>
+ </action>
<action name="actionVolumeFromPool" >
<property name="icon" >
<iconset resource="../main.qrc" >:/images/cartridge-edit.png</iconset>
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);
}
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;
-/*
- *
- * ansi_label.c routines to handle ANSI (and perhaps one day IBM)
- * tape labels.
- *
- * Kern Sibbald, MMV
- *
- *
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2005-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * ansi_label.c routines to handle ANSI (and perhaps one day IBM)
+ * tape labels.
+ *
+ * Kern Sibbald, MMV
+ *
+ *
+ *
+ * Version $Id$
+ */
#include "bacula.h" /* pull in global headers */
#include "stored.h" /* pull in Storage Deamon headers */
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));
ok = true;;
dev->label_type = B_IBM_LABEL;
Dmsg0(100, "Found IBM label.\n");
+ Dmsg0(100, "Got IBM VOL1 label\n");
}
}
}
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) {
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) {
Mmsg0(jcr->errmsg, _("Unknown or bad ANSI/IBM label record.\n"));
return VOL_LABEL_ERROR;
}
+ Dmsg0(100, "Got HDR label\n");
break;
}
}
-/*
- * Authenticate caller
- *
- * Kern Sibbald, October 2000
- *
- * Version $Id$
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Authenticate caller
+ *
+ * Kern Sibbald, October 2000
+ *
+ * Version $Id$
+ *
+ */
+
#include "bacula.h"
#include "stored.h"
+const int dbglvl = 50;
+
static char Dir_sorry[] = "3999 No go\n";
static char OK_hello[] = "3000 OK Hello\n";
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);
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);
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"),
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) {
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)
/* 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) {
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;
}
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;
}
/* 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) {
/* Strip any leading space in front of # of slots */
for (p=buf; B_ISSPACE(*p); p++)
{ }
- bnet_fsend(dir, "slots=%s", p);
+ dir->fsend("slots=%s", p);
Dmsg1(100, "<stored: %s", dir->msg);
}
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;
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
free(jcr->where);
jcr->where = bstrdup(where);
- attr = new_attr();
+ attr = new_attr(jcr);
compress_buf = get_memory(compress_buf_size);
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) {
/* 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;
}
/* 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 */
-/*
- *
- * Dumb program to do an "ls" of a Bacula 1.0 mortal file.
- *
- * Kern Sibbald, MM
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Dumb program to do an "ls" of a Bacula 1.0 mortal file.
+ *
+ * Kern Sibbald, MM
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "stored.h"
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) {
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) {
}
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
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"),
static void do_scan()
{
- attr = new_attr();
+ attr = new_attr(bjcr);
memset(&ar, 0, sizeof(ar));
memset(&pr, 0, sizeof(pr));
if (bs->recv() <= 0) {
Emsg0(M_ERROR, 0, _("Connection request failed.\n"));
- bnet_close(bs);
+ bs->close();
return NULL;
}
* Do a sanity check on the message received
*/
if (bs->msglen < 25 || bs->msglen > (int)sizeof(name)) {
+ Dmsg1(000, "<filed: %s", bs->msg);
Emsg1(M_ERROR, 0, _("Invalid connection. Len=%d\n"), bs->msglen);
- bnet_close(bs);
+ bs->close();
return NULL;
}
/*
* call FD handler.
*/
Dmsg1(110, "Conn: %s", bs->msg);
+ if (debug_level == 3) {
+ Dmsg1(000, "<filed: %s", bs->msg);
+ }
if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
Dmsg0(110, "Got a FD connection\n");
handle_filed_connection(bs, name);
/* 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;
}
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;
}
}
}
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;
}
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);
}
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);
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;
}
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;
}
/* 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;
}
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;
/* 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! */
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;
}
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;
/* 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);
}
/* 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 */
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());
}
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;
}
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;
}
}
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) {
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()) {
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;
}
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()) {
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;
}
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()) {
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);
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;
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;
}
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);
}
}
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");
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;
}
* 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)
* 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
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);
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();
}
}
*/
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 */
/* 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) {
/*
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$
*/
/* Loop through list of duplicate names */
for (int i=0; i<name_list.num_ids; i++) {
/* Get all the Ids of each name */
- db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+ db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i]));
bsnprintf(buf, sizeof(buf), "SELECT FilenameId FROM Filename WHERE Name='%s'", esc_name);
if (verbose > 1) {
printf("%s\n", buf);
/* Loop through list of duplicate names */
for (int i=0; i<name_list.num_ids; i++) {
/* Get all the Ids of each name */
- db_escape_string(esc_name, name_list.name[i], strlen(name_list.name[i]));
+ db_escape_string(NULL, db, esc_name, name_list.name[i], strlen(name_list.name[i]));
bsnprintf(buf, sizeof(buf), "SELECT PathId FROM Path WHERE Path='%s'", esc_name);
if (verbose > 1) {
printf("%s\n", buf);
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",
}
/* 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) {
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();
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.
(MSDN Library is NOT needed).
+ Remember where you install it (e.g. E:\Microsoft Visual Studio 8\)
- - Windows® Server 2003 SP1 Platform SDK Full Download
+ - Windows Server 2003 SP1 Platform SDK Full Download
+ Run psdk-full.exe, type the directory where you downloaded the cab
files.
+ In a command prompt, run "PSDK-full.bat <temp directory>"
+ When asked for components, you can safely remove documentation,
samples, and all 64-bit tools and libs if you want to save disk
space.
+ NOTE: Just after having installed "Windows® Server 2003 SP1 Platform SDK Full Download",
+ my XP was no more considered as "genuine". You are warned.
+ That's why it is recommended to download "volume shadow copy service sdk" before installing SDK
+
+ - Microsoft VSS SDK
+ + Normally the files will be installed in: C:\Program Files\Microsoft\VSSSDK72
+ + You only need to copy everything under the C:\Program Files\Microsoft\VSSSDK72\inc
+ directory into .../depkgs-msvc/vss/inc.
+
+ - Verify what you've got in your system variables :
+ + %INCLUDE% (echo %INCLUDE%) must contain
+ <vc++ install dir>\VC\include;<vc++ install dir>\VC\PlatformSDK\Include;
+ + %LIB% (echo %LIB%) must contain
+ <vc++ install dir>\VC\lib;<vc++ install dir>\VC\PlatformSDK\Lib
One-time Setup
==============
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
========
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
---------------
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
_ZN9dbid_listD2Ev\r
\r
; sql_create.o\r
-_Z12my_batch_endP3JCRP4B_DBPKc\r
-_Z14my_batch_startP3JCRP4B_DB\r
-_Z15my_batch_insertP3JCRP4B_DBP8ATTR_DBR\r
_Z20db_create_job_recordP3JCRP4B_DBP7JOB_DBR\r
_Z21db_create_pool_recordP3JCRP4B_DBP8POOL_DBR\r
_Z22db_create_media_recordP3JCRP4B_DBP9MEDIA_DBR\r
_Z11db_get_typev\r
_Z12db_sql_queryP4B_DBPKcPFiPviPPcES3_\r
_Z13db_next_indexP3JCRP4B_DBPcS3_\r
-_Z16db_escape_stringPcS_i\r
+_Z16db_escape_stringP3JCRP4B_DBPcS3_i\r
_Z16db_init_databaseP3JCRPKcS2_S2_S2_iS2_i\r
_Z16db_open_databaseP3JCRP4B_DB\r
_Z17db_close_databaseP3JCRP4B_DB\r
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"
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"; \
_Z15print_ls_outputP3JCRP4ATTR
_Z24build_attr_output_fnamesP3JCRP4ATTR
_Z24unpack_attributes_recordP3JCRiPcP4ATTR
-_Z8new_attrv
+_Z8new_attrP3JCR
_Z9free_attrP4ATTR
; base64.o
_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
_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
; 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
_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
_Z7new_jcriPFvP3JCRE
_Z9lock_jobsv
timeout_handler
+
+
; lex.o
_Z11scan_to_eolP13s_lex_context
#
# 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
+++ /dev/null
-// 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
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
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.