/tmp/pip-build fixes #780

Merged
merged 11 commits into from Jan 26, 2013

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
@d1b d1b Fix #725 and #729.
Signed-off-by: David <db@d1b.org>
eeaa64d
@d1b d1b 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>
e7bf29e
@d1b d1b 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>
61c444e
@d1b d1b 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>
dc3a359
@d1b d1b 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>
8baeeba
@d1b d1b Also un-patch the patched getpass.getuser method.
Signed-off-by: David <db@d1b.org>
7f13624
@qwcode qwcode setup.py read function fix 9868bc3
@qwcode qwcode update changelog and authors 26c050a
@qwcode qwcode update docs with new build dir 68d983d
@qwcode qwcode windows and other misc test updates 4595613
@qwcode qwcode changelog fix 1af3f2b
@qwcode qwcode merged commit 6961e33 into pypa:develop Jan 26, 2013
@timjr timjr commented on the diff May 22, 2013
pip/locations.py
@@ -25,6 +27,31 @@ def virtualenv_no_global():
if running_under_virtualenv() and os.path.isfile(no_global_file):
return True
+def _get_build_prefix():
+ """ Returns a safe build_prefix """
+ path = os.path.join(tempfile.gettempdir(), 'pip-build-%s' % \
+ getpass.getuser())
@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'

@qwcode
qwcode Jun 8, 2013 Contributor

issue for this: #982

@qwcode
qwcode Jun 8, 2013 Contributor

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

@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