mail-gpg 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9b7a9e0a92468331734266a6593036b8541560b
4
- data.tar.gz: d8f57974921bc967db1c74b137642261f74a36c0
3
+ metadata.gz: 078f6ded49865b4d9209f3287fc4a8847c93c440
4
+ data.tar.gz: 4933780b91d6e63c20f471f011dd27bdc8ad0552
5
5
  SHA512:
6
- metadata.gz: 8578a1a0906b5fee56751fc4d74ae00e6312106134e567633f2a35504c7cb24b676fda6c851074bf33fff8a0161682cfeef35275b2c62133471c0d6c6a730b84
7
- data.tar.gz: 56ee2a97e4bc93d1847273a659b928fd6a9c5a70d393d338b6e1e6a092d48d1da8682d2b52cdc7caf5b7581731fa94a049d9c3dac22fb4744f4507b87a7b785a
6
+ metadata.gz: 001a1eff43c868d332d3f88e880ffff134cc42dfe357e709172bc729049a3ca1e44037971781fc9a62480ca0deed913b842105ed22be78347060ffa8d05ffccd
7
+ data.tar.gz: c6da2c51dd13d9d119d8247a34876a30d0928f76f862cde51f93203872e20587f2bcf1df6480526aafb891767f6ca1ec4a6a394dddbe886b261ef77c00b511ec
@@ -1,10 +1,18 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- - 2.1.3
5
- - 2.0.0
6
- - 1.9.3
3
+ - 2.3.1
4
+ - 2.2.5
5
+ - 2.1.9
7
6
  env:
8
- - RAILS=3.2.21
9
- - RAILS=4.1.10
10
- - RAILS=4.2.1
7
+ - RAILS=3.2.22.1
8
+ - RAILS=4.1.14.1
9
+ - RAILS=4.2.5.1
10
+ - RAILS=5.0.0.1
11
+ matrix:
12
+ exclude:
13
+ - rvm: 2.1.9
14
+ env: RAILS=5.0.0.1
15
+ before_install:
16
+ - gem update bundler
17
+ sudo: false
18
+ cache: bundler
@@ -1,3 +1,10 @@
1
+ == 0.2.7 2016-09-28
2
+
3
+ * fix replying to message objects #35
4
+ * remove usage of deprecated alias_method_chain
5
+ * fix tests with Rails >= 4
6
+ * run tests with Rails 5, bump versions in travis config
7
+
1
8
  == 0.2.6 2015-10-20
2
9
 
3
10
  * fix handling of inline encrypted messages
data/README.md CHANGED
@@ -184,6 +184,42 @@ hkp.fetch_and_import(id)
184
184
  The gpg option takes the same arguments as outlined above for the
185
185
  Mail::Message#gpg method.
186
186
 
187
+
188
+ ## Passwords and GnuPG versions >= 2.x
189
+
190
+ GnuPG versions >= 2.x require the use of gpg-agent for key-handling. That's a problem for using password-protected keys non-interactively, because gpg-agent doesn't read from file-descriptors (which is the usual way to non-interactively provide passwords with GnuPG 1.x).
191
+
192
+ With GnuPG 2.x you have two options to provide passwords to gpg-agent:
193
+
194
+ 1. Implement a pinentry-kind-of program that speaks the assuan-protocol and configure gpg-agent to use it.
195
+ 2. Run gpg-preset-passphrase and allow gpg-agent to read preset passwords.
196
+
197
+ The second options is somewhat easier and is described below.
198
+
199
+ Note: You *don't* need this if your key is *not* protected with a password.
200
+
201
+
202
+ To feed a password into gpg-agent run this code early in your program:
203
+
204
+ ```ruby
205
+ # The next two lines need adaption, obviously.
206
+ fpr = fingerprint_of_key_to_unlock
207
+ passphrase = gpg_passphrase_for_key
208
+ # You may copy&paste the rest of this block unchanged. Maybe you want to change the error-handling, though.
209
+ ENV['GPG_AGENT_INFO'] = `eval $(gpg-agent --allow-preset-passphrase --daemon) && echo $GPG_AGENT_INFO`
210
+ `gpgconf --list-dir`.match(/libexecdir:(.*)/)
211
+ gppbin = File.join($1, 'gpg-preset-passphrase')
212
+ Open3.popen3(gppbin, '--preset', fpr) do |stdin, stdout, stderr|
213
+ stdin.puts passphrase
214
+ err = stderr.readlines
215
+ $stderr.puts err if ! err.to_s.empty?
216
+ end
217
+ # Hook to kill our gpg-agent when script finishes.
218
+ Signal.trap(0, proc { Process.kill('TERM', ENV['GPG_AGENT_INFO'].split(':')[1]) })
219
+
220
+ ```
221
+
222
+
187
223
  ## Running the tests
