From 61fdab85be8c6b2346737b122e43e7e72526327f Mon Sep 17 00:00:00 2001 From: Narrat Date: Sun, 7 Jan 2018 20:03:04 +0100 Subject: [PATCH 1/4] Show only version of pinentry pinentry --version invocation includes License information. As the same applies for gpg, and the information is not displayed there, we should the same with pinentry. And tomb doesn't deal with the gpg sourcecode in any way. This closes #300 --- tomb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tomb b/tomb index 925c15a..1d7585c 100755 --- a/tomb +++ b/tomb @@ -3106,7 +3106,7 @@ main() { cat < Date: Sun, 7 Jan 2018 20:53:20 +0100 Subject: [PATCH 2/4] list_gnupg_ciphers: Pipe everything into /dev/null Firstly the printed binary path is in the wrong place. Reading the text, one assumes Ciphers coming next. Secondly it doesn't make sense to check there for a missing gnupg installation. Before calling list_gnupg_ciphers(), there is a direct call for gpg --version. If that fails the whole text is scrambled and no error reported Dropping the output from which allows to remove the space from printing the ciphers. The text is correctly aligned now --- tomb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tomb b/tomb index 1d7585c..771007c 100755 --- a/tomb +++ b/tomb @@ -1360,7 +1360,7 @@ gen_key() { # prints an array of ciphers available in gnupg (to encrypt keys) list_gnupg_ciphers() { # prints an error if GnuPG is not found - which gpg 2>/dev/null || _failure "gpg (GnuPG) is not found, Tomb cannot function without it." + which gpg &>/dev/null || _failure "gpg (GnuPG) is not found, Tomb cannot function without it." ciphers=(`gpg --version | awk ' BEGIN { ciphers=0 } @@ -1368,7 +1368,7 @@ BEGIN { ciphers=0 } /^Hash:/ { ciphers=0 } { if(ciphers==0) { next } else { gsub(/,/,""); print; } } '`) - print " ${ciphers}" + print "${ciphers}" return 1 } From 5e3b0dec84f97b2031ee931f651ac0b2e3a574d5 Mon Sep 17 00:00:00 2001 From: Narrat Date: Sun, 7 Jan 2018 21:40:32 +0100 Subject: [PATCH 3/4] list_gnupg_ciphers: be language agnostic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old awk implementation always worked on lines beginning with 'Ciphers:' until it found 'Hash:'. This fails for locales where a respective gnupg2.mo entry exists (Example: Ciphers in german is translated as Verschlü.:). This is replaced by pointing awk on a specific line, which is for gpg1 and gpg2 the same. Work is done until awk stumbles up on a line which marks a new section (marked by keyword and :) This closes #299 --- tomb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tomb b/tomb index 771007c..e69b834 100755 --- a/tomb +++ b/tomb @@ -1362,10 +1362,12 @@ list_gnupg_ciphers() { # prints an error if GnuPG is not found which gpg &>/dev/null || _failure "gpg (GnuPG) is not found, Tomb cannot function without it." + # On gpg1 and gpg2 line 10 always point to available ciphers. + # Print those until the next section is found ciphers=(`gpg --version | awk ' BEGIN { ciphers=0 } -/^Cipher:/ { gsub(/,/,""); sub(/^Cipher:/,""); print; ciphers=1; next } -/^Hash:/ { ciphers=0 } +NR==11 { gsub(/,/,""); sub(/^.*:/,""); print; ciphers=1; next } +/^.*:/ { ciphers=0 } { if(ciphers==0) { next } else { gsub(/,/,""); print; } } '`) print "${ciphers}" From 08ca0a8eef95a4cbfa70da900cc41c8977d6168b Mon Sep 17 00:00:00 2001 From: Narrat Date: Sun, 7 Jan 2018 21:56:19 +0100 Subject: [PATCH 4/4] list_gnupg_ciphers: Remove check on gpg This function is called after _ensure_dependencies(), which would bail out if gpg is not found --- tomb | 3 --- 1 file changed, 3 deletions(-) diff --git a/tomb b/tomb index e69b834..232ec1f 100755 --- a/tomb +++ b/tomb @@ -1359,9 +1359,6 @@ gen_key() { # prints an array of ciphers available in gnupg (to encrypt keys) list_gnupg_ciphers() { - # prints an error if GnuPG is not found - which gpg &>/dev/null || _failure "gpg (GnuPG) is not found, Tomb cannot function without it." - # On gpg1 and gpg2 line 10 always point to available ciphers. # Print those until the next section is found ciphers=(`gpg --version | awk '