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

/tmp/pip-build fixes #780

Merged
merged 11 commits into from Jan 26, 2013

Conversation

Projects
None yet
3 participants
@qwcode
Contributor

qwcode commented Jan 26, 2013

fixes and doc/changelog updates on top of commits from pull #734

d1b and others added some commits Nov 23, 2012

Fix #725 and #729.
Signed-off-by: David <db@d1b.org>
Clean up the _get_build_prefix code - close the open fd and print the…
… error message if the fd could not be opened (denied).

Signed-off-by: David <db@d1b.org>
Update the code _get_build_prefix to raise an exception instead of sy…
…s.exit()'ing and also document that on windows user temp directories are already isolated.

Signed-off-by: David <db@d1b.org>
In the os.open call to get the fd to check if the user specific build…
… directory

is in fact owned by another user - add the os.O_NOFOLLOW flag to not follow symbolic links.

Signed-off-by: David <db@d1b.org>
Provide a test to cover the changes to pip/locations.py regarding the…
… use of

the_get_build_prefix method to create a user specific build_prefix directory.

Signed-off-by: David <db@d1b.org>
Also un-patch the patched getpass.getuser method.
Signed-off-by: David <db@d1b.org>

qwcode added a commit that referenced this pull request Jan 26, 2013

@qwcode qwcode merged commit 6961e33 into pypa:develop Jan 26, 2013

def _get_build_prefix():
""" Returns a safe build_prefix """
path = os.path.join(tempfile.gettempdir(), 'pip-build-%s' % \
getpass.getuser())

This comment has been minimized.

@timjr

timjr May 22, 2013

getpass.getuser() returns the value in the LOGNAME environment variable, so this doesn't work under sudo:

$ sudo LOGNAME=foo python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import getpass
getpass.getuser()
'foo'

This should be based off of os.geteuid()

$ sudo LOGNAME=foo python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import os
import pwd
pwd.getpwuid(os.geteuid()).pw_name
'root'

@timjr

timjr May 22, 2013

getpass.getuser() returns the value in the LOGNAME environment variable, so this doesn't work under sudo:

$ sudo LOGNAME=foo python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import getpass
getpass.getuser()
'foo'

This should be based off of os.geteuid()

$ sudo LOGNAME=foo python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import os
import pwd
pwd.getpwuid(os.geteuid()).pw_name
'root'

This comment has been minimized.

@qwcode

qwcode Jun 8, 2013

Contributor

issue for this: #982

@qwcode

qwcode Jun 8, 2013

Contributor

issue for this: #982

This comment has been minimized.

@qwcode

qwcode Jun 8, 2013

Contributor

I would expect LOGNAME to be 'root' under sudo.
I see that on ubuntu and centos.

@qwcode

qwcode Jun 8, 2013

Contributor

I would expect LOGNAME to be 'root' under sudo.
I see that on ubuntu and centos.

This comment has been minimized.

@d1b

d1b Jun 11, 2013

Contributor

@timjr yes it should have been based off os.geteuid(), but getpass.getuser() is supported on windows and linux and so I used that.

@d1b

d1b Jun 11, 2013

Contributor

@timjr yes it should have been based off os.geteuid(), but getpass.getuser() is supported on windows and linux and so I used that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment