[ILUG] umask query
Brian Foster
blf at blf.utvinternet.ie
Sat Apr 23 04:53:23 IST 2005
| Date: Fri, 22 Apr 2005 19:11:52 +0100
| From: Sean O Sullivan <seanos at netsoc.itcarlow.ie>
|
| Need files and directories to be created with permissions '775'.
| umask should then be set to '002', however, apparently when set umask
| it is set, it will dictate that directories will be created as '775',
| however files as '644' (with a umask of 002).
that is not quite correct. or at least it appears you
may believe the umask can do something that it cannot
actually do, and was not designed to do.
the umask(2) _clears_ (sets to 0) unwanted permissions
bits _specified_ by the creating open(2) (for files)
or mkdir(2) (for directories). so, if yer file is
being created by:
open("file", O_CREAT|..., 0666)
as is usually the case --- 0666 is almost always the
mode specified (for files, 0777 for directories) ---
it is absolutely _impossible_ for the umask to cause
any of the eXecute bits (0111) to be set (for files).
the umask can cause any of the specified 0666 bits to
be cleared. e.g., for yer example umask of 002, that
bit would be cleared resulting in 0664 (rw-rw-r--),
as you have observed.
| This is a problem, as I need both to be 775...
| Is there any solution for this ?
either chmod(2)/fchmod(2) the file after creation,
or change the permissions specified in the creating
open(2). I suggest fchmod since that will make you
independent of the umask, which it seems is what
you are really after. either solution does imply
modifying the source code.
cheers!
-blf-
--
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
More information about the ILUG
mailing list