Pārlūkot izejas kodu

Update muttrc after key reconstruction

Bob Mottram 7 gadus atpakaļ
vecāks
revīzija
e4304ced42
2 mainītis faili ar 19 papildinājumiem un 3 dzēšanām
  1. 14
    0
      src/freedombone-utils-gpg
  2. 5
    3
      src/freedombone-utils-keys

+ 14
- 0
src/freedombone-utils-gpg Parādīt failu

@@ -28,6 +28,20 @@
28 28
 # You should have received a copy of the GNU Affero General Public License
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31
+function gpg_update_mutt {
32
+    key_username=$1
33
+
34
+    if [ ! -f /home/$key_username/.muttrc ]; then
35
+        return
36
+    fi
37
+
38
+    CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME
39
+    CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
40
+
41
+    sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
42
+    chown $key_username:$key_username /home/$key_username/.muttrc
43
+}
44
+
31 45
 function gpg_import_public_key {
32 46
     key_username=$1
33 47
     key_filename=$2

+ 5
- 3
src/freedombone-utils-keys Parādīt failu

@@ -36,6 +36,7 @@ function interactive_gpg_from_usb {
36 36
     GPG_LOADING="yes"
37 37
     SSH_IMPORTED="no"
38 38
     GPG_CTR=0
39
+
39 40
     while [[ $GPG_LOADING == "yes" ]]
40 41
     do
41 42
         detect_usb_drive
@@ -43,6 +44,7 @@ function interactive_gpg_from_usb {
43 44
         if [ ! -b $USB_DRIVE ]; then
44 45
             if (( GPG_CTR > 0 )); then
45 46
                 gpg_reconstruct_key $MY_USERNAME interactive
47
+                gpg_update_mutt $MY_USERNAME
46 48
                 return 0
47 49
             fi
48 50
             dialog --title $"Recover Encryption Keys" --msgbox $'No USB drive found' 6 30
@@ -68,6 +70,7 @@ function interactive_gpg_from_usb {
68 70
                 if (( GPG_CTR > 0 )); then
69 71
                     backup_unmount_drive ${USB_DRIVE}
70 72
                     gpg_reconstruct_key $MY_USERNAME interactive
73
+                    gpg_update_mutt $MY_USERNAME
71 74
                     return 0
72 75
                 fi
73 76
                 dialog --title $"Recover Encryption Keys" \
@@ -94,7 +97,7 @@ function interactive_gpg_from_usb {
94 97
                 echo $'No backup key file found on USB drive'
95 98
                 exit 725729
96 99
             fi
97
-            CURR_EMAIL_ADDRESS=$USER@$HOSTNAME
100
+            CURR_EMAIL_ADDRESS=$MY_USERNAME@$HOSTNAME
98 101
             CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
99 102
             CURR_GPG_BACKUP_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
100 103
 
@@ -118,8 +121,7 @@ function interactive_gpg_from_usb {
118 121
                 echo $'Setting permissions'
119 122
                 gpg_set_permissions $MY_USERNAME
120 123
                 echo $"Updating muttrc for $MY_USERNAME"
121
-                CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
122
-                sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc
124
+                gpg_update_mutt $MY_USERNAME
123 125
             fi
124 126
             GPG_LOADING="no"
125 127
             dialog --title $"Recover Encryption Keys" \