Bug 307548 - kmail2 does not update mail after piping mail throught a script
Summary: kmail2 does not update mail after piping mail throught a script
Status: RESOLVED WORKSFORME
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: Mail Filter Agent (show other bugs)
Version: 4.9
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-28 19:16 UTC by Thomas Arend
Modified: 2016-09-25 11:13 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Arend 2012-09-28 19:16:24 UTC
I have a script to change all occurrences of octet-stream to pkcs7-mime. 

The filter log says that the filter was applied. I saved the input and output via "tee" in to files. 
Every thing looked as it should. octet-stream was changed to pkcs7-mime, but the message is not updated. Even in akonadiconsole the log entry says that the message was stored successfully.



Reproducible: Always

Steps to Reproduce:
1. Pipe message through a filter which modiefies parts of the header. 
2.
3.
Actual Results:  
Old message is not replaced by new message.

Expected Results:  
Old message should be replaced by the output of the filter.
Comment 1 András Manţia 2012-10-26 09:11:33 UTC
Please test with akonadi 1.8.1 and kmail from 4.9.2 (and better 4.9.3 when it comes out) as well and report.
Comment 2 Jon Moon 2012-11-23 12:21:27 UTC
I can confirm I'm seeing the same behaviour with kmail 4.9.3 (and akonadi 1.8.1).

I also used tee to confirm that the filter was being executed, but the results seem to be thrown away and the original mail is what is stored.

I'm very willing to help with this problem so if I can help provide more information to debug this then please let me know.
Comment 3 Jon Moon 2012-11-24 12:03:52 UTC
Further to this, I'm seeing the same problem with an 'add header' action in the filter (at least to filters applied before the mail is sent - haven't tried other cases).

Having browsed the code a bit  and put gdb on akonadi_mailfiter_agent, I'm suspicious that something's going wrong in the execution of the 'Akonadi::ItemModifyJob' that's kicked off in FilterManager::processContextItem.

I've stepped through to confirm that the modify job is started and returns success - but the item's still unmodified.

The one thing I've not confirmed is that the item is actually modified by the filter (can't immediately see how to check the relevant fields in gdb), but the fact that both filter types are showing the same behaviour makes this seem unlikely.
Comment 4 Thomas Arend 2012-11-28 12:38:20 UTC
I tested it on 4.9.3. The error is reproducible and I wonder why it ist still unconfirmed.

The message is piped through the program but remains unchanged. Saveing the message to as a file and piping the message through the program shows that it is not a error of the program.

[13:29:00] Applying filter action: Pipe Through "/home/thomas/bin/Patch-BwPKI-SMIME"
[13:31:04] Filterregeln werden geprüft: (match all of the following) "<message>" <contains> "smime.p7m" "<message>" <contains> "octet-stream"
[13:31:04] 1 = "<message>" <contains> "smime.p7m"
[13:31:04] 1 = "<message>" <contains> "octet-stream"
[13:31:04] Filterregeln wurden angewandt.
------------------------------
[13:31:04] Applying filter action: Pipe Through "/home/thomas/bin/Patch-BwPKI-SMIME"
Comment 5 Thomas Arend 2012-11-28 12:48:45 UTC
Here follows the akonadi mailfilter log entry.  I have changed only personal inf with XXX / "example"

* 152163 FETCH (UID 152163 REV 6 REMOTEID "1353764598.R623.x1:2,S" MIMETYPE "message/rfc822" COLLECTIONID 591 SIZE 68722 DATETIME "28-Nov-2012 12:25:29 +0000" FLAGS (\SEEN $ATTACHMENT) ANCESTORS ((591 "inbox")) PLD:ENVELOPE[1] {259} ("Fri, 23 Nov 2012 14:37:49 +0100" "Z" ((NIL NIL "YYYYYY" "example.org")) ((NIL NIL "XXXXXX1example" "example.org")) NIL ((NIL NIL "XXXXXX" "example-rhb.de")) NIL NIL NIL "<OFC003F78A.3289353F-ONC1257ABF.004A99C7-C1257ABF.004ADFD8@example.org>" NIL) PLD:HEAD[1] {1896} Return-Path: <XXXXXX1example@example.org> X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on server.example.tksd X-Spam-Status: No, score=-1.5 required=4.5 tests=BAYES_00,MIME_BASE64_BLANKS autolearn=ham version=3.3.2 X-Spam-Spammy: 0.988-6958--481h-14462s--1d--H*r:smtp, 0.902-3756--5636h-18259s--1d--H*Ad:U*XXXXXX X-Spam-Hammy: 0.000-11--164h-0s--10d--H*UA:Notes, 0.000-11--164h-0s--10d--H*x:Notes X-Original-To: XXXXXX@localhost Delivered-To: XXXXXX@localhost.example.tksd Received: from server.example.tksd (localhost [IPv6:::1]) by server.example.tksd (Postfix) with ESMTP id 393BA289CA for <XXXXXX@localhost>; Sat, 24 Nov 2012 10:23:03 +0100 (CET) X-Original-To: XXXXXX@example-rhb.de Delivered-To: XXXXXX@example-rhb.de Received: from 172.16.0.1 [172.16.0.1] by server.example.tksd with POP3 (fetchmail-6.3.21) for <XXXXXX@localhost> (single-drop); Sat, 24 Nov 2012 10:23:03 +0100 (CET) Received: from Mail201.example-2.de (mail201.example-2.de [91.221.58.4]) by h1383963.stratoserver.net (Postfix) with SMTP id EB0A0206E19C for <XXXXXX@example-rhb.de>; Sat, 24 Nov 2012 10:16:10 +0100 (CET) Received: from (unknown) by Mail201.example-2.de with smtp id 2b4b_799c_d2ee97ba_3573_11e2_b862_0026557db6a8; Fri, 23 Nov 2012 14:43:58 +0100 From: YYYYYY@example.org To: XXXXXX@example-rhb.de Subject: Z MIME-Version: 1.0 X-KeepSent: C003F78A:3289353F-C1257ABF:004A99C7; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 7.0.3 September 26, 2007 Message-ID: <OFC003F78A.3289353F-ONC1257ABF.004A99C7-C1257ABF.004ADFD8@example.org> Sender: XXXXXX1example@example.org Date: Fri, 23 Nov 2012 14:37:49 +0100 X-MIMETrack: Serialize by Router on DHub03CLA/SRV/Z2Z2/Z1Z1/DE(Release 8.5.3FP1HF122 | April 30, 2012) at 23.11.2012 14:43:54 Content-Type: application/octet-stream; name="smime.p7m" Content-Disposition: attachment; filename="smime.p7m" Content-Transfer-Encoding: base64 X-UIDL: joj!!*bV!!;Cp!!1f\!! PLD:RFC822[1] [FILE] {56} /home/XXXXXX/.local/share/akonadi/file_db_data/452964_r0) 
38 OK UID FETCH completed
Comment 6 Thomas Arend 2012-12-09 16:23:05 UTC
Error is also in kmail2 4.9.4
Comment 7 Thomas Arend 2012-12-12 20:12:52 UTC
I have  attached reports from the filter protocol and the debug report from anonadiconsole (I have removed / modified some mail addresses)

