2

I am playing with extended file attributes under Linux/Fedora and I am currently stumbling a bit since I cannot add/change attributes for files in /tmp while in my home it is working fine - while both paths are on the same mount point, i.e.,

/dev/mapper/fedora-root on / type ext4 (rw,relatime,seclabel,data=ordered)

for example, I can successful add and retrieve a attribute for files in my home directory, e.g.,

> setfattr -n user.test.md5 -v 58d8e4cd0e60facf386838cbe8b11767 ~/foo.bar
> getfattr -n user.test.md5 ~/foo.bar 
  # file: foo.bar
  user.test.md5="58d8e4cd0e60facf386838cbe8b11767"

However, the same fails for the same file in /tmp.

> cp ~/foo.bar /tmp/foo.bar
> setfattr -n user.test.md5 -v 58d8e4cd0e60facf386838cbe8b11767 /tmp/foo.bar 
  setfattr: /tmp/foo.bar: Operation not supported

I assumed, that the support for extended attributes only depends on the filesystem mounted 'correctly' with xattr support. However, it seems also be directory(??) dependent and I wonder, what prevents me from setting extended attributes in /tmp and how I can change it? (It seems not to be SELinux related - at least I did not find anything in the audit logs.)

2
  • 3
    Are you sure that /home and /tmp are both part of /? They're quite often not... In particular, /tmp might be a tmpfs file system, which may not support the extended attributes you're interested in...
    – twalberg
    Commented Jun 10, 2015 at 15:49
  • 1
    @twalberg you are right! I had naively not properly checked, how /tmp is actually mounted but assumed from my inital setup tmpfs on /tmp type tmpfs (rw,seclabel)
    – THX
    Commented Jun 15, 2015 at 11:09

2 Answers 2

6

tmpfs can support extended attributes if you enable CONFIG_TMPFS_XATTR in the kernel config. As of version 5.9.3 this enables support only for the trusted.* and security.* namespaces, so your setfattr -n user.test.md5 command would still fail.

1

/tmp was not as I naively assumed mounted plainly but is mounted as tmpfs, that apparently does not support extended attributes

tmpfs on /tmp type tmpfs (rw,seclabel)

Thanks to twalberg!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.