pam_mkhomedir モジュールによるホームディレクトリの自動作成

ホームディレクトリが存在しない状態でログインしても、pam_mkhomedir を利用することでホームティレクトリが作成される。

1.事前準備

/etc/skel を準備する。
pam_mkhomedir のデフォルトの動作では、ホームディレクトリ作成時に、ここに準備したファイルをホームディレクトリに引き継ぐ。

# touch /etc/skel/test_user.txt
# ll /etc/skel/
合計 0
-rw-r--r--. 1 root root 0  3月  5 01:25 2015 test_user.txt
#


2.pam_mkhomedir の有効

# authconfig --enablemkhomedir --update

※以下を参照
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Configuring_Authentication.html
11.1.4.6. ローカル認証セッティングの設定

または、man pam_mkhomedir を参照。

3.動作確認

# useradd test01
# passwd test01
ユーザー test01 のパスワードを変更。
新しいパスワード:
よくないパスワード: 異なる文字が十分に含まれていません
よくないパスワード: 簡単すぎます
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。
#
# rm -fr /home/test01 ★test01 ユーザのホームディレクトリを一旦削除
# ll /home/
合計 0
#
# su - test01 ★test01 ユーザでログイン
ディレクトリ '/home/test01' を作成中
$ ls -lat
合計 28
drwxr-xr-x. 4 test01 test01 4096  3月  5 01:32 2015 .
drwxr-xr-x. 3 root   root   4096  3月  5 01:32 2015 ..
-rw-r--r--. 1 test01 test01   18  3月  5 01:32 2015 .bash_logout
-rw-r--r--. 1 test01 test01  176  3月  5 01:32 2015 .bash_profile
-rw-r--r--. 1 test01 test01  124  3月  5 01:32 2015 .bashrc
drwxr-xr-x. 2 test01 test01 4096  3月  5 01:32 2015 .gnome2
drwxr-xr-x. 4 test01 test01 4096  3月  5 01:32 2015 .mozilla
-rw-r--r--. 1 test01 test01    0  3月  5 01:32 2015 test_user.txt ★ /etc/skel のファイルが引き継がれた
$

※参考 URL
http://d.hatena.ne.jp/akuwano+tips/20110126/1296005855

bind

http://www.system-act.com/server/bind.html
http://k4200.hatenablog.com/entry/20130304/1362379763







bind 超簡易版

http://www.eis.co.jp/engineers-notes/bind9_src_build

/etc/named.conf

http://www4.ueda.ne.jp/~zhongcun/linux32.html

/var/named/chroot/etc/named.conf

-------------------------
options {
        directory       "/var/named";
        allow-query     { any; };
        allow-transfer     { any; };ゾーン転送を無制限で許可
        recursion yes;
        version "";
};


view "local" {
        allow-query { any; };
        zone "." IN {
                type hint;
                file "named.ca";
        };

        zone "testdomain1" {
                type master;
                file "testdomain1.local.hosts";
                also-notify {192.168.11.19;} ;
                };

        zone "11.168.192.in-addr.arpa" IN {
                type master;
                file "192.168.11.0.local.rev";
                };

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
};

view "world" {
        match-clients { any; };
        allow-query { any; };
};
-------------------------


/var/named/chroot/var/named/testdomain1.local.hosts
-------------------------
$ttl 38400
@                 IN      SOA     LVS.testdomain1. root.LVS.testdomain1. (
                                  0000000001
                                  10800
                                  3600
                                  604800
                                  38400 )

testdomain1.      IN      NS      LVS.testdomain1.
testdomain1.      IN      MX      10 mail.testdomain1.
LVS.testdomain1.  IN      A       192.168.11.18
HTTP.testdomain1. IN      A       192.168.11.19
mail.testdomain1. IN      A       192.168.11.20
HTTP2.testdomain1. IN     CNAME   HTTP.testdomain1.
-------------------------

 

/var/named/chroot/var/named/192.168.11.0.local.rev
-------------------------
$ttl 38400
@               IN      SOA     LVS.testdomain1. root.testdomain1. (
                        1353762926
                        10800
                        3600
                        604800
                        38400 )

               IN      NS      LVS.testdomain1.
18             IN      PTR     LVS.testdomain1.
19             IN      PTR     HTTP.testdomain1.
-------------------------

 

 

/etc/resolv.conf
-------------------------
search localdomain example.com
nameserver 192.168.84.132
-------------------------

