perl's tie problem

John Baldwin jhb at FreeBSD.org
Fri Aug 12 20:31:44 GMT 2005


On Friday 12 August 2005 03:49 pm, Igor Pokrovsky wrote:
> Hi all,
> 
> Consider the following except from a perl program:
> 
> tie(%foodb, 'MLDBM', $BAR_FILE, O_CREAT | O_RDWR, 0666)                    
>   or die("Cannot open $BAR_FILE: $!\n");
> 
> I expect it to create a new $BAR_FILE, if none existed, with 0666
> permissions. But it doesn't. It creates a file with default umask 
> specified permissions - 0644. So I have to manually do chmod on that
> file afterwards. Is there anything I don't understand?
> 
> %uname -a
> FreeBSD doom.homeunix.org 4.11-STABLE FreeBSD 4.11-STABLE #0: 
> Tue Jul  5 21:05:20 MSD 2005 [...] i386
> 
> Perl version is 5.8.7
> 
> Thanks,
> 
> -ip

I think this is expected behavior.  Your umask setting affects all calls to 
open(2) with O_CREAT to create a file, and from tie()'s arguments it seems 
that it uses open(2) to create the destination file.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-hackers mailing list