Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

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

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

May 4, 2012, 4:54 PM

Post #1 of 11 (267 views)
Permalink
[perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1

# New Ticket Created by steve.siano [at] yahoo
# 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 [at] yahoo,
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');"
---
Flags:
category=core
severity=medium
---
Site configuration information for perl v5.8.8:

Configured by fai at Thu Feb 5 00:58:00 UTC 2009.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=freebsd, osvers=7.1-release, archname=i386-freebsd-64int
uname='freebsd tinderbox.host 7.1-release freebsd 7.1-release #0: wed feb 4 16:57:47 pst 2009 root [at] tinderbox:usrsrcsysmagickernelpath i386 '
config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-O2 -fno-strict-aliasing -pipe -Dd_dosuid=define -Ui_gdbm -Dusethreads=n -Dusemymalloc=y -Duse64bitint'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=undef uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
optimize='-O2 -fno-strict-aliasing -pipe',
cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
ccversion='', gccversion='4.2.1 20070719 [FreeBSD]', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lm -lcrypt -lutil
perllibs=-lm -lcrypt -lutil
libc=, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
defined-or

---
@INC for perl v5.8.8:
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8
.

---
Environment for perl v5.8.8:
HOME=/homes/dc-builder
LANG (unset)
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/volume/buildtools/bin:/volume/fwtools/ccache/2.4-20100202-jnpr/bin:/volume/fwtools/tkcvs/current/bin:/homes/dc-builder/bin/bless:/homes/ssiano/bin/fx:/homes/ssiano/bin/git-1.7.9.FreeBSD.7.1/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/homes/dc-builder/bin
PERL_BADLANG (unset)
SHELL=/bin/bash


tony at develop-help

May 7, 2012, 4:37 PM

Post #2 of 11 (264 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

On Fri, May 04, 2012 at 04:54:07PM -0700, steve.siano [at] yahoo (via RT) wrote:
> # New Ticket Created by steve.siano [at] yahoo
> # 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 [at] yahoo,
> 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.

Tony


chris at bingosnet

May 8, 2012, 2:33 AM

Post #3 of 11 (251 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

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 [at] yahoo (via RT) wrote:
> > # New Ticket Created by steve.siano [at] yahoo
> > # 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 [at] yahoo,
> > 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&section=ANY

Cheers,

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


steve.siano at yahoo

May 8, 2012, 11:12 AM

Post #4 of 11 (260 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

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 [at] perl>
To: steve.siano [at] yahoo
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 [at] yahoo (via RT) wrote:
> > # New Ticket Created by  steve.siano [at] yahoo
> > # 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 [at] yahoo,
> > 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
==========================


nick at ccl4

May 10, 2012, 1:37 AM

Post #5 of 11 (248 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

On Tue, May 08, 2012 at 11:12:39AM -0700, Steve Siano wrote:
> 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)) {
>

You might want to use $^O instead of `uname`, as it saves some work.
(Although it's 'freebsd', not 'FreeBSD' in $^O)

Nicholas Clark


ikegami at adaelis

May 10, 2012, 8:46 AM

Post #6 of 11 (254 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

On Thu, May 10, 2012 at 4:37 AM, Nicholas Clark <nick [at] ccl4> wrote:

> On Tue, May 08, 2012 at 11:12:39AM -0700, Steve Siano wrote:
> > 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)) {
> >
>
> You might want to use $^O instead of `uname`, as it saves some work.
> (Although it's 'freebsd', not 'FreeBSD' in $^O)
>
> Nicholas Clark
>

I would simply avoid both.

if (mkdir($dir, $mode)) {
if ($mode & 01000) {
if (chmod($mode, $dir)) {


pagaltzis at gmx

May 12, 2012, 12:17 AM

Post #7 of 11 (232 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

* Tony Cook <tony [at] develop-help> [2012-05-08 01:40]:
> This isn't a perl bug, I'm not sure it's worthwhile working around
> this limitation on BSDs.

To me it would seem that it is. Dealing with this limitation in Perl
code requires monkey code to be added to every user program, and for it
to get added requires toes getting stubbed on this bug first. Working
around it at the interpreter level would allow user code to pretend that
all is right in the world.

At the perl level it can be fixed with an #ifdef protecting a chmod
guarded by a bit check. So the workaround is extremely cheap and even
then incurs a penalty only for those who need it; and it can easily be
dropped if and when FreeBSD is ever fixed, but at the same time breaks
nothing if it isn’t removed promptly – so maintenance burden is minimal.

There seems to be essentially zero downside to adding the workaround.

At the same time I can’t see any upside in not adding it and thereby
pushing the complexity out into Perl programs. Did I miss any benefit
here? Does what I missed outweigh the above benefits of doing it at the
interpreter level?

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>


chris at bingosnet

May 12, 2012, 2:22 AM

Post #8 of 11 (236 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

On Thu, May 10, 2012 at 09:37:21AM +0100, Nicholas Clark wrote:
> On Tue, May 08, 2012 at 11:12:39AM -0700, Steve Siano wrote:
> > 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)) {
> >
>
> You might want to use $^O instead of `uname`, as it saves some work.
> (Although it's 'freebsd', not 'FreeBSD' in $^O)
>

Confirmed it on DragonflyBSD 3.0.2 now as well.

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


pagaltzis at gmx

Sep 22, 2013, 6:07 AM

Post #9 of 11 (84 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

* James E Keenan via RT <perlbug-followup [at] perl> [2013-09-19 01:35]:
> Are there outstanding issues in this ticket that need addressing?

Yes: the original report. I am still of the opinion that a workaround
should be added. In the meantime I can also report that the same issue
afflicts Darwin (unsurprisingly).


fawaka at gmail

Sep 22, 2013, 8:03 AM

Post #10 of 11 (77 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

On Sat, May 12, 2012 at 9:17 AM, Aristotle Pagaltzis <pagaltzis [at] gmx>wrote:

> To me it would seem that it is. Dealing with this limitation in Perl
> code requires monkey code to be added to every user program, and for it
> to get added requires toes getting stubbed on this bug first. Working
> around it at the interpreter level would allow user code to pretend that
> all is right in the world.
>

To quote POSIX: "When bits in *mode* other than the file permission bits
are set, the meaning of these additional bits is implementation-defined."
So the BSDs are entirely conformant even if they desire other (equally
conformant) semantics. This is not really a bug.


> At the perl level it can be fixed with an #ifdef protecting a chmod
> guarded by a bit check. So the workaround is extremely cheap and even
> then incurs a penalty only for those who need it; and it can easily be
> dropped if and when FreeBSD is ever fixed, but at the same time breaks
> nothing if it isn’t removed promptly – so maintenance burden is minimal.
>
> There seems to be essentially zero downside to adding the workaround.
>
> At the same time I can’t see any upside in not adding it and thereby
> pushing the complexity out into Perl programs. Did I miss any benefit
> here? Does what I missed outweigh the above benefits of doing it at the
> interpreter level?
>

Sticky bits are uncommon enough that I think it's not worth the maintenence
costs.

Leon


ikegami at adaelis

Sep 22, 2013, 11:18 AM

Post #11 of 11 (63 views)
Permalink
Re: [perl #112760] mkdir in Perl 5.8.8 Fails to Set the Sticky Bit on FreeBSD 7.1 [In reply to]

On Sun, Sep 22, 2013 at 11:03 AM, Leon Timmermans <fawaka [at] gmail> wrote:

> To quote POSIX: "When bits in *mode* other than the file permission bits
> are set, the meaning of these additional bits is implementation-defined."
> So the BSDs are entirely conformant even if they desire other (equally
> conformant) semantics. This is not really a bug.
>
> Sticky bits are uncommon enough that I think it's not worth the
> maintenence costs.
>

Just add that passage to mkdir's docs.

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.