Tuesday, July 28, 2009

Unix process owns file?

In a Unix environment, is it possible to set the file permissions such that only the process which created the file can delete it or change it, but other processes are given read access to the file? if no how close to this specification can I get?

Unix process owns file?
The answer is yes.


You set the permissions as below for both directories and files.


drwxr--r--


-rwxr--r--


Use the setting


744





See the link for a full explaination.
Reply:Absolutely it's possible... well, actually, it's possible to set a file permission so the owner of the process (ie the process itself plus any other process run by the same account) can read/write/update the file but no-one else can do anything other than read. Except of course 'root' can always do everything.





Set the process mask to 155... files should be created readable by anyone, writable only by the current owner of the process.





Alternatively... in a program create the file then use:


chmod 644 %26lt;filename%26gt;





If you make the process owned by a unique user account used for nothing else that won't allow direct logon then you get very close.





To get even closer, put the file in a directory that is set for rwxr-xr-x permissions (= chmod 755 %26lt;directory%26gt;) and owned by the account that runs the process... that way only the process / anything that account runs / root will be able to create or delete files in the directory.


No comments:

Post a Comment