From 348443164908c223c56ed5b1e609ede38c24b9f9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 6 Dec 2006 18:30:08 +0000 Subject: [PATCH] kes Put make_catalog_backup SQL_BINDIR in an environment variable to make it easier for the user to change. kes Fail any backup job that tries to use encryption and sparse options. Hopefully this is a temporary change. kes Correct the EndJob return string for non-backup jobs. kes Review the encryption restore code. kes Implement a new encryption regression test with compression. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3762 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 10 +++++---- bacula/src/cats/make_catalog_backup.in | 12 ++++++----- bacula/src/dird/backup.c | 8 ++++--- bacula/src/filed/backup.c | 6 +++++- bacula/src/filed/job.c | 8 +++++-- bacula/src/filed/restore.c | 29 +++++++++++++------------- bacula/technotes-1.39 | 7 +++++++ 7 files changed, 50 insertions(+), 30 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 381b412024..9729fb8722 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -41,13 +41,11 @@ Document: Priority: +- Check if gnome-console works with TLS. - Ensure that the SD re-reads the Media record if the JobFiles does not match -- it may have been updated by another job. - Look at moving the Storage directive from the Job to the Pool in the default conf files. -- Make sure the new level=Full syntax is used in all - example conf files (especially in the manual). -- Fix prog copyright (SD) all other files. - Migration Volume span bug - Rescue release - Bug reports @@ -59,7 +57,6 @@ Priority: - Wrong jobbytes with query 12 (todo) - bacula-1.38.2-ssl.patch - Bare-metal recovery Windows (todo) -- Document need for UTF-8 format @@ -1749,3 +1746,8 @@ Block Position: 0 - Make release unload any autochanger. - Arno's reservation deadlock. - Eric's SD patch +- Make sure the new level=Full syntax is used in all + example conf files (especially in the manual). +- Fix prog copyright (SD) all other files. +- Document need for UTF-8 format + diff --git a/bacula/src/cats/make_catalog_backup.in b/bacula/src/cats/make_catalog_backup.in index fcd060d4df..1a5d2370b8 100755 --- a/bacula/src/cats/make_catalog_backup.in +++ b/bacula/src/cats/make_catalog_backup.in @@ -11,10 +11,12 @@ # (default "") # # +BINDIR=@SQL_BINDIR@ + cd @working_dir@ rm -f bacula.sql if test xsqlite = x@DB_NAME@ ; then - echo ".dump" | @SQL_BINDIR@/sqlite $1.db >$1.sql + echo ".dump" | ${BINDIR}/sqlite $1.db >$1.sql else if test xmysql = x@DB_NAME@ ; then if test $# -gt 2; then @@ -22,23 +24,23 @@ else else MYSQLPASSWORD="" fi - @SQL_BINDIR@/mysqldump -u $2$MYSQLPASSWORD -f --opt $1 >$1.sql + ${BINDIR}/mysqldump -u $2$MYSQLPASSWORD -f --opt $1 >$1.sql else if test xpostgresql = x@DB_NAME@ ; then if test $# -gt 2; then PGPASSWORD=$3 export PGPASSWORD fi - exec @SQL_BINDIR@/pg_dump -c -U $2 $1 >$1.sql + exec ${BINDIR}/pg_dump -c -U $2 $1 >$1.sql else - echo ".dump" | @SQL_BINDIR@/sqlite3 $1.db >$1.sql + echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql fi fi fi # # To read back a MySQL database use: # cd @working_dir@ -# rm -f @SQL_BINDIR@/../var/bacula/* +# rm -f ${BINDIR}/../var/bacula/* # mysql file_bsock; bool fd_ok = false; uint32_t JobFiles, Errors; - uint64_t ReadBytes, JobBytes; + uint64_t ReadBytes = 0; + uint64_t JobBytes = 0; int VSS = 0; int Encrypt = 0; @@ -284,6 +285,7 @@ int wait_for_job_termination(JCR *jcr) break; } } + if (is_bnet_error(fd)) { Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"), job_type_to_str(jcr->JobType), bnet_strerror(fd)); diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 343552ed6c..aa69ec1270 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -662,11 +662,15 @@ int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, #endif if (ff_pkt->flags & FO_ENCRYPT) { + if (ff_pkt->flags & FO_SPARSE) { + Jmsg0(jcr, M_FATAL, 0, _("Encrypting sparse data not supported.\n")); + goto err; + } /* Allocate the cipher context */ if ((cipher_ctx = crypto_cipher_new(jcr->pki_session, true, &cipher_block_size)) == NULL) { /* Shouldn't happen! */ - Jmsg0(jcr, M_FATAL, 0, _("Failed to initialize encryption context\n")); + Jmsg0(jcr, M_FATAL, 0, _("Failed to initialize encryption context.\n")); goto err; } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 6ceacea896..dbec9bd976 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1543,7 +1543,9 @@ static int verify_cmd(JCR *jcr) /* Send termination status back to Dir */ bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->ReadBytes, ed1), - edit_uint64(jcr->JobBytes, ed2), jcr->Errors); + edit_uint64(jcr->JobBytes, ed2), jcr->Errors, 0, + jcr->pki_encrypt); + Dmsg1(110, "End FD msg: %s\n", dir->msg); /* Inform Director that we are done */ bnet_sig(dir, BNET_TERMINATE); @@ -1637,7 +1639,9 @@ bail_out: /* Send termination status back to Dir */ bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->ReadBytes, ed1), - edit_uint64(jcr->JobBytes, ed2), jcr->Errors); + edit_uint64(jcr->JobBytes, ed2), jcr->Errors, 0, + jcr->pki_encrypt); + Dmsg1(110, "End FD msg: %s\n", dir->msg); /* Inform Director that we are done */ bnet_sig(dir, BNET_TERMINATE); diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index f10bda6037..c2cebe8416 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -99,7 +99,6 @@ void do_restore(JCR *jcr) bool extract = false; int32_t file_index; char ec1[50]; /* Buffer printing huge values */ - BFILE bfd; /* File content */ uint64_t fileAddr = 0; /* file write address */ uint32_t size; /* Size of file */ @@ -768,7 +767,7 @@ bool sparse_data(JCR *jcr, BFILE *bfd, uint64_t *addr, char **data, uint32_t *le Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), edit_uint64(*addr, ec1), jcr->last_fname, be.strerror(bfd->berrno)); - return false; + return false; } } *data += SPARSE_FADDR_SIZE; @@ -898,8 +897,8 @@ int32_t extract_data(JCR *jcr, BFILE *bfd, POOLMEM *buf, int32_t buflen, Dmsg1(500, "Crypto unser block size=%d\n", jcr->crypto_packet_len - CRYPTO_LEN_SIZE); if (jcr->crypto_packet_len == 0 || jcr->crypto_buf_len < jcr->crypto_packet_len) { - /* No full preserved block is available. */ - return 0; + /* No full preserved block is available. */ + return 0; } /* We have one full block, set up the filter input buffers */ @@ -910,9 +909,9 @@ int32_t extract_data(JCR *jcr, BFILE *bfd, POOLMEM *buf, int32_t buflen, } if (flags & FO_SPARSE) { - if (!sparse_data(jcr, bfd, addr, &wbuf, &wsize)) { - return -1; - } + if (!sparse_data(jcr, bfd, addr, &wbuf, &wsize)) { + return -1; + } } if (flags & FO_GZIP) { @@ -934,9 +933,9 @@ int32_t extract_data(JCR *jcr, BFILE *bfd, POOLMEM *buf, int32_t buflen, if (flags & FO_ENCRYPT) { /* Move any remaining data to start of buffer */ if (jcr->crypto_buf_len > 0) { - Dmsg1(30, "Moving %u buffered bytes to start of buffer\n", jcr->crypto_buf_len); - memmove(jcr->crypto_buf, &jcr->crypto_buf[jcr->crypto_packet_len], - jcr->crypto_buf_len); + Dmsg1(30, "Moving %u buffered bytes to start of buffer\n", jcr->crypto_buf_len); + memmove(jcr->crypto_buf, &jcr->crypto_buf[jcr->crypto_packet_len], + jcr->crypto_buf_len); } /* The packet was successfully written, reset the length so that the next * packet length may be re-read by unser_crypto_packet_len() */ @@ -983,8 +982,8 @@ bool flush_cipher(JCR *jcr, BFILE *bfd, uint64_t *addr, int flags, CIPHER_CONTEX if (jcr->crypto_buf_len != jcr->crypto_packet_len) { Jmsg2(jcr, M_FATAL, 0, - _("Unexpected number of bytes remaining at end of file, received %u, expected %u\n"), - jcr->crypto_packet_len, jcr->crypto_buf_len); + _("Unexpected number of bytes remaining at end of file, received %u, expected %u\n"), + jcr->crypto_packet_len, jcr->crypto_buf_len); return false; } @@ -992,9 +991,9 @@ bool flush_cipher(JCR *jcr, BFILE *bfd, uint64_t *addr, int flags, CIPHER_CONTEX jcr->crypto_packet_len = 0; if (flags & FO_SPARSE) { - if (!sparse_data(jcr, bfd, addr, &wbuf, &wsize)) { - return false; - } + if (!sparse_data(jcr, bfd, addr, &wbuf, &wsize)) { + return false; + } } if (flags & FO_GZIP) { diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 96c755101c..f75e441418 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -2,6 +2,13 @@ General: 06Dec06 +kes Put make_catalog_backup SQL_BINDIR in an environment variable to + make it easier for the user to change. +kes Fail any backup job that tries to use encryption and sparse options. + Hopefully this is a temporary change. +kes Correct the EndJob return string for non-backup jobs. +kes Review the encryption restore code. +kes Implement a new encryption regression test with compression. kes Modify migrate not to fail if nothing found to migrate. kes Add #undef HAVE_OPENSSL, HAVE_TLS, HAVE_CYRPTO to autoconf/config.h.in because they were not always set correctly. -- 2.39.5