aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2019-01-30 15:01:25 -0200
committerSilvio Rhatto <rhatto@riseup.net>2019-01-30 15:01:25 -0200
commitefd2b4887d30fb9163bb14dffe8312e4a2097b2a (patch)
tree247cfaa26950d8579abd86a4502ca08d4862cbe8 /lib
parenta5e39bf904e83989b763f001a29adb9053df60f2 (diff)
parentbfb19958de60135f98deec6089cd291b43ba9d9c (diff)
downloadkeyringer-efd2b4887d30fb9163bb14dffe8312e4a2097b2a.tar.gz
keyringer-efd2b4887d30fb9163bb14dffe8312e4a2097b2a.tar.bz2
New upstream version 0.5.4upstream_keyringer_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