Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does chmod work for windows? [closed]

Tags:

windows

chmod

Windows file permissions are quite different from *nix permissions, so how is chmod from GnuWin coreutils implemented in windows?

like image 397
Charles Ma Avatar asked Dec 30 '11 18:12

Charles Ma


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.

like image 56
Randolpho Avatar answered Sep 27 '22 23:09

Randolpho