Windows file permissions are quite different from *nix permissions, so how is chmod from GnuWin coreutils implemented in windows?
-
Probably not at all. From what I've seen from *some* GnuWin32 binaries at least they simply drop things that don't work on Windows. – Joey Dec 30 '11 at 18:29
-
If this is really about programming, please reword as such. – Randolpho Dec 30 '11 at 20:26
-
4What is unclear about "how is chmod ... _implemented_ in windows" being a programming question? – Chris Becke Dec 31 '11 at 09:43
-
@ChrisBecke Quite so. I'm baffled by how anyone can fail to understand this quite clear question. It's weird that Randopho actually answers the question asked, "assuming" it means exactly what it says, rather than something completely different ("really a serverfault question", which it obviously isn't). – Jim Balter Jun 02 '15 at 00:09
1 Answers
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.
-
underscore prefixed functions are (usually) always c-runtime extensions. _chmod is a ms visual c++ extension, not strictly a Win32 function. – Chris Becke Dec 31 '11 at 09:45
-
@ChrisBecke You're right, it's part of the [Microsoft Runtime](http://msdn.microsoft.com/en-us/library/sk54f3f5(v=vs.80).aspx) which isn't necessarily Win32 – Randolpho Jan 01 '12 at 18:44