summarylogtreecommitdiffstats
path: root/log_gpg_warnings.patch
blob: fc3c039bc4fa1cf6a71d1dec358b0a4fdfce3157 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
diff --git a/lib/schleuder/gpgme/ctx.rb b/lib/schleuder/gpgme/ctx.rb
index 295f4de..0011112 100644
--- a/lib/schleuder/gpgme/ctx.rb
+++ b/lib/schleuder/gpgme/ctx.rb
@@ -211,7 +211,7 @@ module GPGME
       errors = []
       output = []
       base_cmd = gpg_engine.file_name
-      base_args = '--no-greeting --no-permission-warning --quiet --armor --trust-model always --no-tty --command-fd 0 --status-fd 1'
+      base_args = '--no-greeting --quiet --armor --trust-model always --no-tty --command-fd 0 --status-fd 1'
       cmd = [base_cmd, base_args, args].flatten.join(' ')
       Open3.popen3(cmd) do |stdin, stdout, stderr, thread|
         if block_given?
@@ -224,6 +224,16 @@ module GPGME
         exitcode = thread.value.exitstatus
       end
 
+      # Don't treat warnings as errors but log them.
+      errors = errors.map do |line|
+        if line.match?(/gpg: WARNING: (unsafe permissions on homedir|using insecure memory)/i)
+          Schleuder.logger.warn(line)
+          nil
+        else
+          line
+        end
+      end.compact
+
       [errors, output, exitcode]
     rescue Errno::ENOENT
       raise 'Need gpg in $PATH or in $GPGBIN'