diff --git a/PKGBUILD b/PKGBUILD index 9257b6d..878484a 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -25,13 +25,13 @@ source=('20-kdump-steamos.conf' sha256sums=('dbedff54addfb5dce51614c73df04c90fca9f27d0d3a690243259ccbbfcca07c' '2514f79a496f76af847e262eadd55a5c2f8d95375cc513efa8cadd4cd98fe1d2' - 'd33778b5ba356f96ae2b78998deaeb7059260b8e2aa4253be3f7da4e9877f94c' + '4267a2b52ba3016a541d8d6149fc5d4974dd92fb8844439eaa81bd9cde6aa735' '7956c6cf1ce5c5e9aaf573ceee8c6ac2a0cad7e0cfa8f5b21adaa20f9f3db929' '06b38bd9f09da5fb22a765b6f1945fc349cc5f9d13cd32c9218b9b60b40a9010' '12a9124b907f208471ba7aaac0f3261cbbd34a168cce3260fa9e7793994beebd' '26bc2b64af0d468f050c0e0dd9e2053176d56886edad9146bc495797bf2c5810' - 'ada82c11a2ceef871dd2b7b6c265390903753c49b13f08f00514bccd58037230' - 'b1a4a0f77cae137d3f5155a0fcc4b9d1e1b7ffd0089adb06b6bb21e71c751e27' + '84723f6448e8b914d110078d71d4c3e114ac5637be53a1a91423728f6bb611d7' + '37620d55624a26d87b2f3018d3e3f2f5ba909fbfcb9da5a28ead318ba0450a36' 'cbb207ecc0f6bacefbeed41f0d4910daac6500ac2345366e1f95f09a7653c65a') package() { diff --git a/README.md b/README.md index fe5990c..0af2968 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,9 @@ # # 6. Error and succeeding messages are sent to systemd journal, so running # 'journalctl | grep kdump' would hopefully bring some information. Also, -# the ZIP file collected is automatically submitted to Valve servers; see -# below under DETAILS/LOG SUBMISSION for API details, decisions made, etc. +# the ZIP file collected is automatically submitted to Valve servers (unless +# the feature is disabled by the user); see below under DETAILS/LOG SUBMISSION +# for API details, decisions made, how to disable the feature, etc. # # # ############################## DETAILS ################################## @@ -127,14 +128,15 @@ # The logs collected and compressed in the ZIP file are kept in the system, # but they provide valuable data to Valve in order to determine issue in the # field, and hopefully fix them, so users are happy. Hence, the kdump-steamos -# is capable now to submit logs to Valve servers, through an API. Below such -# API is described, but first worth to mention some assumptions / decisions -# made in the log submission mechanism: +# is capable to submit logs to Valve servers, through an API. If users wish +# to disable this feature, just set LOG_SUBMISSION=0 in /etc/default/kdump. +# Below such API is described, but first worth to mention some assumptions +# and decisions made in the log submission mechanism: # # * First of all, we attempt to verify network connectivity by pinging the # URL "steampowered.com" - quick pings (2 packets, 0.5s between each one) # are attempted, but if after 99 of such pings network is considered not -# not reliable, the log submission is aborted, but the ZIP file is kept +# reliable, the log submission is aborted, but the ZIP file is kept # locally of course. # # * The 'curl' tool is used to submit the requests to Valve servers; for diff --git a/kdump.etc b/kdump.etc index e39c10f..5e8bad3 100644 --- a/kdump.etc +++ b/kdump.etc @@ -38,6 +38,11 @@ GRUB_AUTOSET=1 # in size. USE_PSTORE_RAM=1 +# By default, collected logs are submitted automatically to Valve servers. +# Setting LOG_SUBMISSION to '0' will disable this behavior; but notice that +# even with the log submission disabled, the logs are saved locally. +LOG_SUBMISSION=1 + # Below some log submission settings, based on Steam config files and Valve # URLs. These settings *should not* be changed, or else the log sending # mechanism will be impaired. diff --git a/submit_report.sh b/submit_report.sh index 6697232..3f92a43 100755 --- a/submit_report.sh +++ b/submit_report.sh @@ -11,6 +11,17 @@ # if kdump logs are present. # +# Function to bail-out in case logs can't/shouldn't be sent to Valve servers. +# Arg1: folder / Arg2: full filename +save_locally_and_bail() { + mkdir -p "$1" + mv "$2" "$1" + + LOG_FNAME="$(basename "$2")" + logger "kdump-steamos: logs not submitted, only saved locally ($1/${LOG_FNAME})" + exit 0 +} + # We do some validation to be sure KDUMP_MNT pointed path is valid... # That and having a valid /etc/default/kdump are essential conditions. if [ ! -f "/etc/default/kdump" ]; then @@ -174,10 +185,20 @@ if [ ${LOGS_FOUND} -ne 0 ]; then ############################## + NOT_SENT_FLD="${KDUMP_MAIN_FOLDER}/not_sent_logs" + SENT_FLD="${KDUMP_MAIN_FOLDER}/sent_logs" + # The POST request requires a valid Steam ID. if [ "${STEAM_ID}" -eq 0 ]; then logger "kdump-steamos: invalid Steam ID, cannot submit logs" - exit 0 + LOG_SUBMISSION=0 # force to enter next conditional + fi + + # If users don't want to submit the logs (or Steam ID is invalid), + # just save them locally and bail out. + if [ "${LOG_SUBMISSION}" -eq 0 ]; then + rm -rf "${KDUMP_LOGS_FOLDER}" + save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}" fi # Construct the POST request fields... @@ -213,7 +234,7 @@ if [ ${LOGS_FOUND} -ne 0 ]; then # Bail out in case we have network issues if [ ${LOOP_CNT} -ge ${MAX_LOOP} ]; then logger "kdump-steamos: network issue - cannot send logs" - exit 0 + save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}" fi CURL_ERR="${KDUMP_MAIN_FOLDER}/.curl_err" @@ -224,7 +245,8 @@ if [ ${LOGS_FOUND} -ne 0 ]; then if ! curl -X POST -d "${POST_REQ}" "${START_URL}" 1>"${RESPONSE_FILE}" 2>"${CURL_ERR}"; then logger "kdump-steamos: curl issues - failed in the log submission POST (err=$?)" #rm -f "${RESPONSE_FILE}" # keep this for now, as debug information - exit 0 + + save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}" fi RESPONSE_PUT_URL="$(jq -r '.response.url' "${RESPONSE_FILE}")" @@ -238,7 +260,8 @@ if [ ${LOGS_FOUND} -ne 0 ]; then if [ "${PUT_HEADERS_LEN}" -le 0 ] || [ "${PUT_HEADERS_LEN}" -gt 20 ]; then logger "kdump-steamos: unsupported number of response headers (${PUT_HEADERS_LEN}), aborting..." #rm -f "${RESPONSE_FILE}" # keep this for now, as debug information - exit 0 + + save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}" fi LOOP_CNT=0 @@ -254,23 +277,28 @@ if [ ${LOGS_FOUND} -ne 0 ]; then if ! curl -X PUT --data-binary "@${LOG_FNAME}" -H "@${CURL_PUT_HEADERS}" "${RESPONSE_PUT_URL}" 1>/dev/null 2>"${CURL_ERR}"; then logger "kdump-steamos: curl issues - failed in the log submission PUT (err=$?)" #rm -f "${CURL_PUT_HEADERS}" # keep this for now, as debug information - exit 0 + + save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}" fi - rm -f "${CURL_PUT_HEADERS}" if ! curl -X POST -d "gid=${RESPONSE_GID}" "${FINISH_URL}" 1>/dev/null 2>"${CURL_ERR}"; then logger "kdump-steamos: curl issues - failed in the log finish POST (err=$?)" - exit 0 + #rm -f "${CURL_PUT_HEADERS}" # keep this for now, as debug information + + save_locally_and_bail "${NOT_SENT_FLD}" "${LOG_FNAME}" fi # If we reached this point, the zipped log should have been submitted # succesfully; save a local copy as well. # TODO: implement a clean-up routine to just keep up to N logs... + rm -f "${CURL_PUT_HEADERS}" rm -f "${CURL_ERR}" - SENT_FLD="${KDUMP_MAIN_FOLDER}/sent_logs/" mkdir -p "${SENT_FLD}" + logger "kdump-steamos: successfully submitted crash logs to Valve" + mv "${LOG_FNAME}" "${SENT_FLD}" - logger "kdump-steamos: successfully submitted crash log to Valve" + LOG_FNAME="$(basename "${LOG_FNAME}")" + logger "kdump-steamos: logs also saved locally (${SENT_FLD}/${LOG_FNAME})" fi