Add Nextcloud bad-signature recovery toolkit

This commit is contained in:
2026-09-14 15:08:53 +02:00
parent c8997cc2e1
commit f108a71a80
5 changed files with 5477 additions and 13 deletions
+13 -13
View File
@@ -813,14 +813,8 @@ if ! $_revalidate_only_explicit && $terminal ; then
blank_line
echo -e "\033[37m\033[1mWhich mode should this run use?\033[m"
echo ""
echo -e " \033[1m[1] Recovery\033[m - decrypt bad-signature files (temporarily skips the
signature check), write them under
${DEFAULT_RECOVERY_BASE_DIR}/<website>
and validate them"
echo ""
echo " [2] Revalidate-only - re-run just the validation checks against files a previous
recovery run already wrote to disk (same as '-V'); nothing
is decrypted again and no config value is touched"
echo -e " \033[1m[1] Recovery\033[m - decrypt bad-signature files (temporarily skips the signature check), write them under ${DEFAULT_RECOVERY_BASE_DIR}/<website> and validate them"
echo " [2] Revalidate-only - re-run just the validation checks against files a previous recovery run already wrote to disk (same as '-V'); nothing is decrypted again and no config value is touched"
info "Just press Return to use the default: [1] Recovery."
echo -n " Select mode by number [1]: "
read _mode_choice
@@ -1425,9 +1419,9 @@ for _user in "${selected_user_arr[@]}" ; do
_local="${user_out_dir}/${_rel}"
if [[ -f "$_local" ]] ; then
_b=$(stat -c%s "$_local" 2> /dev/null)
echo -e "${_p}\t${_b:-0}\t${_osize}\tOK"
printf '%s\t%s\t%s\t%s\n' "$_p" "${_b:-0}" "$_osize" "OK"
else
echo -e "${_p}\t0\t${_osize}\tNOT_RECOVERED: no file found under ${user_out_dir} (run without -V first)"
printf '%s\t%s\t%s\t%s\n' "$_p" "0" "$_osize" "NOT_RECOVERED: no file found under ${user_out_dir} (run without -V first)"
fi
done < "$list_file"
} > "$user_result_tsv"
@@ -1484,7 +1478,13 @@ for _user in "${selected_user_arr[@]}" ; do
(( _user_read_errors++ ))
fi
echo -e "${_path}\t${_recbytes}\t${_origsize}\t${_status}\t${_val_class}\t${_val_detail}" >> "$recovery_report_file"
# printf, not 'echo -e': $_val_detail (or $_status for a
# READ_ERROR row) can contain a raw PHP exception message (e.g.
# 'OCA\Encryption\Exceptions\...') - 'echo -e' would reinterpret
# those backslashes as escape sequences and silently mangle/eat
# parts of the text. printf's %s never reinterprets its argument,
# only the literal \t in the format string itself.
printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$_path" "$_recbytes" "$_origsize" "$_status" "$_val_class" "$_val_detail" >> "$recovery_report_file"
done < "$user_result_tsv"
@@ -1522,7 +1522,7 @@ for _user in "${selected_user_arr[@]}" ; do
echo " Datenmuell (ungueltig) - Account ${_user} (${_user_invalid})"
echo " ------------------------------------------------------------------"
for _line in "${_user_invalid_lines[@]}" ; do
echo -e " ${_line}"
printf ' %s\n' "$_line"
done
fi
if [[ $_user_unverified -gt 0 ]] ; then
@@ -1531,7 +1531,7 @@ for _user in "${selected_user_arr[@]}" ; do
echo " Nicht pruefbar - Account ${_user} (${_user_unverified})"
echo " ------------------------------------------------------------------"
for _line in "${_user_unverified_lines[@]}" ; do
echo -e " ${_line}"
printf ' %s\n' "$_line"
done
fi
} >> "$recovery_report_file"