X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Ffiled%2Frestore.c;h=f9e8c5f8cb827b2f3db94c28b0335364fc22919b;hb=5c53840c9a02cefaaa45aee96c02c6f9cdaf3703;hp=cbb08899919b8ab26592cf5452e12662e0541e3d;hpb=8dd0eaddfad501873e0c12e5b39e79bc3586e749;p=bacula%2Fbacula diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index cbb0889991..f9e8c5f8cb 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -30,8 +30,6 @@ * * Kern Sibbald, November MM * - * Version $Id$ - * */ #include "bacula.h" @@ -526,75 +524,77 @@ void do_restore(JCR *jcr) } break; - /* Resource fork stream - only recorded after a file to be restored */ - /* Silently ignore if we cannot write - we already reported that */ + /* + * Resource fork stream - only recorded after a file to be restored + * Silently ignore if we cannot write - we already reported that + */ case STREAM_ENCRYPTED_MACOS_FORK_DATA: case STREAM_MACOS_FORK_DATA: -#ifdef HAVE_DARWIN_OS - rctx.fork_flags = 0; - jcr->ff->flags |= FO_HFSPLUS; + if (have_darwin_os) { + rctx.fork_flags = 0; + jcr->ff->flags |= FO_HFSPLUS; - if (rctx.stream == STREAM_ENCRYPTED_MACOS_FORK_DATA) { - rctx.fork_flags |= FO_ENCRYPT; + if (rctx.stream == STREAM_ENCRYPTED_MACOS_FORK_DATA) { + rctx.fork_flags |= FO_ENCRYPT; - /* Set up a decryption context */ - if (rctx.extract && !rctx.fork_cipher_ctx.cipher) { - if (!rctx.cs) { - Jmsg1(jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), jcr->last_fname); - rctx.extract = false; - bclose(&rctx.bfd); - continue; - } + /* Set up a decryption context */ + if (rctx.extract && !rctx.fork_cipher_ctx.cipher) { + if (!rctx.cs) { + Jmsg1(jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), jcr->last_fname); + rctx.extract = false; + bclose(&rctx.bfd); + continue; + } - if ((rctx.fork_cipher_ctx.cipher = crypto_cipher_new(rctx.cs, false, &rctx.fork_cipher_ctx.block_size)) == NULL) { - Jmsg1(jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), jcr->last_fname); - free_session(rctx); - rctx.extract = false; - bclose(&rctx.bfd); - continue; + if ((rctx.fork_cipher_ctx.cipher = crypto_cipher_new(rctx.cs, false, &rctx.fork_cipher_ctx.block_size)) == NULL) { + Jmsg1(jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), jcr->last_fname); + free_session(rctx); + rctx.extract = false; + bclose(&rctx.bfd); + continue; + } } } - } - if (rctx.extract) { - if (rctx.prev_stream != rctx.stream) { - if (bopen_rsrc(&rctx.forkbfd, jcr->last_fname, O_WRONLY | O_TRUNC | O_BINARY, 0) < 0) { - Jmsg(jcr, M_ERROR, 0, _(" Cannot open resource fork for %s.\n"), jcr->last_fname); + if (rctx.extract) { + if (rctx.prev_stream != rctx.stream) { + if (bopen_rsrc(&rctx.forkbfd, jcr->last_fname, O_WRONLY | O_TRUNC | O_BINARY, 0) < 0) { + Jmsg(jcr, M_ERROR, 0, _(" Cannot open resource fork for %s.\n"), jcr->last_fname); + rctx.extract = false; + continue; + } + + rctx.fork_size = rsrc_len; + Dmsg0(130, "Restoring resource fork\n"); + } + + if (extract_data(jcr, &rctx.forkbfd, sd->msg, sd->msglen, &rctx.fork_addr, rctx.fork_flags, + &rctx.fork_cipher_ctx) < 0) { rctx.extract = false; + bclose(&rctx.forkbfd); continue; } - - rctx.fork_size = rsrc_len; - Dmsg0(130, "Restoring resource fork\n"); - } - - if (extract_data(jcr, &rctx.forkbfd, sd->msg, sd->msglen, &rctx.fork_addr, rctx.fork_flags, - &rctx.fork_cipher_ctx) < 0) { - rctx.extract = false; - bclose(&rctx.forkbfd); - continue; } + } else { + non_support_rsrc++; } -#else - non_support_rsrc++; -#endif break; case STREAM_HFSPLUS_ATTRIBUTES: -#ifdef HAVE_DARWIN_OS - Dmsg0(130, "Restoring Finder Info\n"); - jcr->ff->flags |= FO_HFSPLUS; - if (sd->msglen != 32) { - Jmsg(jcr, M_ERROR, 0, _(" Invalid length of Finder Info (got %d, not 32)\n"), sd->msglen); - continue; - } - if (setattrlist(jcr->last_fname, &attrList, sd->msg, sd->msglen, 0) != 0) { - Jmsg(jcr, M_ERROR, 0, _(" Could not set Finder Info on %s\n"), jcr->last_fname); - continue; + if (have_darwin_os) { + Dmsg0(130, "Restoring Finder Info\n"); + jcr->ff->flags |= FO_HFSPLUS; + if (sd->msglen != 32) { + Jmsg(jcr, M_ERROR, 0, _(" Invalid length of Finder Info (got %d, not 32)\n"), sd->msglen); + continue; + } + if (setattrlist(jcr->last_fname, &attrList, sd->msg, sd->msglen, 0) != 0) { + Jmsg(jcr, M_ERROR, 0, _(" Could not set Finder Info on %s\n"), jcr->last_fname); + continue; + } + } else { + non_support_finfo++; } -#else - non_support_finfo++; -#endif break; case STREAM_UNIX_ACCESS_ACL: