Added patch: Emit a warning when running with root privileges

This commit is contained in:
Tomas Orsava 2017-02-16 11:48:01 +01:00
parent 71bf5a7601
commit 3d0a78651f
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From 5023ea0feceb5a9cc4931f6be9404d4582cb8502 Mon Sep 17 00:00:00 2001
From: Tomas Orsava <torsava@redhat.com>
Date: Tue, 14 Feb 2017 17:10:09 +0100
Subject: [PATCH] Emit a warning when running with root privileges
---
pip/commands/install.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pip/commands/install.py b/pip/commands/install.py
index b7e662bd..c1bcf3b5 100644
--- a/pip/commands/install.py
+++ b/pip/commands/install.py
@@ -192,6 +192,13 @@ class InstallCommand(RequirementCommand):
cmdoptions.resolve_wheel_no_use_binary(options)
cmdoptions.check_install_build_global(options)
+ # Check whether we have root privileges
+ if os.getuid() == 0:
+ logger.warning(
+ "WARNING: Running pip install with root privileges is "
+ "generally not advised. Try `pip install --user` instead."
+ )
+
if options.as_egg:
warnings.warn(
"--egg has been deprecated and will be removed in the future. "
--
2.11.0

View File

@ -17,7 +17,7 @@
Name: python-%{srcname}
Version: 9.0.1
Release: 5%{?dist}
Release: 6%{?dist}
Summary: A tool for installing and managing Python packages
Group: Development/Libraries
@ -38,6 +38,11 @@ Source1: pip-9.0.1-tests.tar.gz
# https://github.com/pypa/pip/issues/1351
Patch0: allow-stripping-given-prefix-from-wheel-RECORD-files.patch
# Downstream only patch
# Emit a warning to the user if pip install is run with root privileges
# Issue upstream: https://github.com/pypa/pip/issues/4288
Patch1: emit-a-warning-when-running-with-root-privileges.patch
%description
Pip is a replacement for `easy_install
<http://peak.telecommunity.com/DevCenter/EasyInstall>`_. It uses mostly the
@ -114,6 +119,7 @@ tar -xf %{SOURCE1}
%endif
%patch0 -p1
%patch1 -p1
sed -i '1d' pip/__init__.py
@ -238,6 +244,9 @@ py.test-%{python3_version} -m 'not network'
%endif # with_python3
%changelog
* Tue Feb 14 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-6
- Added patch 1: Emit a warning when running with root privileges
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 9.0.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild