Index: library/package.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/package.tcl,v
retrieving revision 1.23.2.4
diff -u -r1.23.2.4 package.tcl
--- library/package.tcl	22 Sep 2006 01:26:24 -0000	1.23.2.4
+++ library/package.tcl	27 Jun 2008 16:40:01 -0000
@@ -502,8 +502,14 @@
 	    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 @@
 	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 @@
 # 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 @@
 	    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 @@
 	    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
