[GRASS5] temp file permissions: 0666?

Glynn Clements glynn at gclements.plus.com
Thu Feb 10 14:26:46 EST 2005


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.]

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list