Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python startup should not require passwd entry #54705

Closed
bbi5291 mannequin opened this issue Nov 22, 2010 · 50 comments
Closed

Python startup should not require passwd entry #54705

bbi5291 mannequin opened this issue Nov 22, 2010 · 50 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@bbi5291
Copy link
Mannequin

bbi5291 mannequin commented Nov 22, 2010

BPO 10496
Nosy @loewis, @birkenfeld, @arekm, @vstinner, @tiran, @tarekziade, @ned-deily, @merwok, @bitdancer, @IIIIllllIIIIllllIIIIllllIIIIllllIIIIll, @serhiy-storchaka, @matrixise, @seirl, @yan12125, @surajssd, @izbyshev, @Cinerar, @miss-islington, @pxinwr
PRs
  • bpo-10496 Runing Inside docker container from non root user raises KeyError #3403
  • bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error #10919
  • [3.7] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10924
  • [3.7] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10924
  • [3.7] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10924
  • [3.6] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10925
  • [3.6] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10925
  • [2.7] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10930
  • [2.7] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10930
  • [2.7] bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) #10930
  • bpo-10496: distutils check_environ() handles getpwuid() error #10931
  • bpo-10496: distutils check_environ() handles getpwuid() error #10931
  • bpo-10496: distutils check_environ() handles getpwuid() error #10931
  • [3.7] bpo-10496: distutils check_environ() handles getpwuid() error (GH-10931) #11212
  • [2.7] bpo-10496: distutils check_environ() handles getpwuid() error (GH-10931) #11213
  • bpo-31904: posixpath.expanduser() handles user home of None #23530
  • Files
  • bug.c
  • nonexistent_user.patch
  • user.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/merwok'
    closed_at = <Date 2018-12-18.16:37:38.410>
    created_at = <Date 2010-11-22.00:59:48.070>
    labels = ['3.7', 'tests', '3.8', 'type-bug', 'library']
    title = 'Python startup should not require passwd entry'
    updated_at = <Date 2020-12-17.20:40:51.564>
    user = 'https://bugs.python.org/bbi5291'

    bugs.python.org fields:

    activity = <Date 2020-12-17.20:40:51.564>
    actor = 'pxinwr'
    assignee = 'eric.araujo'
    closed = True
    closed_date = <Date 2018-12-18.16:37:38.410>
    closer = 'vstinner'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2010-11-22.00:59:48.070>
    creator = 'bbi5291'
    dependencies = []
    files = ['19760', '21896', '47211']
    hgrepos = []
    issue_num = 10496
    keywords = ['patch', 'needs review']
    message_count = 50.0
    messages = ['122086', '122272', '122640', '132771', '133626', '133674', '133675', '133676', '133742', '133743', '133830', '134984', '134987', '135044', '135047', '135195', '135551', '135592', '135596', '155530', '155534', '156373', '193987', '257513', '270771', '272115', '282502', '282503', '282504', '302176', '302355', '303943', '304128', '331100', '331103', '331108', '331115', '331123', '331125', '331127', '331128', '331129', '331133', '331135', '331136', '331163', '332065', '332067', '332070', '332071']
    nosy_count = 29.0
    nosy_names = ['loewis', 'georg.brandl', 'arekm', 'vstinner', 'christian.heimes', 'nadeem.vawda', 'tarek', 'ned.deily', 'eric.araujo', 'grahamd', 'r.david.murray', 'neologix', 'filippo', 'xuanji', 'bbi5291', 'Denis.Barmenkov', 'aikinci', 'serhiy.storchaka', 'matrixise', 'zaytsev', 'antoine.pietri', 'yan12125', 'Jonathon Reinhart', 'surajd', 'izbyshev', 'cinerar', 'Nicholas Brown', 'miss-islington', 'pxinwr']
    pr_nums = ['3403', '10919', '10924', '10924', '10924', '10925', '10925', '10930', '10930', '10930', '10931', '10931', '10931', '11212', '11213', '23530']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue10496'
    versions = ['Python 2.7', 'Python 3.7', 'Python 3.8']

    @bbi5291 bbi5291 mannequin added the type-bug An unexpected behavior, bug, or error label Nov 22, 2010
    @bbi5291
    Copy link
    Mannequin Author

    bbi5291 mannequin commented Nov 22, 2010

    This bug is Linux-specific.

    When Python cannot find the home directory of the user invoking it, it prints "'import site' failed; use -v for traceback".

    This occurs only when both of these conditions are met:

    1. /etc/passwd contains no entry for the current real UID
    2. the HOME environment variable does not exist

    To duplicate this bug, compile and run the attached program as root.
    (This program assumes that 12345 is not a legitimate user on your system, and that Python is at /usr/bin/python ; if this is not the case then edit it accordingly.)

    @ned-deily
    Copy link
    Member

    The problem is reproducible on a current Debian Linux system although with different results for current versions of Python (only security issues are accepted against 2.6). Unlike with 2.6, 3.1 reports no error. 2.7 and 3.2 both fail with an exception:

    Traceback (most recent call last):
      File "/usr/lib/python2.7/site.py", line 548, in <module>
        main()
      File "/usr/lib/python2.7/site.py", line 530, in main
        known_paths = addusersitepackages(known_paths)
      File "/usr/lib/python2.7/site.py", line 257, in addusersitepackages
        user_site = getusersitepackages()
      File "/usr/lib/python2.7/site.py", line 232, in getusersitepackages
        user_base = getuserbase() # this will also set USER_BASE
      File "/usr/lib/python2.7/site.py", line 222, in getuserbase
        USER_BASE = get_config_var('userbase')
      File "/usr/lib/python2.7/sysconfig.py", line 541, in get_config_var
        return get_config_vars().get(name)
      File "/usr/lib/python2.7/sysconfig.py", line 449, in get_config_vars
        _CONFIG_VARS['userbase'] = _getuserbase()
      File "/usr/lib/python2.7/sysconfig.py", line 198, in _getuserbase
        return env_base if env_base else joinuser("~", ".local")
      File "/usr/lib/python2.7/sysconfig.py", line 185, in joinuser
        return os.path.expanduser(os.path.join(*args))
      File "/usr/lib/python2.7/posixpath.py", line 256, in expanduser
        userhome = pwd.getpwuid(os.getuid()).pw_dir
    KeyError: 'getpwuid(): uid not found: 12345'

    @IIIIllllIIIIllllIIIIllllIIIIllllIIIIll
    Copy link
    Mannequin

    I tried running bug.c using the svn head of python and got this:

    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
    Fatal Python error: Py_Initialize: Unable to get the locale encoding
    LookupError: no codec search functions registered: can't find encoding
    Aborted

    @DenisBarmenkov
    Copy link
    Mannequin

    DenisBarmenkov mannequin commented Apr 1, 2011

    I saw similar error on Python 2.6 installed on freeBSD.
    I had test SVN server and wrote pre-commit hook using python. When remote developer commited his changes to repository, hook called os.path.expanduser and exception was raised:
    # File "/usr/local/lib/python2.6/posixpath.py", line 259, in expanduser
    # userhome = pwd.getpwuid(os.getuid()).pw_dir
    #KeyError: 'getpwuid(): uid not found: 12345'

    So its not a just-Linux issue.

    @vstinner
    Copy link
    Member

    This issue remembers me the issue bpo-6612 (failure if the current directory was removed): the fix was to ignore os.getcwd().

    Attached patch ignores os.path.expanduser() error (KeyError) and keeps ~ in the path. Example without HOME var and with an non existent user (uid 12345):

    ----------------------

    $ env -i ./python
    >>> import sysconfig
    >>> sysconfig.get_config_var('userbase')
    '~/.local'
    >>> sysconfig.get_paths(scheme='posix_user', expand=False)
    {'platstdlib': '{userbase}/lib/python{py_version_short}', 'platlib': '{userbase}/lib/python{py_version_short}/site-packages', 'purelib': '{userbase}/lib/python{py_version_short}/site-packages', 'stdlib': '{userbase}/lib/python{py_version_short}', 'scripts': '{userbase}/bin', 'include': '{userbase}/include/python{py_version_short}', 'data': '{userbase}'}
    
    >>> sysconfig.get_paths(scheme='posix_user')              
    {'platstdlib': '~/.local/lib/python3.3', 'platlib': '~/.local/lib/python3.3/site-packages', 'purelib': '~/.local/lib/python3.3/site-packages', 'stdlib': '~/.local/lib/python3.3', 'scripts': '~/.local/bin', 'include': '~/.local/include/python3.3', 'data': '~/.local'}

    Example with an existant user but without HOME var:
    ----------------------

    marge$ env -i ./python
    >>> import sysconfig
    >>> sysconfig.get_config_var('userbase')
    '/home/haypo/.local'
    >>> sysconfig.get_paths(scheme='posix_user')      
    {'platstdlib': '/home/haypo/.local/lib/python3.3', 'platlib': '/home/haypo/.local/lib/python3.3/site-packages', 'purelib': '/home/haypo/.local/lib/python3.3/site-packages', 'stdlib': '/home/haypo/.local/lib/python3.3', 'scripts': '/home/haypo/.local/bin', 'include': '/home/haypo/.local/include/python3.3', 'data': '/home/haypo/.local'}

    @vstinner vstinner changed the title "import site failed" when Python can't find home directory "import site failed" when Python can't find home directory (sysconfig._getuserbase) Apr 12, 2011
    @merwok
    Copy link
    Member

    merwok commented Apr 13, 2011

    Can someone explain how it can happen that a user has no home directory?

    @bbi5291
    Copy link
    Mannequin Author

    bbi5291 mannequin commented Apr 13, 2011

    I discovered this while I was implementing and testing a sandbox for automatic evaluation of programs.

    @merwok
    Copy link
    Member

    merwok commented Apr 13, 2011

    Can you be more precise? IOW, why is this a Python bug rather than a system misconfiguration? Note that I don’t know a lot about POSIX, so I’m open to change my mind.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Apr 14, 2011

    I'm not sure whether POSIX warrants anything about this behavior, but nothing prevents a process from running with a UID not listed in /etc/passwd (or NIS, whatever). For example, sudo allows running a command with a UID not listed in the password database, see http://linux.die.net/man/5/sudoers :
    """
    targetpw

    If set, sudo will prompt for the password of the user specified by the -u flag (defaults to root) instead of the password of the invoking user. Note that this precludes the use of a uid not listed in the passwd database as an argument to the -u flag. This flag is off by default.
    """

    UIDs not backed by users are useful for example if you're working with a sandbox, or virtual users such as in some FTP servers http://www.proftpd.org/docs/howto/VirtualUsers.html :
    """
    Question: What makes a user "virtual", then?
    Answer: A virtual user is, quite simply, a user that is not defined in the system /etc/passwd file. This file associates a user name, given by the system administrator, to a user ID (commonly shortened to UID) and a group ID (GID), among other details. The Unix kernel does not deal with users in terms of their user names; it only "knows" about UIDs and GIDs. This means that an application like proftpd can look up the IDs to use for a given user name however it sees fit. Using /etc/passwd is not strictly required.
    """

    @vstinner
    Copy link
    Member

    Because the patch is simple (just add a try/except), I think that it doesn't matter if only few people use users without entry in /etc/passwd and we should fix this issue.

    @merwok
    Copy link
    Member

    merwok commented Apr 15, 2011

    It’s not just a try/except, it’s a behavior change: after the patch, paths returned by sysconfig may not be fully expanded paths. I would like Tarek to make a call on this.

    @vstinner
    Copy link
    Member

    vstinner commented May 2, 2011

    I would like Tarek to make a call on this.

    So Tarek, what do you think?

    @tarekziade
    Copy link
    Mannequin

    tarekziade mannequin commented May 2, 2011

    As discussed w/ Victor, a process should be able to run Python even if its user does not have a home.

    So the call to _getuserbase() should be protected.

    But then we have to control that all the code that uses CONFIG_VARS['userbase'] is protected when the value is not set.

    I am thinking about per-user installation and such things: we need to make sure everything is checking this.

    @merwok
    Copy link
    Member

    merwok commented May 3, 2011

    This is the one thing about which I wanted a call: “after the patch, paths returned by sysconfig may not be fully expanded paths” (i.e. they may start with '~').

    @tarekziade
    Copy link
    Mannequin

    tarekziade mannequin commented May 3, 2011

    Paths that are starting with ~ should be extended with the right value with the user base. If the user base cannot be calculated, paths starting with ~ should not exist or be used at all in this context.

    Maybe we need to completely reset them to None like userbase. We need to list all use cases within the stdlib and come up with a general rule.

    @vstinner
    Copy link
    Member

    vstinner commented May 5, 2011

    If the user base cannot be calculated, paths
    starting with ~ should not exist or be used at all in this context.

    It's not "~" but "{userbase}" substitution variable.

    Here is a new patch implementing this idea: don't create the variables using the user directory if the user doesn't exist (if we cannot get the user directory). I didn't test distutils, I just try to start Python (it does work using bug.c).

    @vstinner
    Copy link
    Member

    vstinner commented May 8, 2011

    @eric.araujo, @tarek: do you prefer nonexistent_user.patch? I removed sysconfig_getuserbase.patch, because I agree that an expanded path containing "~" is a bug.

    @merwok
    Copy link
    Member

    merwok commented May 9, 2011

    In the absence of tests or doc update, can you tell in English what the new behavior is? IIUC, when the home dir is not found, all the variables that depend on it would not exist, right? Or would they be set to None?

    @vstinner
    Copy link
    Member

    vstinner commented May 9, 2011

    Main changes of the patch, if the current user has no home directory (no entry in /etc/passwd) and there is HOME environment variable:

    • sysconfig.get_config_vars() doesn't have a 'userbase' variable. sysconfig.get_config_var('userbase') returns None as any other nonexistent key.
    • sysconfig.get_paths() doesn't create a path if expand fails (without raising an error or emiting a warning). For example, sysconfig.get_paths(scheme='posix_user') returns an empty dict.

    @merwok
    Copy link
    Member

    merwok commented Mar 13, 2012

    Adding people from the duplicate report bpo-14238.

    Georg said:

    there should be a guard here that just doesn't add user site directories if the lookup fails.

    I concurred and added:

    we also need to fix sysconfig; I think the right thing to do would be not to have a config var
    named 'userbase' when run from a UID without passwd entry. This implies that the functions
    listed under http://docs.python.org/library/sysconfig#installation-paths would also need to omit
    *user schemes.

    @merwok merwok changed the title "import site failed" when Python can't find home directory (sysconfig._getuserbase) Python startup should not require passwd entry Mar 13, 2012
    @merwok merwok assigned merwok and unassigned tarekziade Mar 13, 2012
    @merwok
    Copy link
    Member

    merwok commented Mar 13, 2012

    I reviewed haypo’s patch. I’d be happy to update it to address my remarks if you want me to.

    @vstinner
    Copy link
    Member

    I’d be happy to update it to address my remarks if you want me to.

    Please write your own patch addressing your concerns.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Jul 31, 2013

    Is there a hope to get this fixed?
    It can be needed to e.g. run python as nobody user (used for example for CGI scripts, etc).

    @JonathonReinhart
    Copy link
    Mannequin

    JonathonReinhart mannequin commented Jan 5, 2016

    I have another scenario where this happens: Running Python in a Docker container, passing the --user option to 'docker run'. This sets the UID in the container, which has its own /etc/passwd. Couple this with the fact that $HOME might not be set (e.g. when Python is invoked from SCons which deliberately clears the environment for sub-processes), and *boom*, Python is non-functional.

    Regardless of where the fix is done, the ideal behavior is straightforward: if Python can't determine the home directory, don't try to add user site packages.

    This bug is now over 5 years old, and people have identified real-life various scenarios where this bug manifests itself, and submitted patches. Could we please address this?

    @surajssd
    Copy link
    Mannequin

    surajssd mannequin commented Dec 6, 2016

    I did not encounter this issue in fedora24 based container on docker but when I run it in openshift I see errors as:

    That container has Python 2.7.12 installed. While flask and redis python libs are installed via pip.

    bash: /usr/local/bin/wait-for-it.sh: Permission denied
     * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
     * Restarting with stat
     * Debugger is active!
    Traceback (most recent call last):
      File "app.py", line 18, in <module>
        app.run(host="0.0.0.0", port=5000, debug=True)
      File "/usr/lib64/python2.7/site-packages/flask/app.py", line 843, in run
        run_simple(host, port, self, **options)
      File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 633, in run_simple
        application = DebuggedApplication(application, use_evalex)
      File "/usr/lib/python2.7/site-packages/werkzeug/debug/__init__.py", line 254, in __init__
        if self.pin is None:
      File "/usr/lib/python2.7/site-packages/werkzeug/debug/__init__.py", line 264, in _get_pin
        self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app)
      File "/usr/lib/python2.7/site-packages/werkzeug/debug/__init__.py", line 144, in get_pin_and_cookie_name
        username = getpass.getuser()
      File "/usr/lib64/python2.7/getpass.py", line 158, in getuser
        return pwd.getpwuid(os.getuid())[0]
    KeyError: 'getpwuid(): uid not found: 1000050000'
    

    @grahamd
    Copy link
    Mannequin

    grahamd mannequin commented Dec 6, 2016

    @surajd Why aren't you using the Python S2I builders for OpenShift?

    When you run anything under OpenShift, it will assign your project a UID which any containers are forced to run under. The OpenShift containers include a mechanism using a package call nss_wrapper so that correct passwd entries are reported for the assigned UID. If your own image doesn't have a similar provision, and in general aren't designed to run as an arbitrary assigned UID, you will encounter various issues.

    Read through the latter section of posts in:

    for further details.

    Anyway, this isn't the place to discuss OpenShift, use instead:

    if you have questions about running Python under OpenShift.

    @surajssd
    Copy link
    Mannequin

    surajssd mannequin commented Dec 6, 2016

    @Grahamd thanks this helps.

    @bitdancer
    Copy link
    Member

    Unless I'm mistaken, this has come up again in bpo-31469.

    @bitdancer
    Copy link
    Member

    Dmitriy: you will note from the discussion on this issue that your "simple patch" was not considered sufficient. There were additional concerns voiced about haypo's patch, which is why I guess it didn't get applied. However, can you review that and confirm that it solves your problem? Maybe that will encourage a reconsideration of this issue.

    @NicholasBrown
    Copy link
    Mannequin

    NicholasBrown mannequin commented Oct 9, 2017

    This is also a problem when using the DynamicUser=yes feature available in systemd 232 onward with a service that's implemented in python.
    See http://0pointer.net/blog/dynamic-users-with-systemd.html for details of the DynamicUser= systemd feature.

    @vstinner
    Copy link
    Member

    user.py: short Python script to reproduce the bug. It runs Python as user 12345, group 12345 and unset the HOME environment variable to reproduce the bug.

    The python binary must be readable and executable by any user, especially uid 12345 gid 12345. On my Fedora, /home/haypo is only accessible by the usr haypo. I cloned Python in /opt/cpython to work around the issue.

    I confirm that Python 3.7 still has the bug.

    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    According to seirl on IRC, this issue is trigged when a Python application is run by systemd using DynamicUser=yes:

    "DynamicUser: Takes a boolean parameter. If set, a UNIX user and group pair is allocated dynamically when the unit is started, and released as soon as it is stopped. The user and group will not be added to /etc/passwd or /etc/group, but are managed transiently during runtime. (...)"

    @seirl
    Copy link
    Mannequin

    seirl mannequin commented Dec 5, 2018

    Trivial way to reproduce, run this as root:

    systemd-run -p DynamicUser=yes -t python3
    

    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    I wrote PR bpo-10919 which fix posix.expandpath() and also fix indirectly the site module.

    @antoine Pietri: Would you mind to try the fix?

    @izbyshev
    Copy link
    Mannequin

    izbyshev mannequin commented Dec 5, 2018

    If I understood PR 10919 correctly, sysconfig.get_config_var('userbase') can now return unexpanded paths containing '~'. Is it intended despite the previous discussion starting with msg135047?

    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    If I understood PR 10919 correctly, sysconfig.get_config_var('userbase') can now return unexpanded paths containing '~'. Is it intended despite the previous discussion starting with msg135047?

    With my PR 10919, "python3 setup.py install" and "python3 setup.py install --user" still fail with:

    Traceback (most recent call last):
      File "setup.py", line 79, in <module>
        main()
      File "setup.py", line 75, in main
        setup(**options)
      File "/tmp/cpython/Lib/distutils/core.py", line 121, in setup
        dist.parse_config_files()
      File "/tmp/cpython/Lib/distutils/dist.py", line 397, in parse_config_files
        filenames = self.find_config_files()
      File "/tmp/cpython/Lib/distutils/dist.py", line 349, in find_config_files
        check_environ()
      File "/tmp/cpython/Lib/distutils/util.py", line 161, in check_environ
        os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
    KeyError: 'getpwuid(): uid not found: 12345'

    I suggest to open a new issue if you want to enhance the error message and/or handle getpwuid() failure in find_config_files().

    I prefer to stick to the initial bug report which hasn't been fixed in 8 years:

    When Python cannot find the home directory of the user invoking it, it prints "'import site' failed; use -v for traceback".

    IMHO PR 10919 fix is straighforward, it respects the contract (documentation) of posixpath.expanduser() ("If user or $HOME is unknown, do nothing."), and expanduser() already handles KeyError on getpwnam() (since the function has been created in 1992 by Guido van Rossum! commit 7ac4878).

    @seirl
    Copy link
    Mannequin

    seirl mannequin commented Dec 5, 2018

    Would it make sense to backport this fix in 3.6 and 3.7? As distros increasingly move in the direction of using DynamicUser=yes for most stateless services, it would really help to have that, for instance in Debian Buster (which will probably be on 3.7 if my understanding is correct).

    FYI the cutoff date for the release candidate of 3.6.8 is 2018-12-07 (in two days).

    @izbyshev
    Copy link
    Mannequin

    izbyshev mannequin commented Dec 5, 2018

    I prefer to stick to the initial bug report which hasn't been fixed in 8 years

    I'm interested in fixing this bug too since it bit me in SCons and I had to use a local patch for it. I welcome the upstream fix and don't object to PR 10919. I'm not personally affected by unexpanded paths in sysconfig (at least not in a way I know of), so I just want to make sure that all effects of the PR are considered, given the previous discussions. Thanks, Victor!

    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    Yes, I plan to try to backport the fix to stable branches.

    @izbyshev
    Copy link
    Mannequin

    izbyshev mannequin commented Dec 5, 2018

    Would it make sense to backport this fix in 3.6 and 3.7?

    I'd like to see it there, given that this bug surfaced in many use cases not involving any modern features or systemd at all.

    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    New changeset f2f4555 by Victor Stinner in branch 'master':
    bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919)
    f2f4555

    @miss-islington
    Copy link
    Contributor

    New changeset 983d1ab by Miss Islington (bot) in branch '3.7':
    bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919)
    983d1ab

    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    New changeset 31b635d by Victor Stinner in branch '3.6':
    bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) (GH-10925)
    31b635d

    @vstinner vstinner added 3.7 (EOL) end of life 3.8 only security fixes labels Dec 5, 2018
    @vstinner
    Copy link
    Member

    vstinner commented Dec 5, 2018

    New changeset b50b33b by Victor Stinner in branch '2.7':
    bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919) (GH-10930)
    b50b33b

    @vstinner
    Copy link
    Member

    New changeset 17d0c05 by Victor Stinner in branch 'master':
    bpo-10496: distutils check_environ() handles getpwuid() error (GH-10931)
    17d0c05

    @miss-islington
    Copy link
    Contributor

    New changeset 6e96fb4 by Miss Islington (bot) in branch '3.7':
    bpo-10496: distutils check_environ() handles getpwuid() error (GH-10931)
    6e96fb4

    @vstinner
    Copy link
    Member

    New changeset ea6b322 by Victor Stinner in branch '2.7':
    bpo-10496: distutils check_environ() handles getpwuid() error (GH-10931) (GH-11213)
    ea6b322

    @vstinner
    Copy link
    Member

    A few minor tests are still failing when the uid doesn't exist in the password database, but the main issue in pwdhas been fixed and distutils should work more or lesss. I close this 8 years old issue. Thanks to everyone who has been involved in helping to fix it!

    @vstinner vstinner added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir labels Dec 18, 2018
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants