# HG changeset patch # User Gabriele Svelto # Date 1573765919 0 # Node ID 5df0e903d13fa096db7b3d90c3d1fe972a5b34d4 # Parent f558d0198db9ea97757260a9af0673d16967aa3c Bug 1516367 - Move the minidump-analyzer out of the crash reporter application bundle r=spohl,dmajor The minidump-analyzer tool was originally conceived to be used from the crash report client and as such was installed in the crash reporter client application bundle on macOS. It was later adapted to work from Firefox itself but this caused linking problems when invoked from the Firefox app bundle. This patch moves the minidump-analyzer into the Firefox app bundle and adapts the relevant code to find it there. The minidump-analyzer was also not signed like the rest of our executables and this patch addresses that issue too. Differential Revision: https://phabricator.services.mozilla.com/D52910 diff --git a/browser/app/macbuild/Contents/MacOS-files.in b/browser/app/macbuild/Contents/MacOS-files.in --- a/browser/app/macbuild/Contents/MacOS-files.in +++ b/browser/app/macbuild/Contents/MacOS-files.in @@ -1,12 +1,15 @@ /*.app/*** /certutil /firefox-bin /gtest/*** #if defined(MOZ_ASAN) || defined(MOZ_TSAN) /llvm-symbolizer #endif +#if defined(MOZ_CRASHREPORTER) +/minidump-analyzer +#endif /pk12util /ssltunnel /webrtc-gtest /xpcshell /XUL diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -753,27 +753,32 @@ bin/libfreebl_32int64_3.so @RESPATH@/components/CrashService.manifest @RESPATH@/components/CrashService.js @RESPATH@/components/toolkit_crashservice.xpt #ifdef XP_MACOSX @BINPATH@/crashreporter.app/ #else @BINPATH@/crashreporter@BIN_SUFFIX@ @RESPATH@/crashreporter.ini -@BINPATH@/minidump-analyzer@BIN_SUFFIX@ #ifdef XP_UNIX @RESPATH@/Throbber-small.gif #endif #endif @RESPATH@/browser/crashreporter-override.ini #ifdef MOZ_CRASHREPORTER_INJECTOR @BINPATH@/breakpadinjector.dll #endif #endif +; [ minidump-analyzer ] +; +#ifdef MOZ_CRASHREPORTER +@BINPATH@/minidump-analyzer@BIN_SUFFIX@ +#endif + @RESPATH@/components/dom_audiochannel.xpt ; Shutdown Terminator @RESPATH@/components/nsTerminatorTelemetry.js @RESPATH@/components/terminator.manifest #ifdef LLVM_SYMBOLIZER @BINPATH@/@LLVM_SYMBOLIZER@ diff --git a/python/mozbuild/mozbuild/artifacts.py b/python/mozbuild/mozbuild/artifacts.py --- a/python/mozbuild/mozbuild/artifacts.py +++ b/python/mozbuild/mozbuild/artifacts.py @@ -384,27 +384,25 @@ class MacArtifactJob(ArtifactJob): 'libnssckbi.dylib', 'libnssdbm3.dylib', 'libplugin_child_interpose.dylib', # 'libreplace_jemalloc.dylib', # 'libreplace_malloc.dylib', 'libmozavutil.dylib', 'libmozavcodec.dylib', 'libsoftokn3.dylib', + 'minidump-analyzer', 'plugin-container.app/Contents/MacOS/plugin-container', 'updater.app/Contents/MacOS/org.mozilla.updater', # 'xpcshell', 'XUL', ]) # These get copied into dist/bin with the path, so "root/a/b/c" -> "dist/bin/a/b/c". paths_keep_path = [ - ('Contents/MacOS', [ - 'crashreporter.app/Contents/MacOS/minidump-analyzer', - ]), ('Contents/Resources', [ 'browser/components/libbrowsercomps.dylib', 'dependentlibs.list', # 'firefox', 'gmp-clearkey/0.1/libclearkey.dylib', # 'gmp-fake/1.0/libfake.dylib', # 'gmp-fakeopenh264/1.0/libfakeopenh264.dylib', '**/interfaces.xpt', diff --git a/security/mac/hardenedruntime/codesign.bash.1516367.later b/security/mac/hardenedruntime/codesign.bash.1516367.later new file mode 100644 --- /dev/null +++ b/security/mac/hardenedruntime/codesign.bash.1516367.later @@ -0,0 +1,20 @@ +--- codesign.bash ++++ codesign.bash +@@ -112,16 +112,17 @@ echo "---------------------------------- + # Clear extended attributes which cause codesign to fail + xattr -cr "${BUNDLE}" + + # Sign these binaries first. Signing of some binaries has an ordering + # requirement where other binaries must be signed first. + codesign --force -o runtime --verbose --sign "$IDENTITY" \ + "${BUNDLE}/Contents/MacOS/XUL" \ + "${BUNDLE}/Contents/MacOS/pingsender" \ ++"${BUNDLE}/Contents/MacOS/minidump-analyzer" \ + "${BUNDLE}"/Contents/MacOS/*.dylib + + codesign --force -o runtime --verbose --sign "$IDENTITY" --deep \ + "${BUNDLE}"/Contents/MacOS/crashreporter.app + + codesign --force -o runtime --verbose --sign "$IDENTITY" --deep \ + "${BUNDLE}"/Contents/MacOS/updater.app + diff --git a/toolkit/components/crashes/CrashService.js b/toolkit/components/crashes/CrashService.js --- a/toolkit/components/crashes/CrashService.js +++ b/toolkit/components/crashes/CrashService.js @@ -31,23 +31,16 @@ var gRunningProcesses = new Set(); */ function runMinidumpAnalyzer(minidumpPath, allThreads) { return new Promise((resolve, reject) => { try { const binSuffix = AppConstants.platform === "win" ? ".exe" : ""; const exeName = "minidump-analyzer" + binSuffix; let exe = Services.dirsvc.get("GreBinD", Ci.nsIFile); - - if (AppConstants.platform === "macosx") { - exe.append("crashreporter.app"); - exe.append("Contents"); - exe.append("MacOS"); - } - exe.append(exeName); let args = [ minidumpPath ]; let process = Cc["@mozilla.org/process/util;1"] .createInstance(Ci.nsIProcess); process.init(exe); process.startHidden = true; process.noShell = true; diff --git a/toolkit/crashreporter/client/crashreporter.cpp b/toolkit/crashreporter/client/crashreporter.cpp --- a/toolkit/crashreporter/client/crashreporter.cpp +++ b/toolkit/crashreporter/client/crashreporter.cpp @@ -526,16 +526,26 @@ bool CheckEndOfLifed(string version) { string reportPath = gSettingsPath + UI_DIR_SEPARATOR + "EndOfLife" + version; return UIFileExists(reportPath); } static string GetProgramPath(const string& exename) { string path = gArgv[0]; size_t pos = path.rfind(UI_CRASH_REPORTER_FILENAME BIN_SUFFIX); path.erase(pos); +#ifdef XP_MACOSX + // On macOS the crash reporter client is shipped as an application bundle + // contained within Firefox' main application bundle. So when it's invoked + // its current working directory looks like: + // Firefox.app/Contents/MacOS/crashreporter.app/Contents/MacOS/ + // The other applications we ship with Firefox are stored in the main bundle + // (Firefox.app/Contents/MacOS/) so we we need to go back three directories + // to reach them. + path.append("../../../"); +#endif // XP_MACOSX path.append(exename + BIN_SUFFIX); return path; } int main(int argc, char** argv) { gArgc = argc; gArgv = argv; diff --git a/toolkit/crashreporter/minidump-analyzer/moz.build b/toolkit/crashreporter/minidump-analyzer/moz.build --- a/toolkit/crashreporter/minidump-analyzer/moz.build +++ b/toolkit/crashreporter/minidump-analyzer/moz.build @@ -1,19 +1,16 @@ # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- # vim: set filetype=python: # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_TARGET'] != 'Android': - GeckoProgram(name='minidump-analyzer', linkage=None) - - if CONFIG['OS_TARGET'] == 'Darwin': - DIST_SUBDIR = 'crashreporter.app/Contents/MacOS' + GeckoProgram('minidump-analyzer', linkage=None) if CONFIG['OS_TARGET'] == 'WINNT': DEFINES['UNICODE'] = True DEFINES['_UNICODE'] = True if CONFIG['CPU_ARCH'] == 'x86_64': UNIFIED_SOURCES += [ 'MozStackFrameSymbolizer.cpp',