]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic: mac_[selinux,smack]_apply_fd does not work when applying labels
authorDonald Chan <hoiho@amazon.com>
Fri, 28 Jan 2022 22:53:46 +0000 (22:53 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 30 Jan 2022 19:43:56 +0000 (04:43 +0900)
commita718364e9d9242cc2111c9860f2ab5bb9bb26db9
tree2b39677da87c6f54b8f03ba3766fde81518576bd
parent5b2d0f9efd2634a07522ce0383d3a44d417f8f1e
basic: mac_[selinux,smack]_apply_fd does not work when applying labels

Commit a7fdc6c introduced a regression where file descriptors are opened
using O_PATH option. mac_smack_apply_fd() calls fsetxattr() and would fail
with a -EBADF (Bad file descriptor) error.

Use FORMAT_PROC_FD_PATH(fd) to convert the fd back into a full path and
call setxattr() or setfilecon() instead.

Signed-off-by: Donald Chan <hoiho@amazon.com>
src/shared/selinux-util.c
src/shared/smack-util.c