Skip Menu |

This queue is for tickets about the IO-Compress-Base CPAN distribution.

Report information
The Basics
Id: 26821
Status: resolved
Priority: 0/
Queue: IO-Compress-Base

People
Owner: Nobody in particular
Requestors: thomas.blank [...] de.debitel.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.004
Fixed in: (no value)



Subject: Errors if using POSIX ACLs
I'm using POSIX ACLs on an NFS-mount. My directory is this: $ pwd /tstnfs01/fts/t_ftsadm/in/test2 $ ll total 4 -rwxr-x---+ 1 t_ftsadm t_ftsadm 458 Apr 30 10:44 gzip.pl -rw-rw----+ 1 blankt itopbs 2806 Apr 30 10:08 info.log And I'm currently working as user t_ftsadm: $ id -a uid=20261(t_ftsadm) gid=20286(t_ftsadm) These are the ACL entries on the directory and the file info.log: $ getfacl . # file: . # owner: t_ftsadm # group: t_ftsadm user::rwx user:t_ftsadm:rwx #effective:rwx group::rwx #effective:rwx group:t_ftsadm:rwx #effective:rwx mask:rwx other:--- default:user::rwx default:user:t_ftsadm:rwx default:group::rwx default:group:t_ftsadm:rwx default:mask:rwx default:other:--- $ getfacl info.log # file: info.log # owner: blankt # group: itopbs user::rw- user:t_ftsadm:rwx #effective:rw- group::rwx #effective:rw- group:t_ftsadm:rwx #effective:rw- mask:rw- other:--- As you can see, t_ftsadm is the owner of the directory, I am owner of info.log. Both users have full permissions on them. By the way, user blankt is a member of group t_ftsadm. I use the following script to gzip the file info.log: $ cat gzip.pl #!/usr/local/bin/perl use strict; use filetest 'access'; use IO::Compress::Gzip qw(gzip $GzipError) ; my $input = "./info.log"; my $output = "./info.log.gz"; my $status = gzip $input => $output, AutoClose => 1, BinModeIn => 1 or die "gzip failed: $GzipError\n"; If I execute this, I get the following error: $ ./gzip.pl gzip failed: cannot open file './info.log': As expected, no gz file is there: $ ll total 4 -rwxr-x---+ 1 t_ftsadm t_ftsadm 273 Apr 30 11:29 gzip.pl -rw-rw----+ 1 blankt itopbs 2806 Apr 30 10:08 info.log Nothing more to see with truss: [...] 3033: stat64("./info.log", 0x00123920) = 0 3033: stat64("./info.log", 0x00123920) = 0 3033: getgroups(0, 0x00000000) = 3 3033: getgroups(3, 0x003066B8) = 3 3033: fstat64(2, 0xFFBFF310) = 0 gzip failed: cannot open file './info.log': 3033: write(2, " g z i p f a i l e d :".., 45) = 45 [...] I already know this problem with ACLs, therefore I use "use filetest 'access'" which normally solves this issue. But not in this case. But if I add this pragma to the beginning of IO/Compress/Base/Common.pm, it works: # head /usr/local/lib/perl5/site_perl/5.8.8/IO/Compress/Base/Common.pm package IO::Compress::Base::Common; use strict ; use warnings; use bytes; use Carp; use Scalar::Util qw(blessed readonly); use File::GlobMapper; use filetest 'access'; require Exporter; [...] Executing gzip.pl again, it works as expected: $ ./gzip.pl $ ll total 5 -rwxr-x---+ 1 t_ftsadm t_ftsadm 273 Apr 30 11:29 gzip.pl -rw-rw----+ 1 blankt itopbs 2806 Apr 30 10:08 info.log -rw-rw----+ 1 t_ftsadm t_ftsadm 358 Apr 30 11:44 info.log.gz So please add the pragma "use filetest 'access'" to IO::Compress::Base, maybe more modules are affected. My system: SunOS strsun11a 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Fire-V240 Solaris Perl version: This is perl, v5.8.8 built for sun4-solaris Module version: IO::Compress::Base 2.004
Hi Thomas, Sorry for not getting back to you sooner. I'm not keen on adding "use filetest 'access'" to my code - I want it to work on versions of perl that don't have the filetest pragma available. Here is a workaround #!/usr/local/bin/perl use strict; use IO::Compress::Gzip qw($GzipError) ; sub gzip { use filetest 'access'; my $inFile = shift; my $outFile = shift; my $in = new IO::File "<$inFile" or die "Cannot open input file '$inFile': $!\n"; my $out = new IO::File ">$outFile" or die "Cannot open output file '$outFile': $!\n"; IO::Compress::Gzip::gzip $in, $out, @_; } my $input = "./info.log"; my $output = "./info.log.gz"; my $status = gzip $input => $output, AutoClose => 1, BinModeIn => 1 or die "gzip failed: $GzipError\n"; Paul
Subject: AW: [rt.cpan.org #26821] Errors if using POSIX ACLs
Date: Fri, 11 May 2007 11:00:41 +0200
To: bug-IO-Compress-Base [...] rt.cpan.org
From: Thomas Blank <Thomas.Blank [...] de.debitel.com>
Hi Paul Show quoted text
> I'm not keen on adding "use filetest 'access'" to my code - I want it > to work on versions of perl that don't have the filetest pragma > available. >
Sure, I understand this. If the hardcoded variant is not the way you want, think about adding eval "require filetest" or something like this. The workaround works fine, if using gzip and zip with a single input file. I currently use zip with single AND multiple input files, where $input is an array reference. Your workaround fails there. How would you handle this? Thanks, Thomas --------------------------------------------------------------------------------- debitel AG Gropiusplatz 10 70545 Stuttgart Sitz und Registergericht Stuttgart, HRB Nr. 19 835 Vorsitz Aufsichtsrat: Dr. Hellmut K. Albrecht Vorstand: Axel Rückert (Vorsitzender) Joachim Preisig, Oliver Steil ---------------------------------------------------------------------------------
From: PMQS [...] cpan.org
On Fri May 11 05:02:53 2007, thomas.blank@de.debitel.com wrote: Show quoted text
> Hi Paul
Hi Thomas Show quoted text
> > I'm not keen on adding "use filetest 'access'" to my code - I want
> it
> > to work on versions of perl that don't have the filetest pragma > > available. > >
> Sure, I understand this. If the hardcoded variant is not the way you > want, > think about adding > eval "require filetest" > or something like this.
That is certainly a possibility, but I'd rather not have the pragma included at all unless it is really needed - like in your ACL use-case. There is a performance penalty to be paid for using the pragma - I don't want everyone to take the hit unnecessarily. If I did do something it would probably be to make it an install-time option. So you would have to explicitly enable the code to be installed with the filetest pragma included. I do something similar to allow my code to be installed on perl's that don't have the warnings pragma. Just to guage the size of this issue, have you tripped over any other modules that need the same treatement? If this is a big enough problem, the fix should be to get perl to support the equivalent of a global "use filetest" option. Then your problem goes away. Show quoted text
> The workaround works fine, if using gzip and zip with a single input > file. > I currently use zip with single AND multiple input files, where $input > is > an array reference. Your workaround fails there. > How would you handle this?
Something like this (which is untested) sub gzip { use filetest 'access'; my $inFile = shift; my $outFile = shift; my $in; if (ref $inFile && ref InFile eq 'ARRAY') { my @in ; $in = \@in; for (@$inFile) { my $i = new IO::File "<$_" ; or die "Cannot open input file '$_': $!\n"; push @in, $i; } } else { $in = new IO::File "<$inFile" ; or die "Cannot open input file '$inFile': $!\n"; } my $out = new IO::File ">$outFile" or die "Cannot open output file '$outFile': $!\n"; IO::Compress::Gzip::gzip $in, $out, @_; } Paul
From: thomas.blank [...] de.debitel.com
On Di. 15. Mai 2007, 04:22:20, PMQS wrote: Show quoted text
> Hi Thomas >
Hi Paul Show quoted text
> That is certainly a possibility, but I'd rather not have the pragma > included at all unless it is really needed - like in your ACL use-case. > There is a performance penalty to be paid for using the pragma - I > don't want everyone to take the hit unnecessarily. > > If I did do something it would probably be to make it an install-time > option. So you would have to explicitly enable the code to be installed > with the filetest pragma included. I do something similar to allow my > code to be installed on perl's that don't have the warnings pragma. >
Enabling this option at install time would be an option. You could also provide a function or parameter to enable it explicitly at runtime, the call would look like this: my $status = gzip $input => $output, AutoClose => 1, BinModeIn => 1, FiletestAccess => 1 or die "gzip failed: $GzipError\n"; Param FiletestAccess calls eval "require filetest" and croaks/dies/warns if module is not installed. What do you think about this? Show quoted text
> Just to guage the size of this issue, have you tripped over any other > modules that need the same treatement? If this is a big enough problem, > the fix should be to get perl to support the equivalent of a > global "use filetest" option. Then your problem goes away. >
Some modules are not POSIX-ACL aware, but the number is too small. Sure, enabling it globally (you suppose, by install time?) is possible. Show quoted text
> Something like this (which is untested) > > sub gzip > { > use filetest 'access'; > > my $inFile = shift; > my $outFile = shift; > > my $in; > > if (ref $inFile && ref InFile eq 'ARRAY') > { > my @in ; > $in = \@in; > for (@$inFile) > { > my $i = new IO::File "<$_" ; > or die "Cannot open input file '$_': $!\n"; > push @in, $i; > } > } > else > { > $in = new IO::File "<$inFile" ; > or die "Cannot open input file '$inFile': $!\n"; > } > > my $out = new IO::File ">$outFile" > or die "Cannot open output file '$outFile': $!\n"; > > IO::Compress::Gzip::gzip $in, $out, @_; > } >
Your workaround looks fine, I'll test this. Thanks, Thomas
... Show quoted text
> Enabling this option at install time would be an option. You could
also Show quoted text
> provide a function or parameter to enable it explicitly at runtime,
the Show quoted text
> call would look like this: > my $status = gzip $input => $output, AutoClose => 1, BinModeIn => 1, > FiletestAccess => 1 > or die "gzip failed: $GzipError\n"; > Param FiletestAccess calls eval "require filetest" and
croaks/dies/warns Show quoted text
> if module is not installed. > What do you think about this?
Sorry, the filetest pragma has to be invoked at compile time. Eval'ing it at runtime won't work. Show quoted text
> > Just to guage the size of this issue, have you tripped over any
other Show quoted text
> > modules that need the same treatement? If this is a big enough
problem, Show quoted text
> > the fix should be to get perl to support the equivalent of a > > global "use filetest" option. Then your problem goes away. > >
> Some modules are not POSIX-ACL aware, but the number is too small. > Sure, enabling it globally (you suppose, by install time?) is
possible. I guess any module that uses the filtest operators is a potential problem. Paul
From: thomas.blank [...] de.debitel.com
On Di. 15. Mai 2007, 10:49:51, PMQS wrote: Show quoted text
> Sorry, the filetest pragma has to be invoked at compile time. Eval'ing > it at runtime won't work. >
Are you sure? So, if you think, enabling filetest at install-time is the best option, then please implement it. Or what will you do now?
From: PMQS [...] cpan.org
On Wed May 16 04:40:14 2007, thomas.blank@de.debitel.com wrote: Show quoted text
> On Di. 15. Mai 2007, 10:49:51, PMQS wrote:
> > Sorry, the filetest pragma has to be invoked at compile time.
Eval'ing Show quoted text
> > it at runtime won't work. > >
> Are you sure?
Yep - the magic is done in the filetest::import method. It passes hints to the compiler. Show quoted text
> So, if you think, enabling filetest at install-time is the best
option, Show quoted text
> then please implement it. Or what will you do now?
I'd prefer this to be dealt with in the core perl code itself, but I need to have a think about the best way to achieve that. Possibilities are either with a variant of the existing filetest pragma (but the scope is global rather than lexical), or with perl compile-time option. If that comes to nothing I'll consider adding it as an install-time option for my module. Paul
Resolved in IO-Compress 2.057 vai a fix for RT #80855