linux - xattr/extended attributes not settable for file in/tmp while in $home on same mount 工作正常

标签 linux file-attributes xattr tmpfs

我在 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/

相关文章:

linux - 没有元数据的 tar 存档

ls - “ls -lah”输出中许可权末尾的小点是什么意思?

Linux 内核模块读/写文件

c - 通过将 char 转换为 USHORT 得到错误的 UTF-8 值

c# 检查一个目录是否被隐藏?

c# - 设置文件压缩属性

linux - 不支持 Xattrs

linux - 设置安全属性时 xattr 命令错误

linux - 将批处理文件转换为 Linux Shell 脚本

python - 构建 OpenSSL 以编译 Python 的可移植版本