/etc/sysconfig/network
-------------------------
NETWORKING=yes
HOSTNAME=LVS.testdomain1
-------------------------


slave 側
-----------------------------------------------------------------
options {
        directory       "/var/named";
        allow-query     { any; };
        allow-transfer     { any; };ゾーン転送を無制限で許可
        recursion yes;
        version "";
};


view "local" {
        allow-query { any; };
        zone "." IN {
                type hint;
                file "named.ca";
        };

        zone "testdomain1" IN {
                type slave;
                file "slaves/testdomain1.local.hosts";
                masters {192.168.11.18;} ;
                };

        zone "11.168.192.in-addr.arpa" IN {
                type slave;
                file "slaves/192.168.11.0.local.rev";
                masters {192.168.11.18;} ;
                };

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
};

view "world" {
        match-clients { any; };
        allow-query { any; };
};
-----------------------------------------------------------------

[root@LVS sample]# dig @dns3.odn.ne.jp. gihyo.co.jp AXFR

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @dns3.odn.ne.jp. gihyo.co.jp AXFR
; (1 server found)
;; global options: +cmd
; Transfer failed.
[root@LVS sample]#



[root@LVS sample]# dig @localhost testdomain1 axfr
;; Connection to ::1#53(::1) for testdomain1 failed: connection refused.

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @localhost testdomain1 axfr
; (2 servers found)
;; global options: +cmd
testdomain1.            38400   IN      SOA     LVS.testdomain1. root.testdomain1. 1353762479 10800 3600 604800 38400
testdomain1.            38400   IN      NS      LVS.testdomain1.
testdomain1.            38400   IN      MX      10 mail.example.com.
HTTP.testdomain1.       38400   IN      A       192.168.11.19
HTTP2.testdomain1.      38400   IN      CNAME   HTTP.testdomain1.
LVS.testdomain1.        38400   IN      A       192.168.11.18
testdomain1.            38400   IN      SOA     LVS.testdomain1. root.testdomain1. 1353762479 10800 3600 604800 38400
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Oct 17 19:22:33 2014
;; XFR size: 7 records (messages 1, bytes 213)

[root@LVS sample]#


[root@LVS sample]# dig @localhost testdomain1 any

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @localhost testdomain1 any
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24048
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;testdomain1.                   IN      ANY

;; ANSWER SECTION:
testdomain1.            38400   IN      SOA     LVS.testdomain1. root.testdomain1. 1353762479 10800 3600 604800 38400
testdomain1.            38400   IN      NS      LVS.testdomain1.
testdomain1.            38400   IN      MX      10 mail.example.com.

;; ADDITIONAL SECTION:
LVS.testdomain1.        38400   IN      A       192.168.11.18

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Oct 17 19:23:06 2014
;; MSG SIZE  rcvd: 136

[root@LVS sample]#






















bind 超簡易版

http://www.eis.co.jp/engineers-notes/bind9_src_build

/etc/named.conf

http://www4.ueda.ne.jp/~zhongcun/linux32.html

 

/var/named/chroot/etc/named.conf

-------------------------
options {
        directory       "/var/named";
        allow-query     { any; };
        allow-transfer     { any; };
        recursion yes;
        version "";
};


view "local" {
        allow-query { any; };
        zone "." IN {
                type hint;
                file "named.ca";
        };

        zone "testdomain1" {
                type master;
                file "testdomain1.local.hosts";
                };

        zone "11.168.192.in-addr.arpa" {
                type master;
                file "192.168.11.0.local.rev";
                };

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
};

view "world" {
        match-clients { any; };
        allow-query { any; };
};
-------------------------


/var/named/chroot/var/named/testdomain1.local.hosts
-------------------------
$ttl 38400
@               IN      SOA     LVS.testdomain1. root.testdomain1. (
                        1353762479
                        10800
                        3600
                        604800
                        38400 )

testdomain1.    IN      NS      LVS.testdomain1.
testdomain1.    IN      MX      10 mail.example.com.
LVS             IN      A       192.168.11.18
HTTP            IN      A       192.168.11.19
HTTP2           IN      CNAME   HTTP
-------------------------

 

/var/named/chroot/var/named/192.168.11.0.local.rev
-------------------------
$ttl 38400
@               IN      SOA     LVS.testdomain1. root.testdomain1. (
                        1353762926
                        10800
                        3600
                        604800
                        38400 )

               IN      NS      LVS.testdomain1.