188
224
 
189
225
  bundle exec rake
@@ -101,7 +101,7 @@ module Mail
101
101
  end
102
102
 
103
103
  STANDARD_HEADERS = %w(from to cc bcc reply_to subject in_reply_to return_path message_id)
104
- MORE_HEADERS = %w(Auto-Submitted List-Id List-Unsubscribe References)
104
+ MORE_HEADERS = %w(Auto-Submitted OpenPGP References)
105
105
 
106
106
  private
107
107
 
@@ -117,7 +117,7 @@ module Mail
117
117
  header['Message-ID'] = cleartext_mail['Message-ID'].value
118
118
  end
119
119
  cleartext_mail.header.fields.each do |field|
120
- if MORE_HEADERS.include?(field.name) or field.name =~ /^X-/
120
+ if MORE_HEADERS.include?(field.name) or field.name =~ /^(List|X)-/
121
121
  header[field.name] = field.value
122
122
  end
123
123
  end
@@ -151,14 +151,14 @@ module Mail
151
151
 
152
152
  # decrypts inline PGP encrypted mail
153
153
  def self.decrypt_pgp_inline(encrypted_mail, options)
154
- InlineDecryptedMessage.new(encrypted_mail, options)
154
+ InlineDecryptedMessage.setup(encrypted_mail, options)
155
155
  end
156
156
 
157
157
  def self.verify(signed_mail, options = {})
158
158
  if signed_mime?(signed_mail)
159
- Mail::Gpg::MimeSignedMessage.new signed_mail, options
159
+ Mail::Gpg::MimeSignedMessage.setup signed_mail, options
160
160
  elsif signed_inline?(signed_mail)
161
- Mail::Gpg::InlineSignedMessage.new signed_mail, options
161
+ Mail::Gpg::InlineSignedMessage.setup signed_mail, options
162
162
  else
163
163
  signed_mail
164
164
  end
@@ -12,9 +12,9 @@ module Mail
12
12
  # options are:
13
13
  #
14
14
  # :verify: decrypt and verify
15
- def initialize(cipher_mail, options = {})
15
+ def self.setup(cipher_mail, options = {})
16
16
  if cipher_mail.multipart?
17
- super() do
17
+ self.new do
18
18
  cipher_mail.header.fields.each do |field|
19
19
  header[field.name] = field.value
20
20
  end
@@ -48,7 +48,7 @@ module Mail
48
48
  end # of multipart
49
49
  else
50
50
  decrypted = cipher_mail.body.empty? ? '' : GpgmeHelper.decrypt(cipher_mail.body.decoded, options)
51
- super() do
51
+ self.new do
52
52
  cipher_mail.header.fields.each do |field|
53
53
  header[field.name] = field.value
54
54
  end
@@ -4,9 +4,9 @@ module Mail
4
4
  module Gpg
5
5
  class InlineSignedMessage < Mail::Message
6
6
 
7
- def initialize(signed_mail, options = {})
7
+ def self.setup(signed_mail, options = {})
8
8
  if signed_mail.multipart?
9
- super() do
9
+ self.new do
10
10
  global_verify_result = []
11
11
  signed_mail.header.fields.each do |field|
12
12
  header[field.name] = field.value
@@ -29,7 +29,7 @@ module Mail
29
29
  verify_result global_verify_result
30
30
  end # of multipart
31
31
  else
32
- super() do
32
+ self.new do
33
33
  signed_mail.header.fields.each do |field|
34
34
  header[field.name] = field.value
35
35
  end
@@ -4,10 +4,10 @@ module Mail
4
4
  module Gpg
5
5
  class MimeSignedMessage < Mail::Message
6
6
 
7
- def initialize(signed_mail, options = {})
7
+ def self.setup(signed_mail, options = {})
8
8
  content_part, signature = signed_mail.parts
9
9
  success, vr = SignPart.verify_signature(content_part, signature, options)
10
- super() do
10
+ self.new do
11
11
  verify_result vr
12
12
  signed_mail.header.fields.each do |field|
13
13
  header[field.name] = field.value
@@ -2,6 +2,8 @@ begin
2
2
  require 'action_mailer'
3
3
  require 'active_support'
4
4
  require 'mail/gpg/rails/action_mailer_base_patch'
5
+
6
+ Mail::Gpg::Rails::ActionMailerPatch.apply
5
7
  rescue LoadError
6
8
  # no actionmailer, do nothing
