From ea3941f630d9753b93e7be702b345163b7717c43 Mon Sep 17 00:00:00 2001 From: Thiemo Nagel Date: Thu, 21 Aug 2014 14:41:12 +0200 Subject: [PATCH] crash-reporter: Fix overzealous crash purging in guest mode. Previously, if crash_sender was invoked during a guest session all crashes that could be accessed (i.e. that were stored outside of user directories) were deleted. This is fixed by re-ordering some of the conditions in send_crashes(). The problem had been introduced by 57f6efa4: https://chromium-review.googlesource.com/200060 BUG=chromium:393334 TEST=unit tests passed TEST=try success on amd64-generic-full Change-Id: I931665891eca8e645135f7f08c15b3086fcb7d73 Reviewed-on: https://chromium-review.googlesource.com/213470 Reviewed-by: Mike Frysinger Commit-Queue: Thiemo Nagel Tested-by: Thiemo Nagel --- crash_reporter/crash_sender | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender index f0848286f..c83a12ae2 100755 --- a/crash_reporter/crash_sender +++ b/crash_reporter/crash_sender @@ -514,20 +514,6 @@ send_crashes() { continue fi - # Remove existing crashes in case user consent has not (yet) been given or - # has been revoked. - if ! ${METRICS_CLIENT} -c; then - lecho "Crash reporting is disabled. Removing crash." - remove_report "${meta_path}" - continue - fi - - if ! is_mock && ! is_official_image; then - lecho "Not an official OS version. Removing crash." - remove_report "${meta_path}" - continue - fi - if ! is_complete_metadata "${meta_path}"; then # This report is incomplete, so if it's old, just remove it. local old_meta=$(${FIND} "${dir}" -mindepth 1 -name \ @@ -541,6 +527,12 @@ send_crashes() { continue fi + if ! is_mock && ! is_official_image; then + lecho "Not an official OS version. Removing crash." + remove_report "${meta_path}" + continue + fi + # Don't send crash reports from previous sessions while we're in guest mode # to avoid the impression that crash reporting was enabled, which it isn't. # (Don't exit right now because subsequent reports may be candidates for @@ -550,6 +542,15 @@ send_crashes() { continue fi + # Remove existing crashes in case user consent has not (yet) been given or + # has been revoked. This must come after the guest mode check because + # ${METRICS_CLIENT} always returns "not consented" in guest mode. + if ! ${METRICS_CLIENT} -c; then + lecho "Crash reporting is disabled. Removing crash." + remove_report "${meta_path}" + continue + fi + # Skip report if the upload rate is exceeded. (Don't exit right now because # subsequent reports may be candidates for deletion.) if ! check_rate; then