aboutsummaryrefslogtreecommitdiff
path: root/pkgs/crypto-wrapper/0001-Do-not-rely-on-sysinfo-file-that-is-not-available-ou.patch
blob: f902adee79e791fb391d89579cb2be352e5af262 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 20e8f70af32e23c59f54a1f712b7c517b6e0a9be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= <cynerd@email.cz>
Date: Mon, 3 Oct 2022 22:27:17 +0200
Subject: [PATCH] Do not rely on sysinfo file that is not available outside of
 OpenWrt

This instead uses just architecture to try to detect the correct OTP
type.
---
 crypto-wrapper.sh | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/crypto-wrapper.sh b/crypto-wrapper.sh
index 3a5deb4..4828f1b 100755
--- a/crypto-wrapper.sh
+++ b/crypto-wrapper.sh
@@ -12,7 +12,6 @@ SCRIPTNAME=${0##*/}
 HASH_TYPE='sha256'
 CRYPTO_WRAPPER_ROOT_PREFIX='/tmp/crypto_wrapper'
 
-SYSINFO_MODEL_FILE='/tmp/sysinfo/model'
 TYPE_ATSHA='atsha'
 TYPE_OTP='otp'
 
@@ -338,38 +337,25 @@ cached_otp_sign() {
 
 # --------------------------------------------------------------------
 get_device_type(){
-    local model
-
-    [ -f "$SYSINFO_MODEL_FILE" ] || {
-        error "Unknown device model; sysinfo file ($SYSINFO_MODEL_FILE) is missing"
-        return 2
-    }
-
-    model=$(cat "$SYSINFO_MODEL_FILE")
-    case "$model" in
-        # WARNING:
-        #   Turris string is also included in other models
-        #   This case must not include wildcards
-        Turris|Turris\ 1.?)
+    local arch
+    arch="$(uname -m)"
+    case "$arch" in
+        ppc)
             debug "Device recognized as Turris 1.x"
             echo "$TYPE_ATSHA"
             ;;
-
-        *Omnia*)
+        amrv7l)
             debug "Device recognized as Omnia"
             echo "$TYPE_ATSHA"
             ;;
-
-        *Mox*)
+        aarch64)
             debug "Device recognized as MOX"
             echo "$TYPE_OTP"
             ;;
-
         *)
-            error "Unknown device model: '$model'"
+            error "Unknown device architecture: '$arch'"
             return 2
             ;;
-
     esac
 }
 
-- 
2.37.3