Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Aug 2005 13:34:51 -0700
From:      steve@Watt.COM (Steve Watt)
To:        ip@doom.homeunix.org
Cc:        hackers@freebsd.org
Subject:   Re: perl's tie problem
Message-ID:  <200508122034.j7CKYp2x033829@wattres.watt.com>
In-Reply-To: <20050812194927.GA74052@doom.homeunix.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <20050812194927.GA74052@doom.homeunix.org> you write:
>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

umask applies after the open call's permissions, and is used to remove
bits from the value passed in to the open.  That's the way POSIX
says it works, and that's how it works on UNIX machines.

Down in the guts of the open() syscall, there's a line that
effectively says
  file_permissions = passed_in_permissions & ~umask;

It's working as designed.

-- 
Steve Watt KD6GGD  PP-ASEL-IA          ICBM: 121W 56' 57.8" / 37N 20' 14.9"
 Internet: steve @ Watt.COM                         Whois: SW32
   Free time?  There's no such thing.  It just comes in varying prices...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508122034.j7CKYp2x033829>