18             IN      PTR     LVS.testdomain1.
19             IN      PTR     HTTP.testdomain1.
-------------------------

 

 

/etc/resolv.conf
-------------------------
search localdomain example.com
nameserver 192.168.84.132
-------------------------

/etc/sysconfig/network
-------------------------
NETWORKING=yes
HOSTNAME=LVS.testdomain1
-------------------------



[root@LVS sample]# dig @dns3.odn.ne.jp. gihyo.co.jp AXFR

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @dns3.odn.ne.jp. gihyo.co.jp AXFR
; (1 server found)
;; global options: +cmd
; Transfer failed.
[root@LVS sample]#



[root@LVS sample]# dig @localhost testdomain1 axfr
;; Connection to ::1#53(::1) for testdomain1 failed: connection refused.

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @localhost testdomain1 axfr
; (2 servers found)
;; global options: +cmd
testdomain1.            38400   IN      SOA     LVS.testdomain1. root.testdomain1. 1353762479 10800 3600 604800 38400
testdomain1.            38400   IN      NS      LVS.testdomain1.
testdomain1.            38400   IN      MX      10 mail.example.com.
HTTP.testdomain1.       38400   IN      A       192.168.11.19
HTTP2.testdomain1.      38400   IN      CNAME   HTTP.testdomain1.
LVS.testdomain1.        38400   IN      A       192.168.11.18
testdomain1.            38400   IN      SOA     LVS.testdomain1. root.testdomain1. 1353762479 10800 3600 604800 38400
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Oct 17 19:22:33 2014
;; XFR size: 7 records (messages 1, bytes 213)

[root@LVS sample]#


[root@LVS sample]# dig @localhost testdomain1 any

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @localhost testdomain1 any
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24048
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;testdomain1.                   IN      ANY

;; ANSWER SECTION:
testdomain1.            38400   IN      SOA     LVS.testdomain1. root.testdomain1. 1353762479 10800 3600 604800 38400
testdomain1.            38400   IN      NS      LVS.testdomain1.
testdomain1.            38400   IN      MX      10 mail.example.com.

;; ADDITIONAL SECTION:
LVS.testdomain1.        38400   IN      A       192.168.11.18

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Oct 17 19:23:06 2014
;; MSG SIZE  rcvd: 136

[root@LVS sample]#

iptables のログ出力とその抑止

1.INPUT をログ出力する場合

# iptables -A INPUT -j LOG


2.特定の送信元からの INPUT をログ出力する場合

# iptables -A INPUT -s 192.168.11.19 -j LOG


3.特定の送信元からの INPUT 除外してログ出力する場合

# iptables -A INPUT ! -s 192.168.11.19 -j LOG


ただし、除外する際に複数の送信元を指定することは実質不可能。

以下のように、複数の送信元を指定しても、最初に除外を指定した送信元は
次の除外の指定のルールによって出力されてしまう。

# iptables -A INPUT ! -s 192.168.11.3 -j LOG --log-prefix rule1 ★192.168.11.3 以外のログを出力
# iptables -A INPUT ! -s 192.168.11.18 -j LOG --log-prefix rule2 ★192.168.11.18 以外のログを出力 (要するに上記で除外した 192.168.11.18 もこのルールによって出力される)

以下のように出力される。

Sep 28 15:22:23 HTTP01 kernel: rule1IN=eth2 OUT= MAC=00:0c:29:12:2c:22:00:0c:29:52:84:4b:08:00 SRC=192.168.11.18 DST=192.168.11.19 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=ICMP TYPE=8 CODE=0 ID=60165 SEQ=2199
Sep 28 15:22:23 HTTP01 kernel: rule2IN=eth2 OUT= MAC=00:0c:29:12:2c:22:e8:40:f2:a6:ff:35:08:00 SRC=192.168.11.3 DST=192.168.11.19 LEN=40 TOS=0x00 PREC=0x00 TTL=128 ID=30837 DF PROTO=TCP SPT=53817 DPT=22 WINDOW=16425 RES=0x00 ACK URGP=0


ちなみに、送信元は以下のように複数指定可能。

# iptables -A INPUT --src 192.168.11.3,192.168.11.19 -j LOG
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
LOG        all  --  192.168.11.3         anywhere            LOG level warning
LOG        all  --  192.168.11.19        anywhere            LOG level warning

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination


