bug 1316329 - follow symlinks for srcdir path in symbol dumping on windows. r?gps draft
authorTed Mielczarek <ted@mielczarek.org>
Tue, 22 Nov 2016 14:41:57 -0500
changeset 442697 e64df213faa18e41fe9d21a23b847e3445ce88ac
parent 442695 43499c982578ec30e570416cc89043082cc47143
child 442698 cf0587a0166386d518e1bdbb617b9764773434ed
push id36786
push userbmo:ted@mielczarek.org
push dateWed, 23 Nov 2016 01:54:54 +0000
reviewersgps
bugs1316329
milestone53.0a1
bug 1316329 - follow symlinks for srcdir path in symbol dumping on windows. r?gps If the srcdir is in a path containing a symlink on Windows, when `FixFilenameCase` calls `GetFinalPathNameByHandleW` to normalize the case of a source file it will get a path to the file with the symlink resolved. This breaks our "is this file in the source repository" check. This patch makes the code call `FixFilenameCase` for any srcdir arguments that are passed to the script, so any symlinks will be resolved there and the prefix matching will work. MozReview-Commit-ID: 2UibW9XYWoK
toolkit/crashreporter/tools/symbolstore.py
--- a/toolkit/crashreporter/tools/symbolstore.py
+++ b/toolkit/crashreporter/tools/symbolstore.py
@@ -420,17 +420,17 @@ class Dumper:
         # popen likes absolute paths, at least on windows
         self.dump_syms = os.path.abspath(dump_syms)
         self.symbol_path = symbol_path
         if archs is None:
             # makes the loop logic simpler
             self.archs = ['']
         else:
             self.archs = ['-a %s' % a for a in archs.split()]
-        self.srcdirs = [os.path.normpath(a) for a in srcdirs]
+        self.srcdirs = [os.path.normpath(self.FixFilenameCase(a)) for a in srcdirs]
         self.copy_debug = copy_debug
         self.vcsinfo = vcsinfo
         self.srcsrv = srcsrv
         self.exclude = exclude[:]
         if repo_manifest:
             self.parse_repo_manifest(repo_manifest)
         self.file_mapping = file_mapping or {}
 
@@ -758,17 +758,20 @@ class Dumper_Win32(Dumper):
         handle = ctypes.windll.kernel32.CreateFileW(file,
                                                     # GENERIC_READ
                                                     0x80000000,
                                                     # FILE_SHARE_READ
                                                     1,
                                                     None,
                                                     # OPEN_EXISTING
                                                     3,
-                                                    0,
+                                                    # FILE_FLAG_BACKUP_SEMANTICS
+                                                    # This is necessary to open
+                                                    # directory handles.
+                                                    0x02000000,
                                                     None)
         if handle != -1:
             size = ctypes.windll.kernel32.GetFinalPathNameByHandleW(handle,
                                                                     None,
                                                                     0,
                                                                     0)
             buf = ctypes.create_unicode_buffer(size)
             if ctypes.windll.kernel32.GetFinalPathNameByHandleW(handle,