[mdk-re] Снова замена адреса отправителя в Postfix : ПОМОГИТЕ!

John =?iso-8859-1?q?john_=CE=C1_rmts=2Edonpac=2Eru?=
Чт Мар 14 08:41:01 MSK 2002


Здраствуйте!

Пишу в третий раз. Первый раз меня отправили по факам, второй раз Игорь 
Хомяков указал конкретный документ (похоже едиственный из всей 
документации, которая идет вместе с постфиксом, кроме него вообще ничего 
похожего я не нашел, если кто-то знает, ткните) - /usr/doc/postfix ... 
/FILTER_README.

Еще раз постановка задачи: *как переименовать адрес отправителя письма, 
если адрес получателя не заканчивается на localhost, в противном случае 
оставить как есть*.

Я читаю вышеупомянутый файл

/1 - Create a dedicated local user account called "filter".  The
    user will never log in, and can be given a "*" password and
    non-existent shell and home directory. This user handles all
    potentially dangerous mail content - that is why it should be
    a separate account./

сделал

/2 - Create a directory /var/spool/filter that is accessible only
    to the "filter" user. This is where the content filtering will
    store its temporary files./

сделал

/3 - Define a content filtering entry in the Postfix master file:

    /etc/postfix/master.cf:
      filter    unix  -       n       n       -       -       pipe
        flags=Rq user=filter argv=/somewhere/filter -f ${sender} -- 
${recipient}/

сделал, только написал argv=/etc/postfix/filter, дал вообще всем права 
на его исполнение

/The /some/where/filter program can be a simple shell script like this:

    #!/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; }

    # filter <in.$$ || { echo Message content rejected; exit 
$EX_UNAVAILABLE; }

    $SENDMAIL "$@" <in.$$

    exit $?/

Тоже сделал. Кстати, а куда echo должно выводится? На 12 консоль?  Этот 
файл все равно не не выполняется, т.к. я в него в самое начало даже 
вписывал echo hello > /tmp/xxx, и этот файл создан не был. Наверное, 
что-то не так в //etc/postfix/master.cf/. ЧТО?

И это только полбеды. Далее написано:

/The idea is to first capture the message to file and then run the
content through run a third-party content filter program.  If the
mail cannot be captured to file, mail delivery is deferred by
terminating with exit status 75 (EX_TEMPFAIL).  If the content
filter program finds a problem, the mail is bounced by terminating
the shell script with exit status 69 (EX_UNAVAILABLE).  If the
content is OK, it is given as input to Postfix sendmail, and the
exit status of the filter command is whatever exit status Postfix
sendmail produces./

А я не содержание, а адрес получателя хочу проверить, а адрес 
отправителя изменить (грубо говоря, динамически комментровать и 
раскомментировать в в main.cf строку sender_canonical_map = 
hash:/etc/postfix/canonical без перезапуска постфикса). Я так понял, что 
адреса я получу как параметры /-f ${sender} -- ${recipient}/. Так как 
мне их изменить? Не сам же параметр sender модифицировать (или меня 
подводит мой опыт программирования на С/С++, а здесь такое можно)?

Извиняюсь, если кого запарил своим длинным письмом, но я правда не 
понимаю, что мне сделать. Скажите мне прямо, что я слишком много хочу и 
этого нельзя, или покажите, как это сделать.

С уважением, Прокопьев Евгений






Подробная информация о списке рассылки community