Front page | perl.perl5.porters |
Postings from September 2000
[ID 20000906.002] -T and -B invalidate _ filehandle when no readpermission on file
From:
Martien Verbruggen
Date:
September 6, 2000 04:27
Subject:
[ID 20000906.002] -T and -B invalidate _ filehandle when no readpermission on file
Message ID:
200009061130.WAA13801@martien.heliotrope.home
This is a bug report for perl from mgjv@tradingpost.com.au
generated with the help of perlbug 1.28 running under perl v5.6.0.
-----------------------------------------------------------------
[Please enter your report here]
When using -T or -B one needs read permission on the file. This is fine.
However, when the -B or -T operators are used to inspect the _ file
handle, and the file opened there does not allow read, the whole file
handle gets unusable, even for information which is perfectly available
and safe to obtain (via stat)
To reproduce:
#!/usr/local/bin/perl -w
$file = 'gobble';
open(F, ">$file") or die $!;
print F "gobble\n";
close F;
chmod 0777, $file or die $!;
@a = stat($file);
printf "@a\n%d %d %d\n", -s _, -T _, -s _;
chmod 0077, $file or die $!;
@a = stat($file);
printf "@a\n%d %d %d\n", -s _, -T _, -s _;
chmod 0777, $file;
unlink $file;
OUTPUT:
769 191765 33279 1 500 100 41660 7 968239612 968239612 968239612 4096 8
7 1 7
Use of uninitialized value in printf at ./foo.pl line 15.
Use of uninitialized value in printf at ./foo.pl line 15.
769 191765 32831 1 500 100 41660 7 968239612 968239612 968239612 4096 8
7 0 0
I believe that this is misbehaviour, and should be fixed in a future
version of Perl. -T and -B are exceptions in the list of -X operators,
and should be treated that way. Documenting the behaviour shown above,
only to allow this misbehaviour to continue should be considered evil. I
can't imagine anyone's programs breaking if this gets fixed, but it will
fix the correctness of the operator set and the _ filehandle.
Of course, in any case, the documentaiton of the list of -X operators
needs to be adapted to reflect that -B and -T are the only ones that
require read access to the file itself.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl v5.6.0:
Configured by mgjv at Sat Mar 25 17:48:49 EST 2000.
Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
Platform:
osname=linux, osvers=2.2.12-20, archname=i686-linux
uname='linux martien 2.2.12-20 #1 mon sep 27 10:40:35 edt 1999 i686 unknown '
config_args='-des -Dprefix=/opt/perl'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define
use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
Compiler:
cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
stdchar='char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=/lib/libc-2.1.2.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.6.0:
/opt/perl/lib/5.6.0/i686-linux
/opt/perl/lib/5.6.0
/opt/perl/lib/site_perl/5.6.0/i686-linux
/opt/perl/lib/site_perl/5.6.0
/opt/perl/lib/site_perl/5.005/i686-linux
/opt/perl/lib/site_perl/5.005
/opt/perl/lib/site_perl
.
---
Environment for perl v5.6.0:
HOME=/home/mgjv
LANG=en_US
LANGUAGE (unset)
LD_LIBRARY_PATH=/opt/pgplot:/opt/postgresql/lib:/opt/gimp/lib
LOGDIR (unset)
PATH=/home/mgjv/bin:/opt/teTeX/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/openwin/bin:/usr/openwin/demo:/opt/samba/bin:/usr/local/ssl/bin:/opt/perl/bin:/opt/ImageMagick/bin:/opt/java/bin:/opt/mysql/bin:/opt/postgresql/bin:/opt/gimp/bin
PERL_BADLANG (unset)
SHELL=/bin/tcsh
-
[ID 20000906.002] -T and -B invalidate _ filehandle when no readpermission on file
by Martien Verbruggen