LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Postfix Amavisd-New Autosignature (http://www.linuxquestions.org/questions/programming-9/postfix-amavisd-new-autosignature-766918/)

kevinslair 11-04-2009 05:43 PM

Postfix Amavisd-New Autosignature
 
Hey, everyone.

I hope this is the right place for this question.

I am trying to get autosignature working on my postfix and Amavisd-new.

Here is the info:


Here is my master.cf:
Code:



==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#              (yes)  (yes)  (yes)  (never) (100)
#
==========================================================================
smtp        inet        n        -        n        -        -        smtpd
    -o content_filter=signature

amavisfeed unix    -      -      n      -      2    smtp
    -o smtp_data_done_timeout=1200
    -o smtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o max_use=20

127.0.0.1:10025 inet n    -      n      -      -    smtpd
    -o content_filter=
    -o smtpd_delay_reject=no
    -o smtpd_client_restrictions=permit_mynetworks,reject
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o smtpd_data_restrictions=reject_unauth_pipelining
    -o smtpd_end_of_data_restrictions=
    -o smtpd_restriction_classes=
    -o mynetworks=127.0.0.0/8
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_client_connection_rate_limit=0
    -o
receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
    -o local_header_rewrite_clients=
    -o smtpd_milters=
    -o local_recipient_maps=
    -o relay_recipient_maps=

# END Added for amavis support

# Signature/Disclaimer
signature          unix    -      n      n      -      -      pipe
  flags=Rq user=filter argv=/etc/postfix/signature/disclaimer.sh -f
${sender} -- ${recipient}


Here is disclaimer.sh:

Code:


#!/bin/sh
# Localize these.
INSPECT_DIR=/var/spool/filter
SENDMAIL=/usr/sbin/sendmail

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

# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
$EX_TEMPFAIL; }

cat >in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

/usr/bin/altermime --input=in.$$ \
  --disclaimer=/etc/postfix/signature/disclaimer.txt \
  --disclaimer-html=/etc/postfix/signature/disclaimer.html \
  --xheader="X-CUSTOM-MOTD: Have a great day" || \
  { echo Message content rejected; exit $EX_UNAVAILABLE; }

$SENDMAIL "$@" <in.$$
                                                                     
exit $?

I created the user and here is the code:

Code:

# chmod 750 disclaimer.sh
# chown root:filter /etc/postfix/signature/disclaimer.sh

Please, if anyone knows an easier way to do this...please let me know.

The error I keep getting is permission denied on the pipe for the file disclaimer.sh.

thanks,
Kevin

wfh 11-08-2009 12:53 AM

What are the file permissions and ownership for /usr/bin/altermime?

You might try to debug this by brute force; insert a few 'echo' commands and redirect unique strings into a log...see the exact line where disclaimer.sh fails.

kevinslair 11-08-2009 05:00 AM

/usr/bin/altermime is owned by root with user root.

Should this be changed to root:filter?

wfh 11-09-2009 12:44 AM

Quote:

Originally Posted by kevinslair (Post 3744967)
Code:

# Signature/Disclaimer
signature          unix    -      n      n      -      -      pipe
  flags=Rq user=filter argv=/etc/postfix/signature/disclaimer.sh -f
${sender} -- ${recipient}


You run this as user 'filter' as indicated in red, above.

Does user 'filter' have rights to execute /usr/bin/altermime? Does this executable have +x for 'other' users?

kevinslair 11-09-2009 04:07 AM

No, the file is owned by root:root.

I am going to change it to root:filter and see if that works.

Thanks,
Kevin

kevinslair 11-14-2009 07:08 PM

Ok, I got it to work. I didn't know it but amavis has it's own signature disclaimer.

I will post with info on how to get it turned on.

kevinslair 11-14-2009 07:26 PM

Ok,
Here is the code I used to get the auto signature disclaimer working:

/etc/postfix/

main.cf:

Code:

content_filter=amavisfeed:[127.0.0.1]:10024
smtp_send_xforward_command = yes
smtpd_authorized_xforward_hosts = $mynetworks

master.cf:

Code:

# Added 11/14/09 for amavis support
#[...]


amavisfeed unix    -      -      n      -      2    smtp
    -o smtp_data_done_timeout=1200
    -o smtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o max_use=20

127.0.0.1:10025 inet n    -      n      -      -    smtpd
    -o content_filter=
    -o smtpd_delay_reject=no
    -o smtpd_client_restrictions=permit_mynetworks,reject
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o smtpd_data_restrictions=reject_unauth_pipelining
    -o smtpd_end_of_data_restrictions=
    -o smtpd_restriction_classes=
    -o mynetworks=127.0.0.0/8
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_client_connection_rate_limit=0
    -o
receive_override_options=no_header_body_checks,no_unknown_recipient_checks
    -o local_header_rewrite_clients=
    -o smtpd_milters=
    -o local_recipient_maps=
    -o relay_recipient_maps=
    -o smtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o local_header_rewrite_clients=
    -o smtpd_milters=



# END Added for amavis support








/etc/amavisd/

amavisd.conf:


find: MYNETS policy bank:

Code:


$allow_disclaimers = 1;
$terminate_dsn_on_notify_success = 1;
$policy_bank{'MYNETS'} = {  # mail originating from @mynetworks
#  terminate_dsn_on_notify_success => 0,
#  spam_kill_level_maps => 6.9,
#  syslog_facility => 'LOCAL4',  # tell syslog to log to a separate
file
#  virus_admin_maps => ["virusalert\@$mydomain"], # alert of internal
viruses
#  spam_admin_maps  => ["spamalert\@$mydomain"],  # alert of internal
spam
#  bypass_spam_checks_maps  => [1],  # or: don't spam-check internal
mail
#  bypass_banned_checks_maps => [1],  # don't banned-check internal
mail
#  warnbadhsender => 1,  # warn local senders about their broken MUA
#  banned_filename_maps => ['MYNETS-DEFAULT'], # more permissive
banning rules
#  spam_quarantine_cutoff_level_maps => undef, # quarantine all local
spam
#  spam_dsn_cutoff_level_maps => undef,  # ensure NDN regardless of
spam level
#  spam_dsn_cutoff_level_bysender_maps => # but only from local domain
senders


  originating => 1,
  allow_disclaimers => 1,

#    [ { lc(".$mydomain") => undef,  '.' => 15 } ],



};

@altermime_args_disclaimer =
  qw(--verbose  --disclaimer=/var/spool/amavisd/disclaimer.txt \
--disclaimer-html=/var/spool/amavisd/disclaimer.html);
  $defang_maps_by_ccat{+CC_CLEAN} = [ 'disclaimer' ];



/var/spool/amavisd/

disclaimer.txt

text message here.




disclaimer.html


Code:

<p>html disclaimer message here</p>


Just edit the txt and html disclaimer file to what you would like it to say.

Thanks,
Kevin


All times are GMT -5. The time now is 12:13 AM.