[ic] Usertag and permissions on create file

m.mescoli at omnib.it m.mescoli at omnib.it
Fri Sep 19 21:38:04 UTC 2008


Stefan Hornburg (Racke) ha scritto:
> m.mescoli at omnib.it wrote:
>> m.mescoli at omnib.it ha scritto:
>>> Perl beginner.
>>>
>>> With an usertag i create a png plot file with umask permission 0660. 
>>> This permissions do not permits apache to read the file and trasmit it 
>>> to web clients. How create and write a file inside usertag with read 
>>> permission for all ?
>>>
>>> Thanks
>>> Marco Mescoli
>> Sorry but i don't understand. After more attempts to permit to overwrite 
>> old file or create a new one and leave it readable:
>> ...
>> my $prevumask = umask 0002;
>> open( GRAPH, "> $GRAPH" ); # file created has -rw-rw-r-- perms octal 0664
>> ...
>> ...
>> close( GRAPH );
>> umask = $prevumask; # reset file permission
>> ------------------------------------------
>> But why setting umask to octal 0002 it create the file with octal 0664 
>> perms ?
> 
> Just use $Tag->write_relative_file :-).
> 
> $ret = $Tag->write_relative_file({auto_create_dir => 1,
> 	umask => 002,
> 	file => "images/artikel/abc.png",
> 	body => $Scratch->{image}});

Ops ... only now (italian 23:22) i have understand :-)

0666 perm: creation mode for regular file
0002 umask: modified as Racke suggested (normally in usertag 0007)
0664 mperm: masked perm file creation mode (as i see)

mperm = perm & ~umask

where & is bitwise AND and ~ is bitwise NOT

Thanks to all
Marco



More information about the interchange-users mailing list