【问题标题】:ls: Operation not Permittedls:不允许操作
【发布时间】:2014-11-01 06:34:23
【问题描述】:

我正在运行一个带有选项 allow_other 和 umask 0 的保险丝 fs。这给了我一组权限设置为 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 更明智。
  • 我可以设置为755。我设置为777只是为了检查各种调试场景。现在我更感兴趣的是找到解决这个问题的方法。

标签: unix fuse


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 是目录,不是文件夹。
    【解决方案3】:

    至少使用strace(1)

     strace ls -l
    

    这将向您显示 ls 完成的所有系统调用,并且您将识别出与 syscalls(2) 相关的 FUSE 文件系统失败。

    也许stat(2)tags 等个别目录条目上失败...?

    您可能忘记在 FUSE 中实现一些操作。

    【讨论】:

    • 用 strace 输出更新了问题。问题似乎在于获取 selinux 属性。
    【解决方案4】:

    问题在于我的 getxattr 实现。我在转换为 EPERM 的错误上返回 -1,而不是我应该返回 ENODATA,这对于我的逻辑来说是更正确的错误情况。这也修复了这些错误。

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

    【讨论】:

      猜你喜欢
      • 2016-03-28
      • 1970-01-01
      • 2012-01-03
      • 2021-02-10
      • 2021-01-01
      • 2014-06-30
      • 2012-03-19
      • 2023-04-03
      • 1970-01-01
      相关资源
      最近更新 更多