![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help on umask | suvendu4urs | Linux | 6 | 04-11-2008 09:12 AM |
| umask with find | braindrain | Shell Programming and Scripting | 4 | 09-25-2006 04:28 AM |
| Selective Umask | baanprog | UNIX for Advanced & Expert Users | 3 | 08-03-2006 06:48 AM |
| Umask help | x96riley3 | AIX | 1 | 04-04-2006 12:56 PM |
| umask | rsh | UNIX for Dummies Questions & Answers | 2 | 12-14-2002 09:52 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
umask
in this unix book that i have, it says:
the statement: filedes = open(pathname, O_CREAT, mode); is actually filedes = open(pathname, O_CREAT, (~mask)&mode); /* ~ is the negation symbol */ like it's doing some type of masking. for example, fd = open("newfile", O_CREAT, 0644); will actually given the mode of 0640. how did it come up with that? what value does it mask to my mode set to come up with 0640? why is it doing that? thanks Last edited by bb00y; 11-06-2002 at 01:51 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
It would be more accurate to say something like the thing that the first thing that the open() system call does is:
mode=(~mask)&mode; The "mask" is called umask. It is set with the umask() system call. And there is a umask command for users. Umask will also affect creat(), mkdir(), and mknod(). If you use bind() on a unix_domain socket you will create a socket in the filesystem. bind() is immune to umask which is actually something I find to be a little odd. As for why, well I don't really know. However, here is my guess... I think that after people wrote a bunch of programs that did: fd = open("newfile", O_CREAT, 0644); or even fd = open("newfile", O_CREAT, 0666); they one day woke up and realized that was not great for security. So rather than rewrite all the programs, they just invented umask() to give users some control over what the mode is. |
||||
| Google The UNIX and Linux Forums |