diff options
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/filesystem.py')
| -rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/filesystem.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/filesystem.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/filesystem.py new file mode 100644 index 0000000..94fa2c6 --- /dev/null +++ b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/filesystem.py | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | import os | ||
| 2 | import os.path | ||
| 3 | |||
| 4 | from pip._internal.compat import get_path_uid | ||
| 5 | |||
| 6 | |||
| 7 | def check_path_owner(path): | ||
| 8 | # If we don't have a way to check the effective uid of this process, then | ||
| 9 | # we'll just assume that we own the directory. | ||
| 10 | if not hasattr(os, "geteuid"): | ||
| 11 | return True | ||
| 12 | |||
| 13 | previous = None | ||
| 14 | while path != previous: | ||
| 15 | if os.path.lexists(path): | ||
| 16 | # Check if path is writable by current user. | ||
| 17 | if os.geteuid() == 0: | ||
| 18 | # Special handling for root user in order to handle properly | ||
| 19 | # cases where users use sudo without -H flag. | ||
| 20 | try: | ||
| 21 | path_uid = get_path_uid(path) | ||
| 22 | except OSError: | ||
| 23 | return False | ||
| 24 | return path_uid == 0 | ||
| 25 | else: | ||
| 26 | return os.access(path, os.W_OK) | ||
| 27 | else: | ||
| 28 | previous, path = path, os.path.dirname(path) | ||
