[GRASS5] temp file permissions: 0666?

Radim Blazek blazek at itc.it
Sat Feb 12 05:47:36 EST 2005


Glynn Clements wrote:
> Markus Neteler wrote:
> 
> 
>>while working on r.los, I found numerous lines in
>>GRASS where temporary files are created with 0666 permissions:
>>
>> creat (tempname, 0666)
>>                  ^^^^
>> (and similar)
>>
>>A good thing?
> 
> 
> Yep.
> 
> The actual permissions of the resulting file are obtained by AND-ing
> the specified permissions with ones-complement of the process' umask
> setting.
> 
> E.g. if you pass 0666 to creat(), and the umask is 0022 (which is a
> fairly typical setting), the file will have permissions of 0644.
> 
> The mode passed to creat() or open(..., O_CREAT) should almost always
> be 0666 (except for executable files, where it should be 0777). That
> way, the user has maximum control over the actual permissions, via
> their umask setting.
> 
> [You can set or view the umask for a bash process via the "umask"
> built-in command. New processes inherit the umask from their parent,
> so putting a umask command into e.g. ~/.bashrc will determine the
> umask for all of your processes.]


What does happen with umask in this case?:

    execl ("/bin/sh", "sh", "-c", startup, 0);

The problem appeares in DB drivers which create 0666 files even if umask 
  in shell is 0022. How to set umask correctly?

Radim




More information about the grass-dev mailing list