Show More
@@ -848,18 +848,23 b' def checkexec(path):' | |||||
848 |
|
848 | |||
849 | Requires a directory (like /foo/.hg) |
|
849 | Requires a directory (like /foo/.hg) | |
850 | """ |
|
850 | """ | |
|
851 | ||||
|
852 | # VFAT on some Linux versions can flip mode but it doesn't persist | |||
|
853 | # a FS remount. Frequently we can detect it if files are created | |||
|
854 | # with exec bit on. | |||
|
855 | ||||
851 | try: |
|
856 | try: | |
852 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
|
857 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | |
853 | fh, fn = tempfile.mkstemp("", "", path) |
|
858 | fh, fn = tempfile.mkstemp("", "", path) | |
854 | os.close(fh) |
|
859 | try: | |
855 |
|
|
860 | os.close(fh) | |
856 | # VFAT on Linux can flip mode but it doesn't persist a FS remount. |
|
861 | m = os.stat(fn).st_mode & 0777 | |
857 | # frequently we can detect it if files are created with exec bit on. |
|
862 | new_file_has_exec = m & EXECFLAGS | |
858 | new_file_has_exec = m & EXECFLAGS |
|
863 | os.chmod(fn, m ^ EXECFLAGS) | |
859 | os.chmod(fn, m ^ EXECFLAGS) |
|
864 | exec_flags_cannot_flip = (os.stat(fn).st_mode == m) | |
860 | exec_flags_cannot_flip = (os.stat(fn).st_mode == m) |
|
865 | finally: | |
861 | os.unlink(fn) |
|
866 | os.unlink(fn) | |
862 | except (IOError,OSError): |
|
867 | except (IOError, OSError): | |
863 | # we don't care, the user probably won't be able to commit anyway |
|
868 | # we don't care, the user probably won't be able to commit anyway | |
864 | return False |
|
869 | return False | |
865 | return not (new_file_has_exec or exec_flags_cannot_flip) |
|
870 | return not (new_file_has_exec or exec_flags_cannot_flip) |
General Comments 0
You need to be logged in to leave comments.
Login now