Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-22-2005, 12:04 PM
Junior Member
 
Posts: 6
Default Hooking in another process or content_filter?

I currently use Postfix with SpamAssassin, Anomy, and a custom content filter that associates emails with certain records in a contact database based on certain criteria in the Subject.

With Zimbra the only thing that I would need to add is my own custom piece, but I can't seem to get it to work.

In the existing system I set :content_filter=spamfilter:

spamfilter unix - n n - - pipe
flags=Rq user=filter argv=/usr/local/bin/filter.sh -f ${sender} -- ${recipient}


I can get the Postfix in Zimbra to execute but it always fails with an error message generated by my script. Basically the execution back into the smtp process fails.

I believe that it is failing at the $SENDMAIL command, Probably because of the pipe(?):

SENDMAIL="/usr/sbin/sendmail -i"
ANOMY=/opt/zimbra/anomy
ANOMY_CONF=/opt/zimbra/anomy/sanitizer.cfg
ANOMY_LOG=/dev/null
SPAMC=/usr/bin/spamc
DOC=/opt/zimbra/anomy/mail.pl

export ANOMY

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

cat | $DOC \
| $ANOMY/bin/sanitizer.pl $ANOMY_CONF 2>>$ANOMY_LOG \
| $SENDMAIL "$@" || \
{ echo Message content rejected; exit $EX_UNAVAILABLE; }

exit $?


fyi this script works via the command line by executing it outside of the MTA:

cat spool/test.txt | /opt/zimbra/anomy/filter.sh -f root@theinsitegroup.com -- jmcknight@theinsitegroup.com

Ideas?
Reply With Quote
  #2 (permalink)  
Old 09-22-2005, 01:57 PM
Zimbra Employee
 
Posts: 2,103
Default permissions?

When you ran the test, did you run it as the postfix user? Make sure it works that way - postfix may not have the permissions to write to the sendmail queue dir.
Reply With Quote
  #3 (permalink)  
Old 09-28-2005, 07:50 AM
Junior Member
 
Posts: 6
Default

I ran the test as root. I'll check running as postfix.

Thanks for the tip.
Reply With Quote
  #4 (permalink)  
Old 02-02-2006, 08:35 AM
Senior Member
 
Posts: 53
Default

OK I'll bite how does one make this work?
/opt/zimbra/postfix/spool is owned by postfix
/var/spool/postfix is owned by root ... but it's not being used correct?
Regardless of which user I set in master.cf for the script (add_disclaimer in my case) I get the error (zimbra, filter, postfix even tried root once)... I get that postfix doesn't have the correct permissions to reinject the mail... how do I give it permission or which user should this be run as?

Thanks for any help

If it makes any difference I am also using zimbras sendmail in my script:
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail

Last edited by Dux T; 02-02-2006 at 09:10 AM.. Reason: Update
Reply With Quote
  #5 (permalink)  
Old 02-03-2006, 12:47 PM
Senior Member
 
Posts: 53
Question

Just to recap my efforts and remaining question:

Global Footer
Global Footer

Wanted Global Disclaimer
Wanted: Global disclaimer

Postfix Chapter 12 (Currently using Postfix as the user)
http://www.nostarch.com/download/postfix_ch12.pdf

Custom Message Filter
Hooking in another process or content_filter?

I tried using zmlmtpinject but it failed unless run on the command line also ... I'm not sure if this will be reprocessed if it does work.

If anyone can help me I sure would appreciate it.

Last edited by Dux T; 02-14-2006 at 10:25 AM..
Reply With Quote
  #6 (permalink)  
Old 02-14-2006, 10:31 AM
Zimbra Employee
 
Posts: 2,103
Default not enough info

Quote:
Originally Posted by Dux T
OK I'll bite how does one make this work?
/opt/zimbra/postfix/spool is owned by postfix
/var/spool/postfix is owned by root ... but it's not being used correct?
Regardless of which user I set in master.cf for the script (add_disclaimer in my case) I get the error (zimbra, filter, postfix even tried root once)... I get that postfix doesn't have the correct permissions to reinject the mail... how do I give it permission or which user should this be run as?

Thanks for any help

