develooper Front page | perl.perl5.porters | Postings from May 2012

Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1

Thread Previous | Thread Next
From:
Steve Siano
Date:
May 10, 2012 01:25
Subject:
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1
Message ID:
1336500759.42128.YahooMailNeo@web43408.mail.sp1.yahoo.com
Thanks Tony for tracking down the root cause and thanks Chris for confirming it.

Since it is a BSD bug and not a Perl bug, I've updated my code accordingly:

if (mkdir($dir, $mode)) {
    chomp(my $OS = `uname`);

    if ($OS eq 'FreeBSD' && $mode & 01000) {
        if (chmod($mode, $dir)) {


Sincerely,

Steve




----- Original Message -----
From: Kidney Bingos via RT <perlbug-followup@perl.org>
To: steve.siano@yahoo.com
Cc: 
Sent: Tuesday, May 8, 2012 2:34 AM
Subject: Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1

On Tue, May 08, 2012 at 09:37:50AM +1000, Tony Cook wrote:
> On Fri, May 04, 2012 at 04:54:07PM -0700, steve.siano@yahoo.com (via RT) wrote:
> > # New Ticket Created by  steve.siano@yahoo.com 
> > # Please include the string:  [perl #112760]
> > # in the subject line of all future correspondence about this issue. 
> > # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=112760 >
> > 
> > 
> > 
> > This is a bug report for perl from steve.siano@yahoo.com,
> > generated with the help of perlbug 1.35 running under perl v5.8.8.
> > 
> > The following does not set the sticky bit on FreeBSD, but it works on Linux:
> > 
> >     perl -e "umask 0000; mkdir('foo', 01777);"
> > 
> > This behavior was observed on local disk and over NFS.
> > 
> > However, chmod does set the sticky bit on FreeBSD and Linux:
> > 
> >     perl -e "umask 0000; chmod(01777, 'foo');"
> 
> perl 5.8.8 is no longer supported.
> 
> >From man 8 sticky on FreeBSD 8.2:
> 
> BUGS
>      Neither open(2) nor mkdir(2) will create a file with the sticky bit set.
> 
> This isn't a perl bug, I'm not sure it's worthwhile working around
> this limitation on BSDs.
> 
>   mkdir -m 01775 foo
> 
> on FreeBSD does set the sticky bit, but it also ignores umask.
> 

I confirmed this on FreeBSD 7.4 with v5.8.9 and v5.14.0

Also behaves the same with v5.14.2 on FreeBSD 8.3 and 9.0

It also does on NetBSD 3.1 and 5.1.2

where man sticky says the same as on FreeBSD

And the same on OpenBSD 5.1 which again says the same bug
in man sticky.

I haven't checked DragonflyBSD nor MirBSD, but the docs for
DragonflyBSD suggest it is the same:

http://leaf.dragonflybsd.org/cgi/web-man?command=sticky§ion=ANY

Cheers,

-- 
Chris Williams
aka BinGOs
PGP ID 0x4658671F
http://www.gumbynet.org.uk
==========================

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About