ls:操作不允许。

7

我正在运行一个带有选项allow_other和umask 0的fuse文件系统。这给了我一组权限设置为777的文件。但是当我尝试在包含这些文件的目录中执行ls -l命令时,输出如下:

ls: name: Operation not permitted
ls: tags: Operation not permitted
ls: location: Operation not permitted
ls: ext: Operation not permitted
ls: experiment_id: Operation not permitted
ls: file_path: Operation not permitted

有人能告诉我为什么我拥有全局权限(777),但仍然收到“操作不允许”的消息吗?

运行strace后,我得到以下跟踪结果:

lstat("tags", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lgetxattr("tags", "security.selinux", 0x112ae80, 255) = -1 EPERM (Operation not     permitted)
write(2, "ls: ", 4ls: )                     = 4
write(2, "tags", 4tags)                     = 4
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1
)                       = 1
lstat("location", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lgetxattr("location", "security.selinux", 0x112aea0, 255) = -1 EPERM (Operation not      permitted)
write(2, "ls: ", 4ls: )                     = 4
write(2, "location", 8location)                 = 8
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1)                       = 1
lstat("ext", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lgetxattr("ext", "security.selinux", 0x112aec0, 255) = -1 EPERM (Operation not permitted)
write(2, "ls: ", 4ls: )                     = 4
write(2, "ext", 3ext)                      = 3
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1)                       = 1
lstat("experiment_id", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lgetxattr("experiment_id", "security.selinux", 0x112aee0, 255) = -1 EPERM (Operation not    permitted)  
write(2, "ls: ", 4ls: )                     = 4
write(2, "experiment_id", 13experiment_id)           = 13
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1)                       = 1
lstat("file_path", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
lgetxattr("file_path", "security.selinux", 0x112af00, 255) = -1 EPERM (Operation not permitted)
write(2, "ls: ", 4ls: )                     = 4
write(2, "file_path", 9file_path)                = 9
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "\n", 1)                       = 1

所以从跟踪记录来看,尽管在我的系统上已禁用,但它仍然试图获取selinux属性。
cat /etc//sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted

设置777权限几乎总是不明智的,因为它允许系统上的任何用户修改相应的文件或目录。755或最多775更为合理。 - Keith Thompson
我可以将它设置为755。我将其设置为777,只是为了检查各种调试场景。现在我更感兴趣的是找到如何修复这个问题。 - Akash Gangil
4个回答

15

请按照以下步骤解决问题。我尝试了以下步骤,对我有用: 1.下拉 苹果菜单并选择“系统偏好设置” 2.选择“安全性与隐私”控制面板 3.现在选择“隐私”选项卡,然后从左侧菜单中选择“完全磁盘访问权限” 4.单击首选项面板左下角的锁图标,并使用管理员级别登录进行身份验证 5.现在单击[+]加号按钮以添加具有完全磁盘访问权限的应用程序 6.导航到/Applications/Utilities/文件夹并选择“终端”以授予终端完全磁盘访问权限 7.重新启动终端,"Operation not permitted"错误消息将消失


2

在包含文件的目录上设置权限。


这是一个目录,不是一个文件夹。 - Basile Starynkevitch

1
请使用strace(1)至少作为。
 strace ls -l

这将展示所有由ls执行的系统调用,您会认识到哪些与FUSE文件系统相关的syscalls(2)正在失败。 也许像tags等单个目录条目上的stat(2)正在失败? 您可能忘记在您的FUSE中实现某些操作。

更新了带有strace输出的问题。问题似乎出在获取selinux属性上。 - Akash Gangil

1
我的问题出在 getxattr 实现上。当出现错误时我返回了 -1,这被翻译成了 EPERM,而我应该返回 ENODATA,这才是我的逻辑中更正确的错误情况。这个修改也解决了那些错误。

https://gowalker.org/github.com/hanwen/go-fuse/fuse


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接