From 1f2fc65f6336e0983f349301797ffcca0424a7ae Mon Sep 17 00:00:00 2001 From: tfolbrecht Date: Sun, 28 Jul 2019 09:29:05 -0400 Subject: [PATCH 1/4] If statement check path owner on option paths --- src/pip/_internal/commands/install.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index b18bbd45172..60112b74a40 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -240,6 +240,28 @@ def __init__(self, *args, **kw): self.parser.insert_option_group(0, cmd_opts) def run(self, options, args): + if options.target_dir != None and not check_path_owner(options.target_dir): + logger.error( + "The user that ran pip install doesn't have write access " + "to target directory '%s'", + options.target_dir, + ) + return ERROR + if options.prefix_path != None and not check_path_owner(options.prefix_path): + logger.error( + "The user that ran pip install doesn't have write access " + "to target prefix directory '%s'", + options.prefix_path, + ) + return ERROR + if options.root_path != None and not check_path_owner(options.root_path): + logger.error( + "The user that ran pip install doesn't have write access " + "to target root directory '%s'", + options.root_path, + ) + return ERROR + cmdoptions.check_install_build_global(options) upgrade_strategy = "to-satisfy-only" if options.upgrade: From 32b116ab6ae08575f03fa15ee8a8651134207e56 Mon Sep 17 00:00:00 2001 From: tfolbrecht Date: Sun, 28 Jul 2019 09:41:48 -0400 Subject: [PATCH 2/4] add news file .buxfix --- news/6762.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/6762.bugfix diff --git a/news/6762.bugfix b/news/6762.bugfix new file mode 100644 index 00000000000..174c94bd6ba --- /dev/null +++ b/news/6762.bugfix @@ -0,0 +1 @@ +Fail without collecting and downloading packages if user doesn't have write permissions. \ No newline at end of file From 0e1c2a81aba476f4e0a6a1cda0d11b1e232fde95 Mon Sep 17 00:00:00 2001 From: tfolbrecht Date: Sun, 28 Jul 2019 10:51:36 -0400 Subject: [PATCH 3/4] != to not --- src/pip/_internal/commands/install.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index 60112b74a40..c99f5c40d3f 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -240,28 +240,28 @@ def __init__(self, *args, **kw): self.parser.insert_option_group(0, cmd_opts) def run(self, options, args): - if options.target_dir != None and not check_path_owner(options.target_dir): + if options.target_dir not None and not check_path_owner(options.target_dir): logger.error( "The user that ran pip install doesn't have write access " "to target directory '%s'", options.target_dir, ) return ERROR - if options.prefix_path != None and not check_path_owner(options.prefix_path): + if options.prefix_path not None and not check_path_owner(options.prefix_path): logger.error( "The user that ran pip install doesn't have write access " "to target prefix directory '%s'", options.prefix_path, ) return ERROR - if options.root_path != None and not check_path_owner(options.root_path): + if options.root_path not None and not check_path_owner(options.root_path): logger.error( "The user that ran pip install doesn't have write access " "to target root directory '%s'", options.root_path, ) return ERROR - + cmdoptions.check_install_build_global(options) upgrade_strategy = "to-satisfy-only" if options.upgrade: From 809118ae2ae3bd3eceecb1f80a391c84284098b8 Mon Sep 17 00:00:00 2001 From: tfolbrecht Date: Sun, 28 Jul 2019 11:15:17 -0400 Subject: [PATCH 4/4] lint-py2 & 3 compliant --- src/pip/_internal/commands/install.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index c99f5c40d3f..2833b39f8ab 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -240,21 +240,24 @@ def __init__(self, *args, **kw): self.parser.insert_option_group(0, cmd_opts) def run(self, options, args): - if options.target_dir not None and not check_path_owner(options.target_dir): + if (options.target_dir is not None and not + check_path_owner(options.target_dir)): logger.error( "The user that ran pip install doesn't have write access " "to target directory '%s'", options.target_dir, ) return ERROR - if options.prefix_path not None and not check_path_owner(options.prefix_path): + if (options.prefix_path is not None and not + check_path_owner(options.prefix_path)): logger.error( "The user that ran pip install doesn't have write access " "to target prefix directory '%s'", options.prefix_path, ) return ERROR - if options.root_path not None and not check_path_owner(options.root_path): + if (options.root_path is not None and not + check_path_owner(options.root_path)): logger.error( "The user that ran pip install doesn't have write access " "to target root directory '%s'",