Skip to content

Commit

Permalink
Fix Mail::Exim, forgotten in 4875bc2
Browse files Browse the repository at this point in the history
The parameters of Mail::Sendmail.call changed in 4875bc2 but
Mail::Exim was not changed accordingly.

Backport to 2-6-stable

References #689
  • Loading branch information
jethrogb authored and jeremy committed May 17, 2017
1 parent ae405e3 commit 67ac9bb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 50 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Security:
* #1097 – SMTP security: prevent command injection via To/From addresses. (jeremy)

Bugs:
* #689 - Fix Exim delivery method broken by #477 in 2.5.4. (jethrogb)

== Version 2.6.5 - 2017-04-26 Jeremy Daer <jeremydaer@gmail.com>

Features:
Expand Down
16 changes: 6 additions & 10 deletions lib/mail/network/delivery_methods/exim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,13 @@ module Mail
#
# mail.deliver!
class Exim < Sendmail
def initialize(values)
self.settings = { :location => '/usr/sbin/exim',
:arguments => '-i -t' }.merge(values)
end
DEFAULTS = {
:location => '/usr/sbin/exim',
:arguments => '-i -t'
}

def self.call(path, arguments, destinations, mail)
popen "#{path} #{arguments}" do |io|
io.puts ::Mail::Utilities.to_lf(mail.encoded)
io.flush
end
def self.call(path, arguments, destinations, encoded_message)
super path, arguments, nil, encoded_message
end

end
end
8 changes: 6 additions & 2 deletions lib/mail/network/delivery_methods/sendmail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ module Mail
#
# mail.deliver!
class Sendmail
DEFAULTS = {
:location => '/usr/sbin/sendmail',
:arguments => '-i'
}

attr_accessor :settings

def initialize(values)
self.settings = { :location => '/usr/sbin/sendmail',
:arguments => '-i' }.merge(values)
self.settings = self.class::DEFAULTS.merge(values)
end

def deliver!(mail)
Expand Down
61 changes: 23 additions & 38 deletions spec/mail/network/delivery_methods/exim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
to 'marcel@test.lindsaar.net, bob@test.lindsaar.net'
subject 'invalid RFC2822'
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
'-i -t -f "roger@test.lindsaar.net" --',
'"marcel@test.lindsaar.net" "bob@test.lindsaar.net"',
mail.encoded)

expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', '-i -t -f "roger@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver!
end

Expand All @@ -51,14 +49,10 @@
message_id "<1234@test.lindsaar.net>"
body "body"
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
'-i -t -f "return@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail.encoded)

mail.deliver

expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', '-i -t -f "return@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver
end

it "should use the sender address is no return path is specified" do
Expand All @@ -75,14 +69,11 @@
body "body"
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
'-i -t -f "sender@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail.encoded)
expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', '-i -t -f "sender@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver
end

it "should use the from address is no return path or sender are specified" do
Mail.defaults do
delivery_method :exim
Expand All @@ -96,10 +87,8 @@
body "body"
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
'-i -t -f "from@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail.encoded)
expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', '-i -t -f "from@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver
end

Expand All @@ -116,10 +105,8 @@
body 'body'
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
'-i -t -f "\"from+suffix test\"@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail.encoded)
expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', '-i -t -f "\"from+suffix test\"@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver
end

Expand All @@ -133,10 +120,8 @@
from 'from@test.lindsaar.net'
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
'-i -t -f "from@test.lindsaar.net" --',
'"-hyphen@test.lindsaar.net"',
mail.encoded)
expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', '-i -t -f "from@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver
end
end
Expand All @@ -152,10 +137,8 @@
subject 'invalid RFC2822'
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
' -f "from@test.lindsaar.net" --',
'"marcel@test.lindsaar.net" "bob@test.lindsaar.net"',
mail.encoded)
expect(Mail::Sendmail).to receive(:call).with('/usr/sbin/exim', ' -f "from@test.lindsaar.net" --', nil, mail.encoded)

mail.deliver!
end

Expand All @@ -169,11 +152,13 @@
to 'marcel@test.lindsaar.net'
subject 'invalid RFC2822'
end

expect(Mail::Exim).to receive(:call).with('/usr/sbin/exim',
" -f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
'"marcel@test.lindsaar.net"',
mail.encoded)

expect(Mail::Sendmail).to receive(:call).with(
'/usr/sbin/exim',
" -f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
nil,
mail.encoded)

mail.deliver!
end

Expand Down

0 comments on commit 67ac9bb

Please sign in to comment.