]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-xattr-util: relax listxattr() retval check
authorMike Yuan <me@yhndnzj.com>
Sun, 9 Feb 2025 22:18:05 +0000 (23:18 +0100)
committerMike Yuan <me@yhndnzj.com>
Tue, 11 Feb 2025 15:57:56 +0000 (16:57 +0100)
Follow-up for d228afd792d713a754e4368c014c1f43f10cf5b7

Apparently security.selinux might get set on the file too,
behind our back.

src/test/test-xattr-util.c

index 25f982e1fd909c565a0a36911ae6aa5cfaec57bb..86b72b39e1602592ea2972f1412e028dac1fb179 100644 (file)
 #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);