If it makes any difference I am also using zimbras sendmail in my script:
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
Not enough information. WHat's your change to master.cf, and what's in your script, and what do you expect it to do?
Reply With Quote
  #7 (permalink)  
Old 02-14-2006, 10:32 AM
Zimbra Employee
 
Posts: 2,103
Default

Quote:
Originally Posted by Dux T
Just to recap my efforts and remaining question:

Global Footer
Global Footer

Wanted Global Disclaimer
Wanted: Global disclaimer

Postfix Chapter 12 (Currently using Postfix as the user)
http://www.nostarch.com/download/postfix_ch12.pdf

Custom Message Filter
Hooking in another process or content_filter?

I tried using zmlmtpinject but it failed unless run on the command line also ... I'm not sure if this will be reprocessed if it does work.

If anyone can help me I sure would appreciate it.
Bugs are opened on the first two, what do you want to know for #3, and #4 is a repeat of your previous post, no?
Reply With Quote
  #8 (permalink)  
Old 02-14-2006, 11:33 AM
Senior Member
 
Posts: 53
Default

Quote:
Originally Posted by marcmac
Bugs are opened on the first two, what do you want to know for #3, and #4 is a repeat of your previous post, no?
That was a post to show the steps I took to get to the stumbling block on #4 basically by following the directions in the PDF I had this for my master.cf

Code:
...
#
# Testing
#
disclaimer  unix  -       n       n       -       -       pipe
  flags=Rq user=zimbra argv=/opt/zimbra/filter/add_disclaimer -f ${sender} -- ${recipient}
...
127.0.0.1:10025 inet n  -       n       -       -  smtpd
        -o content_filter=disclaimer:
changing user to several values including postfix and root (yes it's a no-no but I'm desperate!)

add_disclaimer looks like this:
Code:
#!/bin/sh
# System dependent settings
ALTERMIME=/usr/local/bin/altermime
ALTERMIME_DIR=/opt/zimbra/filter/scratch
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
# Exit codes of commands invoked by Postfix are expected
# to follow the conventions defined in <sysexits.h>.
TEMPFAIL=75
UNAVAILABLE=69
# Change in to alterMIME's working directory and
# notify Postfix if 'cd' fails.
cd $ALTERMIME_DIR || { echo $ALTERMIME_DIR does not exist; exit $TEMPFAIL; }
# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15
# Write mail to a temporary file
# Notify Postfix if this fails
cat >in.$$ || { echo Cannot write to $ALTERMIME_DIR; exit $TEMPFAIL; }
# Call alterMIME, hand over the message and
# tell alterMIME what to do with it
$ALTERMIME --input=in.$$ \
            --disclaimer=/opt/zimbra/filter/disclaimer.txt \
            --disclaimer-html=/opt/zimbra/filter/disclaimer.html \
            --xheader="X-Copyrighted-Material: Please visit http://www.duxarea.com" \
             || \
            { echo Message content rejected; exit $UNAVAILABLE; }
# Call sendmail to reinject the message into Postfix
$SENDMAIL "$@" <in.$$
# Use sendmail's EXIT STATUS to tell Postfix
# how things went.
exit $?
Reply With Quote
  #9 (permalink)  
Old 02-14-2006, 11:45 AM
Zimbra Employee
 
Posts: 2,103
Default

What error do you get? WHat happens when you run this as the zimbra user?

BTW - from man pipe:
user=username (required)

user=username:groupname
The external command is executed with the rights of the specified username. The
software refuses to execute commands with root privileges, or with the privi-
leges of the mail system owner. If groupname is specified, the corresponding
group ID is used instead of the group ID of username.

So setting the user to postfix or root will fail you.
Reply With Quote
  #10 (permalink)  
Old 02-14-2006, 01:17 PM
Senior Member
 
Posts: 53
Default

Quote:
Originally Posted by marcmac
What error do you get? WHat happens when you run this as the zimbra user?
When running as zimbra I get this several times in a row:
Code:
postdrop: warning: mail_queue_enter: create file maildrop/114141.17234: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/114141.17234: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/114141.17234: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/114141.17234: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/114141.17234: Permission denied
Almost like it's stuck in a loop, of course any execution results in a different file name in place of 114141.17234
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.