[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sup-devel] [PATCH] gpg related fixes (resubmitted)
I am resubmitting these patches. 0001-Give-gpg-a-known-suffix.patch
and 0001-Stop-worrying-notice-when-no-signature-present.patch are two
patches to replace the previous
0001-Stop-worrying-notice-when-no-signature-present.patch, though note
the known suffix patch is required for the second one to work.
And I didn't put [PATCH] in the subject line when I posted
0001-Deal-with-r-n-inside-encrypted-messages.patch so I'm attaching it
to this email in case the last one was missed due to workflow etc.
Hamish Downer
From 1c8cbcf77666c9cbe918876889a73e6db08a45ae Mon Sep 17 00:00:00 2001
From: Hamish Downer <dmishd@gmail.com>
Date: Sun, 17 Oct 2010 19:48:36 +0100
Subject: [PATCH] Deal with "\r\n" inside encrypted messages
RMail expects "\n\n" to be the dividing line between the header and
body, but sometimes the decrypted message has "\r\n" as line ending
so the RMail parsing does not work. This commit fixes that.
---
lib/sup/crypto.rb | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
index 386dbb8..3069483 100644
--- a/lib/sup/crypto.rb
+++ b/lib/sup/crypto.rb
@@ -170,6 +170,10 @@ EOS
end
msg.body = output
else
+ # It appears that some clients use Windows new lines - CRLF - but RMail
+ # splits the body and header on "\n\n". So to allow the parse below to
+ # succeed, we will convert the newlines to what RMail expects
+ output = output.gsub(/\r\n/, "\n")
# This is gross. This decrypted payload could very well be a multipart
# element itself, as opposed to a simple payload. For example, a
# multipart/signed element, like those generated by Mutt when encrypting
--
1.7.1
From f2cfc432879d6fe103f0327078ca70984a7eeb06 Mon Sep 17 00:00:00 2001
From: Hamish Downer <dmishd@gmail.com>
Date: Mon, 18 Oct 2010 19:35:41 +0100
Subject: [PATCH] Give gpg a known suffix
Give gpg a file to decrypt ending in ".asc" to stop gpg complaining
about "unknown suffix".
---
lib/sup/crypto.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
index 386dbb8..4222b8d 100644
--- a/lib/sup/crypto.rb
+++ b/lib/sup/crypto.rb
@@ -139,7 +139,7 @@ EOS
def decrypt payload, armor=false # a RubyMail::Message object
return unknown_status(cant_find_binary) unless @cmd
- payload_fn = Tempfile.new "redwood.payload"
+ payload_fn = Tempfile.new(["redwood.payload", ".asc"])
payload_fn.write payload.to_s
payload_fn.close
--
1.7.1
From 38e01f89178f06c3a29d494b56fe28c0aa82de81 Mon Sep 17 00:00:00 2001
From: Hamish Downer <dmishd@gmail.com>
Date: Sun, 17 Oct 2010 23:25:20 +0100
Subject: [PATCH] Stop worrying notice when no signature present
When no signature is present, there was a message saying
"Unable to determine validity of cryptographic signature".
This fix means that if there are no error messages and no
messages about signature verification then the message is
assumed to not be signed at all. This fix also saves the
encrypted messages to a temp file with a suffix of .asc
to stop gpg complaining about "unknown suffix".
---
lib/sup/crypto.rb | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
index 386dbb8..fd4c91c 100644
--- a/lib/sup/crypto.rb
+++ b/lib/sup/crypto.rb
@@ -108,6 +108,9 @@ EOS
else
Chunk::CryptoNotice.new :invalid, $1, output_lines
end
+ elsif output_lines.length == 0 && rc == 0
+ # the message wasn't signed
+ Chunk::CryptoNotice.new :valid, "Encrypted message wasn't signed", output_lines
else
unknown_status output_lines
end
@@ -139,7 +142,7 @@ EOS
def decrypt payload, armor=false # a RubyMail::Message object
return unknown_status(cant_find_binary) unless @cmd
- payload_fn = Tempfile.new "redwood.payload"
+ payload_fn = Tempfile.new(["redwood.payload", ".asc"])
payload_fn.write payload.to_s
payload_fn.close
--
1.7.1
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel