Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to set some extended attributes on a symbolic link on Fedora 15.

According to setfattr's usage, there is an option -h for such purpose:

setfattr 2.4.44 -- set extended attributes
Usage: setfattr {-n name} [-v value] [-h] file...
       setfattr {-x name} [-h] file...
  -n, --name=name         set the value of the named extended attribute
  -x, --remove=name       remove the named extended attribute
  -v, --value=value       use value as the attribute value
  -h, --no-dereference    do not dereference symbolic links
      --restore=file      restore extended attributes
      --version           print version and exit
      --help              this help text

However, the option doesn't seem to work. Using -h on symlink files just reports Operation not permitted without setting the extended attribute.

For example:

[dummy@notebook test]$ ls -l
total 0
-rw-rw-r-- 1 dummy dummy 0 Jul 12 14:35 file
lrwxrwxrwx 1 dummy dummy 6 Jul 12 14:35 link -> ./file
[dummy@notebook test]$ setfattr -n user.name -v value1 file
[dummy@notebook test]$ getfattr -n user.name file
# file: file
user.name="value1"

[dummy@notebook test]$ setfattr -n user.name -v value2 link
[dummy@notebook test]$ getfattr -n user.name file
# file: file
user.name="value2"

[dummy@notebook test]$ setfattr -n user.name -v value3 -h link
setfattr: link: Operation not permitted
[dummy@notebook test]$ getfattr -n user.name -h link
link: user.name: Operation not permitted

Why is this?

share|improve this question
add comment

migrated from stackoverflow.com Jul 12 '11 at 17:09

This question came from our site for professional and enthusiast programmers.

1 Answer

I found this comment in fs/xattr.c:

    /* In user.* namespace, only regular files and directories can have
     * extended attributes. For sticky directories, only the owner and
     * privileged user can write attributes.
     */

I'm not sure why that is, but there you have it; the kernel won't allow user.* eas on anything but a regular file or directory.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.