diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-08-18 09:43:25 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-08-19 09:19:27 +0200 |
commit | ddb6eeafe2d3445eeab2c450cf9d270d68b3a4b7 (patch) | |
tree | 4ff19b6603b181e4e6f8c1181fbbc7256937479d /src/shared/selinux-util.c | |
parent | test: add test for FORMAT_PROC_FD_PATH() (diff) | |
download | systemd-ddb6eeafe2d3445eeab2c450cf9d270d68b3a4b7.tar.xz systemd-ddb6eeafe2d3445eeab2c450cf9d270d68b3a4b7.zip |
tree-wide: port things over to FORMAT_PROC_FD_PATH()
Diffstat (limited to 'src/shared/selinux-util.c')
-rw-r--r-- | src/shared/selinux-util.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c index e4890e8170..34e78e6792 100644 --- a/src/shared/selinux-util.c +++ b/src/shared/selinux-util.c @@ -266,7 +266,6 @@ int mac_selinux_fix_container_fd(int fd, const char *path, const char *inside_pa assert(inside_path); #if HAVE_SELINUX - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; _cleanup_freecon_ char* fcon = NULL; struct stat st; int r; @@ -292,8 +291,7 @@ int mac_selinux_fix_container_fd(int fd, const char *path, const char *inside_pa goto fail; } - xsprintf(procfs_path, "/proc/self/fd/%i", fd); - if (setfilecon_raw(procfs_path, fcon) < 0) { + if (setfilecon_raw(FORMAT_PROC_FD_PATH(fd), fcon) < 0) { _cleanup_freecon_ char *oldcon = NULL; /* If the FS doesn't support labels, then exit without warning */ @@ -307,7 +305,7 @@ int mac_selinux_fix_container_fd(int fd, const char *path, const char *inside_pa r = -errno; /* If the old label is identical to the new one, suppress any kind of error */ - if (getfilecon_raw(procfs_path, &oldcon) >= 0 && streq(fcon, oldcon)) + if (getfilecon_raw(FORMAT_PROC_FD_PATH(fd), &oldcon) >= 0 && streq(fcon, oldcon)) return 0; goto fail; |