Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Hooking in another process or content_filter?

  1. #1
    jmcknight is offline Junior Member
    Join Date
    Sep 2005
    Posts
    6
    Rep Power
    9

    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?

  2. #2
    marcmac is offline Expert Member
    Join Date
    Sep 2005
    Posts
    2,103
    Rep Power
    13

    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.

  3. #3
    jmcknight is offline Junior Member
    Join Date
    Sep 2005
    Posts
    6
    Rep Power
    9

    Default

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

    Thanks for the tip.

  4. #4
    Dux T's Avatar
    Dux T is offline Senior Member
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    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 10:10 AM. Reason: Update

  5. #5
    Dux T's Avatar
    Dux T is offline Senior Member
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    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 11:25 AM.

  6. #6
    marcmac is offline Expert Member
    Join Date
    Sep 2005
    Posts
    2,103
    Rep Power
    13

    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?

  7. #7
    marcmac is offline Expert Member
    Join Date
    Sep 2005
    Posts
    2,103
    Rep Power
    13

    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?

  8. #8
    Dux T's Avatar
    Dux T is offline Senior Member
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    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 $?

  9. #9
    marcmac is offline Expert Member
    Join Date
    Sep 2005
    Posts
    2,103
    Rep Power
    13

    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.

  10. #10
    Dux T's Avatar
    Dux T is offline Senior Member
    Join Date
    Jan 2006
    Location
    Seattle, WA
    Posts
    53
    Rep Power
    9

    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

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Zimbra .pids / service monitoring
    By bin2hex in forum Administrators
    Replies: 24
    Last Post: 04-03-2010, 09:12 PM
  2. Admin login stuck on "Loading..."
    By danfluidmind in forum Installation
    Replies: 9
    Last Post: 07-12-2007, 09:04 AM
  3. 4.53: tomcat is not running
    By michaeln in forum Administrators
    Replies: 41
    Last Post: 06-13-2007, 06:42 PM
  4. tomcat not running / postfix/postqueue errors
    By seravitae in forum Installation
    Replies: 7
    Last Post: 03-10-2007, 08:18 PM
  5. Why is Tomcat shuting down ever nights?
    By trapanator in forum Administrators
    Replies: 2
    Last Post: 11-30-2006, 11:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •