From 24bf56a9e5fae1c156a9624c43196a5b50a2700a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 30 Jan 2008 12:59:34 +0000 Subject: [PATCH] kes Apply patch from bug #1049 to prevent stripping the path on a symlink. kes Attempt to fix bug #1047 where stripping a path corrupts the heap. Waiting for feedback. kes Correct the Mount message not to suggest labeling a new tape when doing a restore. Submitted by email by John Stoffel. kes Attempt to work around gcc FORTIFY_SOURCE bug that crashes the FD by using casting. Reported in bug #1042. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6345 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/newvol.c | 2 +- bacula/src/filed/backup.c | 18 ++++++++++-------- bacula/src/lib/parse_conf.c | 2 +- bacula/src/stored/acquire.c | 2 +- bacula/src/stored/askdir.c | 18 ++++++++++++++---- bacula/src/stored/bcopy.c | 4 ++-- bacula/src/stored/bextract.c | 30 +++++++++++++++--------------- bacula/src/stored/bls.c | 4 ++-- bacula/src/stored/bscan.c | 2 +- bacula/src/stored/btape.c | 2 +- bacula/src/stored/mount.c | 4 ++-- bacula/src/stored/protos.h | 2 +- bacula/src/version.h | 4 ++-- bacula/technotes-2.3 | 9 +++++++++ 14 files changed, 62 insertions(+), 41 deletions(-) diff --git a/bacula/src/dird/newvol.c b/bacula/src/dird/newvol.c index b15ade839d..4a57019e01 100644 --- a/bacula/src/dird/newvol.c +++ b/bacula/src/dird/newvol.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index a42ad87049..3620355675 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -1176,20 +1176,22 @@ static void strip_path(FF_PKT *ff_pkt) /* * Strip path. If it doesn't succeed put it back. If * it does, and there is a different link string, - * attempt to strip the link. If it fails, but them + * attempt to strip the link. If it fails, back them * both back. + * Do not strip symlinks. * I.e. if either stripping fails don't strip anything. */ if (do_strip(ff_pkt->strip_path, ff_pkt->fname)) { - if (ff_pkt->fname != ff_pkt->link) { + /* Strip links but not symlinks */ + if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { pm_strcpy(ff_pkt->link_save, ff_pkt->link); if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { - strcpy(ff_pkt->link, ff_pkt->link_save); - strcpy(ff_pkt->fname, ff_pkt->fname_save); + pm_strcpy(ff_pkt->link, ff_pkt->link_save); + pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); } } } else { - strcpy(ff_pkt->fname, ff_pkt->fname_save); + pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); } Dmsg2(200, "fname=%s stripped=%s\n", ff_pkt->fname_save, ff_pkt->fname); } @@ -1199,8 +1201,8 @@ static void unstrip_path(FF_PKT *ff_pkt) if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) { return; } - strcpy(ff_pkt->fname, ff_pkt->fname_save); - if (ff_pkt->fname != ff_pkt->link) { - strcpy(ff_pkt->link, ff_pkt->link_save); + pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); + if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { + pm_strcpy(ff_pkt->link, ff_pkt->link_save); } } diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index c581c422c3..6144714f98 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -201,7 +201,7 @@ static void init_resource(int type, RES_ITEM *items, int pass) int i; int rindex = type - r_first; - memset(&res_all, 0, res_all_size); + memset((char *)&res_all, 0, res_all_size); res_all.hdr.rcode = type; res_all.hdr.refcnt = 1; diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 64d83e0cc5..e060ae9e16 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -263,7 +263,7 @@ default_path: /* Mount a specific volume and no other */ Dmsg0(200, "calling dir_ask_sysop\n"); - if (!dir_ask_sysop_to_mount_volume(dcr)) { + if (!dir_ask_sysop_to_mount_volume(dcr, ST_READ)) { goto get_out; /* error return */ } try_autochanger = true; /* permit using autochanger again */ diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index a4dc84ed7f..5b14f360de 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. @@ -553,7 +553,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) * Note, must create dev->errmsg on error return. * */ -bool dir_ask_sysop_to_mount_volume(DCR *dcr) +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int mode) { int stat = W_TIMEOUT; DEVICE *dev = dcr->dev; @@ -582,11 +582,21 @@ bool dir_ask_sysop_to_mount_volume(DCR *dcr) * Otherwise skip it. */ if (!dev->poll && (stat == W_TIMEOUT || stat == W_MOUNT)) { - Jmsg(jcr, M_MOUNT, 0, _("Please mount Volume \"%s\" or label a new one for:\n" + char *msg; + if (mode == ST_APPEND) { + msg = _("Please mount Volume \"%s\" or label a new one for:\n" " Job: %s\n" " Storage: %s\n" " Pool: %s\n" - " Media type: %s\n"), + " Media type: %s\n"); + } else { + msg = _("Please mount Volume \"%s\" for:\n" + " Job: %s\n" + " Storage: %s\n" + " Pool: %s\n" + " Media type: %s\n"); + } + Jmsg(jcr, M_MOUNT, 0, msg, dcr->VolumeName, jcr->Job, dev->print_name(), diff --git a/bacula/src/stored/bcopy.c b/bacula/src/stored/bcopy.c index 2397838333..e99662477a 100644 --- a/bacula/src/stored/bcopy.c +++ b/bacula/src/stored/bcopy.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2007 Free Software Foundation Europe e.V. + Copyright (C) 2002-2008 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. @@ -350,7 +350,7 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;} bool dir_send_job_status(JCR *jcr) {return 1;} -bool dir_ask_sysop_to_mount_volume(DCR *dcr) +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /*mode*/) { DEVICE *dev = dcr->dev; fprintf(stderr, _("Mount Volume \"%s\" on device %s and press return when ready: "), diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 3737551d75..d3bda67e04 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -1,16 +1,7 @@ -/* - * - * Dumb program to extract files from a Bacula backup. - * - * Kern E. Sibbald, MM - * - * Version $Id$ - * - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. @@ -34,6 +25,15 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Dumb program to extract files from a Bacula backup. + * + * Kern E. Sibbald, MM + * + * Version $Id$ + * + */ #include "bacula.h" #include "stored.h" @@ -276,15 +276,15 @@ static bool store_data(BFILE *bfd, char *data, const int32_t length) if (is_win32_stream(attr->data_stream) && !have_win32_api()) { set_portable_backup(bfd); if (!processWin32BackupAPIBlock(bfd, data, length)) { - berrno be; - Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), - attr->ofname, be.bstrerror()); + berrno be; + Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), + attr->ofname, be.bstrerror()); return false; } } else if (bwrite(bfd, data, length) != (ssize_t)length) { berrno be; Emsg2(M_ERROR_TERM, 0, _("Write error on %s: %s\n"), - attr->ofname, be.bstrerror()); + attr->ofname, be.bstrerror()); return false; } @@ -497,7 +497,7 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;} bool dir_send_job_status(JCR *jcr) {return 1;} -bool dir_ask_sysop_to_mount_volume(DCR *dcr) +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /*mode*/) { DEVICE *dev = dcr->dev; fprintf(stderr, _("Mount Volume \"%s\" on device %s and press return when ready: "), diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index 7f74b99bb0..ab36f4af8f 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. @@ -454,7 +454,7 @@ bool dir_send_job_status(JCR *jcr) {return 1;} int generate_job_event(JCR *jcr, const char *event) { return 1; } -bool dir_ask_sysop_to_mount_volume(DCR *dcr) +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /*mode*/) { DEVICE *dev = dcr->dev; fprintf(stderr, _("Mount Volume \"%s\" on device %s and press return when ready: "), diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 0c79056a04..a5b6cf2841 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -1292,7 +1292,7 @@ bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;} bool dir_send_job_status(JCR *jcr) {return 1;} int generate_job_event(JCR *jcr, const char *event) { return 1; } -bool dir_ask_sysop_to_mount_volume(DCR *dcr) +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /*mode*/) { DEVICE *dev = dcr->dev; Dmsg0(20, "Enter dir_ask_sysop_to_mount_volume\n"); diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index b285c72e39..f469691fd1 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -2675,7 +2675,7 @@ bool dir_find_next_appendable_volume(DCR *dcr) return dcr->VolumeName[0] != 0; } -bool dir_ask_sysop_to_mount_volume(DCR *dcr) +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /* mode */) { DEVICE *dev = dcr->dev; Dmsg0(20, "Enter dir_ask_sysop_to_mount_volume\n"); diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 893fdeb778..10f7a117f4 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -86,7 +86,7 @@ mount_next_vol: if (!dev->poll && retry++ > 4) { /* Last ditch effort before giving up, force operator to respond */ dcr->VolCatInfo.Slot = 0; - if (!dir_ask_sysop_to_mount_volume(dcr)) { + if (!dir_ask_sysop_to_mount_volume(dcr, ST_APPEND)) { Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"), dev->print_name()); return false; @@ -162,7 +162,7 @@ mount_next_vol: Dmsg2(150, "Ask=%d autochanger=%d\n", ask, autochanger); release = true; /* release next time if we "recurse" */ - if (ask && !dir_ask_sysop_to_mount_volume(dcr)) { + if (ask && !dir_ask_sysop_to_mount_volume(dcr, ST_APPEND)) { Dmsg0(150, "Error return ask_sysop ...\n"); return false; /* error return */ } diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 0944a5ebaa..5ce0294da3 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -52,7 +52,7 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw); bool dir_find_next_appendable_volume(DCR *dcr); bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten); bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr); -bool dir_ask_sysop_to_mount_volume(DCR *dcr); +bool dir_ask_sysop_to_mount_volume(DCR *dcr, int mode); bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec); bool dir_send_job_status(JCR *jcr); bool dir_create_jobmedia_record(DCR *dcr); diff --git a/bacula/src/version.h b/bacula/src/version.h index 4227ca72d2..7a98591ff5 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.8" -#define BDATE "28 January 2008" -#define LSMDATE "28Jan08" +#define BDATE "30 January 2008" +#define LSMDATE "30Jan08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 158057f5a5..b21eb75d89 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,15 @@ Technical notes on version 2.3 General: +30Jan08 +kes Apply patch from bug #1049 to prevent stripping the path on a + symlink. +kes Attempt to fix bug #1047 where stripping a path corrupts the + heap. Waiting for feedback. +kes Correct the Mount message not to suggest labeling a new tape + when doing a restore. Submitted by email by John Stoffel. +kes Attempt to work around gcc FORTIFY_SOURCE bug that crashes the + FD by using casting. Reported in bug #1042. 28Jan08 kes A bit of crypto cleanup. More later. 25Jan08 -- 2.39.5