我在 Linux/Fedora 下玩扩展文件属性,我目前有点绊脚石,因为我无法在 /tmp
中添加/更改文件属性,而在我家里它工作正常 - 虽然两条路径都在同一个挂载点上,即
/dev/mapper/fedora-root on / type ext4 (rw,relatime,seclabel,data=ordered)
例如,我可以成功地为我的主目录中的文件添加和检索属性,例如,
> setfattr -n user.test.md5 -v 58d8e4cd0e60facf386838cbe8b11767 ~/foo.bar
> getfattr -n user.test.md5 ~/foo.bar
# file: foo.bar
user.test.md5="58d8e4cd0e60facf386838cbe8b11767"
但是,对于 /tmp
中的同一文件,同样会失败。
> cp ~/foo.bar /tmp/foo.bar
> setfattr -n user.test.md5 -v 58d8e4cd0e60facf386838cbe8b11767 /tmp/foo.bar
setfattr: /tmp/foo.bar: Operation not supported
我假设,对扩展属性的支持仅取决于具有 xattr 支持的“正确”安装的文件系统。但是,它似乎也依赖于目录(??),我想知道,是什么阻止我在/tmp 中设置扩展属性以及如何更改它? (这似乎与 SELinux 无关——至少我在审计日志中没有发现任何东西。)
最佳答案
如果启用 CONFIG_TMPFS_XATTR
,
tmpfs 可以支持扩展属性在内核配置中。
从 5.9.3 版本开始,这仅支持 trusted.*
和 security.*
命名空间,因此您的 setfattr -n user.test.md5
命令仍然会失败。
关于linux - xattr/extended attributes not settable for file in/tmp while in $home on same mount 工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30760177/