Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glob gives up if it can't access a directory #1610

Closed
gopherbot opened this issue Mar 15, 2011 · 3 comments
Closed

Glob gives up if it can't access a directory #1610

gopherbot opened this issue Mar 15, 2011 · 3 comments

Comments

@gopherbot
Copy link
Contributor

by mikesech:

What steps will reproduce the problem?
1. Attempt to use filepath.Glob() with a pattern that will match directories the user
does not have permission to access. For example, "/proc/*/fd/*", which
includes protected directories about processes of other users.

What is the expected output?
Glob, as with the standard POSIX function and the Python implementation, should ignore
directories it cannot open and continue looking for files/directories that match the
pattern.

What do you see instead?
When Glob reaches a directory it lacks permissions to stat properly, it  does not
continue searching.

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g


Which operating system are you using?
Linux


Which revision are you using?  (hg identify)
c5c62aeb6267 tip

Please provide any additional information below.
The problem lies in match.go glob(). It is supposed to append additional matches to the
given matches []string. However, if the stat fails, the given directory cannot be
confirmed to be a directory (particularly because the user lacks permissions to treat it
as one), or Readdirnames fails, it returns nil, getting rid of the original matches
array. For my example pattern "/proc/*/fd/*", IsDirectory() returns false,
which causes the problem.

I've attached a patch which simply replaces the three instances of "return
nil" with "return matches".

Attachments:

  1. glob.patch (633 bytes)
@rsc
Copy link
Contributor

rsc commented Mar 15, 2011

Comment 1:

Thanks for the patch.  Could you please use the
standard code review process, described at
http://golang.org/doc/contribute.html ?
Thanks.
Russ.

@adg
Copy link
Contributor

adg commented Mar 21, 2011

Comment 2:

Also when you create the changelist, please add the line "Fixes issue #1610." (verbatim)
to the change description. That will associate the fix with this issue.
Thanks.

@robpike
Copy link
Contributor

robpike commented Apr 1, 2011

Comment 3:

This issue was closed by revision a78a25a.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants