lsetxattr returns EPERM 如果尝试将值设置为符号链接
lsetxattr returns EPERM if attempt to set a value to symlink
我正在测试将时间戳添加到 xattr 的简单程序。
lsetxattr 系统调用 returns EPERM 错误。这是预期的行为吗?
如何将 xattr 设置为 symlink,而不是遵循 link?
#include <sys/types.h>
#include <attr/xattr.h>
#include <errno.h>
#include <time.h>
#include <stdio.h>
int main(int argc, char **argv){
time_t t = time(NULL);
if(lsetxattr(argv[1], "user.ts", &t, sizeof(time_t), 0) == -1){
perror(argv[1]);
}
return(0);
}
示例:
> ls -l a b c
-rw-r--r-- 1 saka users 0 Feb 1 09:08 a
-rw-r--r-- 1 saka users 0 Feb 1 09:08 b
lrwxrwxrwx 1 saka users 1 Feb 1 09:08 c -> b
> ./ts a
> ./ts c
c: Operation not permitted
我用 xfs 或 ext3 在 3.10.0-862.14.4.el7.x86_64 上测试过。
我猜是 this:
/*
* In the user.* namespace, only regular files and directories can have
* extended attributes. For sticky directories, only the owner and
* privileged users can write attributes.
*/
事实上,尝试在 lsetxattr(2)
的符号链接上设置 trusted.foo
属性作为根有效,而 user.foo
失败 EPERM
.
我正在测试将时间戳添加到 xattr 的简单程序。 lsetxattr 系统调用 returns EPERM 错误。这是预期的行为吗? 如何将 xattr 设置为 symlink,而不是遵循 link?
#include <sys/types.h>
#include <attr/xattr.h>
#include <errno.h>
#include <time.h>
#include <stdio.h>
int main(int argc, char **argv){
time_t t = time(NULL);
if(lsetxattr(argv[1], "user.ts", &t, sizeof(time_t), 0) == -1){
perror(argv[1]);
}
return(0);
}
示例:
> ls -l a b c
-rw-r--r-- 1 saka users 0 Feb 1 09:08 a
-rw-r--r-- 1 saka users 0 Feb 1 09:08 b
lrwxrwxrwx 1 saka users 1 Feb 1 09:08 c -> b
> ./ts a
> ./ts c
c: Operation not permitted
我用 xfs 或 ext3 在 3.10.0-862.14.4.el7.x86_64 上测试过。
我猜是 this:
/*
* In the user.* namespace, only regular files and directories can have
* extended attributes. For sticky directories, only the owner and
* privileged users can write attributes.
*/
事实上,尝试在 lsetxattr(2)
的符号链接上设置 trusted.foo
属性作为根有效,而 user.foo
失败 EPERM
.