심볼릭 링크의 확장 속성

심볼릭 링크의 확장 속성

Fedora 15의 심볼릭 링크에 일부 확장 속성을 설정하려고 합니다.

setfattr용도 에 따라 -h이 목적을 위한 옵션이 있습니다.

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

그러나 이 옵션은 작동하지 않는 것 같습니다. 확장 속성을 설정하지 않고 -h기호 링크 파일에 대해 보고서 전용을 사용합니다 .Operation not permitted

예를 들어:

[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

왜 이런거야?

답변1

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.
 */

커널은 일반 파일이나 디렉토리 이외의 사용자 네임스페이스에 속성을 설정하는 것을 허용하지 않습니다.

xattr(7)자세한 내용을 제공하세요.

확장된 사용자 속성

Extended user attributes may be assigned to files and directories for
storing arbitrary additional information such as the mime type,
character set or encoding of a file.  The access permissions for user
attributes are defined by the file permission bits: read permission
is required to retrieve the attribute value, and writer permission is
required to change it.

The file permission bits of regular files and directories are
interpreted differently from the file permission bits of special
files and symbolic links.  For regular files and directories the file
permission bits define access to the file's contents, while for
device special files they define access to the device described by
the special file.  The file permissions of symbolic links are not
used in access checks.  These differences would allow users to
consume filesystem resources in a way not controllable by disk quotas
for group or world writable special files and directories.

For this reason, extended user attributes are allowed only for
regular files and directories, and access to extended user attributes
is restricted to the owner and to users with appropriate capabilities
for directories with the sticky bit set (see the chmod(1) manual page
for an explanation of the sticky bit).

관련 정보