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

Does filetest work at all?

Thread Next
From:
Slaven Rezic
Date:
May 1, 2003 08:56
Subject:
Does filetest work at all?
Message ID:
200305011540.h41FeVuq004669@vran.herceg.de
If I try use filetest as advertised,

	use filetest 'access';
	my $x = -x "/COPYRIGHT";
	
truss reports on FreeBSD 4.6 with perl 5.8.0:

	...
	fcntl(0x3,0x2,0x1)                               = 0 (0x0)
	stat("/COPYRIGHT",0x8119240)                     = 0 (0x0)
	getgroups(0x10,0xbfbff0f0)                       = 12 (0xc)
	...
	
that is, access() is not used at all.

However, if I set the hints on runtime:

	require filetest;
	$^H |= $filetest::hint_bits;
	my $x = -x "/COPYRIGHT";

truss reports that access() is actually used (meaning FreeBSD has and
can access()):

	...
	getuid()                                         = 1000 (0x3e8)
	geteuid()                                        = 1000 (0x3e8)
	getgid()                                         = 1000 (0x3e8)
	getegid()                                        = 1000 (0x3e8)
	setreuid(0x3e8,0x3e8)                            = 0 (0x0)
	setregid(0x3e8,0x3e8)                            = 0 (0x0)
	access("/COPYRIGHT",1)                           ERR#13 'Permission denied'
	setreuid(0x3e8,0x3e8)                            = 0 (0x0)
	setregid(0x3e8,0x3e8)                            = 0 (0x0)
	...

Looking at the source code in pp_sys.c I see the condition

    if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {

I think this cannot work because PL_hints is a compile time only thing
and therefore cannot be used here. Or is there a thinko?

Regards,
	Slaven

-- 
Slaven Rezic - slaven@rezic.de
  BBBike - route planner for cyclists in Berlin
  WWW version:                           http://www.bbbike.de
  Perl/Tk version for Unix and Windows:  http://bbbike.sourceforge.net

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