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

23.7.x find commands permission error #13086

Merged

Conversation

kenodegard
Copy link
Contributor

Description

While we check whether a path is a directory we don't also check whether the user has read access resulting in PermissionError if any paths are restricted.

Resolves #13058

Target 23.7.x instead of main, supersedes #13062

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

conda/cli/find_commands.py Outdated Show resolved Hide resolved
dholth
dholth previously approved these changes Sep 11, 2023
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Sep 11, 2023
@kenodegard kenodegard merged commit ec90105 into conda:23.7.x Sep 11, 2023
60 of 67 checks passed
@kenodegard kenodegard deleted the 23.7.x-find-commands-permission-error branch September 11, 2023 19:31
try:
for entry in os.scandir(dir_path):
m = pat.match(entry.name)
if m and entry.is_file():
res.add(m.group(1))
except PermissionError:
except (FileNotFoundError, PermissionError):
Copy link
Contributor

@dholth dholth Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A call to os.scandir('conda.py') produces NotADirectoryError which is a subclass of OsError. Should be added to this except: clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this locally:

$ python -c "import os; os.scandir('yellow')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'yellow'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an existing file to PATH.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh

@kenodegard kenodegard mentioned this pull request Sep 11, 2023
3 tasks
@kenodegard kenodegard linked an issue Sep 12, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

conda fails if PATH contains unreadable directories
4 participants