aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-01-30 15:01:30 -0200
committerSilvio Rhatto <rhatto@riseup.net>2019-01-30 15:01:30 -0200
commit7472e865ef5975ef33d6aae4aea6fcda395016b5 (patch)
treed8fae0c630d6884895f5189f981b996dcbaf8ca3 /lib
parente4b30172df9c54e5672b901a6420de67ef8f76a0 (diff)
parentefd2b4887d30fb9163bb14dffe8312e4a2097b2a (diff)
downloadkeyringer-7472e865ef5975ef33d6aae4aea6fcda395016b5.tar.gz
keyringer-7472e865ef5975ef33d6aae4aea6fcda395016b5.tar.bz2
Merge tag 'upstream_keyringer_0.5.4' into debian
Upstream version 0.5.4
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/genkeys11
-rwxr-xr-xlib/keyringer/actions/shell2
-rwxr-xr-xlib/keyringer/functions4
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