-
Notifications
You must be signed in to change notification settings - Fork 535
ENH: Disable symlinks on CIFS filesystems #1941
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0d5359d
RF: Disable symlinks if destination is on CIFS
effigies dafb5ee
RF: Precompute CIFS table to minimize overhead
effigies a4dd608
DOC: Update documentation
effigies a9cb28c
TEST: Check on_cifs with simulated mount table
effigies ae5c6e1
PY2: Remove list.clear
effigies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
import sys | ||
import pickle | ||
import subprocess | ||
import gzip | ||
import hashlib | ||
from hashlib import md5 | ||
|
@@ -237,6 +238,30 @@ def hash_timestamp(afile): | |
return md5hex | ||
|
||
|
||
def _on_cifs(fname): | ||
""" Checks whether a PATH is on a CIFS filesystem mounted in a POSIX | ||
host (i.e., has the "mount" command). | ||
|
||
CIFS shares are how Docker mounts Windows host directories into containers. | ||
CIFS has partial support for symlinks that can break, causing misleading | ||
errors, so this test is used to disable them on such systems. | ||
""" | ||
exit_code, output = subprocess.getstatusoutput("mount") | ||
# Not POSIX | ||
if exit_code != 0: | ||
return False | ||
|
||
# (path, fstype) tuples, sorted by path length (longest first) | ||
paths_types = sorted((line.split()[2:5:2] for line in output.splitlines()), | ||
key=lambda x: len(x[0]), | ||
reverse=True) | ||
# Only the first match counts | ||
for fspath, fstype in paths_types: | ||
if fname.startswith(fspath): | ||
return fstype == 'cifs' | ||
return False | ||
|
||
|
||
def copyfile(originalfile, newfile, copy=False, create_new=False, | ||
hashmethod=None, use_hardlink=False, | ||
copy_related_files=True): | ||
|
@@ -288,6 +313,10 @@ def copyfile(originalfile, newfile, copy=False, create_new=False, | |
if hashmethod is None: | ||
hashmethod = config.get('execution', 'hash_method').lower() | ||
|
||
# Don't try creating symlinks on CIFS | ||
if _on_cifs(newfile): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For performance reasons, I would only run this check if we are about to make a symlink. |
||
copy = True | ||
|
||
# Existing file | ||
# ------------- | ||
# Options: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make it public - could be useful in other places