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 <vapier@chromium.org>
Commit-Queue: Thiemo Nagel <tnagel@google.com>
Tested-by: Thiemo Nagel <tnagel@google.com>
diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender
index f084828..c83a12a 100755
--- a/crash_reporter/crash_sender
+++ b/crash_reporter/crash_sender
@@ -514,20 +514,6 @@
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 @@
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 @@
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