Re: File permissions - semi off topic
Re: File permissions - semi off topic
- Subject: Re: File permissions - semi off topic
- From: Darkshadow <email@hidden>
- Date: Sat, 27 Sep 2003 08:04:29 -0400
- Nightproductions: dreamstatic.dyndns.org
Ok, here goes:
the first one that you list there (d), is just an "extra" bit, it'll
describe what type of file it is...in this case, it means a directory.
(are you using stat to get that, by any chance?)
The first three rwx are for user permissions, i.e. the user that *owns*
the file. The next three are group permissions - anyone that is a part
of the group the file is a part of will have those permissions. The
last three are for *other* users - this is anyone who is not the owner
of the file or a part of the group the file belongs to.
Ok then, a breakdown of the bits that make the numbers (i.e. your 777
for rwxrwxrwx):
*note that these numbers are octal numbers, not decimal numbers
0700 - rwx for the owner
0400 - read for the owner
0200 - write for the owner
0100 - execute for the owner
0070 - rwx for the group
0040 - read for the group
0020 - write for the group
0010 - execute for the group
0007 - rwx for others
0004 - read for others
0002 - write for others
0001 - execute for others
*specials
4000 - set user ID on execution
2000 - set group ID on execution
1000 - sticky bit.
So, say you have a file that is rwsr-sr-x, this would be 0700 (rwx for
user) + 0040 (read for group) + 0010 (execute for group) + 0004 (read
for others) + 0001 (executer for others) + 4000 (SUID) + 200 (SGID) =
6755.
(note that when you have the set UID or set GID bits on, you still need
to figure in the executable bit as well)
One more gotcha - if you're using NSFileManager to get/set the
permissions for files, it actually uses *decimal* for the permissions
rather than the more familiar octal code. You'll have to convert the
octal to a decimal first if you are setting permissions, or the decimal
to an octal if you are receiving permissions.
Hope this helps, and if you have more questions feel free to email me
with 'em.
Darkshadow
On Saturday, September 27, 2003, at 02:17 AM, April Gendill wrote:
Ok this is a totally lame question I am sure, but file permissions in
n*x list as drwxrwxrwx (for 777 if I'm not mistaken)
is there some where that I can find information on the ordering and
meaning of this permission sceme (It's read/write/execute if I am not
mistaken) but I need to know how chmod and that permission listing
match up. Or if it's chmod that is used for it.
BTW I am asking here because I am working on an app and need to know
this.
Thank you
April.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.