除外する場合は以下のように複数指定不可能。
もっとも、仮に、指定出来ても当初記載したように複数行になってしまうと考えられるので実質意味なし。
※指定のコマンドが 1 回になる程度の意味しかない。

# iptables -A INPUT ! --src 192.168.11.3,192.168.11.19 -j LOG
iptables v1.4.7: ! not allowed with multiple source or destination IP addresses
Try `iptables -h' or 'iptables --help' for more information.
#


このため、複数の送信元からのログを除外したい場合は、rsyslog の機能を使用した方がよい。
/etc/rsyslog.conf に以下と追加して rsyslog を再起動。

#### RULES ####
if $msg contains 'SRC=192.168.11.3' or $msg contains 'SRC=192.168.11.18' then            ~★追加
# Log all kernel messages to the console.


※rsyslog の参考
http://www.geocities.jp/yasasikukaitou/rsyslog-filter.html
http://www.usupi.org/sysad/208.html

RHEL7 でのハードウェアクロックの変更

RHEL7 より前、OS をインストールする際、ハードウェアクロックの時間 (世界標準時 or ローカル時) を設定することが可能だった。
しかし、RHEL7 ではこの設定が不可能。
このため、OS インストール後に設定する必要がある。

※RHEL4 では以下にある /etc/sysconfig/clock の UTC で設定していた。
http://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-ja-4/ch-sysconfig.html

以下は、RHEL7 での設定コマンド。

デフォルトでは以下の状態。
ハードウェアクロックとシステムクロックで時差がある。

# timedatectl
      Local time: 月 2014-09-15 03:42:09 JST★
  Universal time: 日 2014-09-14 18:42:09 UTC
        RTC time: 日 2014-09-14 18:42:10★
        Timezone: Asia/Tokyo (JST, +0900)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a
# hwclock --debug
hwclock from util-linux 2.23.2
/dev interface to clock を使います。
直前のずれの修正は 1969 年以降 0 秒時点で行なわれました
直前の調整は 1969 年以降 0 秒時点で行なわれました
ハードウェア時計はUTC時刻です
ハードウェア時計UTC時刻を保持しているとみなします
クロックチックを待っています...
...クロックチックを取得しました
ハードウェア時計から読込んだ時刻: 2014/09/14 18:42:17★
ハードウェア時計時刻 : 2014/09/14 18:42:17 = 1969 年以来 1410720137 秒★
2014年09月15日 03時42分17秒  -0.724543 秒
#
# cat /etc/adjtime
0.0 0 0.0
0
UTC★

以下の timedatectl set-local-rtc コマンドで設定変更可能。
※以下のドキュメントを参照
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html-single/System_Administrators_Guide/index.html
2.1.3. Changing the Current Time

# timedatectl set-local-rtc yes
# timedatectl
      Local time: 月 2014-09-15 03:42:36 JST★
  Universal time: 日 2014-09-14 18:42:36 UTC
        RTC time: 月 2014-09-15 03:42:36★
        Timezone: Asia/Tokyo (JST, +0900)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: yes
      DST active: n/a

Warning: The RTC is configured to maintain time in the local timezone. This
         mode is not fully supported and will create various problems with time
         zone changes and daylight saving adjustments. If at all possible use
         RTC in UTC, by calling 'timedatectl set-local-rtc 0'.
# hwclock --debug
hwclock from util-linux 2.23.2
/dev interface to clock を使います。
直前のずれの修正は 1969 年以降 0 秒時点で行なわれました
直前の調整は 1969 年以降 0 秒時点で行なわれました
ハードウェア時計はローカル時刻です
ハードウェア時計ローカル時刻を保持しているとみなします
クロックチックを待っています...
...クロックチックを取得しました
ハードウェア時計から読込んだ時刻: 2014/09/15 03:42:43★
ハードウェア時計時刻 : 2014/09/15 03:42:43 = 1969 年以来 1410720163 秒★
2014年09月15日 03時42分43秒  -0.334092 秒
#
#
# cat /etc/adjtime
0.0 0 0.0
0
LOCAL★

※ハードウェアクロックなどの詳細は以下を参照
パソコンの時計 ハードウェアクロックとシステムクロック

parted コマンド

1.ラベルの作成からパーティションの作成まで

# parted -s /dev/sdb print
エラー: /dev/sdb: ディスクラベルが認識できません。
# parted /dev/sdb
GNU Parted 2.1
/dev/sdb を使用
GNU Parted へようこそ! コマンド一覧を見るには 'help' と入力してください。
(parted) print
エラー: /dev/sdb: ディスクラベルが認識できません。
(parted) mklabel msdos★ラベルの作成。2TB を超える場合は、msdos ではなく GPT になる。
(parted) print
モデル: VMware, VMware Virtual S (scsi)
ディスク /dev/sdb: 8590MB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos

番号  開始  終了  サイズ  タイプ  ファイルシステム  フラグ

(parted) mkpart★mkpart だとファイルシステムが未作成。mkpartfs だとファイルシステムまで作成されるが、ext3、ext4 は不可能な上に廃止予定
パーティションの種類?  primary/プライマリ/extended/拡張? primary
ファイルシステムの種類?  [ext2]? ext4
開始? 1
終了? 2048
(parted) print
モデル: VMware, VMware Virtual S (scsi)
ディスク /dev/sdb: 8590MB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos

番号  開始    終了    サイズ  タイプ   ファイルシステム  フラグ
 1    1049kB  2048MB  2047MB  primary

(parted) quit
通知: 必要であれば /etc/fstab を更新するのを忘れないようにしてください。

#


以下のコマンドでも同じ

# parted /dev/sdb mklabel msdos
# parted /dev/sdb mkpart primary ext4 1049kB 2048MB


以下の場合は、「unit MB」で単位を MB と明示しているので、開始が 1024MB、終了が 2048MB となる。

# parted /dev/sdb unit MB mkpart primary ext4 1024 2048


2.パーティションの削除

# parted /dev/sdb
GNU Parted 2.1
/dev/sdb を使用
GNU Parted へようこそ! コマンド一覧を見るには 'help' と入力してください。
(parted) print
モデル: VMware, VMware Virtual S (scsi)
ディスク /dev/sdb: 8590MB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos

番号  開始    終了    サイズ  タイプ   ファイルシステム  フラグ
 1    1049kB  2048MB  2047MB  primary

(parted) rm
パーティション番号? 1
(parted) print
モデル: VMware, VMware Virtual S (scsi)
ディスク /dev/sdb: 8590MB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos

番号  開始  終了  サイズ  タイプ  ファイルシステム  フラグ

(parted) quit
通知: 必要であれば /etc/fstab を更新するのを忘れないようにしてください。

#

以下のコマンドでも同じ

# parted /dev/sdb rm 1

https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html-single/Storage_Administration_Guide/index.html
第13章 パーティション

dovecot のユーザ認証

参考 URL

http://wiki2.dovecot.org/AuthDatabase/PasswdFile
http://www.dovecot.jp/wiki/BasicConfiguration.txt
http://knowledge4linux.blogspot.jp/2013/08/dovecot-passwd-file.html
http://www.1stdegree.co.jp/blog/yokomaku/?p=83

(1) 変更前

[root@LVS ~]# doveconf -n
# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-358.el6.x86_64 x86_64 CentOS release 6.4 (Final)
disable_plaintext_auth = no
mail_access_groups = mail
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mbox_write_locks = fcntl
passdb {
  driver = pam
}
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem
userdb {
  driver = passwd
}
[root@LVS ~]#

(2) ユーザの作成

# useradd test02
# id test02
uid=503(test02) gid=503(test02) 所属グループ=503(test02)
#

(3) passwd-file の作成

# echo "test02:{PLAIN}test02" > passwd.dovecot
# mv passwd.dovecot /etc/dovecot

(4) /etc/dovecot/conf.d/auth-system.conf.ext の変更

        :       :
passdb {
  args = /etc/dovecot/passwd.dovecot
  driver = passwd-file
}
        :       :
userdb {
  driver = passwd
}
        :       :

(5) 設定変更後

# doveconf -n
# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-358.el6.x86_64 x86_64 CentOS release 6.4 (Final)
disable_plaintext_auth = no
mail_access_groups = mail
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mbox_write_locks = fcntl
passdb {
  args = /etc/dovecot/passwd.dovecot
  driver = passwd-file
}
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem
userdb {
  driver = passwd
}
#

dovecot の基本的な設定 (POP3)

(1) サービス起動直後

ログインできない。

# id test01
uid=502(test01) gid=502(test01) 所属グループ=502(test01)
#
# ls -l /var/spool/mail/| grep test
-rw-rw----  1 test01   mail   0  8月 28 02:39 2014 test01
# ls -laR /home/test01/
/home/test01/:
合計 20
drwx------  2 test01 test01 4096  8月 28 02:39 2014 .
drwxr-xr-x. 5 root   root   4096  8月 28 02:39 2014 ..
-rw-r--r--  1 test01 test01   18  2月 22 06:09 2013 .bash_logout
-rw-r--r--  1 test01 test01  176  2月 22 06:09 2013 .bash_profile
-rw-r--r--  1 test01 test01  124  2月 22 06:09 2013 .bashrc
#
# telnet localhost 110
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user test01
+OK
pass test
Connection closed by foreign host.
#

以下は、maillog

Aug 28 02:40:34 LVS dovecot: master: Dovecot v2.0.9 starting up (core dumps disabled)
Aug 28 02:40:53 LVS dovecot: pop3-login: Login: user=<test01>, method=PLAIN, rip=::1, lip=::1, mpid=1737, secured
Aug 28 02:40:53 LVS dovecot: pop3(test01): Error: user test01: Initialization failed: mail_location not set and autodetection failed: Mail storage autodetection failed with home=/home/test01
Aug 28 02:40:53 LVS dovecot: pop3(test01): Error: Invalid user settings. Refer to server log for more information.


(2) 基本的な設定

/etc/dovecot/conf.d/10-mail.conf に以下を追加

#メールボックスの位置の指定
mail_location = mbox:~/mail:INBOX=/var/mail/%u

#メールボックスの作成で必要
mail_access_groups=mail

/etc/dovecot/conf.d/10-auth.conf に以下を追加

#外部からの接続 (平文での接続) を許可
disable_plaintext_auth = no

※以下は参考 URL
http://server-setting.info/centos/dovecot.html
http://www.atmarkit.co.jp/fnetwork/rensai/netpro07/pop3-commands.html


ログイン (telnet コマンド) できた。

#  telnet localhost 110
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user test01
+OK
pass test
+OK Logged in.
stat
+OK 0 0
quit
+OK Logging out.
Connection closed by foreign host.

ログイン後のファイルの生成状況は以下のとおり。

# ls -l /var/spool/mail/| grep test
-rw-rw----  1 test01   mail   0  8月 28 02:39 2014 test01
# ls -laR /home/test01/
/home/test01/:
合計 24
drwx------  3 test01 test01 4096  8月 28 02:52 2014 .
drwxr-xr-x. 5 root   root   4096  8月 28 02:39 2014 ..
-rw-r--r--  1 test01 test01   18  2月 22 06:09 2013 .bash_logout
-rw-r--r--  1 test01 test01  176  2月 22 06:09 2013 .bash_profile
-rw-r--r--  1 test01 test01  124  2月 22 06:09 2013 .bashrc
drwx------  3 test01 test01 4096  8月 28 02:52 2014 mail

/home/test01/mail:
合計 12
drwx------ 3 test01 test01 4096  8月 28 02:52 2014 .
drwx------ 3 test01 test01 4096  8月 28 02:52 2014 ..
drwx------ 3 test01 test01 4096  8月 28 02:52 2014 .imap

/home/test01/mail/.imap:
合計 12
drwx------ 3 test01 test01 4096  8月 28 02:52 2014 .
drwx------ 3 test01 test01 4096  8月 28 02:52 2014 ..
drwxrwx--- 2 test01 mail   4096  8月 28 02:52 2014 INBOX

/home/test01/mail/.imap/INBOX:
合計 12
drwxrwx--- 2 test01 mail   4096  8月 28 02:52 2014 .
drwx------ 3 test01 test01 4096  8月 28 02:52 2014 ..
-rw-rw---- 1 test01 mail    148  8月 28 02:52 2014 dovecot.index.log★ログイン時、生成された
#


以下は、maillog

Aug 28 02:52:54 LVS dovecot: pop3-login: Login: user=<test01>, method=PLAIN, rip=::1, lip=::1, mpid=1780, secured
Aug 28 02:52:58 LVS dovecot: pop3(test01): Disconnected: Logged out top=0/0, retr=0/0, del=0/0, size=0


※参考ドキュメント
http://www.dovecot.jp/wiki/BasicConfiguration.txt