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

Does filetest work at all?

Thread Next
Slaven Rezic
May 1, 2003 08:56
Does filetest work at all?
Message ID:
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?


Slaven Rezic -
  BBBike - route planner for cyclists in Berlin
  WWW version:                 
  Perl/Tk version for Unix and Windows:

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About