s3: lib/xattr_tdb: fix listing xattrs
authorRalph Boehme <slow@samba.org>
Thu, 28 Jun 2018 19:47:54 +0000 (21:47 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 24 Jul 2018 22:23:12 +0000 (00:23 +0200)
If there's no record in the xattr.tdb, dbwrap_fetch() will return
NT_STATUS_NOT_FOUND. That should not result in an error in callers of
xattr_tdb_load_attrs().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/lib/xattr_tdb.c

index 34afbe29291f532d2c0930ea2f974f787ccf62f7..f3a2e19bf5d47fc51e9939f5eea7dc8e70e2475e 100644 (file)
@@ -115,6 +115,9 @@ static NTSTATUS xattr_tdb_load_attrs(TALLOC_CTX *mem_ctx,
                              make_tdb_data(id_buf, sizeof(id_buf)),
                              &data);
        if (!NT_STATUS_IS_OK(status)) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+                       return status;
+               }
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
@@ -316,14 +319,21 @@ ssize_t xattr_tdb_listattr(struct db_context *db_ctx,
 
        status = xattr_tdb_load_attrs(frame, db_ctx, id, &attribs);
 
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(10, ("xattr_tdb_fetch_attrs failed: %s\n",
+       if (!NT_STATUS_IS_OK(status) &&
+           !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND))
+       {
+               DEBUG(0, ("xattr_tdb_fetch_attrs failed: %s\n",
                           nt_errstr(status)));
                errno = EINVAL;
                TALLOC_FREE(frame);
                return -1;
        }
 
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+               TALLOC_FREE(frame);
+               return 0;
+       }
+
        DEBUG(10, ("xattr_tdb_listattr: Found %d xattrs\n",
                   attribs->num_eas));