summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2008-07-03 17:15:13 (GMT)
committerdgp <dgp@users.sourceforge.net>2008-07-03 17:15:13 (GMT)
commit249cb51f56621900b972cbbc766b6a4afe7a5331 (patch)
tree06ad8aa1662e74b408c8a01671036a6229b9e3a5
parent0c008d2ecb5decdf18c0e0b56d59b960d158f6b9 (diff)
downloadtcl-249cb51f56621900b972cbbc766b6a4afe7a5331.zip
tcl-249cb51f56621900b972cbbc766b6a4afe7a5331.tar.gz
tcl-249cb51f56621900b972cbbc766b6a4afe7a5331.tar.bz2
* library/package.tcl: Removed [file readable] testing from
[tclPkgUnknown] and friends. We find out soon enough whether a file is readable when we try to [source] it, and not testing before allows us to workaround the bugs on some common filesystems where [file readable] lies to us. [Patch 1969717]
-rw-r--r--ChangeLog8
-rw-r--r--library/package.tcl47
2 files changed, 42 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index bc040fc..8907760 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-03 Don Porter <dgp@users.sourceforge.net>
+
+ * library/package.tcl: Removed [file readable] testing from
+ [tclPkgUnknown] and friends. We find out soon enough whether a
+ file is readable when we try to [source] it, and not testing
+ before allows us to workaround the bugs on some common filesystems
+ where [file readable] lies to us. [Patch 1969717]
+
2008-06-28 Don Porter <dgp@users.sourceforge.net>
* generic/tclIOUtil.c: Plug memory leak in latest commit. Thanks
diff --git a/library/package.tcl b/library/package.tcl
index 04145dd..8912769 100644
--- a/library/package.tcl
+++ b/library/package.tcl
@@ -3,7 +3,7 @@
# utility procs formerly in init.tcl which can be loaded on demand
# for package management.
#
-# RCS: @(#) $Id: package.tcl,v 1.23.2.4 2006/09/22 01:26:24 andreas_kupries Exp $
+# RCS: @(#) $Id: package.tcl,v 1.23.2.5 2008/07/03 17:15:14 dgp Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
@@ -502,8 +502,14 @@ proc tclPkgUnknown [expr {
foreach file [glob -directory $dir -join -nocomplain \
* pkgIndex.tcl] {
set dir [file dirname $file]
- if {![info exists procdDirs($dir)] && [file readable $file]} {
- if {[catch {source $file} msg]} {
+ if {![info exists procdDirs($dir)]} {
+ set code [catch {source $file} msg]
+ if {$code == 1 && [lindex $::errorCode 0] eq "POSIX"
+ && [lindex $::errorCode 1] eq "EACCES"} {
+ # $file was not readable; silently ignore
+ continue
+ }
+ if {$code} {
tclLog "error reading package index file $file: $msg"
} else {
set procdDirs($dir) 1
@@ -514,10 +520,15 @@ proc tclPkgUnknown [expr {
set dir [lindex $use_path end]
if {![info exists procdDirs($dir)]} {
set file [file join $dir pkgIndex.tcl]
- # safe interps usually don't have "file readable",
- # nor stderr channel
- if {([interp issafe] || [file readable $file])} {
- if {[catch {source $file} msg] && ![interp issafe]} {
+ # safe interps usually don't have "file exists",
+ if {([interp issafe] || [file exists $file])} {
+ set code [catch {source $file} msg]
+ if {$code == 1 && [lindex $::errorCode 0] eq "POSIX"
+ && [lindex $::errorCode 1] eq "EACCES"} {
+ # $file was not readable; silently ignore
+ continue
+ }
+ if {$code} {
tclLog "error reading package index file $file: $msg"
} else {
set procdDirs($dir) 1
@@ -563,8 +574,6 @@ proc tclPkgUnknown [expr {
# This procedure extends the "package unknown" function for MacOSX.
# It scans the Resources/Scripts directories of the immediate children
# of the auto_path directories for pkgIndex files.
-# Only installed in interps that are not safe so we don't check
-# for [interp issafe] as in tclPkgUnknown.
#
# Arguments:
# original - original [package unknown] procedure
@@ -596,8 +605,14 @@ if {[info exists tcl_platform(tip,268)]} {
foreach file [glob -directory $dir -join -nocomplain \
* Resources Scripts pkgIndex.tcl] {
set dir [file dirname $file]
- if {[file readable $file] && ![info exists procdDirs($dir)]} {
- if {[catch {source $file} msg]} {
+ if {![info exists procdDirs($dir)]} {
+ set code [catch {source $file} msg]
+ if {$code == 1 && [lindex $::errorCode 0] eq "POSIX"
+ && [lindex $::errorCode 1] eq "EACCES"} {
+ # $file was not readable; silently ignore
+ continue
+ }
+ if {$code} {
tclLog "error reading package index file $file: $msg"
} else {
set procdDirs($dir) 1
@@ -634,8 +649,14 @@ if {[info exists tcl_platform(tip,268)]} {
foreach file [glob -directory $dir -join -nocomplain \
* Resources Scripts pkgIndex.tcl] {
set dir [file dirname $file]
- if {[file readable $file] && ![info exists procdDirs($dir)]} {
- if {[catch {source $file} msg]} {
+ if {![info exists procdDirs($dir)]} {
+ set code [catch {source $file} msg]
+ if {$code == 1 && [lindex $::errorCode 0] eq "POSIX"
+ && [lindex $::errorCode 1] eq "EACCES"} {
+ # $file was not readable; silently ignore
+ continue
+ }
+ if {$code} {
tclLog "error reading package index file $file: $msg"
} else {
set procdDirs($dir) 1