]> 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 f03aad6a1ef21f2986b88842dda490b4a72f57df..fe43b042339d89f9ea09da8028b16b3fdd43e32c 100644 (file)
@@ -40,7 +40,7 @@
  *
  *   Written by Marco van Wieringen, November MMVIII
  *
- *   Version $Id: xattr.c 7879 2008-10-23 10:12:36Z kerns $
+ *   Version $Id$
  */
 
 #include "bacula.h"
@@ -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
     */
@@ -244,8 +250,8 @@ static bool generic_xattr_build_streams(JCR *jcr, FF_PKT *ff_pkt, int stream)
 {
    int count = 0;
    int32_t xattr_list_len,
-           xattr_value_len,
-           expected_serialize_len = 0;
+           xattr_value_len;
+   uint32_t expected_serialize_len = 0;
    char *xattr_list, *bp;
    xattr_t *xattr_value_list, *current_xattr;
 
@@ -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;