Unix/Solaris10

Postfix - 깔끔한 정리 -_-

ForceCore 2006. 12. 3. 05:48

아래 세 개의 글이 너무 개판이라서 깔끔하게 정리해보았다 -_-


이 글에는 TLS support가 들어가는 컴파일을 하지 않았는데, (relay 인증의 암호화)
http://blog.naver.com/ssanzing2/140044228903
TLS기능을 넣으려면 이 글을 참고하시오.
 

0. 사용자와 그룹을 추가한다.

# groupadd postifx

# groupadd postdrop

# useradd -g postfix -d / -s /bin/false postfix


0. aliases 파일이 있으면 백업한다. 꼭...;

0. SUNWsndmu, SUNWsndmr 패키지를 제거한다.

Note: SUNWsndmr을 제거하려고 하면 sendmail remains enabled; aborting

이라고 할 수 있는데 이 때 svcadm refresh sendmail을 한번 해주면 제거할 수 있다.

1. SASL 2.몇을 패키지로 설치한다.

2. 버클리DB도 패키지로 설치해둔다.

3. /usr/lib/sasl2/smtpd.conf를 만들어서, 내용을

   pwcheck_method: saslauthd

라고 적어준다. (/usr/local/lib/sasl2인가...;;)

 

트러블슈팅: saslauthd -a pam -d 로 실행을 시켜서 outlook이 sasl에 전혀 접속하는 기색이 없고 relay error가 나면, saslauthd를 다시 설치해야 한다. sasl-2.x.x 를 sunfreeware에서 받아 깔든, 컴파일을 하든 자유이다.

4. /etc/init.d/saslauthd

스크립트를 만든다. 더 잘 된 버전은 첨부파일을 받아서 사용하면 된다. 원작자가 누군지 모르겠지만 필자가 좀 개조했다.

 

#!/sbin/sh
#
# made by ssanzing
#

case "$1" in
'start')

       /usr/local/sbin/saslauthd -a pam
        ;;

'stop')
        /usr/bin/pkill saslauthd
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac

 

진짜 대충 스크립트다 -_-

 

5. postfix 소스코드를 받는다.

 

5. export LD_LIBRARY_PATH='' 로 LD_LIBRARY_PATH를 제거한다. 그렇게 하면

vi나 ls등 중요한 게 안 될 수도 있다. 그러면

 

# crle -l /lib:/usr/lib:/usr/dt/lib:/usr/local/lib:/usr/local/ssl/lib -l /usr/ccs/lib:/usr/sfw/lib -l /opt/sfw/lib:/usr/X11R6/lib

-l 은 소문자 L이다. 대문자 i와 구분이 잘 안 되는군. 너무 길면 -l을 여러개 해서 쪼개줄 수 있다. root권한이 있는 자는 LD_LIBRARY_PATH로 되어야 할 부분을 crle -l [디렉토리] 로 처리해주는 것이 좋다. LD_LIBRARY_PATH는 리눅스나 솔라리스 양쪽 OS 모두 legacy 취급받고 있으니까.

 

혹시 crle로 라이브러리 path를 잘못 설정하면 부팅이 안 되는 수가 있다 -_-;; 부팅시 라이브러리를 쓰는 프로그램들이 엉터리 path를 참조해서 아예 console login 하라는 말도 안 뜬다든지! 그런 위험한 상황에 처하면 솔라리스 설치 디스크 1번 혹은 DVD를 넣고 single user shell로 컴퓨터를 부트시킨 뒤, /var/ld/ld.config를 제거한다. (그러면 crle는 디폴트 상태로 돌아온다.)

 

6. make makefiles CCARGS="-DUSE_CYRUS_SASL -DUSE_SASL_AUTH -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib -lsasl2 -R/usr/local/lib"

로 메이크 파일을 만든다.

 

7. make, 그리고 make install. make에서 나는 에러를 잘 보시오...

 

8. 옵션은

install_root: [/]

Please specify a directory for scratch files while installing Postfix.
You must have write permission in this directory.
tempdir: [/root/src/postfix-2.3.4]

Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix]

Please specify the final destination directory for installed Postfix
daemon programs. This directory should not be in the command search
path of any users.
daemon_directory: [/usr/libexec/postfix]

Please specify the final destination directory for installed Postfix
administrative commands. This directory should be in the command search
path of adminstrative users.
command_directory: [/usr/sbin]

Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix]

Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting
interface.
sendmail_path: [/usr/lib/sendmail]

Please specify the final destination pathname for the installed Postfix
newaliases command. This is the Sendmail-compatible command to build
alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases]

Please specify the final destination pathname for the installed Postfix
mailq command. This is the Sendmail-compatible mail queue listing
command.
mailq_path: [/usr/bin/mailq]

Please specify the owner of the Postfix queue. Specify an account with
numerical user ID and group ID values that are not used by any other
accounts on the system.
mail_owner: [postfix]

Please specify the group for mail submission and for queue management
commands. Specify a group name with a numerical group ID that is not
shared with other accounts, not even with the Postfix mail_owner
account. You can no longer specify "no" here.
setgid_group: [postdrop]

Please specify the destination directory for the Postfix HTML files.
Specify "no" if you do not want to install these files.
html_directory: [no]

Please specify the destination directory for the Postfix on-line manual
pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man]

Please specify the destination directory for the Postfix README files.
Specify "no" if you do not want to install these files.
readme_directory: [no]

이랬다.

 

9. 설정파일을 에디트.

필자가 postconf -n 을 쳐보니 아래와 같이 non-defaults가 나왔다. (개중엔 그냥 non-defaults로 찍혀 나오는데 위의 yes-no때문에 나온 것도 있다.)

alias_database = dbm:/etc/postfix/aliases
alias_maps = dbm:/etc/postfix/aliases
broken_sasl_auth_clients = yes

command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
html_directory = no
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
mydestination = $myhostname, localhost.$mydomain, localhost, yyy, yyy.xxx.ac.kr
mydomain = xxx.ac.kr
myhostname = yyy.xxx.ac.kr
mynetworks_style = host

myorigin = $myhostname
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/lib/sendmail
setgid_group = postdrop
smtpd_recipient_restrictions = permit_sasl_authenticated, check_relay_domains,reject_unauth_destination,reject
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =          # 실수가 아니라 원래 비워둬야 함
smtpd_sasl_security_options = noanonymous

unknown_local_recipient_reject_code = 550

 

10. postfix init.d 스크립트도 대충 만들었다.

#!/sbin/sh
#
# made by ssanzing
#

case "$1" in
'start')
        /usr/sbin/postfix start
        ;;

'stop')
        /usr/sbin/postfix stop
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac

 

11. newaliases명령을 쳐서 aliase.dir파일 생성함.

 

12. mutt를 위해 sendmail을 소프트링크

# ln -s /usr/bin/sendmail /usr/sbin/sendmail 을 해주면 해결된다.)

 

13. Muttrc (대문자M임)파일을 수정한다. 그냥 ID만 치면 로컬 ID로 메일이 가야 하는데 실패하는 경우 그렇게 해주라. 솔라리스10의 경우 /opt/sfw/etc/Muttrc이다. 기타 OS는 locate로 찾든 하라.

 

14. SASL 2.x를 필자는 컴파일 했었다. 혹시 패키지로 해서 안 되었다면, 컴파일도 해보라...;