Package: dehydrated / 0.6.2-2+deb10u1

fixed-fetching-of-account-information-fixes-652-fixes-647.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: Lukas Schauer <lukas@schauer.so>
Date: Tue, 25 Jun 2019 12:19:20 +0200
Subject: fixed fetching of account information (fixes #652, fixes #647,
 fixes #650, closes #648)

---
 dehydrated | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dehydrated b/dehydrated
index 69057e7..a29910b 100755
--- a/dehydrated
+++ b/dehydrated
@@ -396,7 +396,16 @@ init_system() {
 
   # Read account information or request from CA if missing
   if [[ -e "${ACCOUNT_KEY_JSON}" ]]; then
+    if [[ -z "$(cat "${ACCOUNT_KEY_JSON}" | get_json_int_value id)" ]]; then
+      echo "+ Fetching account information..."
+      ACCOUNT_URL="$(signed_request "${CA_NEW_ACCOUNT}" '{"onlyReturnExisting": true}' 4>&1 | grep -i ^Location: | awk '{print $2}' | tr -d '\r\n')"
+      ACCOUNT_INFO="$(signed_request "${ACCOUNT_URL}" '{}')"
+      echo "${ACCOUNT_INFO}" > "${ACCOUNT_KEY_JSON}"
+    fi
     ACCOUNT_ID="$(cat "${ACCOUNT_KEY_JSON}" | get_json_int_value id)"
+    if [[ -z "${ACCOUNT_ID}" ]]; then
+      _exiterr "Unknown error on fetching account information"
+    fi
     if [[ ${API} -eq 1 ]]; then
       ACCOUNT_URL="${CA_REG}/${ACCOUNT_ID}"
     else