2008年7月16日水曜日

LDAPサーバー及びLDAPクライアント設定ファイルについて

># vi /etc/openldap/slapd.conf

#######################################################################
# ldbm and/or bdb database definitions
#######################################################################


#database bdb
#suffix "dc=my-domain,dc=com" # コメントアウト

          ↓
suffix "dc=hoge,dc=fuga,dc=com" # 自ドメインに変更

#rootdn "cn=Manager,dc=my-domain,dc=com" # コメントアウト
          ↓
rootdn "cn=Manager,dc=hoge,dc=fuga,dc=com" # 自ドメインに変更

# Cleartext passwords, especially for the rootdn, should
# be avoided. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# rootpw secret
# rootpw {crypt}ijFYNcSNctBYg

# 暗号化されたパスワードを設定します。

rootpw {MD5}xxxxxxxxxxxxxxxxxxxxxxxx # 後述のslappasswdにて説明

# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.

directory /var/lib/ldap

# Indices to maintain for this database
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub

# Replicas of this database
#replogfile /var/lib/ldap/openldap-master-replog
#replica host=ldap-1.example.com:389 starttls=critical
# bindmethod=sasl saslmech=GSSAPI
# authcId=host/ldap-master.example.com@EXAMPLE.COM


# 以下を追加
access to attrs=userPassword
    by self write
    by dn="cn=Manager,dc=hoge,dc=fuga,dc=com" write
    by anonymous auth
    by * none

access to *
    by dn="cn=Manager,dc=hoge,dc=fuga,dc=com" write
    by self write
    by * read


予めslappasswdにて暗号化されたパスワードを生成しておきます。
secretの部分は任意のパスワードを指定します。

# slappasswd -s secret -h {MD5}
{MD5}xxxxxxxxxxxxxxxxxxxxxxxx

表示された{MD5}~の部分を前述のslapd.confのrootpw行に記述します。



LDAPクライアントの設定
># vi /etc/openldap/ldap.conf

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

#BASE dc=example, dc=com

       ↓
BASE dc=hoge,dc=fuga,dc=com # 自ドメインに変更


nss_ldapの設定
># vi /etc/ldap.conf

# The distinguished name of the search base.
#base dc=example,dc=com

       ↓
base dc=hoge,dc=fuga,dc=com # 自ドメインに変更

2008年7月14日月曜日

FedoraCore6でメールサーバー構築

Fedora Core 6 でメールサーバーを構築してみました。
以下は私の覚え書きです。

Postfix + Dovecot インストール手順

Fedora Core 6 インストール時の前提条件
・インストールタイプの選択で、3つのチェックマークを全て外す。

Postfixのインストール
・パッケージのインストールにはyumを使用します。
# yum -y install postfix

・main.cf(Postfix設定ファイル)の編集
# vi /etc/postfix/main.cf

#myhostname = host.domain.tld
     ↓
myhostname = hoge.fuga.com # コメントを外し、自身のFQDNに変更

#mydomain = domain.tld
     ↓
mydomain = fuga.com # コメントを外し、自身のドメイン名に変更

#myorigin = $mydomain
     ↓
myorigin = $mydomain # コメントを外す

#inet_interface = all
     ↓
inet_interface = all # コメントを外す

inet_interface = localhost
     ↓
#inet_interface = localhost # コメントアウト

mydestination = $myhostname, localhost.$mydomain, localhost
     ↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # 自身のドメインを追加

#home_mailbox = Maildir/
     ↓
home_mailbox = Maildir/ # コメントを外す

#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
     ↓
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
smtpd_banner = $myhostname ESMTP unknown # メールサーバー名を隠す為、unknownを追加

・ホームディレクトリの雛形にMaildirを追加(新規ユーザー用)
# mkdir -p /etc/skel/Maildir/cur
# mkdir -p /etc/skel/Maildir/new
# mkdir -p /etc/skel/Maildir/tmp
# chmod -R 700 /etc/skel/Maildir/

・既存ユーザーのホームディレクトリにMaildirを追加
# mkdir -p /home/honda/Maildir/cur
# mkdir -p /home/honda/Maildir/new
# mkdir -p /home/honda/Maildir/tmp
# chown -R honda /home/honda/Maildir/
# chmod -R 700 /home/honda/Maildir/

root宛メールの代理受信
・rootはメールソフトで受信できない為、代理のユーザーで受信します。
# vi /etc/aliases

root: marc
     ↓
#root: marc # コメントアウト

root: honda # 代理ユーザーを指定

Postfixの起動
・デフォルトのsendmailを停止
# /etc/rc.d/init.d/sendmail stop

・デフォルトをpostfixに変更
# alternatives --config mta

2 プログラムがあり 'mta' を提供します。

選択 コマンド
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
  2 /usr/sbin/sendmail.postfix

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2

ここでは2を選択します。

・Postfixを起動
# /etc/rc.d/init.d/postfix start

・Postfixの自動起動設定
# chkconfig sendmail off
# chkconfig postfix on

Dovecotのインストール
・パッケージのインストールにはyumを使用します。

# yum -y install dovecot

・dovecot.conf(Dovecot設定ファイル)の編集
# vi /etc/dovecot.conf

#protocols = imap imaps pop3 pop3s
     ↓
protocols = imap imaps pop3 pop3s # コメントを外す

#mail_location =
     ↓
mail_location = maildir:~/Maildir # メールボックスを指定

Dovecotの起動
・Dovecotを起動
# /etc/rc.d/init.d/dovecot start

・Dovecotの自動起動設定
# chkconfig dovecot on