Project

General

Profile

« Previous | Next » 

Revision df41472b

Added by Marc Dequènes over 15 years ago

  • ID df41472b818aa0ba7449d072defe60c829d637ad

[evol] handle case when signed content is multipart and propagate other parts as refs for CommandParser

View differences:

postman
#
class CommandParser
def self.run(user, txt)
def self.run(user, txt, refs)
txt.each_line do |line|
line.chomp!
sline = line.strip
......
next
end
decoded_content = mail.pgp_signed_part().body
logger.debug "Proper signed content detected"
sig_check = mail.verify_pgp_signature()
if sig_check.status == 0
......
when 1
user = list.first
logger.info "Mail is from user #{user.uid} (#{user.cn})"
CommandParser.run(user, decoded_content)
signed_content = mail.pgp_signed_part()
if signed_content.multipart?
if signed_content.parts[0].content_type == "text/plain"
command_txt = signed_content.parts[0].body
command_refs = signed_content.parts.collect{|p| p.dup }
end
else
command_txt = signed_content.body if signed_content.content_type == "text/plain"
command_refs = []
end
if command_txt
CommandParser.run(user, command_txt, command_refs)
else
logger.info "Mail does not contain a proper MIME part for commands"
end
else
logger.warn "Multiple users match in database, so i guess there is a mistake. It is safer to skip..."
end

Also available in: Unified diff