#31912: Path.resolve(strict=True) raises PermissionError.
-------------------------------------+-------------------------------------
Reporter: leonyxz | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Core (Other) | Version: 3.1
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jakub SzafraĆski):
This issue is still present in `utils/autoreload.py` and can cause Django
to fail with the following traceback:
{{{
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/__init__.py", line 401, in
execute_from_command_line
utility.execute()
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/commands/runserver.py", line 60, in
execute
super().execute(*args, **options)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 584, in start_django
reloader.run(django_main_thread)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 299, in run
self.run_loop()
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 305, in run_loop
next(ticker)
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 345, in tick
for filepath, mtime in self.snapshot_files():
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 361, in snapshot_files
for file in self.watched_files():
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 260, in watched_files
yield from iter_all_python_module_files()
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 105, in
iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "/usr/home/XXX/.virtualenvs/go/lib/python3.8/site-
packages/django/utils/autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "/usr/local/lib/python3.8/pathlib.py", line 1180, in resolve
s = self._flavour.resolve(self, strict=strict)
File "/usr/local/lib/python3.8/pathlib.py", line 362, in resolve
return _resolve(base, str(path)) or sep
File "/usr/local/lib/python3.8/pathlib.py", line 346, in _resolve
target = accessor.readlink(newpath)
File "/usr/local/lib/python3.8/pathlib.py", line 451, in readlink
return os.readlink(path)
PermissionError: [Errno 13] Permission denied: '/usr'
}}}
Just to explain a little, this configuration is pretty common in shared-
system environments - it is intentional and prevents users from
enumerating local users on the system and accessing their home directories
in case of miss-configured permissions.
--
Ticket URL: <https://code.djangoproject.com/ticket/31912#comment:15>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.7819be4f21e4ea87ccf87ad187ceb7c3%40djangoproject.com.