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

Re: acl based fs support: -x et al supporting POSIX::access underneath

Thread Previous | Thread Next
From:
Slaven Rezic
Date:
May 1, 2003 08:57
Subject:
Re: acl based fs support: -x et al supporting POSIX::access underneath
Message ID:
878ytq4qi9.fsf@vran.herceg.de
Slaven Rezic <slaven@rezic.de> writes:

> Stas Bekman <stas@stason.org> writes:
> 
> > Mark Mielke wrote:
> > > On Mon, Apr 28, 2003 at 01:07:59PM -0400, Benjamin K. Stuhl wrote:
> > > 
> > >>On Sun, 2003-04-27 at 19:56, Stas Bekman wrote:
> > >>
> > >>>Given that, doesn't it make sense to have perl's -x use the access() calls 
> > >>>internally where access() is supported. Also applications don't have to be 
> > >>>rewritten to replace -x with POSIX::access() to support acl-based fs.
> > >>
> > >>use filetest 'access';
> > >>>From the POD:
> > >>    This pragma tells the compiler to change the behaviour of the 
> > >>    filetest permissions operators, the "-r" "-w" "-x" "-R" "-W" "-X"
> > >>    (see perlfunc).
> > >>Note that this only works on filename tests (-X "foo"), not handles 
> > >>(-X FH).
> > >>Standard lexical scoping rules apply - this is _not_ program-wide.
> > > 
> > > 
> > > Sorry all. I missed this in the source:
> > > 
> > >     if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
> > > 
> > > Benjamin is correct. The behaviour I have been describing only happens if
> > > "use filetest 'access'" is in effect. Qualify all of my statements with
> > > this in mind as required. 
> > 
> > 
> > > Stas: Add this to the top of your module.
> > 
> > I can't just add it on the top of the module. mod_perl 1.xx has to support 
> > older perl5005xx versions. the filetest pragma was added in 5.6.0.
> > 
> > I suppose this will do:
> > 
> > BEGIN {
> >    if ( $] < 5.006 ) {
> >        $INC{"filetest.pm"} = __FILE__;
> >        *filetest::import = sub {};
> >    }
> > }
> > use filetest 'access';
> > 
> > ugly... is there a better way to use pragramata optionally when run under perl 
> > versions that have it. using explicit require/import trick won't work with 
> > pragmata.
> > 
> 
>     use if $] >= 5.006, filetest => 'access';
> 

Or a better test (if you don't have the correct perl version at hand):

    use if !!eval { require filetest }, filetest => 'access';

Regards,
	Slaven

-- 
Slaven Rezic - slaven@rezic.de

    tktimex - project time manager
    http://sourceforge.net/projects/ptktools/

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