Revision 2f1c6b5b
Added by Marc Dequènes almost 14 years ago
- ID 2f1c6b5bfb3ebbadde902db6e5d540530976de36
lib/cyborghood/mail.rb | ||
---|---|---|
class Mail < Delegator
|
||
include I18nTranslation
|
||
|
||
DEFAULT_MAX_DRIFT_TIME = 3600
|
||
|
||
attr_accessor :user, :signature_timestamp
|
||
|
||
def initialize(msg = nil)
|
||
... | ... | |
|
||
def process
|
||
if is_marked?
|
||
if not (@config.debug.nil? or @config.debug.flags.nil?) and @config.debug.flags.include?(:debug_ignorereplay)
|
||
if @config.debug.flags.include?('debug_ignorereplay')
|
||
logger.warn "Debug: ignoring replay"
|
||
else
|
||
return MailReport.new(:error => _("Replay detected."))
|
||
... | ... | |
def deliver
|
||
check_headers
|
||
|
||
smtp_server = @config.mail.smtp_server || "localhost"
|
||
smtp_port = @config.mail.smtp_port || 25
|
||
smtp_server = @config.mail.smtp_server
|
||
smtp_port = @config.mail.smtp_port
|
||
smtp_from = @mail.from_addrs.collect{|a| a.address}.join(", ")
|
||
smtp_to = @mail.to_addrs.collect{|a| a.address}
|
||
Net::SMTP.start(smtp_server, smtp_port) do |smtp|
|
||
... | ... | |
|
||
drift = Time.new.to_i - sig_check.timestamp.to_i
|
||
logger.debug "Signature drift time: #{drift}"
|
||
unless drift.abs < (@config.mail.max_drift_time || DEFAULT_MAX_DRIFT_TIME)
|
||
unless drift.abs < @config.mail.max_drift_time
|
||
if drift > 0
|
||
return MailReport.new(:error => _("The signature was made too long ago (check your system clock). Rejected message to avoid replay attacks."), :user => user)
|
||
else
|
Also available in: Unified diff
[evol] configuration defaults and schema checking (closes 21)