我遇到了一个Linux内核tutorial,在那里他们谈到了4对标识符,其中一个是文件系统uid和gid.

有人可以解释一下它是什么以及它与uid和gid有什么不同?

解决方法:

谁会想到这个问题会拖出这样一系列过度自信和反应不足的回复!


文件系统uid或fsuid是一个Linux功能,旨在帮助NFS服务器实现.它是一个额外的(非POSIX)uid,仅用于文件权限检查.对于任何不调用setfsuid的进程(基本上任何不尝试成为NFS服务器的进程),fsuid与有效uid相同.

甚至有一个man page,所以声称它不存在的借口.

更新:我被启发去寻找fsuid的起源.当它在Linux 1.1.44中添加时,此注释被置于新的sys\_setfsuid函数之上:

+/*
+ * "setfsuid()" sets the fsuid - the uid used for filesystem checks. This
+ * is used for "access()" and for the NFS daemon (letting nfsd stay at
+ * whatever uid it wants to). It normally shadows "euid", except when
+ * explicitly set by setfsuid() or for access..
+ */

并且这个更改是在sys\_access上面的注释中进行的:

- * XXX we should use the real ids for checking _all_ components of the
- * path.  Now we only use them for the final component of the path.
+ * access() needs to use the real uid/gid, not the effective uid/gid.
+ * We do this by temporarily setting fsuid/fsgid to the wanted values

所以NFS是最初的两个目的之一.另一个是使access()正常工作. setuid程序使用access()来确定真实用户是否可以访问文件而没有setuid的额外权限.在1.1.44之前它是错误的.从那时起,它一直在使用fsuid的临时更改来完成工作.由于fsuid在access()系统调用返回之前被恢复,因此您实际上永远不会看到来自用户空间的更改.

标签: linux, users, filesystems

相关文章推荐

添加新评论,含*的栏目为必填