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

WIP: Correctly detect if executable with os.stat() #7813

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6364.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly set executable permissions in cases where /tmp is mounted 'noexec.'
9 changes: 6 additions & 3 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,12 @@ def clobber(
os.utime(destfile, (st.st_atime, st.st_mtime))

# If our file is executable, then make our destination file
# executable.
if os.access(srcfile, os.X_OK):
st = os.stat(srcfile)
# executable. Issue #6364: we make the destination executable
# if any -x flags are set on srcfile rather than using
# os.access(), which will always return False if srcfile
# is in a directory mounted 'noexec.'
bsolomon1124 marked this conversation as resolved.
Show resolved Hide resolved
st = os.stat(srcfile)
if st.st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH):
permissions = (
st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
)
Expand Down