rubymta 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1601cb4b77cb390064b8a90aaec523a6bdf3c993
4
- data.tar.gz: 764b1ccf31bfbb1b3386f9ec42a61510ee5a7edc
3
+ metadata.gz: 5365c89f03c443c663b6910c77d8766e007428dc
4
+ data.tar.gz: e15eb994bef497cde1e7035e729ba50e5109edf2
5
5
  SHA512:
6
- metadata.gz: eda93abc4e139bec74e5ef868ff3ed2449832557c24948856158a51ad170ec0e0dde2e88feb81dadad1b6e71d160646ed09501d118bebbe14e018556255cb88f
7
- data.tar.gz: f1c860ab3f0e7b44da1bc34109e6a2583a641521a30a64eed331894168ca05f42a831e6c0d652d6f0d16a445a88401d1b1eb27bf6a137b89a1605c0dabdfbb73
6
+ metadata.gz: 783ffeac1b863c66e6d81aa96f314aca7954029a7d6f1bc3aaf96c8aefd3edeb8c4332812efdcaabe913d9285577e96e6824a0eff565310831432ff57aa094da
7
+ data.tar.gz: a83ca9f014ae626de9f52faba9f9fc622a1664889ceadbb4855a70f1c12709d14717a90ae9cafec6e7c5901deaa24e5460a9c8807b0b4440936b6916d1799e76
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v0.0.11
2
+
3
+ * Changed the STARTTLS to return a 500 error and continue processing. Before this change, it just erred out and closed the port with no feedback to the client. Because this error returns a 500 level error, the client is (ideally) expected to quit or restart the attempt from the beginning (at EHLO).
4
+ * if `e` is in a string like so: `"... #{e} ..."`, it doesn't require a `.to_s` because `#{}` does a `.to_s`. Changed all non-conforming strings to conform to this rule. Exception: where `e` is found in `rescue => e`, it takes the form `"... #{e.inspect} ..."` so that the actual error class will be displayed (so you'll know what specific rescue may be added).
5
+ * moved the initialization code for $ctx out of the `listening_thread` because it only needs to be set once, not for each port.
6
+
7
+
1
8
  # v0.0.10
2
9
 
3
10
  #### Warning: This version changes the queue file format. Previous queue files will *not* be compatible with this version.
@@ -145,9 +145,9 @@ class String
145
145
  end
146
146
  return "250 #{welcome.chomp[4..-1]}"
147
147
  rescue SocketError => e
148
- return "421 Service not available (#{e.to_s})"
148
+ return "421 Service not available (#{e})"
149
149
  rescue Timeout::Error => e
150
- return "421 Service not available (#{e.to_s})"
150
+ return "421 Service not available (#{e})"
151
151
  end
152
152
  end
153
153
 
@@ -76,7 +76,7 @@ class ItemOfMail < Hash
76
76
  end
77
77
  return true
78
78
  rescue => e
79
- LOG.error(self[:mail_id]) {e.to_s}
79
+ LOG.error(self[:mail_id]) {e.inspect}
80
80
  e.backtrace.each { |line| LOG.error(self[:mail_id]) {line} }
81
81
  return false
82
82
  end
@@ -101,7 +101,7 @@ class ItemOfMail < Hash
101
101
  end
102
102
  self[:saved] = true
103
103
  rescue => e
104
- LOG.error(self[:mail_id]) {e.to_s}
104
+ LOG.error(self[:mail_id]) {e.inspect}
105
105
  e.backtrace.each { |line| LOG.error(self[:mail_id]) {line} }
106
106
  return false
107
107
  end
@@ -135,7 +135,7 @@ class ItemOfMail < Hash
135
135
  item = ItemOfMail::new(mail)
136
136
  item[:data][:text] = b
137
137
  rescue => e
138
- LOG.error(mail_id) {e.to_s}
138
+ LOG.error(mail_id) {e.inspect}
139
139
  e.backtrace.each { |line| LOG.error(mail_id) {line} }
140
140
  end
141
141
  return item
@@ -60,10 +60,10 @@ class Receiver
60
60
  return text[0]
61
61
  end
62
62
  rescue Errno::EPIPE => e
63
- LOG.error(@mail[:mail_id]) {"#{e.to_s}#{Unexpectedly}"}
63
+ LOG.error(@mail[:mail_id]) {"#{e}#{Unexpectedly}"}
64
64
  raise Quit
65
65
  rescue Errno::EIO => e
66
- LOG.error(@mail[:mail_id]) {"#{e.to_s}#{Unexpectedly}"}
66
+ LOG.error(@mail[:mail_id]) {"#{e}#{Unexpectedly}"}
67
67
  raise Quit
68
68
  end
69
69
  end
@@ -97,7 +97,7 @@ class Receiver
97
97
  return text
