Protecting files while written ...

  • Follow


Hi,
Let's say I have a process that creates file and write data into it.
The process will create the file with perm 755
( in result of a default umask 022 ).
At this point all users in the domain will be able to read, copy or
execute the file.
I want to protect the file until the end of the writing process.
Is there a reasonable way to do this ?
( aix 4.33 Ml 8 although it's a traditional Unix Q ).
Thanks

--
Posted via http://dbforums.com
0
Reply shark 7/8/2003 9:11:22 PM

In article <3087816.1057698682@dbforums.com>,
 shark <member19781@dbforums.com> wrote:

> Hi,
> Let's say I have a process that creates file and write data into it.
> The process will create the file with perm 755
> ( in result of a default umask 022 ).
> At this point all users in the domain will be able to read, copy or
> execute the file.
> I want to protect the file until the end of the writing process.
> Is there a reasonable way to do this ?
> ( aix 4.33 Ml 8 although it's a traditional Unix Q ).

Can you use creat() with a permissions mask of 755?  If you create a 
file on Solaris, it won't let you do this.  You can create a file with 
permissions 644, but not 755.  Then you have to explicitly set the 
execute permission bit.

Be that as it may, why not just creat() the file with 644 permissions, 
then start writing to it.  True anyone can read or copy it while it's in 
that state.  Then when writing is complete, change permissons to 755 and 
others will be able execute it.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...



0
Reply Michael 7/8/2003 11:56:18 PM


shark <member19781@dbforums.com> wrote:

> Hi,
> Let's say I have a process that creates file and write data into it.
> The process will create the file with perm 755
> ( in result of a default umask 022 ).
> At this point all users in the domain will be able to read, copy or
> execute the file.
> I want to protect the file until the end of the writing process.
> Is there a reasonable way to do this ?
> ( aix 4.33 Ml 8 although it's a traditional Unix Q ).
> Thanks

Create file with open(2) ("file" , O_CREAT| O_RDWR, 006 ) 

write data, then close(2) chmod(2) 

> --
> Posted via http://dbforums.com

-- 
Peter H�kanson         
        IPSec  Sverige      ( At Gothenburg Riverside )
           Sorry about my e-mail address, but i'm trying to keep spam out,
	   remove "icke-reklam" if you feel for mailing me. Thanx.
0
Reply phn 7/9/2003 7:27:37 AM

2 Replies
100 Views

(page loaded in 0.069 seconds)

5/25/2013 12:54:25 PM


Reply: