]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/xattr.c
ebl Add debug message when checking database encoding
[bacula/bacula] / bacula / src / filed / xattr.c
index 88e33a5a76bc1f1e7a29e2722370e00ede29be5e..fe43b042339d89f9ea09da8028b16b3fdd43e32c 100644 (file)
@@ -84,6 +84,12 @@ static bool send_xattr_stream(JCR *jcr, int stream)
    return true;
 #endif
 
+   /*
+    * Sanity check
+    */
+   if (jcr->xattr_data_len <= 0)
+      return true;
+
    /*
     * Send header
     */
@@ -259,6 +265,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream)
          jcr->last_fname, be.bstrerror());
       Dmsg2(100, "llistxattr error file=%s ERR=%s\n",
          jcr->last_fname, be.bstrerror());
+
       return false;
    } else if (xattr_list_len == 0) {
       return true;
@@ -286,6 +293,7 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream)
          jcr->last_fname, be.bstrerror());
 
       free(xattr_list);
+
       return false;
    }
    xattr_list[xattr_list_len] = '\0';
@@ -295,11 +303,24 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream)
     */
    bp = xattr_list;
    while ((bp - xattr_list) + 1 < xattr_list_len) {
+#if defined(HAVE_LINUX_OS)
+      /*
+       * On Linux you also get the acls in the extented attribute list.
+       * So we check if we are already backing up acls and if we do we
+       * don't store the extended attribute with the same info.
+       */
+      if ((ff_pkt->flags & FO_ACL) == 0 || strcmp(bp, "system.posix_acl_access"))
+         count++;
+#else
       count++;
+#endif
 
       bp = strchr(bp, '\0') + 1;
    }
 
+   if (count == 0)
+      return true;
+
    /*
     * Allocate enough room to hold all extended attributes.
     * After allocating the storage make sure its empty by zeroing it.
@@ -319,11 +340,6 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream)
    bp = xattr_list;
    while ((bp - xattr_list) + 1 < xattr_list_len) {
 #if defined(HAVE_LINUX_OS)
-      /*
-       * On Linux you also get the acls in the extented attribute list.
-       * So we check if we are already backing up acls and if we do we
-       * don't store the extended attribute with the same info.
-       */
       if (ff_pkt->flags & FO_ACL && !strcmp(bp, "system.posix_acl_access")) {
          bp = strchr(bp, '\0') + 1;