rubymta 0.0.14 → 0.0.15

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: a72d1a4230d77bdb5c749ec57da73a347f90b1d8
4
- data.tar.gz: a489c579a7e349dd2ef556ac0d431cfaded35d61
3
+ metadata.gz: 0b111a36b3145f824bf81193bb2814bea8ec8e96
4
+ data.tar.gz: 981638f013c0d26b0cc09316041cfdc4e35c3334
5
5
  SHA512:
6
- metadata.gz: 74fa503dd6aa4e0ac0fd4a8b35f1e3defa8a89400d2763e5f561690890c3d9b3f1d0e7495072e8c99b375f4114e2b580bff4cd047c8cf405e3d2fe3bff333000
7
- data.tar.gz: d402fb86f2d46cdc3b8013ea40909c8ea0ccacd0e731e46388d45579d55d649e470687455b3f5379f009d79b9e7bee379f8cd1a55f819016c40f9d671919ddb2
6
+ metadata.gz: 11b8812e113d116da43c3778f72b655ac0e731fdcb98d147c6e3d352524d61dadb480447594748bec0bb38ba59733f2803941e3224abdf142bf295d6c3d12209
7
+ data.tar.gz: f19e0dff3bc40cf2ccc26d92a4588a7057abcffb167bd4820ee9276e67c551b8be2f65558281431314c4c4456a572bfbe661c01629cdd73ba1622c1220eff071
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v0.0.15
2
+
3
+ * Added a rescue for `Server::listening_thread`, at `getnameinfo` to catch errors where the IP address doesn't point to any DNS records. This error is ignored and `hostname` is set to `(none)`. No harm is done because the `hostname` is only used for log messages.
4
+ * Fixed 3 small errors in `queue_runner`.
5
+ * Changed the `Receiver.receive code to convert incomming text to UTF-8 rather than just test for it. A surprising number of emails will contain invalid codeset characters.
6
+
7
+
8
+ # v0.0.14
9
+
10
+ * Took away the check for valid_encoding?, and added a call to convert any characters that are illegal in UTF-8 to '?' as the mail is being stored. This allows email from legacy email generators (that sometimes add strange characters) to still pass when they have illegal characters. It may break some DKIM checks, but that's unavoidable.
11
+
12
+
1
13
  # v0.0.13
2
14
 
3
15
  * Removed code (by commenting it out) that saves partially received emails. I originally added it to help see what *exactly* spammers were sending that caused program faults. In my opinion, it's no longer needed.
@@ -111,6 +111,9 @@ class ItemOfMail < Hash
111
111
  end
112
112
 
113
113
  def self::retrieve_mail_from_queue_folder(mail_id)
114
+ m = mail_id.match(/^[0-9A-Za-z]{6}.[0-9A-Za-z]{6}.[0-9A-Za-z]{2}$/)
115
+ raise ArgumentError.new("*666* #{mail_id.inspect} is invalid") if m.nil?
116
+
114
117
  item = nil
115
118
  begin
116
119
  # Make sure the file that matches the parcel record exists
@@ -124,6 +127,10 @@ class ItemOfMail < Hash
124
127
  end
125
128
 
126
129
  tmp = nil; File::open("#{MailQueue}/#{mail_id}","r") { |f| tmp = f.read }
130
+ if tmp.nil?
131
+ LOG.error(mail_id) {"Failed to read data in 'ItemOfMail::retrieve_mail_from_queue_folder'"}
132
+ end
133
+
127
134
  data = tmp.split("\n")
128
135
 
129
136
  # get the number of lines in the hash, and cut that out first
@@ -132,7 +139,16 @@ class ItemOfMail < Hash
132
139
  b = data[n+1..-1]
133
140
 
134
141
  # convert the hash
142
+ begin
135
143
  mail = eval(a.join("\n"))
144
+ rescue => e
145
+ LOG.error(mail_id) {"--> X800X file=>'#{MailQueue}/#{mail_id}'"}
146
+ LOG.error(mail_id) {"--> X800X tmp.size=>#{tmp.size}, tmp.class=>#{tmp.class.name}"}
147
+ LOG.error(mail_id) {"--> X800X data.size=>#{data.size}, data.class=>#{data.class.name}"}
148
+ LOG.error(mail_id) {"--> X800X e=>#{e.inspect}"}
149
+ LOG.error(mail_id) {"--> X800X a=>#{a.inspect}"}
150
+ return nil
151
+ end
136
152
 
137
153
  # create the ItemOfMail structure and insert the text
138
154
  item = ItemOfMail::new(mail)
@@ -213,7 +213,7 @@ class QueueRunner
213
213
  # ~> To: Jones@xyz.com
214
214
  # ~> From: John Q. Public <JQP@bar.com>
215
215
  # ~> Subject: test Thu, 24 Nov 2016 12:22:39 -0800
216
- # ~>
216
+ # ~>
217
217
  # ~> Bill:
218
218
  # ~> The next meeting of the board of directors will be
219
219
  # ~> on Tuesday.
@@ -276,7 +276,7 @@ class QueueRunner
276
276
  ok, lines = recv_text
277
277
  return mark_parcels(parcels, lines) if ok!='3'
278
278
 
279
- LOG.info(@mail_id) {"<- (data)"} if LogQueueRunnerConversation
279
+ LOG.info(@mail_id) {"<- (data)"} if !LogQueueRunnerConversation
280
280
  mail[:data][:text].each do |line|
281
281
  send_text(line, :data)
282
282
  end
@@ -286,8 +286,8 @@ class QueueRunner
286
286
 
287
287
  # get one final message for all parcels (recipients)
288
288
  ok, lines = recv_text
289
+ ret = mark_parcels(parcels, lines)
289
290
  if ok=='2'
290
- ret = mark_parcels(parcels, lines)
291
291
  LOG.info(@mail_id) {"Mail for #{parcels[0][:to_url]}, et.al. delivered remotely"}
292
292
  else
293
293
  LOG.info(@mail_id) {"Mail for #{parcels[0][:to_url]}, et.al. failed delivery remotely, #{lines.last}"}
@@ -315,7 +315,7 @@ class QueueRunner
315
315
  # ~> To: Jones@xyz.com
316
316
  # ~> From: John Q. Public <JQP@bar.com>
317
317
  # ~> Subject: test Thu, 24 Nov 2016 12:22:39 -0800
318
- # ~>
318
+ # ~>
319
319
  # ~> Bill:
320
320
  # ~> The next meeting of the board of directors will be
321
321
  # ~> on Tuesday.
@@ -374,8 +374,8 @@ class QueueRunner
374
374
  parcels.each do |parcel|
375
375
  # get the response from DoveCot
376
376
  ok, lines = recv_text
377
+ ret = mark_parcels([parcel], lines)
377
378
  if ok=='2'
378
- ret = mark_parcels([parcel], lines)
379
379
  LOG.info(@mail_id) {"Mail for #{parcel[:to_url]} delivered locally"}
380
380
  else
381
381
  LOG.info(@mail_id) {"Mail for #{parcel[:to_url]} failed delivery locally, #{lines.last}"}
@@ -80,12 +80,8 @@ class Receiver
80
80
  when temp.nil?
81
81
  LOG.warn(@mail[:mail_id]) {"The client abruptly closed the connection"}
82
82
  text = nil
83
- # when !temp.valid_encoding?
84
- # LOG.warn(@mail[:mail_id]) {"The client sent non-UTF-8 text"}
85
- # send_text("500 5.5.1 non-UTF-8 text detected")
86
- # raise Quit
87
83
  else
88
- text = temp.chomp
84
+ text = temp.chomp.utf8
89
85
  end
90
86
  rescue Errno::ECONNRESET => e
91
87
  LOG.warn(@mail[:mail_id]) {"The client slammed the connection shut"}
@@ -246,22 +242,6 @@ class Receiver
246
242
  (LOG.info(@mail[:mail_id]) { "Received Mail:\n#{@mail.pretty_inspect}" }) if DumpMailIntoLog
247
243
 
248
244
  ensure
249
- =begin # this is debugging logic
250
- # make sure the incoming email is saved, in case there was a receive error;
251
- # otherwise, it gets saved just before the "250 OK" in the DATA section
252
- if @mail && !@mail[:saved]
253
- LOG.error(@mail[:mail_id]) {"#{@mail[:mail_id]} was not received completely. Saving the partial copy to queue."}
254
-
255
- # the email is faulty--save for reference
256
- case
257
- when !@mail.insert_parcels
258
- LOG.error(@mail[:mail_id]) {"#{ServerName} error: unable to save packet id=#{@mail[:mail_id]}"}
259
- when !@mail.save_mail_into_queue_folder
260
- LOG.error(@mail[:mail_id]) {"#{ServerName} error: unable to save queue id=#{@mail[:mail_id]}"}
261
- end
262
- end
263
- =end
264
-
265
245
  # run the mail queue queue runner now, if it's not running already
266
246
  ok = nil
267
247
  File.open(LockFilePath,"w") do |f|
@@ -449,11 +429,6 @@ class Receiver
449
429
  break
450
430
  end
451
431
  break if text=="."
452
- # if !text.valid_encoding?
453
- # LOG.warn(@mail[:mail_id]) {"The client sent non-UTF-8 data"}
454
- # send_text("500 5.5.1 non-UTF-8 data detected")
455
- # raise Quit
456
- # end
457
432
  lines << text
458
433
  end
459
434
 
@@ -177,7 +177,12 @@ class Server
177
177
  Process::fork do
178
178
  begin
179
179
  drop_root_privileges if !UserName.nil?
180
- remote_hostname, remote_service = connection.io.remote_address.getnameinfo
180
+ begin
181
+ remote_hostname, remote_service = connection.io.remote_address.getnameinfo
182
+ rescue SocketError => e
183
+ LOG.info("%06d"%Process::pid) { e.to_s }
184
+ remote_hostname, remote_service = "(none)", nil
185
+ end
181
186
  remote_ip, remote_port = connection.io.remote_address.ip_unpack
182
187
  process_call(connection, local_port, remote_port.to_s, remote_ip, remote_hostname, remote_service)
183
188
  LOG.info("%06d"%Process::pid) {"Connection closed on port #{local_port} by #{ServerName}"}
@@ -1,5 +1,5 @@
1
1
  module Version
2
- VERSION = "0.0.14"
3
- MODIFIED = "2017-11-01"
2
+ VERSION = "0.0.15"
3
+ MODIFIED = "2017-11-11"
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.14
4
+ version: 0.0.15
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-11-01 00:00:00.000000000 Z
11
+ date: 2017-11-11 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.