diff --git a/src/freedombone-keydrive b/src/freedombone-keydrive index 587e2671..5926d73d 100755 --- a/src/freedombone-keydrive +++ b/src/freedombone-keydrive @@ -145,17 +145,17 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]]; export GPG_TTY USER_EMAIL_ADDRESS=$MY_USERNAME@$HOSTNAME - GPG_ID=$(gpg --list-keys $USER_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//') - GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//') + GPG_ID=$(su -m root -c "gpg --list-keys $USER_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//'" - $MY_USERNAME) + GPG_BACKUP_ID=$(su -m root -c "gpg --list-keys \"(backup key)\" | sed -n '2p' | sed 's/^[ \t]*//'" - $MY_USERNAME) gpgerrstr=$'error' - gpgkey=$(gpg --armor --export $GPG_ID) + gpgkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export $GPG_ID) if [[ "$gpgkey" == *"$gpgerrstr"* ]]; then echo $'Problem exporting public gpg key' echo "$gpgkey" exit 735282 fi - gpgprivkey=$(gpg --armor --export-secret-key $GPG_ID) + gpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_ID) if [[ "$gpgprivkey" == *"$gpgerrstr"* ]]; then echo $'Problem exporting private gpg key' echo "$gpgprivkey" @@ -163,17 +163,17 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]]; exit 629362 fi - backupgpgkey=$(gpg --armor --export $GPG_BACKUP_ID) + backupgpgkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export $GPG_BACKUP_ID) if [[ "$backupgpgkey" == *"$gpgerrstr"* ]]; then echo $'Problem exporting public gpg backup key' echo "$backupgpgkey" exit 735282 fi - backupgpgprivkey=$(gpg --armor --export-secret-key $GPG_BACKUP_ID) + backupgpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_BACKUP_ID) if [[ "$backupgpgprivkey" == *"$gpgerrstr"* ]]; then echo $'Problem exporting private gpg backup key' echo "$backupgpgprivkey" - gpgprivkey= + backupgpgprivkey= exit 629362 fi diff --git a/src/freedombone-recoverkey b/src/freedombone-recoverkey index c02011bb..aa618157 100755 --- a/src/freedombone-recoverkey +++ b/src/freedombone-recoverkey @@ -174,7 +174,7 @@ fi echo $'Key fragments recombined' # import the gpg key -su -c "gpg --allow-secret-key-import --import $KEYS_FILE" - $MY_USERNAME +gpg --homedir=/home/$MY_USERNAME/.gnupg --allow-secret-key-import --import $KEYS_FILE if [ ! "$?" = "0" ]; then echo $'Unable to import gpg key' shred -zu $KEYS_FILE