Opened 14 years ago
Closed 13 years ago
#181 closed setup (fixed)
python error when email2trac gets an email with any kind of attachment
Reported by: | smcbutler | Owned by: | bas |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | email2trac | Version: | |
Keywords: | Cc: | smcbutler@… |
Description (last modified by bas)
when we send an email to the email2trac address we get the following python error.
i've looked through the archives and couldn't find anything similar (surprisingly)
help! :)
<support@…>: Command died with status 1:
"PYTHON_EGG_CACHE=/var/trac; export PYTHON_EGG_CACHE; /usr/local/bin/email2trac --ticket_prefix=vsc_trac". Command output: TD: saving email to /tmp/tmpGxSGuz.email2trac
Reporting-MTA: dns; methodics-da.com X-Postfix-Queue-ID: 64A8E20B9C X-Postfix-Sender: rfc822; simon@… Arrival-Date: Sat, 20 Feb 2010 19:45:02 -0800 (PST)
Final-Recipient: rfc822; support@… Original-Recipient: rfc822;support@… Action: failed Status: 5.3.0 Diagnostic-Code: x-unix; TD: saving email to /tmp/tmpGxSGuz.email2trac
Attachments (2)
Change History (28)
comment:1 Changed 14 years ago by smcbutler
comment:2 Changed 14 years ago by smcbutler
last bit of information (sorry for not including all this upfront..).
email2trac works great when the originating email doesn't have an attachment. with an attachment the ticket gets created ok, it just seems to be the notification email that causes the error.
in my email2trac.conf i have the python_egg_cache set
python_egg_cache: /var/trac
this dir is owned by www-data:www-data has permissions 777
the notification email got saved to /tmp
-rwxrwxrwx 1 nobody nogroup 2243 Feb 21 10:19 tmpdba_YW.email2trac -rw-r--r-- 1 nobody nogroup 208 Feb 21 10:19 config.3
not sure if this helps?
comment:3 Changed 14 years ago by bas
- Description modified (diff)
- Status changed from new to assigned
- Type changed from defect to setup
As you noticed when an error is detected a file is save in /tmp. Can you try a dry-run:
- email2trac -n < tmpdba_YW.email2trac
If there is no error, try:
- email2trac < tmpdba_YW.email2trac
Is the ticket is created with the attachment attached. Then it is a permission problem with the attachment directory
comment:4 Changed 14 years ago by smcbutler
hi there, i ran this:
core:~> email2trac -n < /tmp/tmpaMuIIo.email2trac DRY_RUN: no attachments saved DRY_RUN: self.notify(tkt, True) simon@…
core:~> email2trac < /tmp/tmpaMuIIo.email2trac TD: saving email to /tmp/tmpaNRTJk.email2trac
the ticket was created but no attachment (or notification email)
comment:5 Changed 14 years ago by bas
- Description modified (diff)
Which userid did you use? It must have write permission for the trac attachments, mostly root. Is there something in the syslog file?
can you set the debug level in email2trac.conf:
debug: 99
rerurn the tests
comment:6 Changed 14 years ago by smcbutler
thx for the followup. i'm logged as myself "simon"
i set the debug and reran those tests:
core:~> email2trac -n < /tmp/tmpaMuIIo.email2trac TD: Message part: Main-Type: multipart TD: Message part: Content-Type: multipart/mixed TD: Skipping multipart container TD: Message part: Main-Type: application TD: Message part: Content-Type: application/octet-stream TD: Filename: config TD: attachment_exists: Ticket number : None, Filename : config TD: Attachment with filename config will be saved as config TD: saving email to /tmp/tmppJS0lC.email2trac TD: writing body (/tmp/tmpQh74x9.email2trac) TD: part1: Content-Type: application/octet-stream TD: part1: filename: config TD: writing part1 (/tmp/config) TD: saving email to /tmp/tmpRQ6PNR.email2trac core:~> core:~> core:~> email2trac < /tmp/tmpaMuIIo.email2trac TD: Message part: Main-Type: multipart TD: Message part: Content-Type: multipart/mixed TD: Skipping multipart container TD: Message part: Main-Type: application TD: Message part: Content-Type: application/octet-stream TD: Filename: config TD: attachment_exists: Ticket number : None, Filename : config TD: Attachment with filename config will be saved as config TD: saving email to /tmp/tmpGNAv86.email2trac TD: writing body (/tmp/tmpGj5T9I.email2trac) TD: part1: Content-Type: application/octet-stream TD: part1: filename: config TD: writing part1 (/tmp/config) TD: saving email to /tmp/tmpq1KcRi.email2trac
comment:7 Changed 14 years ago by smcbutler
i'm running as myself. the attachment file is owned by myself
core:~> whoami simon [olympia:~] smcbutler% ll config 8 -rw-r--r-- 1 smcbutler staff 208 Jan 26 21:46 config [olympia:~] smcbutler% core:~> email2trac -n < /tmp/tmpaMuIIo.email2trac TD: Message part: Main-Type: multipart TD: Message part: Content-Type: multipart/mixed TD: Skipping multipart container TD: Message part: Main-Type: application TD: Message part: Content-Type: application/octet-stream TD: Filename: config TD: attachment_exists: Ticket number : None, Filename : config TD: Attachment with filename config will be saved as config TD: saving email to /tmp/tmppJS0lC.email2trac TD: writing body (/tmp/tmpQh74x9.email2trac) TD: part1: Content-Type: application/octet-stream TD: part1: filename: config TD: writing part1 (/tmp/config) TD: saving email to /tmp/tmpRQ6PNR.email2trac core:~> core:~> core:~> email2trac < /tmp/tmpaMuIIo.email2trac TD: Message part: Main-Type: multipart TD: Message part: Content-Type: multipart/mixed TD: Skipping multipart container TD: Message part: Main-Type: application TD: Message part: Content-Type: application/octet-stream TD: Filename: config TD: attachment_exists: Ticket number : None, Filename : config TD: Attachment with filename config will be saved as config TD: saving email to /tmp/tmpGNAv86.email2trac TD: writing body (/tmp/tmpGj5T9I.email2trac) TD: part1: Content-Type: application/octet-stream TD: part1: filename: config TD: writing part1 (/tmp/config) TD: saving email to /tmp/tmpq1KcRi.email2trac
comment:8 Changed 14 years ago by bas
- Description modified (diff)
Does the user simon have write permission in the trac directory. At my site:
ubtrac2:/var/tmp/email2trac# ls -l /data/trac/oss/project/email2trac/ total 8 drwxr-xr-x 4 www-data www-data 30 2007-11-17 05:25 attachments drwxr-xr-x 2 www-data www-data 43 2010-02-15 16:11 conf drwxr-xr-x 2 www-data www-data 91 2010-02-24 12:39 db drwxr-xr-x 2 www-data www-data 6 2006-12-05 17:14 htdocs drwxr-xr-x 2 www-data www-data 6 2006-12-05 17:14 log drwxr-xr-x 2 www-data www-data 52 2008-07-02 08:55 plugins -rw-r--r-- 1 www-data www-data 98 2006-12-05 17:14 README drwxr-xr-x 2 www-data www-data 103 2007-08-03 10:47 templates -rw-r--r-- 1 www-data www-data 27 2006-12-05 17:14 VERSION drwxr-xr-x 2 www-data www-data 6 2006-12-05 17:14 wiki-macros
So i can test it as root or www-data user
comment:9 Changed 14 years ago by smcbutler
the original permissions were the same as yours
core:/tools/trac/projects/versicUserDocs_trac> ll total 52 4 drwxr-xr-x 10 www-data 48 4096 Feb 16 02:32 . 4 drwxr-xr-x 3 www-data users 4096 Feb 20 23:24 .. 4 -rw-r--r-- 1 www-data www-data 1996 Feb 16 02:32 .htpasswd 4 -rw-r--r-- 1 www-data 48 174 Mar 2 2009 README 4 -rw-r--r-- 1 www-data 48 27 Oct 30 2006 VERSION 4 drwxr-xr-x 4 www-data 48 4096 Aug 30 23:34 attachments 4 drwxr-xr-x 2 www-data 48 4096 Feb 23 19:49 conf 4 drwxrwxrwx 2 nobody www-data 4096 Feb 24 03:31 db 4 drwxr-xr-x 2 www-data 48 4096 Jul 11 2009 htdocs 4 drwxrwxrwx 2 www-data 48 4096 Feb 1 03:05 log 4 drwxr-xr-x 2 www-data 48 4096 Nov 30 03:01 plugins 4 drwxr-xr-x 2 www-data 48 4096 Jan 10 2009 templates 4 drwxr-xr-x 2 www-data 48 4096 Jan 10 2009 wiki-macros
but when i look in the attachments are i see
core:/tools/trac/projects/versicUserDocs_trac/attachments/ticket> lht total 188 drwxr-xr-x 2 nobody nogroup 4096 Feb 24 03:54 545
so the email attachment was owned by nobody:nogroup after email2trac had saved it off..
so i opened up the permissions on this dir and not it work..
thx
comment:10 Changed 14 years ago by bas
- Resolution set to fixed
- Status changed from assigned to closed
Ok, That is strange you configure to use the accounts nobody and www-data for run_email2trac
comment:11 Changed 14 years ago by smcbutler
- Resolution fixed deleted
- Status changed from closed to reopened
on ubuntu the apache user is www-data:www-date so thats where the trac dir permissions come from. the attachments are copied to the trac area as part of the postfix process, which seems to be the nobody:nogroup user..
or perhaps i'm missing something here - would you recommend a different setup?
thx for the support.
comment:12 Changed 14 years ago by bas
Did you installed a deb package or compiled it with configure. The default settings for email2trac are:
- postfix = nobody
- trac = www-data
and run_email2trac must be suid root. So we can switch from the user nobody to www-data and all the files in the directory have the right permissions. There is also alternatice setup for postfix described in doc section
comment:13 Changed 14 years ago by smcbutler
i compiled email2trac from source with configure - i used the alternate postfix setup which didn't require run_email2trac
still not sure whats strange about my setup.. i have the same user"group for my trac and postfix that you have?
i have a feeling i'm missing something here :(
comment:14 Changed 14 years ago by bas
The stange thing is that the attachments had the wrong permission. Does it work for new emails with attachments?
comment:15 Changed 14 years ago by smcbutler
sorry to keep complaining about this but i have one last issue that i haven't been able to figure out (yet).
i can do the following
1) send mail an attachment from my apple mailclient to support@… which will run email2trac and create a ticket 2) send mail (no attachment) using /usr/bin/mail on my desktop, which will run email2trac and create a ticket
i cannot send mail WITH ATTACHMENT using /usr/bin/mail on my desktop and have it create a ticket.
for example i run this command
/usr/bin/mail support@… < .cshrc
and I get the message
Mar 28 14:35:29 core postfix/pickup[5250]: B820220A1C: uid=0 from=<root> Mar 28 14:35:29 core postfix/cleanup[5888]: B820220A1C: message-id=<20100328213529.B820220A1C@methodics-da.com> Mar 28 14:35:29 core postfix/qmgr[1916]: B820220A1C: from=<root@methodics-da.com>, size=603, nrcpt=1 (queue active) Mar 28 14:35:29 core postfix/smtp[5890]: B820220A1C: to=<support@methodics-da.com>, relay=mail.methodics-da.com[64.151.125.214]:25, delay=0.06, delays=0.01/0/0.02/0.03, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 735811B81A2) Mar 28 14:35:29 core postfix/qmgr[1916]: B820220A1C: removed Mar 28 14:35:29 core postfix/smtpd[5891]: connect from mail.methodics-da.com[64.151.125.214] Mar 28 14:35:29 core postfix/smtpd[5891]: F03BF20A1C: client=mail.methodics-da.com[64.151.125.214] Mar 28 14:35:29 core postfix/cleanup[5888]: F03BF20A1C: message-id=<20100328213529.B820220A1C@methodics-da.com> Mar 28 14:35:29 core postfix/qmgr[1916]: F03BF20A1C: from=<root@methodics-da.com>, size=1789, nrcpt=1 (queue active) Mar 28 14:35:29 core postfix/smtpd[5891]: disconnect from mail.methodics-da.com[64.151.125.214] Mar 28 14:35:30 core email2trac: Traceback (most recent call last): Mar 28 14:35:30 core email2trac: File "/usr/local/bin/email2trac", line 1642, in <module>#012 tktparser.parse(sys.stdin) Mar 28 14:35:30 core email2trac: File "/usr/local/bin/email2trac", line 961, in parse#012 m.replace_header('Subject', m['Subject'].replace('\r', '').replace('\n', '')) Mar 28 14:35:30 core email2trac: AttributeError: 'NoneType' object has no attribute 'replace' Mar 28 14:35:30 core postfix/local[5893]: F03BF20A1C: to=<support@core.methodics-da.com>, relay=local, delay=0.38, delays=0/0/0/0.37, dsn=5.3.0, status=bounced (Command died with status 1: "PYTHON_EGG_CACHE=/var/trac; export PYTHON_EGG_CACHE; /usr/local/bin/email2trac --ticket_prefix=vsc_trac". Command output: TD: saving email to /tmp/tmpYyZafJ.email2trac ) Mar 28 14:35:30 core postfix/cleanup[5888]: 57B862C673: message-id=<20100328213530.57B862C673@methodics-da.com> Mar 28 14:35:30 core postfix/qmgr[1916]: 57B862C673: from=<>, size=3867, nrcpt=1 (queue active) Mar 28 14:35:30 core postfix/bounce[5896]: F03BF20A1C: sender non-delivery notification: 57B862C673 Mar 28 14:35:30 core postfix/qmgr[1916]: F03BF20A1C: removed Mar 28 14:35:30 core postfix/smtp[5890]: 57B862C673: to=<root@methodics-da.com>, relay=mail.methodics-da.com[64.151.125.214]:25, delay=0.03, delays=0/0/0/0.02, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 0AC771B81A2) Mar 28 14:35:30 core postfix/qmgr[1916]: 57B862C673: removed
i'm guessing i have some kind of permissions problem again, what permissions do i need to allow /usr/bin/mail to be able to save the attachment to the trac area?
comment:16 Changed 14 years ago by smcbutler
2 other snippets of information i was able to glean.. the attachment that gets saved to /tmp when email2trac fails looks like this
1) core:/var/log# ll /tmp/tmp2DnJ65.email2trac 108 -rwxrwxrwx 1 nobody nogroup 107289 Mar 28 17:54 /tmp/tmp2DnJ65.email2trac
Are these permissions an issue perhaps?
2) the attachment in this case is a file called "Mail Attachment" (the automatically generated name from the mail tool). could the space in the name of the attachment be causing problems?
comment:16 Changed 14 years ago by smcbutler
2 other snippets of information i was able to glean.. the attachment that gets saved to /tmp when email2trac fails looks like this
1) core:/var/log# ll /tmp/tmp2DnJ65.email2trac 108 -rwxrwxrwx 1 nobody nogroup 107289 Mar 28 17:54 /tmp/tmp2DnJ65.email2trac
Are these permissions an issue perhaps?
2) the attachment in this case is a file called "Mail Attachment" (the automatically generated name from the mail tool). could the space in the name of the attachment be causing problems?
comment:16 Changed 14 years ago by smcbutler
2 other snippets of information i was able to glean.. the attachment that gets saved to /tmp when email2trac fails looks like this
1) core:/var/log# ll /tmp/tmp2DnJ65.email2trac 108 -rwxrwxrwx 1 nobody nogroup 107289 Mar 28 17:54 /tmp/tmp2DnJ65.email2trac
Are these permissions an issue perhaps?
2) the attachment in this case is a file called "Mail Attachment" (the automatically generated name from the mail tool). could the space in the name of the attachment be causing problems?
comment:17 Changed 14 years ago by bas
Which version do you use? The error is here:
Mar 28 14:35:30 core email2trac: File "/usr/local/bin/email2trac", line 1642, in <module>#012 tktparser.parse(sys.stdin) Mar 28 14:35:30 core email2trac: File "/usr/local/bin/email2trac", line 961, in parse#012 m.replace_header('Subject', m['Subject'].replace('\r', '').replace('\n', '')) Mar 28 14:35:30 core email2trac: AttributeError: 'NoneType' object has no attribute 'replace'
This means there is no subject line in the email. This is fixed in 1.3.0. Else just attach the file in /tmp to this ticket so i can test it.
comment:18 Changed 14 years ago by smcbutler
i added the attachments you asked for. as you can see from the email i'm attaching there is an subject here in there so i'm not sure thats our issue. rgds
comment:19 Changed 14 years ago by bas
I just tested this and have i ticket without an attachment. Because everything is in body of the the ticket. Because the message has no attachments. How did you attach this file in your mail program?
If it is a coorect email message it contains mulitpart containers.
comment:20 Changed 14 years ago by smcbutler
the email is generated by the script below
cat /tmp/simon/simon_supportLogs8862_i.tgz.uu | /bin/mail support@… simon@… -s "Demo User Issue: email2trac test"
/bin/mail (BSD binary) doesn't take an attachment as an argument so this one to effect the same thing
comment:21 Changed 14 years ago by bas
That is why there is no attachment. It is just plain text mail for email2trac. As said at our side it works and the whole text is inserted in the ticket.
comment:22 Changed 14 years ago by smcbutler
but i get a python error when i process that email and email2trac fails to create the ticket.
you said earlier that this could be due to the lack of a subject heading, however the email does have a subject?
thx for the support by the way, i appreciate it
comment:23 Changed 14 years ago by bas
I just tested it:
cat /etc/services | mail -s 'bas' test
First it did not work because i enabled the debug mode in email2trac.conf. when i disabled it the message was delivered.
Which version do you use?
comment:24 Changed 13 years ago by smcbutler
- Resolution set to fixed
- Status changed from reopened to closed
i turned off debug and now this works for me also.
thx for the help!!
i was also using 1.2 so i've upgraded to 1.3.2
rgds
i should have included my system information
on ubuntu 9.10