98
98
  end
99
99
  rescue Errno::EIO => e
100
- LOG.error(@mail[:mail_id]) {"#{e.to_s}#{Unexpectedly}"}
100
+ LOG.error(@mail[:mail_id]) {"#{e}#{Unexpectedly}"}
101
101
  raise Quit
102
102
  rescue Timeout::Error => e
103
103
  LOG.info(@mail[:mail_id]) {" -> <eod>"} if LogReceiverConversation
@@ -235,13 +235,10 @@ class Receiver
235
235
  @contact.violation
236
236
  send_text(response)
237
237
  end
238
- rescue =>e #OpenSSL::SSL::SSLError => e
239
- LOG.error(@mail[:mail_id]) {"SSL error: #{e.to_s}"}
240
- e.backtrace.each { |line| LOG.error(@mail[:mail_id]) {line} }
241
- @done = true
242
238
  end until @done
239
+
243
240
  rescue => e
244
- LOG.fatal(@mail[:mail_id]) {e.to_s}
241
+ LOG.fatal(@mail[:mail_id]) {e.inspect}
245
242
  exit(1)
246
243
  end
247
244
 
@@ -272,7 +269,7 @@ class Receiver
272
269
  if ok
273
270
  pid = Process::spawn("#{$app[:path]}/run_queue.rb")
274
271
  Process::detach(pid)
275
- LOG.info(@mail[:mail_id]) {"Spawned run_queue.rb, pwd=#{`pwd`}, path=>#{$app[:path]}, pid=>#{pid.inspect}"}
272
+ LOG.info(@mail[:mail_id]) {"Spawned run_queue.rb, pwd=#{`pwd`.chomp}, path=>#{$app[:path]}, pid=>#{pid.inspect}"}
276
273
  end
277
274
  end
278
275
 
@@ -622,14 +619,16 @@ class Receiver
622
619
  def starttls(value)
623
620
  send_text("220 2.0.0 TLS go ahead")
624
621
  LOG.info(@mail[:mail_id]) {"<-> (handshake)"} if LogReceiverConversation
622
+ conn = @connection.clone # save the unencrypted connection in case of error
625
623
  begin
626
624
  @connection.accept
627
- @encrypted = true
628
- @mail[:encrypted] = true
629
- rescue => e
630
- LOG.error(@mail[:mail_id]) {e.inspect}
625
+ @mail[:encrypted] = @encrypted = true
631
626
  rescue OpenSSL::SSL::SSLError => e
632
- LOG.error(@mail[:mail_id]) {e.to_s}
627
+ # STARTTLS failed: restore the unencrypted connection
628
+ LOG.error(@mail[:mail_id]) {"Error during STARTTLS: #{e}"}
629
+ @connection = conn # restore original
630
+ @mail[:encrypted] = @encrypted = false
631
+ return "500 5.0.0 STARTTLS failed: #{e}"
633
632
  end
634
633
  return nil
635
634
  end
@@ -148,11 +148,6 @@ class Server
148
148
  # argument passed to it -- it can be '<ipv6>/<port>', '<ipv4>:<port>', or just '<port>'
149
149
  def listening_thread(local_port)
150
150
  LOG.info("%06d"%Process::pid) {"listening on port #{local_port}..."}
151
-
152
- # establish an SSL context
153
- $ctx = OpenSSL::SSL::SSLContext.new
154
- $ctx.key = $prv
155
- $ctx.cert = $crt
156
151
 
157
152
  # check the parameter to see if it's valid
158
153
  m = /^(([0-9a-fA-F]{0,4}:{0,1}){1,8})\/([0-9]{1,5})|(([0-9]{1,3}\.{0,1}){4}):([0-9]{1,5})|([0-9]{1,5})$/.match(local_port)
@@ -242,6 +237,11 @@ class Server
242
237
  $prv = if PrivateKey then OpenSSL::PKey::RSA.new File.read(PrivateKey) else nil end
243
238
  $crt = if Certificate then OpenSSL::X509::Certificate.new File.read(Certificate) else nil end
244
239
 
240
+ # establish an SSL context for use in `listening_thread`
241
+ $ctx = OpenSSL::SSL::SSLContext.new
242
+ $ctx.key = $prv
243
+ $ctx.cert = $crt
244
+
245
245
  # daemonize it if the option was set--it doesn't have to be root to daemonize it
246
246
  Process::daemon if @options.daemonize
247
247
 
@@ -1,5 +1,5 @@
1
1
  module Version
2
- VERSION = "0.0.10"
3
- MODIFIED = "2017-10-18"
2
+ VERSION = "0.0.11"
3
+ MODIFIED = "2017-10-21"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubymta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Welch, Ph.D.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2017-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RubyMta is an experimental mail transport agent written in Ruby. See
14
14
  the README.