但假设这实际上是关于在 Windows 中实现 POSIX 兼容的 chmod 所涉及的编程,我将尝试回答这个问题。首先,一些背景...这篇维基百科文章很好地讨论了两个系统。简而言之:基于 Windows NT 的操作系统(Windows XP non-FAT、Windows Vista、Windows 7、Windows Server 200X)使用的访问控制列表系统与 VAX 比与 UNIX 更相似。他们还拥有比读/写/执行更多的权限。
Unless I misread your question, I think this is really a serverfault question.
But assuming this is really about the programming involved in implementing POSIX-compliant chmod in Windows, I'll give a go of answering the question. First, some background... this wikipedia article does a fair job of discussing the differences between the two systems. In short: Windows NT based OSes (Windows XP non-FAT, Windows Vista, Windows 7, Windows Server 200X) use an Access Control List system that is more similar to VAX than it is to UNIX. They also have a few more permissions than just read/write/execute.
That said... the differences aren't all that great: the owner of a file can grant permissions on the file just like in POSIX systems, but rather than being limited to the owner, the owner's group, and the rest of the world as in POSIX, the permissions can be fine-tuned to specific users and user groups.
Given that a user can belong to more than one group, I would guess that setting group permissions would simply add all groups the user is a part of to the file ACL and set the same permissions on them. World is easy enough, that's the "Everyone" group. Ditto owner. I would also imagine that the permissions themselves would be limited to POSIX permissions, i.e. read, write, execute.
Since this covers 99% of most permissions issues a user might want to handle on a file, I'd image that's as far as the chmod utility would go. A user can always just open the properties window of the file and get more fine-tuned with the permissions to their heart's content.
Were I to implment chmod on Windows, I'd probably add additional command switches to allow the addition of specific users and permissions to the ACL by name.
Edit I just found this answer right here on StackOverflow that deals with the subject more directly.
Turns out, there's a win32 function called _chmod that works almost exactly like chmod in unix-like kernels.
发布评论
评论(1)
除非我误读了你的问题,否则我认为这确实是一个服务器故障问题。
但假设这实际上是关于在 Windows 中实现 POSIX 兼容的 chmod 所涉及的编程,我将尝试回答这个问题。首先,一些背景...这篇维基百科文章很好地讨论了两个系统。简而言之:基于 Windows NT 的操作系统(Windows XP non-FAT、Windows Vista、Windows 7、Windows Server 200X)使用的访问控制列表系统与 VAX 比与 UNIX 更相似。他们还拥有比读/写/执行更多的权限。
也就是说......差异并不是那么大:文件的所有者可以像在 POSIX 系统中一样授予文件权限,但不限于所有者、所有者的组和世界其他地方与 POSIX 一样,权限可以针对特定用户和用户组进行微调。
鉴于一个用户可以属于多个组,我猜想设置组权限只需将用户所属的所有组添加到文件 ACL 中,并为它们设置相同的权限。世界很简单,那就是“每个人”群体。同上业主。我还想象权限本身将仅限于 POSIX 权限,即读、写、执行。
由于这涵盖了用户可能想要处理文件的 99% 的大多数权限问题,我想这就是 chmod 实用程序所能做到的。用户始终可以打开文件的属性窗口,并根据自己的喜好对其权限进行更精细的调整。
如果我要在 Windows 上实现 chmod,我可能会添加额外的命令开关以允许按名称向 ACL 添加特定用户和权限。
编辑
我刚刚找到这个答案就在这里StackOverflow 更直接地处理这个主题。
事实证明,有一个名为
_chmod
的 win32 函数,其工作方式几乎与类 UNIX 内核中的chmod
完全相同。Unless I misread your question, I think this is really a serverfault question.
But assuming this is really about the programming involved in implementing POSIX-compliant chmod in Windows, I'll give a go of answering the question. First, some background... this wikipedia article does a fair job of discussing the differences between the two systems. In short: Windows NT based OSes (Windows XP non-FAT, Windows Vista, Windows 7, Windows Server 200X) use an Access Control List system that is more similar to VAX than it is to UNIX. They also have a few more permissions than just read/write/execute.
That said... the differences aren't all that great: the owner of a file can grant permissions on the file just like in POSIX systems, but rather than being limited to the owner, the owner's group, and the rest of the world as in POSIX, the permissions can be fine-tuned to specific users and user groups.
Given that a user can belong to more than one group, I would guess that setting group permissions would simply add all groups the user is a part of to the file ACL and set the same permissions on them. World is easy enough, that's the "Everyone" group. Ditto owner. I would also imagine that the permissions themselves would be limited to POSIX permissions, i.e. read, write, execute.
Since this covers 99% of most permissions issues a user might want to handle on a file, I'd image that's as far as the chmod utility would go. A user can always just open the properties window of the file and get more fine-tuned with the permissions to their heart's content.
Were I to implment chmod on Windows, I'd probably add additional command switches to allow the addition of specific users and permissions to the ACL by name.
Edit
I just found this answer right here on StackOverflow that deals with the subject more directly.
Turns out, there's a win32 function called
_chmod
that works almost exactly likechmod
in unix-like kernels.