test-xattr-util: relax listxattr() retval check

Follow-up for d228afd792

Apparently security.selinux might get set on the file too,
behind our back.
This commit is contained in:
Mike Yuan
2025-02-11 16:57:56 +01:00
parent 78b47a4e89
commit d696e9e64f
+9 -2
View File
@@ -11,8 +11,10 @@
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
#include "nulstr-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "xattr-util.h"
@@ -89,13 +91,18 @@ static void verify_xattr(int dfd, const char *expected) {
static void xattr_symlink_test_one(int fd, const char *path) {
_cleanup_free_ char *value = NULL, *list = NULL;
_cleanup_strv_free_ char **list_split = NULL;
int r;
ASSERT_OK(xsetxattr(fd, path, 0, "trusted.test", "schaffen"));
ASSERT_OK_EQ(getxattr_at_malloc(fd, path, "trusted.test", 0, &value), (int) STRLEN("schaffen"));
ASSERT_STREQ(value, "schaffen");
ASSERT_OK_EQ(listxattr_at_malloc(fd, path, 0, &list), (int) sizeof("trusted.test"));
ASSERT_STREQ(list, "trusted.test");
r = listxattr_at_malloc(fd, path, 0, &list);
ASSERT_OK(r);
ASSERT_GE(r, (int) sizeof("trusted.test"));
ASSERT_NOT_NULL(list_split = strv_parse_nulstr(list, r));
ASSERT_TRUE(strv_contains(list_split, "trusted.test"));
ASSERT_OK(xremovexattr(fd, path, 0, "trusted.test"));
ASSERT_ERROR(getxattr_at_malloc(fd, path, "trusted.test", 0, &value), ENODATA);