summaryrefslogtreecommitdiff
path: root/src/shared/smack-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-06 16:31:49 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-07 11:49:22 +0200
commitc53e07e249d4635babe901fd40dc1ecdfc32f0d4 (patch)
treea0ea4c9b2d302ddfe19a83e71ebe680a0055f102 /src/shared/smack-util.c
parentc9d1c37c93b779006d901b13e1c32b79cd03877a (diff)
downloadsystemd-c53e07e249d4635babe901fd40dc1ecdfc32f0d4.tar.gz
xattr-util: merge various getxattr()/listxattr() helpers into getxattr_at_malloc() + listxattr_at_malloc()
Unfortunately fgetxattr() and flistxattr() don't work via O_PATH fds. Let's thus add fallbacks to go via /proc/self/fd/ in these cases. Also, let's merge all the various flavours we have here into singular implementations that can do everything we need: 1. malloc() loop handling 2. by fd, by path, or combination (i.e. a proper openat() like API) 3. work on O_PATH
Diffstat (limited to 'src/shared/smack-util.c')
-rw-r--r--src/shared/smack-util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
index 1d04020027..d7fbbdc913 100644
--- a/src/shared/smack-util.c
+++ b/src/shared/smack-util.c
@@ -52,7 +52,7 @@ int mac_smack_read(const char *path, SmackAttr attr, char **label) {
if (!mac_smack_use())
return 0;
- return getxattr_malloc(path, smack_attr_to_string(attr), label, true);
+ return getxattr_malloc(path, smack_attr_to_string(attr), label);
}
int mac_smack_read_fd(int fd, SmackAttr attr, char **label) {
@@ -166,7 +166,7 @@ static int smack_fix_fd(int fd, const char *abspath, LabelFixFlags flags) {
return 0;
/* If the old label is identical to the new one, suppress any kind of error */
- if (getxattr_malloc(FORMAT_PROC_FD_PATH(fd), "security.SMACK64", &old_label, false) >= 0 &&
+ if (lgetxattr_malloc(FORMAT_PROC_FD_PATH(fd), "security.SMACK64", &old_label) >= 0 &&
streq(old_label, label))
return 0;