Bug 1650327

Summary: pip can corrupt system packages
Product: Red Hat Enterprise Linux 8 Reporter: Carl George <carl>
Component: python-pipAssignee: Python Maintainers <python-maint>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: cstratak, cww, hhorak, jamills, jkejda, jwboyer, kwalker, mhroncok, pviktori, torsava
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-26 15:58:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1626408    
Bug Blocks: 1623566    

Description Carl George 2018-11-15 21:01:50 UTC
Description of problem:

Interacting with the RHEL 8 Beta, I noticed that it appears to include this Fedora change.

https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe

However, it is still possible to corrupt system packages running pip as root.  Upgrading a python module that is owned by a system package installs the new version in `/usr/local/lib/python3.6/site-packages` as desired, but removes the files in `/usr/lib/python3.6/site-packages`, which corrupts the system package.

    [root@el8 ~]# /usr/libexec/platform-python -c 'import setuptools; print(setuptools.version.__version__)'
    39.2.0
    [root@el8 ~]# rpm -V python3-setuptools | grep -c missing
    0
    [root@el8 ~]# pip3.6 install -U setuptools &> /dev/null
    [root@el8 ~]# /usr/libexec/platform-python -c 'import setuptools; print(setuptools.version.__version__)'
    40.6.2
    [root@el8 ~]# rpm -V python3-setuptools | grep -c missing
    182

This same behavior can be observed in Fedora 28.

    [root@f28 ~]# python3 -c 'import setuptools; print(setuptools.version.__version__)'
    39.2.0
    [root@f28 ~]# rpm -V python3-setuptools | grep -c missing
    0
    [root@f28 ~]# pip3.6 install -U setuptools &> /dev/null
    [root@f28 ~]# python3 -c 'import setuptools; print(setuptools.version.__version__)'
    40.6.2
    [root@f28 ~]# rpm -V python3-setuptools | grep -c missing
    182

Something changed between Fedora 28 and 29, because it does the right thing now.

    [root@f29 ~]# python3 -c 'import setuptools; print(setuptools.version.__version__)'
    40.4.3
    [root@f29 ~]# rpm -V python3-setuptools | grep -c missing
    0
    [root@f29 ~]# pip3.7 install -U setuptools &> /dev/null
    [root@f29 ~]# python3 -c 'import setuptools; print(setuptools.version.__version__)'
    40.6.2
    [root@f29 ~]# rpm -V python3-setuptools | grep -c missing
    0

Please track down this change from F28->F29 and backport it to EL8.


Version-Release number of selected component (if applicable):
python3-pip-9.0.3-4.el8.noarch


Steps to Reproduce:
1. pip3.6 install -U setuptools
2. rpm -V python3-setuptools


Actual results:
Corrupt system package, files missing from `/usr/lib/python3.6/site-packages`.


Expected results:
Files from system package left alone.

Comment 1 Miro HronĨok 2018-11-15 23:00:03 UTC
The change is in https://src.fedoraproject.org/rpms/python-pip/pull-request/16

I'm still unsure whether to apply it to Fedora 28 or not, as it changes pip's behavior and hence is not backwards compatible.

As for RHEL8, I'm unsure whether I can disclose any plans or information, however rest assured that we are aware of the issue.

Comment 2 Petr Viktorin (pviktori) 2018-11-16 11:40:44 UTC
Also note that `sudo pip install` translates to "download stuff from the Internet and run it on my machine, as root".

We can be better at limiting the damage (and, with no promises, it might be one of the things to look into after Beta). But the baseline assumption here needs to be that `sudo pip` *will* break your system. It's not something Red Hat can fully support.

Please use venv if you can.
(See "Third-party packages" in https://developers.redhat.com/blog/2018/11/14/python-in-rhel-8/ )

Comment 4 Carl George 2018-11-16 15:44:41 UTC
I know that.  I'm not requesting this for myself.  I'm asking because in the real world people do this.  It breaks systems and eventually ends up wasting the time of people that know better who get called on to fix it.

If RHEL8 is going to include the "Making sudo pip safe" change, it might as well be the complete solution, not just a partial solution that leads people into a false sense of safety.

Comment 13 Carl George 2019-08-26 16:21:56 UTC
Closing a public bug as a duplicate of a private bug is frustrating.  Can I please be added as a CC on bug 1626408 so I can view it?

Comment 14 Petr Viktorin (pviktori) 2019-08-27 09:03:04 UTC
Sorry for that!
I've made bug 1626408 public instead.

Comment 15 Carl George 2019-08-27 19:58:17 UTC
Thanks for making the other bug public Petr.  I can confirm this is fixed in python3-pip-9.0.3-13.el8.noarch in ubi8.