Przeglądaj źródła

Optionally recover keys from a master keydrive during interactive install

Bob Mottram 8 lat temu
rodzic
commit
f57f273519
2 zmienionych plików z 30 dodań i 4 usunięć
  1. 1
    0
      src/freedombone-config
  2. 29
    4
      src/freedombone-utils-keys

+ 1
- 0
src/freedombone-config Wyświetl plik

@@ -1067,6 +1067,7 @@ function interactive_config {
1067 1067
     choose_dynamic_dns
1068 1068
     choose_default_domain_name
1069 1069
     choose_email_address
1070
+    interactive_key_recovery
1070 1071
 
1071 1072
     # delete the temporary configuration file
1072 1073
     if [ -f temp.cfg ]; then

+ 29
- 4
src/freedombone-utils-keys Wyświetl plik

@@ -126,10 +126,19 @@ function interactive_gpg_from_usb {
126 126
             fi
127 127
         fi
128 128
 
129
+        if [ -d $GPG_USB_MOUNT/letsencrypt ]; then
130
+            if [ ! -d /etc/letsencrypt ]; then
131
+                mkdir /etc/letsencrypt
132
+            fi
133
+            echo $'Recovering LetsEncrypt keys'
134
+            cp -r $GPG_USB_MOUNT/letsencrypt/* /etc/letsencrypt
135
+        fi
136
+
129 137
         if [ -d $GPG_USB_MOUNT/.gnupg ]; then
130 138
             if [ ! -d $HOME_DIR/.gnupg ]; then
131 139
                 mkdir $HOME_DIR/.gnupg
132 140
             fi
141
+            echo $'Recovering GPG keys'
133 142
             cp -r $GPG_USB_MOUNT/.gnupg/* $HOME_DIR/.gnupg
134 143
             GPG_LOADING="no"
135 144
             dialog --title $"Recover Encryption Keys" \
@@ -170,14 +179,14 @@ function interactive_gpg_from_remote {
170 179
     ${PROJECT_NAME}-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
171 180
 
172 181
     if [ ! -f $REMOTE_SERVERS_LIST ]; then
173
-        dialog --title $"Encryption keys" --msgbox $'Error obtaining server list' 6 70
182
+        dialog --title $"Encryption Keys Recovery" --msgbox $'Error obtaining server list' 6 70
174 183
         return 1
175 184
     fi
176 185
 
177 186
     # check the number of entries in the file
178 187
     no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
179 188
     if (( no_of_servers < 3 )); then
180
-        dialog --title $"Encryption keys" \
189
+        dialog --title $"Encryption Keys Recovery" \
181 190
                --msgbox $'There must be at least three servers to recover the key' 6 70
182 191
         return 2
183 192
     fi
@@ -186,11 +195,11 @@ function interactive_gpg_from_remote {
186 195
     apt-get -yq install libgfshare-bin gnupg
187 196
     ${PROJECT_NAME}-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
188 197
     if [ ! "$?" = "0" ]; then
189
-        dialog --title $"Encryption keys" --msgbox $'Your key could not be recovered' 6 70
198
+        dialog --title $"Encryption Keys Recovery" --msgbox $'Your key could not be recovered' 6 70
190 199
         return 3
191 200
     fi
192 201
 
193
-    dialog --title $"Encryption keys" --msgbox $'Your key has been recovered' 6 70
202
+    dialog --title $"Encryption Keys Recovery" --msgbox $'Your key has been recovered' 6 70
194 203
 
195 204
     return 0
196 205
 }
@@ -227,4 +236,20 @@ function interactive_gpg {
227 236
     done
228 237
 }
229 238
 
239
+function interactive_key_recovery {
240
+    data=$(tempfile 2>/dev/null)
241
+    trap "rm -f $data" 0 1 2 5 15
242
+
243
+    dialog --title $"Encryption Keys Recovery" \
244
+           --backtitle $"Freedombone Configuration" \
245
+           --defaultno \
246
+           --yesno $"Do you wish to recover your previous encryption keys from a USB master keydrive?" 7 60
247
+    sel=$?
248
+    case $sel in
249
+        1) return;;
250
+        255) return;;
251
+    esac
252
+    ${PROJECT_NAME}-recoverkey -u $MY_USERNAME
253
+}
254
+
230 255
 # NOTE: deliberately there is no "exit 0"