【问题标题】:xattr/extended attributes not settable for file in /tmp while in $home on same mount works finexattr/extended 属性不可为 /tmp 中的文件设置,而在同一挂载上的 $home 中工作正常
【发布时间】:2015-06-10 15:01:47
【问题描述】:

我正在使用 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 无关——至少我在审计日志中没有发现任何内容。)

【问题讨论】:

  • 确定/home/tmp 都是/ 的一部分吗?它们通常不...尤其是/tmp 可能是tmpfs 文件系统,它可能不支持您感兴趣的扩展属性...
  • @twalberg 你是对的!我天真地没有正确检查 /tmp 是如何实际安装的,但是从我的初始设置 tmpfs on /tmp type tmpfs (rw,seclabel)

标签: linux file-attributes xattr tmpfs


【解决方案1】:
如果您在内核配置中启用CONFIG_TMPFS_XATTR

tmpfs 可以支持扩展属性。 从 5.9.3 版开始,这仅支持 trusted.*security.* 命名空间,因此您的 setfattr -n user.test.md5 命令仍然会失败。

【讨论】:

    【解决方案2】:

    /tmp 并没有像我天真假设的那样简单安装,而是作为 tmpfs 安装,显然不支持扩展属性

    tmpfs on /tmp type tmpfs (rw,seclabel)

    感谢特瓦尔伯格!

    【讨论】:

      猜你喜欢
      • 2011-11-25
      • 1970-01-01
      • 2016-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多