Unfortunately there is no hint in the debugger about the result oft the pipe. Maybe that the filter protocol is wrong and the mail is not piped through the program or the debugger does not report the piping or ... or ...

The only thing I can confirm is: The mail is the same before and after piping.  But it works when I save the mail and do the piping on command line. 

--- Filter protocol ---   

21:00:37] Applying filter action: Pipe Through "/usr/bin/spamassassin -d"
[21:02:48] Filterregeln werden geprüft: (match all of the following) "X-Spam-Flag" <contains> "YES"
[21:02:48] 1 = "X-Spam-Flag" <contains> "YES" (YES)
[21:02:48] Filterregeln wurden angewandt.
------------------------------
[21:02:48] Applying filter action: Pipe Through "/usr/bin/spamassassin -d"

--- Akonadi Console Debug All ---

akonadi_mailfilter_agent (0x24b4700) 1945 UID FETCH 156716 FULLPAYLOAD ANCESTORS 1 EXTERNALPAYLOAD (UID REMOTEID REMOTEREVISION COLLECTIONID FLAGS SIZE DATETIME) 
akonadi_mailfilter_agent (0x24b4700) * 156716 FETCH (UID 156716 REV 3 REMOTEID "1355296352.R58.x1:2,S" MIMETYPE "message/rfc822" COLLECTIONID 591 SIZE 9572 DATETIME "12-Dec-2012 19:55:09 +0000" FLAGS (\SEEN) ANCESTORS ((591 "inbox")) PLD:ENVELOPE[1] {1148} ("Wed, 12 Dec 2012 06:23:44 +0100" "****SPAM(4.9)**** Schauspieler gesucht..." ( 

...
To: "'Thomas Arend'" <thomas@example.com>, 
...
... Subject: ****SPAM(4.9)**** Schauspieler gesucht... Date: Wed, 12 Dec 2012 06:23:44 +0100 Message-Id: <001501cdd828$dbd65280$9382f780$@de> X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on server.arend.tksd X-Spam-Flag: YES X-Spam-Level: **** X-Spam-Status: Yes, score=4.9 required=4.5 tests=BAYES_50,FREEMAIL_FROM, KHOP_BIG_TO_CC autolearn=no version=3.3.2 X-Spam-Spammy: 0.994-60--2h-120s--7d--att, ...

MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----------=_50C814B7.8054FDA7" X-UIDL: g+Z!!5g`"!5gF!!!pc"! PLD:RFC822[1] [FILE] {56} /home/thomas/.local/share/akonadi/file_db_data/469382_r0) 
akonadi_mailfilter_agent (0x24b4700) 1945 OK UID FETCH completed
Comment 8 András Manţia 2012-12-12 20:26:18 UTC
Thanks for the information provided, I'll look at it as soon as I have some "kde" time. Unfortunately I can't make promises about when it will be.
Comment 9 Denis Kurz 2016-09-24 20:42:40 UTC
This bug has only been reported for versions older than KDEPIM 4.14 (at most akonadi-1.3). Can anyone tell if this bug still present?

If noone confirms this bug for a recent version of akonadi (part of KDE Applications 15.08 or later), it gets closed in about three months.
Comment 10 Jon Moon 2016-09-25 10:49:02 UTC
Denis - 

Just tried with kmail 5.1.3 and bug seems to have gone - I was able to pipe through a script which added a gratuitous line, and another which removed the last line in the mail and both seemed to work.

So from my perspective, looks like it could be closed.

HTH
Comment 11 Christophe Marin 2016-09-25 11:13:51 UTC
Thanks for the feedback.