Control: tags -1 -patch On Thu, Jan 08, 2015 at 08:25:45PM +0100, Muri Nicanor wrote: > hi, > > On 01/08/2015 07:33 PM, Antoine Beaupré wrote: > > On 2015-01-08 13:20:19, Muri Nicanor wrote: > >> however, i stumbled over another problem: thunderbird sets the > >> content-type for messages, so the mail then looks a bit confusing if i > >> just copy and paste the output... > >> if i find the time i'll think about a solution (maybe don't set content > >> type and just save two files, content and attachment...) > > > > hmm... maybe changing what is saved then? maybe a non encoded version > > would be enough? just the signature > > output... ie. self.tmpkeyring.export_data(self.keyfpr)? > > so, it now safes only the signature in the file, but i changed the email > on stdout from > msg.create_mail_from_block() to msg.body > if -o is set, then the signature is being written to the file, if not, > it is shown on stdout with the email body. > (i don't know if there is a usecase for having the MIME output printed > on the console...?) > > muri
> diff --git a/monkeysign/ui.py b/monkeysign/ui.py > index c9b6a30..c7c2219 100644 > --- a/monkeysign/ui.py > +++ b/monkeysign/ui.py > @@ -93,6 +93,7 @@ class MonkeysignUi(object): > help=_('do not send email at all (default: use > sendmail)')) > parser.add_option('-t', '--to', dest='to', > help=_('override destination email for testing > (default: send individually encrypted email to each uid chosen)')) > + parser.add_option('-o', '--output', dest='output', help=_('save the > signature to a file')) > return parser > > def parse_args(self, args): > @@ -380,7 +381,19 @@ expects an EmailFactory email, but will not mail if > nomail is set""" > self.warn(_("""\ > not sending email to %s, as requested, here's the email message: > > -%s""") % (msg.mailto, msg.create_mail_from_block())) > +%s""") % (msg.mailto, msg.body)) > + if self.options.output is not None: > + if not os.path.exists(self.options.output): > + try: > + with open(self.options.output, 'w') as f: > + > f.write(str(self.tmpkeyring.export_data(msg.keyfpr))) > + self.warn(_('Signature has been written to %s') > % self.options.output) > + except IOError: > + self.warn(_('Could not write to file %s') % > self.options.output) > + else: > + self.warn(_('Could not write to %s: file exists') % > self.options.output) > + else: > + self.warn(_('and here is the signature:\n%s') % > str(self.tmpkeyring.export_data(msg.keyfpr))) > > > class EmailFactory: Hi, unfortunately, this patch doesn't apply anymore. :( I have since them implemented a `--mta` option which allows the user to pipe the message through an arbitrary command. It can be (ab-)used to save it to a file (with `--mta "tee file.txt"` or `--mta "dd status=none of=file.txt"` for the more obsessive types). But my hope is that saving to a file shouldn't generally be necessary, as we should be able to help the user send the actual email already. In fact, it has been made *more* difficult for users to bypass the email step recently by always encrypting the signed key material (see #833605 for a more in-depth discussion about this). So it is not quite clear to me what is gained by saving the key material to a file. So even if we would want a --output file, the above patch would need some changes: * it shouldn't show the signed material in the clear (as per #833605) * it should use the 'x' flag (from Python 3.3) or os.open(...O_EXCL) instead of testing if the file exists (because that's a race condition) Thanks for the patch, though! A.
signature.asc
Description: Digital signature