Operating System - HP-UX
1832941 Members
2707 Online
110048 Solutions
New Discussion

Is that possible to set "file creation mode" ?

 
SOLVED
Go to solution
yyghp
Super Advisor

Is that possible to set "file creation mode" ?

Is that possible to control the "file creation mode" ?
Now we are using an application called egate ( Seebeyond product ), it generates the some files with rw-rw---, how can I make it to create files with rw-rw-r-- ( read only for others ). As i know i can't do nothing with "umask" to change the permission.
Thanks !
4 REPLIES 4
RAC_1
Honored Contributor

Re: Is that possible to set "file creation mode" ?

You can set umask for that. But that can always be overidden by a knowledgible user. Also is your application specifying umask before creating a file?? If that is the case, setting umask willn ot help.

Anil
There is no substitute to HARDWORK
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Is that possible to set "file creation mode" ?

Not unless you have access to the source code.

When a file is created using the creat() system call or with the open() system call if O_CREAT is asserted, the actual mode of the file is the mode as supplied to the system call with the current umask value "subtracted" from it. It's not really subtraction but the idea is the same. If you have umask set to 000 then whatever mode results when the application creats a file is the mode that the programmer intended.

There is no way to override this behavior nor should there be. If there were, all kinds of security holes would be created.

What you can do, is have a cron process that looks for new regular files on a certain directory tree, owned by a certain user or group and does the chmod after the fact.

If it ain't broke, I can fix that.
Thierry Poels_1
Honored Contributor

Re: Is that possible to set "file creation mode" ?

Hi,

files are per default created with rw-rw-rw- permissions (directories with rwxrwxrwx).
You can only *lower* the permission by using umask.
"umask 002" should result in rw-rw-r-- for files.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Muthukumar_5
Honored Contributor

Re: Is that possible to set "file creation mode" ?

Based upon user setting to umask, file creation mode will be changed.

Execute as,

umask
...

It will give user file-creation mas there.

Try to change that as,

umask 022

touch testfile
ls -l testfile
you can note that permission will be changed to rw-rw-r--

If you want to keep this always from login then, go to your login profile and put umask 002

so that file creation will be changed to your requirement.

HTH.

Easy to suggest when don't know about the problem!