diff options
author | Shubham Saini <shubham6405@gmail.com> | 2018-12-11 10:01:23 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2018-12-11 10:01:23 +0000 |
commit | 68df54d6629ec019142eb149dd037774f2d11e7c (patch) | |
tree | 345bc22d46b4e01a4ba8303b94278952a4ed2b9e /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/filesystem.py |
First commit
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) | ||