From: Mike Yuan Date: Sun, 9 Feb 2025 22:18:05 +0000 (+0100) Subject: test-xattr-util: relax listxattr() retval check X-Git-Tag: v258-rc1~1360^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d696e9e64f5b7b1a9776957e30eb5ae20e3b0fdf;p=thirdparty%2Fsystemd.git test-xattr-util: relax listxattr() retval check Follow-up for d228afd792d713a754e4368c014c1f43f10cf5b7 Apparently security.selinux might get set on the file too, behind our back. --- diff --git a/src/test/test-xattr-util.c b/src/test/test-xattr-util.c index 25f982e1fd9..86b72b39e16 100644 --- a/src/test/test-xattr-util.c +++ b/src/test/test-xattr-util.c @@ -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);