From f96efc7d30726fe864e38e2d7d15f8add3d22ee7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 2 Oct 2004 10:19:09 +0000 Subject: [PATCH] - Use different share mode when opening files on WinMe/98/95 since SHARE_DELETE is not implemented on those systems. - In new syntax Includes, pass *all* files through the acceptance filter so that no error messages will be printed for files that cannot be opened if they are excluded. - Fix bug 126 (Martin) -- prevent failed console label request from going into fixup code and thus trying to update the catalog. - Always fold case in fnmatch() on Win32 systems - Create patches/README and the patch summary file. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1625 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/examples/next_tape.sh | 78 ++++++++++++++++++++++++++++++++++++ bacula/kernstodo | 2 + bacula/patches/README | 18 +++++++++ bacula/src/findlib/bfile.c | 14 +++---- bacula/src/findlib/find.c | 20 ++++++--- bacula/src/findlib/match.c | 16 +++++++- bacula/src/stored/block.c | 2 +- bacula/src/version.h | 4 +- 8 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 bacula/examples/next_tape.sh create mode 100644 bacula/patches/README diff --git a/bacula/examples/next_tape.sh b/bacula/examples/next_tape.sh new file mode 100644 index 0000000000..d09f44a6f7 --- /dev/null +++ b/bacula/examples/next_tape.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +# A script which kicks out messages if a new tape is required for the next job. +# It may be used as RunAfterJob script and it works fine for me. +# Maybe someone considers it useful or has some ideas to improve it. +# +# Contributed by Dirk grosse Osterhues +# +# select language: english (en) or german (de) +LANG="en" +# reciepient-address for notification +MAILTO_ADDR="your-email-address" +# bcc-address for notification +BCC_ADDR="email-address" +# directory for temp-files +TEMP_DIR="/tmp/bacula" +# bacula's console.conf +CONSOLE_CONF=/etc/bacula/bconsole.conf +############################################ + +# test if console.conf exists +if [ ! -f $CONSOLE_CONF ]; then + echo "You need to reconfigure varible \$CONSOLE_CONF" + exit 1 +fi +# get todays tape +director_output() { +/usr/sbin/bacula-console -c $CONSOLE_CONF <$TEMP_DIR/NEXT-TAPE-$YESTERDAY +fi +echo $TAPE_TODAY>$TEMP_DIR/NEXT-TAPE-$TODAY + +# definition of language-dependent variables +case $LANG in + de) + MAIL_SUBJECT="[Bacula] Bitte Tape wechslen!" + MAIL_BODY="Nachricht von Bacula-Backup-System auf $HOST:\ + \n\n Tape entfernen:\t\""$TAPE_YESTERDAY"\"\ + \n Tape einlegen: \t\""$TAPE_TODAY"\"" + ;; + en) + MAIL_SUBJECT="[Bacula] Please replace Tape tonight!" + MAIL_BODY="Message from bacula-backup-service on $HOST:\ + \n\n Remove Tape:\t\""$TAPE_YESTERDAY"\"\ + \n Insert Tape:\t\""$TAPE_TODAY"\"" + ;; +esac + +# send notification +if [ $TAPE_TODAY != $TAPE_YESTERDAY ] ; then + echo -e $MAIL_BODY | mail -a "X-Bacula: Tape-Notifier on $HOST" -s "`echo $MAIL_SUBJECT`" -b $BCC_ADDR $MAILTO_ADDR +fi + +# remove older temp-files +find $TEMP_DIR -type f -name NEXT-TAPE-\*| while read I; do + TAPE_FILE=${I##/tmp/bacula/} + if [ $TAPE_FILE ]; then + if [ $TAPE_FILE != NEXT-TAPE-$TODAY ] && [ $TAPE_FILE != NEXT-TAPE-$YESTERDAY ]; then + rm $TEMP_DIR/$TAPE_FILE + fi + fi +done diff --git a/bacula/kernstodo b/bacula/kernstodo index 2374bb5ed7..353dcb9578 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -69,6 +69,8 @@ Testing to do: (painful) For 1.37 Testing/Documentation: +- Implement a Client filename case fold option (default = fold + on Win32). - Fix list volumes to output volume retention in some other units, perhaps via a directive. - If opening a tape in read/write mode fails attempt to open diff --git a/bacula/patches/README b/bacula/patches/README new file mode 100644 index 0000000000..910d6ed776 --- /dev/null +++ b/bacula/patches/README @@ -0,0 +1,18 @@ + +This directory contains patches to the *previous* released version +of Bacula. As they are developed, they will be put into this directory +so that they are all in one place, and you can easily find all +the patches that exist at a particular time. + +When a new official version of Bacula is released (for example 1.36.0), +the patches for the previous release (for example 1.34) will be +placed in a subdirectory, and patches for the new version will +go into the main directory. + +The file "patches-version" (for example "patches-1.34.6") will +contain a summary of each of the patches and when it was created, +so that you can easily see the order and the purpose of each patch. +Sometimes there may be dependencies between the patches -- i.e. a +later patch needs a prior patch to be applied first. I'll try to +note those, but cannot guarantee it. + diff --git a/bacula/src/findlib/bfile.c b/bacula/src/findlib/bfile.c index 9197233da3..1f9122a070 100644 --- a/bacula/src/findlib/bfile.c +++ b/bacula/src/findlib/bfile.c @@ -9,7 +9,7 @@ * */ /* - Copyright (C) 2000-2003 Kern Sibbald and John Walker + Copyright (C) 2003-2004 Kern Sibbald and John Walker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -192,7 +192,7 @@ HANDLE bget_handle(BFILE *bfd) int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) { POOLMEM *win32_fname; - DWORD dwaccess, dwflags; + DWORD dwaccess, dwflags, dwshare; /* Convert to Windows path format */ win32_fname = get_pool_memory(PM_FNAME); @@ -217,11 +217,7 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) } else if (flags & O_WRONLY) { /* Open existing for write */ if (bfd->use_backup_api) { -#ifdef HAVE_WIN32 - dwaccess = GENERIC_WRITE|/*FILE_ALL_ACCESS|*/WRITE_OWNER|WRITE_DAC/*|ACCESS_SYSTEM_SECURITY*/; -#else - dwaccess = GENERIC_WRITE|FILE_ALL_ACCESS|WRITE_OWNER|WRITE_DAC|ACCESS_SYSTEM_SECURITY; -#endif + dwaccess = GENERIC_WRITE|WRITE_OWNER|WRITE_DAC; dwflags = FILE_FLAG_BACKUP_SEMANTICS; } else { dwaccess = GENERIC_WRITE; @@ -240,13 +236,15 @@ int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode) if (bfd->use_backup_api) { dwaccess = GENERIC_READ|READ_CONTROL|ACCESS_SYSTEM_SECURITY; dwflags = FILE_FLAG_BACKUP_SEMANTICS; + dwshare = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE; } else { dwaccess = GENERIC_READ; dwflags = 0; + dwshare = FILE_SHARE_READ|FILE_SHARE_WRITE; } bfd->fh = CreateFile(win32_fname, dwaccess, /* Requested access */ - FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, + dwshare, /* Share modes */ NULL, /* SecurityAttributes */ OPEN_EXISTING, /* CreationDisposition */ dwflags, /* Flags and attributes */ diff --git a/bacula/src/findlib/find.c b/bacula/src/findlib/find.c index 4180319cf6..c8a510f6d8 100644 --- a/bacula/src/findlib/find.c +++ b/bacula/src/findlib/find.c @@ -1,6 +1,9 @@ /* * Main routine for finding files on a file system. - * The heart of the work is done in find_one.c + * The heart of the work to find the files on the + * system is done in find_one.c. Here we have the + * higher level control as well as the matching + * routines for the new syntax Options resource. * * Kern E. Sibbald, MM */ @@ -38,6 +41,13 @@ int32_t path_max; /* path name max length */ static int our_callback(FF_PKT *ff, void *hpkt); static bool accept_file(FF_PKT *ff); +/* Fold case in fnmatch() on Win32 */ +#ifdef WIN32 +static const int fnmode = FNM_CASEFOLD; +#else +static const int fnmode = 0; +#endif + /* * Initialize the find files "global" variables @@ -165,7 +175,7 @@ static bool accept_file(FF_PKT *ff) ff->reader = fo->reader; ff->writer = fo->writer; for (k=0; kwild.size(); k++) { - if (fnmatch((char *)fo->wild.get(k), ff->fname, 0) == 0) { + if (fnmatch((char *)fo->wild.get(k), ff->fname, fnmode) == 0) { if (ff->flags & FO_EXCLUDE) { return false; /* reject file */ } @@ -191,14 +201,14 @@ static bool accept_file(FF_PKT *ff) for (j=0; jopts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); for (k=0; kwild.size(); k++) { - if (fnmatch((char *)fo->wild.get(k), ff->fname, 0) == 0) { + if (fnmatch((char *)fo->wild.get(k), ff->fname, fnmode) == 0) { Dmsg1(400, "Reject wild1: %s\n", ff->fname); return false; /* reject file */ } } } for (j=0; jname_list.size(); j++) { - if (fnmatch((char *)incexe->name_list.get(j), ff->fname, 0) == 0) { + if (fnmatch((char *)incexe->name_list.get(j), ff->fname, fnmode) == 0) { Dmsg1(400, "Reject wild2: %s\n", ff->fname); return false; /* reject file */ } @@ -223,7 +233,7 @@ static int our_callback(FF_PKT *ff, void *hpkt) case FT_NORECURSE: case FT_NOFSCHG: case FT_NOOPEN: - return ff->callback(ff, hpkt); +// return ff->callback(ff, hpkt); /* These items can be filtered */ case FT_LNKSAVED: diff --git a/bacula/src/findlib/match.c b/bacula/src/findlib/match.c index 43a27a2b53..a1b811418d 100644 --- a/bacula/src/findlib/match.c +++ b/bacula/src/findlib/match.c @@ -2,6 +2,10 @@ * Routines used to keep and match include and exclude * filename/pathname patterns. * + * Note, this file is used for the old style include and + * excludes, so is deprecated. The new style code is + * found in find.c + * * Kern E. Sibbald, December MMI * */ @@ -36,6 +40,14 @@ #define FNM_LEADING_DIR 0 #endif +/* Fold case in fnmatch() on Win32 */ +#ifdef WIN32 +static const int fnmode = FNM_CASEFOLD; +#else +static const int fnmode = 0; +#endif + + #undef bmalloc #define bmalloc(x) sm_malloc(__FILE__, __LINE__, x) @@ -279,7 +291,7 @@ int file_is_included(FF_PKT *ff, const char *file) for ( ; inc; inc=inc->next ) { if (inc->pattern) { - if (fnmatch(inc->fname, file, FNM_LEADING_DIR) == 0) { + if (fnmatch(inc->fname, file, fnmode|FNM_LEADING_DIR) == 0) { return 1; } continue; @@ -316,7 +328,7 @@ file_in_excluded_list(struct s_excluded_file *exc, const char *file) Dmsg0(900, "exc is NULL\n"); } for ( ; exc; exc=exc->next ) { - if (fnmatch(exc->fname, file, FNM_PATHNAME) == 0) { + if (fnmatch(exc->fname, file, fnmode|FNM_PATHNAME) == 0) { Dmsg2(900, "Match exc pat=%s: file=%s:\n", exc->fname, file); return 1; } diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index 1c73dc47d5..d7288b0126 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -366,7 +366,7 @@ bool write_block_to_device(DCR *dcr) } if (!write_block_to_dev(dcr)) { - if (job_canceled(jcr)) { + if (job_canceled(jcr) || jcr->JobType == JT_SYSTEM) { stat = false; } else { stat = fixup_device_block_write_error(dcr); diff --git a/bacula/src/version.h b/bacula/src/version.h index 95bcb0d1c0..f499ef9438 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.35.6" -#define BDATE "30 September 2004" -#define LSMDATE "30Sep04" +#define BDATE "02 October 2004" +#define LSMDATE "02Oct04" /* Debug flags */ #undef DEBUG -- 2.39.2