diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-10-10 11:06:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-10-10 16:00:15 +0200 |
commit | 00675c363ffdb0144873ae24ce555556aedcab0d (patch) | |
tree | cb704aa245834efce4ec64d17870304b276a7dfc /src/shared | |
parent | dcf1bf3b6dd934d3af629a1f9f24e083fce85255 (diff) | |
download | systemd-00675c363ffdb0144873ae24ce555556aedcab0d.tar.gz |
tree-wide: add ERRNO_IS_XATTR_ABSENT() helper
We check the same list of error codes on various xattr operations, and
we should on some more. Add a common helper for this purpose.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/cgroup-show.c | 4 | ||||
-rw-r--r-- | src/shared/chown-recursive.c | 2 | ||||
-rw-r--r-- | src/shared/dissect-image.c | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index ca96e198f3..e34a68ef86 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -135,12 +135,12 @@ static int is_delegated(int cgfd, const char *path) { assert(cgfd >= 0 || path); r = getxattr_malloc(cgfd < 0 ? path : FORMAT_PROC_FD_PATH(cgfd), "trusted.delegate", &b); - if (r == -ENODATA) { + if (r < 0 && ERRNO_IS_XATTR_ABSENT(r)) { /* If the trusted xattr isn't set (preferred), then check the untrusted one. Under the * assumption that whoever is trusted enough to own the cgroup, is also trusted enough to * decide if it is delegated or not this should be safe. */ r = getxattr_malloc(cgfd < 0 ? path : FORMAT_PROC_FD_PATH(cgfd), "user.delegate", &b); - if (r == -ENODATA) + if (r < 0 && ERRNO_IS_XATTR_ABSENT(r)) return false; } if (r < 0) diff --git a/src/shared/chown-recursive.c b/src/shared/chown-recursive.c index 05a7a10ce4..bbc270d34b 100644 --- a/src/shared/chown-recursive.c +++ b/src/shared/chown-recursive.c @@ -32,7 +32,7 @@ static int chown_one( /* Drop any ACL if there is one */ FOREACH_STRING(n, "system.posix_acl_access", "system.posix_acl_default") if (removexattr(FORMAT_PROC_FD_PATH(fd), n) < 0) - if (!IN_SET(errno, ENODATA, EOPNOTSUPP, ENOSYS, ENOTTY)) + if (!ERRNO_IS_XATTR_ABSENT(errno)) return -errno; r = fchmod_and_chown(fd, st->st_mode & mask, uid, gid); diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index ed58b9d0ab..bea29b8ccf 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -2379,7 +2379,7 @@ int verity_settings_load( if (r < 0) { _cleanup_free_ char *p = NULL; - if (!IN_SET(r, -ENODATA, -ENOENT) && !ERRNO_IS_NOT_SUPPORTED(r)) + if (r != -ENOENT && !ERRNO_IS_XATTR_ABSENT(r)) return r; p = build_auxiliary_path(image, ".roothash"); @@ -2408,7 +2408,7 @@ int verity_settings_load( if (r < 0) { _cleanup_free_ char *p = NULL; - if (!IN_SET(r, -ENODATA, -ENOENT) && !ERRNO_IS_NOT_SUPPORTED(r)) + if (r != -ENOENT && !ERRNO_IS_XATTR_ABSENT(r)) return r; p = build_auxiliary_path(image, ".usrhash"); |