diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/keyringer/actions/genkeys | 11 | ||||
-rwxr-xr-x | lib/keyringer/actions/shell | 2 | ||||
-rwxr-xr-x | lib/keyringer/functions | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/lib/keyringer/actions/genkeys b/lib/keyringer/actions/genkeys index deacbfd..addd10d 100755 --- a/lib/keyringer/actions/genkeys +++ b/lib/keyringer/actions/genkeys @@ -52,7 +52,7 @@ function genkeys_gpg { passphrase="`keyringer_exec decrypt "$BASEDIR" "$FILE.passwd"`" # TODO: insert random bytes - # TODO: custom Name-Comment and Name-Email + # TODO: custom Name-Email $GPG --homedir "$TMPWORK" --gen-key --batch <<EOF Key-Type: RSA Key-Length: 4096 @@ -66,8 +66,11 @@ function genkeys_gpg { EOF # Encrypt the result + # See https://superuser.com/questions/1135812/gpg2-asking-for-passphrase-when-importing-secret-keys#1135950 + # https://stackoverflow.com/questions/49072403/suppress-the-passphrase-prompt-in-gpg-command + # https://dev.gnupg.org/T2313 echo "Encrypting secret key into keyringer..." - $GPG --armor --homedir "$TMPWORK" --export-secret-keys | keyringer_exec encrypt "$BASEDIR" "$FILE" + echo -e "${passphrase}\n" | $GPG --armor --homedir "$TMPWORK" --passphrase-fd 0 --batch --no-tty --pinentry-mode=loopback --export-secret-keys | keyringer_exec encrypt "$BASEDIR" "$FILE" echo "Encrypting public key into keyringer..." $GPG --armor --homedir "$TMPWORK" --export | keyringer_exec encrypt "$BASEDIR" "$FILE.pub" #echo "Encrypting passphrase into keyringer..." @@ -76,8 +79,8 @@ EOF if [ ! -z "$OUTFILE" ]; then mkdir -p `dirname $OUTFILE` printf "Saving copies at %s and %s.pub\n" "$OUTFILE" "$OUTFILE" - $GPG --armor --homedir "$TMPWORK" --export-secret-keys > "$OUTFILE" - $GPG --armor --homedir "$TMPWORK" --export > "$OUTFILE.pub" + echo -e "${passphrase}\n" | $GPG --armor --homedir "$TMPWORK" --passphrase-fd 0 --batch --no-tty --pinentry-mode=loopback --export-secret-keys > "$OUTFILE" + $GPG --armor --homedir "$TMPWORK" --export > "$OUTFILE.pub" fi echo "Done" diff --git a/lib/keyringer/actions/shell b/lib/keyringer/actions/shell index 3b98d68..d87a638 100755 --- a/lib/keyringer/actions/shell +++ b/lib/keyringer/actions/shell @@ -15,6 +15,8 @@ keyringer_usage $KEYRING # While a "quit" command isn't entered, read STDIN while read -rep "keyringer:/${KEYRING}${SHELLPATH}> " STDIN; do + history -s "$STDIN" + if [ "$STDIN" == "quit" ] || [ "$STDIN" == "exit" ] || [ "$STDIN" == "bye" ]; then break elif [ "$STDIN" == "shell" ]; then diff --git a/lib/keyringer/functions b/lib/keyringer/functions index d529daf..308d0ea 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -314,9 +314,9 @@ function keyringer_set_env { fi if [ ! -z "$KEYID" ]; then - GPG="gpg --quiet -u $KEYID" + GPG="gpg --quiet --no-encrypt-to -u $KEYID" else - GPG="gpg --quiet" + GPG="gpg --quiet --no-encrypt-to" fi # Check keyring config version |