From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 13 16:51:31 2005 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D907A16A41F for ; Sat, 13 Aug 2005 16:51:31 +0000 (GMT) (envelope-from igor@doom.homeunix.org) Received: from voodoo.oberon.net (voodoo.oberon.net [212.118.165.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6D65743D46 for ; Sat, 13 Aug 2005 16:51:31 +0000 (GMT) (envelope-from igor@doom.homeunix.org) Received: from dialup84116-41.ip.peterstar.net ([84.204.116.41] helo=doom.homeunix.org) by voodoo.oberon.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.52 (FreeBSD)) id 1E3zED-0000j5-6u for hackers@freebsd.org; Sat, 13 Aug 2005 18:51:26 +0200 Received: from doom.homeunix.org (localhost [127.0.0.1]) by doom.homeunix.org (8.13.3/8.13.3) with ESMTP id j7DGpJZq001547 for ; Sat, 13 Aug 2005 20:51:20 +0400 (MSD) (envelope-from igor@doom.homeunix.org) Received: (from igor@localhost) by doom.homeunix.org (8.13.3/8.13.3/Submit) id j7DGpJZ2001546 for hackers@freebsd.org; Sat, 13 Aug 2005 20:51:19 +0400 (MSD) (envelope-from igor) Date: Sat, 13 Aug 2005 20:51:19 +0400 From: Igor Pokrovsky To: hackers@freebsd.org Message-ID: <20050813165119.GA1234@doom.homeunix.org> Mail-Followup-To: hackers@freebsd.org References: <20050812194927.GA74052@doom.homeunix.org> <200508122034.j7CKYp2x033829@wattres.watt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200508122034.j7CKYp2x033829@wattres.watt.com> User-Agent: Mutt/1.4.2.1i Cc: Subject: Re: perl's tie problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2005 16:51:32 -0000 On Fri, Aug 12, 2005 at 01:34:51PM -0700, Steve Watt wrote: > 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. Thanks for explanation guys. I guess I'm still thinking windoze. -ip -- If there isn't a law, there will be.