]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/restore.c
Merge branch 'master' into basejobv3
[bacula/bacula] / bacula / src / filed / restore.c
index 1ec7dfaa10a76851041e92b9dab3066daa181329..c1dc3b735264a6baf83297535803989a5008f326 100644 (file)
@@ -57,9 +57,9 @@ const bool have_acl = false;
 #endif
 
 #ifdef HAVE_SHA2
-   const bool have_sha2 = true;
+const bool have_sha2 = true;
 #else
-   const bool have_sha2 = false;
+const bool have_sha2 = false;
 #endif
 
 #if defined(HAVE_XATTR)
@@ -229,8 +229,9 @@ void do_restore(JCR *jcr)
     *        d. Alternate data stream (e.g. Resource Fork)
     *        e. Finder info
     *        f. ACLs
-    *        g. Possibly a cryptographic signature
-    *        h. Possibly MD5 or SHA1 record
+    *        g. XATTRs
+    *        h. Possibly a cryptographic signature
+    *        i. Possibly MD5 or SHA1 record
     *   3. Repeat step 1
     *
     * NOTE: We keep track of two bacula file descriptors:
@@ -249,8 +250,14 @@ void do_restore(JCR *jcr)
    binit(&rctx.bfd);
    binit(&rctx.forkbfd);
    attr = rctx.attr = new_attr(jcr);
-   jcr->acl_data = get_pool_memory(PM_MESSAGE);
-   jcr->xattr_data = get_pool_memory(PM_MESSAGE);
+   if (have_acl) {
+      jcr->acl_data = get_pool_memory(PM_MESSAGE);
+      jcr->total_acl_errors = 0;
+   }
+   if (have_xattr) {
+      jcr->xattr_data = get_pool_memory(PM_MESSAGE);
+      jcr->total_xattr_errors = 0;
+   }
 
    while (bget_msg(sd) >= 0 && !job_canceled(jcr)) {
       /* Remember previous stream type */
@@ -605,17 +612,33 @@ void do_restore(JCR *jcr)
          if (have_acl) {
             pm_memcpy(jcr->acl_data, sd->msg, sd->msglen);
             jcr->acl_data_len = sd->msglen;
-            if (!parse_acl_stream(jcr, rctx.stream)) {
-               Qmsg1(jcr, M_WARNING, 0, _("Can't restore ACLs of %s\n"), jcr->last_fname);
+            switch (parse_acl_streams(jcr, rctx.stream)) {
+            case bacl_exit_fatal:
+               goto bail_out;
+            case bacl_exit_error:
+               /*
+                * Non-fatal errors, count them and when the number is under ACL_REPORT_ERR_MAX_PER_JOB
+                * print the error message set by the lower level routine in jcr->errmsg.
+                */
+               if (jcr->total_acl_errors < ACL_REPORT_ERR_MAX_PER_JOB) {
+                  Qmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+               }
+               jcr->total_acl_errors++;
+               break;
+            case bacl_exit_ok:
+               break;
             }
          } else {
             non_support_acl++;
          }
          break;
 
+      case STREAM_XATTR_SOLARIS_SYS:
+      case STREAM_XATTR_SOLARIS:
       case STREAM_XATTR_DARWIN:
       case STREAM_XATTR_FREEBSD:
       case STREAM_XATTR_LINUX:
+      case STREAM_XATTR_NETBSD:
          /*
           * Do not restore Extended Attributes when
           * a) The current file is not extracted
@@ -628,8 +651,21 @@ void do_restore(JCR *jcr)
          if (have_xattr) {
             pm_memcpy(jcr->xattr_data, sd->msg, sd->msglen);
             jcr->xattr_data_len = sd->msglen;
-            if (!parse_xattr_stream(jcr, rctx.stream)) {
-               Qmsg1(jcr, M_WARNING, 0, _("Can't restore Extended Attributes of %s\n"), jcr->last_fname);
+            switch (parse_xattr_streams(jcr, rctx.stream)) {
+            case bxattr_exit_fatal:
+               goto bail_out;
+            case bxattr_exit_error:
+               /*
+                * Non-fatal errors, count them and when the number is under XATTR_REPORT_ERR_MAX_PER_JOB
+                * print the error message set by the lower level routine in jcr->errmsg.
+                */
+               if (jcr->total_xattr_errors < XATTR_REPORT_ERR_MAX_PER_JOB) {
+                  Qmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+               }
+               jcr->total_xattr_errors++;
+               break;
+            case bxattr_exit_ok:
+               break;
             }
          } else {
             non_support_xattr++;
@@ -728,13 +764,29 @@ ok_out:
       jcr->compress_buf = NULL;
       jcr->compress_buf_size = 0;
    }
+
+   if (have_xattr && jcr->xattr_data) {
+      free_pool_memory(jcr->xattr_data);
+      jcr->xattr_data = NULL;
+   }
+   if (have_acl && jcr->acl_data) {
+      free_pool_memory(jcr->acl_data);
+      jcr->acl_data = NULL;
+   }
+
    bclose(&rctx.forkbfd);
    bclose(&rctx.bfd);
    free_attr(rctx.attr);
-   free_pool_memory(jcr->xattr_data);
-   free_pool_memory(jcr->acl_data);
    Dmsg2(10, "End Do Restore. Files=%d Bytes=%s\n", jcr->JobFiles,
       edit_uint64(jcr->JobBytes, ec1));
+   if (jcr->total_acl_errors > 0) {
+      Jmsg(jcr, M_ERROR, 0, _("Encountered %ld acl errors while doing restore\n"),
+           jcr->total_acl_errors);
+   }
+   if (jcr->total_xattr_errors > 0) {
+      Jmsg(jcr, M_ERROR, 0, _("Encountered %ld xattr errors while doing restore\n"),
+           jcr->total_xattr_errors);
+   }
    if (non_support_data > 1 || non_support_attr > 1) {
       Jmsg(jcr, M_ERROR, 0, _("%d non-supported data streams and %d non-supported attrib streams ignored.\n"),
          non_support_data, non_support_attr);