7
9
  end
@@ -5,28 +5,29 @@ module Mail
5
5
  module Rails
6
6
 
7
7
  module ActionMailerPatch
8
- extend ActiveSupport::Concern
9
8
 
10
- included do
11
- alias_method_chain :mail, :gpg
12
- class << self
13
- alias_method_chain :deliver_mail, :gpg
9
+ def self.apply
10
+ unless ActionMailer::Base < InstanceMethods
11
+ ActionMailer::Base.prepend InstanceMethods
12
+ ActionMailer::Base.singleton_class.prepend ClassMethods
14
13
  end
15
14
  end
16
15
 
17
- def mail_with_gpg(headers = {}, &block)
18
- headers = headers.dup
19
- gpg_options = headers.delete :gpg
20
- mail_without_gpg(headers, &block).tap do |m|
21
- if gpg_options
22
- m.gpg gpg_options
16
+ module InstanceMethods
17
+ def mail(headers = {}, &block)
18
+ headers = headers.dup
19
+ gpg_options = headers.delete :gpg
20
+ super(headers, &block).tap do |m|
21
+ if gpg_options
22
+ m.gpg gpg_options
23
+ end
23
24
  end
24
25
  end
25
26
  end
26
27
 
27
28
  module ClassMethods
28
- def deliver_mail_with_gpg(mail, &block)
29
- deliver_mail_without_gpg(mail) do
29
+ def deliver_mail(mail, &block)
30
+ super(mail) do
30
31
  Mail::Gpg::DeliveryHandler.deliver_mail mail, &block
31
32
  end
32
33
  end
@@ -34,10 +35,6 @@ module Mail
34
35
 
35
36
  end
36
37
 
37
- unless ActionMailer::Base.included_modules.include?(ActionMailerPatch)
38
- ActionMailer::Base.send :include, ActionMailerPatch
39
- end
40
-
41
38
  end
42
39
  end
43
40
  end
@@ -1,5 +1,5 @@
1
1
  module Mail
2
2
  module Gpg
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ class GpgTest < Test::Unit::TestCase
14
14
  v_part, enc_part = encrypted.parts
15
15
 
16
16
  assert_match /Version: 1/, v_part.to_s
17
- assert_equal 'application/pgp-encrypted; charset=UTF-8', v_part.content_type
17
+ assert_match /application\/pgp-encrypted(?:; charset=UTF-8)?/, v_part.content_type
18
18
 
19
19
  assert_equal 'application/octet-stream; name=encrypted.asc',
20
20
  enc_part.content_type
Binary file
Binary file
@@ -74,13 +74,23 @@ class MessageTest < Test::Unit::TestCase
74
74
  context "" do
75
75
  setup do
76
76
  @mail.header['Auto-Submitted'] = 'foo'
77
+ @mail.header['List-Help'] = 'https://lists.example.org/help/'
78
+ @mail.header['List-Id'] = 'test.lists.example.org'
79
+ @mail.header['List-Owner'] = 'test-owner@lists.example.org'
80
+ @mail.header['List-Post'] = '<mailto:test@lists.example.org> (Subscribers only)'
77
81
  @mail.header['List-Unsubscribe'] = 'bar'
82
+ @mail.header['OpenPGP'] = 'id=0x0123456789abcdef0123456789abcdefdeadbeef (present on keyservers); (Only encrypted and signed emails are accepted)'
78
83
  @mail.deliver
79
84
  end
80
85
 
81
86
  should 'keep custom header value' do
82
87
  assert_equal 'foo', @mails.first.header['Auto-Submitted'].value
88
+ assert_equal 'https://lists.example.org/help/', @mails.first.header['List-Help'].value
89
+ assert_equal 'test.lists.example.org', @mails.first.header['List-Id'].value
90
+ assert_equal 'test-owner@lists.example.org', @mails.first.header['List-Owner'].value
91
+ assert_equal '<mailto:test@lists.example.org> (Subscribers only)', @mails.first.header['List-Post'].value
83
92
  assert_equal 'bar', @mails.first.header['List-Unsubscribe'].value
93
+ assert_equal 'id=0x0123456789abcdef0123456789abcdefdeadbeef (present on keyservers); (Only encrypted and signed emails are accepted)', @mails.first.header['OpenPGP'].value
84
94
  end
85
95
 
86
96
  should "deliver signed mail" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-gpg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Kraemer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-20 00:00:00.000000000 Z
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -229,4 +229,3 @@ test_files:
229
229
  - test/sign_part_test.rb
230
230
  - test/test_helper.rb
231
231
  - test/version_part_test.rb
232
- has_rdoc: