drhgzx4727 2010-10-24 21:45
浏览 36
已采纳

检查用户是否具有* nix中文件的权限

Out of curiosity. I've been thinking about the different access models often seen in *nix and the one seen in windows nt based systems.

Is there any command or api to check if a file is readable, executable etc for a user different than the logged in user. For instance something like: http://www.php.net/manual/en/function.is-executable.php or Checking File Permissions in Linux with Python But for any user that the executing user has permission to see.

Is there any reason why such a function should not be found?

  • 写回答

1条回答 默认 最新

  • donglu5041 2010-10-24 21:56
    关注

    In *nix whether a user's permissions on a file can be determined by 2 attributes: the world and group permissions on a file. If the world permissions are set for r,w, or x than of course any user will have those rights on that file. Similarly if the user is a member of the group that is specified as the group owner of the file, and those permissions are set on the group level then again the user will have that right on the file. Of course you need to be sure the user the appropriate rights on all directories in the absolute path of the file. And, of course, root can access any file regardless of the permissions or ownerships.

    So for any particular file it is relatively easy to determine whether a specific user has permissions on that file by looking at the file permissions and the group memberships of the user.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路