451 See http://pobox.com/~djb/docs/smtplf.html.
[root@centos-qmail bin]# ./qmail-smtpd
220 centos-qmail.local ESMTP
helo qq.com
250 centos-qmail.local
mail fre^H
250 ok
mail from:qidizi@qq.com
250 ok
rcpt qi^H
250 ok
rcpt to:qidizi@qq.com
250 ok
data
354 go ahead
Subject:?=gb2312?B?d=?=
451 See http://pobox.com/~djb/docs/smtplf.html.
上面测试直接使用qmail的smtp来测试可以正常
但是使用telnet却不行
因为 netstat -a 看不到smtp 25端口有东西在监听
现在才明白tcpcspi是监听用的
使用官方的run启动时提示
[root@centos-qmail bin]# chown qmaill /var/log/qmail /var/log/qmail/smtpd
[root@centos-qmail bin]# qmailctl stat
/service/qmail-send: up (pid 10823) 2693 seconds
/service/qmail-send/log: up (pid 10822) 2693 seconds
/service/qmail-smtpd: up (pid 26643) 0 seconds
/service/qmail-smtpd/log: up (pid 26642) 0 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0
[root@centos-qmail bin]# ps -efl | grep "service errors" | grep -v grep
0 S root 10815 10812 0 80 0 - 957 pipe_w 01:23 pts/0 00:00:00 readproctitle service errors: ...denied?multilog: fatal: unable to lock directory /var/log/qmail/smtpd: access denied?multilog: fatal: unable to lock directory /var/log/qmail/smtpd: access denied?multilog: fatal: unable to lock directory /var/log/qmail/smtpd: access denied?multilog: fatal: unable to lock directory /var/log/qmail/smtpd: access denied?multilog: fatal: unable to lock directory /var/log/qmail/smtpd: access denied?
[root@centos-qmail bin]# /service/qmail-smtpd/run
Segmentation fault
运行这个服务时,提示出错
Segmentation fault
手动调试这个sh脚本时,发现是官方教程把端口使用smtp时出错,改成25即可
[root@centos-qmail bin]# id -u qmaild
503
[root@centos-qmail bin]# id -g qmaild
502
[root@centos-qmail bin]# cat /var/qmail/control/concurrentcyincoming
cat: /var/qmail/control/concurrentcyincoming: No such file or directory
[root@centos-qmail bin]# cat /var/qmail/control/concurrencyincoming
20
[root@centos-qmail bin]# head -1 /var/qmail/control/me
centos-qmail.local
[root@centos-qmail bin]# /service/qmail-smtpd/run
Segmentation fault
[root@centos-qmail bin]# /service/qmail-smtpd/run
Segmentation fault
[root@centos-qmail bin]# /service/qmail-smtpd/run
dkdjkf
Segmentation fault
[root@centos-qmail bin]# /service/qmail-smtpd/run
dkdjkf
kjkjkjkfjkdjkf
Segmentation fault
[root@centos-qmail bin]# /service/qmail-smtpd/run
-bash: /service/qmail-smtpd/run: Permission denied
[root@centos-qmail bin]# /service/qmail-smtpd/run
-bash: /service/qmail-smtpd/run: Permission denied
[root@centos-qmail bin]# chmod 755 /service/qmail-smtpd/run
[root@centos-qmail bin]# /service/qmail-smtpd/run
dkdjkf
kjkkjkk
Segmentation fault
[root@centos-qmail bin]# exec /usr/local/bin/softlimit -m 2000000 \
> /usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
> -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
这里0 stmp /var 中的smtp就是端口,要改成25
Last login: Wed Oct 26 01:20:09 2011 from 192.168.21.36
[root@centos-qmail ~]# /usr/local/bin/tcpserver -v -R -l
tcpserver: option requires an argument -- l
tcpserver: usage: tcpserver [ -1UXpPhHrRoOdDqQv ] [ -c limit ] [ -x rules.cdb ] [ -B banner ] [ -g gid ] [ -u uid ] [ -b backlog ] [ -l localname ] [ -t timeout ] host port program
[root@centos-qmail ~]# /usr/local/bin/tcpserver -v -R -l "centos-qmail.local"
tcpserver: usage: tcpserver [ -1UXpPhHrRoOdDqQv ] [ -c limit ] [ -x rules.cdb ] [ -B banner ] [ -g gid ] [ -u uid ] [ -b backlog ] [ -l localname ] [ -t timeout ] host port program
[root@centos-qmail ~]# /service/qmail-smtpd/run
dkdjkf
kjkkjkk
Segmentation fault
[root@centos-qmail ~]# /service/qmail-smtpd/run
-bash: /service/qmail-smtpd/run: Permission denied
[root@centos-qmail ~]# chmod 755 /service/qmail-smtpd/run
[root@centos-qmail ~]# /service/qmail-smtpd/run
Segmentation fault
[root@centos-qmail ~]# /service/qmail-smtpd/run
/usr/local/bin/softlimit -m 2000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
Segmentation fault
[root@centos-qmail ~]# /usr/local/bin/softlimit -m 2000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
Segmentation fault
[root@centos-qmail ~]# /usr/local/bin/softlimit -m 2000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 5
02 0 smtp /var/qmail/bin/qmail-smtpd
Segmentation fault
[root@centos-qmail ~]# /usr/local/bin/softlimit
softlimit: usage: softlimit [-a allbytes] [-c corebytes] [-d databytes] [-f filebytes] [-l lockbytes] [-m membytes] [-o openfiles] [-p processes] [-r residentbytes] [-s stackbytes] [-t cpusecs] child
这里把内存2000000 改成4000000 不再提示 Segmentation fault
[root@centos-qmail ~]# /usr/local/bin/softlimit -m 4000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd
tcpserver: fatal: unable to figure out port number for smtp
但是提示这个错误 这是因为商品错误,可能是有东西在用.
[root@centos-qmail ~]# /service/qmail-smtpd/run
/usr/local/bin/softlimit -m 4000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
tcpserver: fatal: unable to figure out port number for smtp
[root@centos-qmail ~]# yum list inetd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
Error: No matching Packages to list
[root@centos-qmail ~]# ps -A
PID TTY TIME CMD
1 ? 00:00:00 init
2 ? 00:00:00 kthreadd
3 ? 00:00:00 migration/0
4 ? 00:00:00 ksoftirqd/0
5 ? 00:00:00 watchdog/0
6 ? 00:00:00 migration/1
7 ? 00:00:00 ksoftirqd/1
8 ? 00:00:00 watchdog/1
9 ? 00:00:00 events/0
10 ? 00:00:03 events/1
11 ? 00:00:00 cpuset
12 ? 00:00:00 khelper
13 ? 00:00:00 netns
14 ? 00:00:00 async/mgr
15 ? 00:00:00 pm
16 ? 00:00:00 sync_supers
17 ? 00:00:00 bdi-default
18 ? 00:00:00 kintegrityd/0
19 ? 00:00:00 kintegrityd/1
20 ? 00:00:00 kblockd/0
21 ? 00:00:00 kblockd/1
22 ? 00:00:00 kacpid
23 ? 00:00:00 kacpi_notify
24 ? 00:00:00 kacpi_hotplug
25 ? 00:00:00 ata/0
26 ? 00:00:00 ata/1
27 ? 00:00:00 ata_aux
28 ? 00:00:00 ksuspend_usbd
29 ? 00:00:00 khubd
30 ? 00:00:00 kseriod
33 ? 00:00:00 khungtaskd
34 ? 00:00:00 kswapd0
35 ? 00:00:00 ksmd
36 ? 00:00:00 khugepaged
37 ? 00:00:00 aio/0
38 ? 00:00:00 aio/1
39 ? 00:00:00 crypto/0
40 ? 00:00:00 crypto/1
46 ? 00:00:00 kpsmoused
47 ? 00:00:00 usbhid_resumer
77 ? 00:00:00 kstriped
225 ? 00:00:00 scsi_eh_0
226 ? 00:00:00 scsi_eh_1
246 ? 00:00:00 cciss_scan
305 ? 00:00:00 kdmflush
312 ? 00:00:00 kdmflush
324 ? 00:00:00 jbd2/dm-0-8
325 ? 00:00:00 ext4-dio-unwrit
326 ? 00:00:00 ext4-dio-unwrit
364 ? 00:00:00 kauditd
414 ? 00:00:00 udevd
532 ? 00:00:00 edac-poller
693 ? 00:00:00 kdmflush
726 ? 00:00:00 jbd2/cciss!c0d0
727 ? 00:00:00 ext4-dio-unwrit
728 ? 00:00:00 ext4-dio-unwrit
729 ? 00:00:00 jbd2/dm-2-8
730 ? 00:00:00 ext4-dio-unwrit
731 ? 00:00:00 ext4-dio-unwrit
1159 ? 00:00:00 rsyslogd
1208 ? 00:00:00 rpcbind
1226 ? 00:00:00 rpc.statd
1238 ? 00:00:00 mdadm
1263 ? 00:00:00 rpciod/0
1264 ? 00:00:00 rpciod/1
1271 ? 00:00:00 rpc.idmapd
1300 ? 00:00:00 dbus-daemon
1326 ? 00:00:00 acpid
1335 ? 00:00:00 hald
1336 ? 00:00:00 hald-runner
1364 ? 00:00:00 hald-addon-inpu
1377 ? 00:00:00 hald-addon-acpi
1394 ? 00:00:00 automount
1412 ? 00:00:00 sshd
1420 ? 00:00:00 xinetd
1429 ? 00:00:00 abrtd
1437 ? 00:00:00 crond
1448 ? 00:00:00 atd
1458 tty1 00:00:00 mingetty
1460 tty2 00:00:00 mingetty
1462 tty3 00:00:00 mingetty
1466 tty4 00:00:00 mingetty
1468 tty5 00:00:00 mingetty
1469 ? 00:00:00 udevd
1470 ? 00:00:00 udevd
1472 tty6 00:00:00 mingetty
1492 ? 00:00:01 auditd
1528 ? 00:00:00 tcpserver
1542 ? 00:00:00 multilog <defunct>
1543 pts/1 00:00:00 ps
10754 ? 00:00:00 flush-253:0
10755 ? 00:00:00 sshd
10777 ? 00:00:00 sftp-server
10810 ? 00:00:00 csh
10812 ? 00:00:00 svscanboot
10814 ? 00:00:00 svscan
10815 ? 00:00:00 readproctitle
10816 ? 00:00:02 supervise
10817 ? 00:00:03 supervise
10820 ? 00:00:00 supervise
10821 ? 00:00:00 supervise
10822 ? 00:00:00 multilog
10823 ? 00:00:00 qmail-send
10828 ? 00:00:00 qmail-lspawn
10829 ? 00:00:00 qmail-rspawn
10830 ? 00:00:00 qmail-clean
30685 pts/1 00:00:00 bash
[root@centos-qmail ~]# yum list xinetd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* updates: mirror.neu.edu.cn
Installed Packages
xinetd.x86_64 2:2.3.14-29.el6 @base
[root@centos-qmail ~]# yum erase xinetd
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package xinetd.x86_64 2:2.3.14-29.el6 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
xinetd x86_64 2:2.3.14-29.el6 @base 257 k
Transaction Summary
================================================================================
Remove 1 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : 2:xinetd-2.3.14-29.el6.x86_64 1/1
Removed:
xinetd.x86_64 2:2.3.14-29.el6
Complete!
[root@centos-qmail ~]# /service/qmail-smtpd/run
/usr/local/bin/softlimit -m 4000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
tcpserver: fatal: unable to figure out port number for smtp
[root@centos-qmail ~]# /usr/local/bin/softlimit
softlimit: usage: softlimit [-a allbytes] [-c corebytes] [-d databytes] [-f filebytes] [-l lockbytes] [-m membytes] [-o openfiles] [-p processes] [-r residentbytes] [-s stackbytes] [-t cpusecs] child
[root@centos-qmail ~]# /usr/local/bin/tcpserver
tcpserver: usage: tcpserver [ -1UXpPhHrRoOdDqQv ] [ -c limit ] [ -x rules.cdb ] [ -B banner ] [ -g gid ] [ -u uid ] [ -b backlog ] [ -l localname ] [ -t timeout ] host port program
[root@centos-qmail ~]# /service/qmail-smtpd/run
-bash: /service/qmail-smtpd/run: Permission denied
[root@centos-qmail ~]# chmod 755 /service/qmail-smtpd/run
改成25后就不再出错了.
tcpserver: ok 1900 centos-qmail.local:127.0.0.1:25 localhost:127.0.0.1::49866
sh echo 出来还是smtp是我不记得改echo 这节的代码,
[root@centos-qmail ~]# /service/qmail-smtpd/run
/usr/local/bin/softlimit -m 4000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
tcpserver: status: 0/20
tcpserver: status: 1/20
tcpserver: pid 1900 from 127.0.0.1
tcpserver: ok 1900 centos-qmail.local:127.0.0.1:25 localhost:127.0.0.1::49866
tcpserver: warning: dropping connection, unable to run /var/qmail/bin/qmail-smtpd: out of memory
tcpserver: end 1900 status 28416
tcpserver: status: 0/20
tcpserver: status: 1/20
tcpserver: pid 1924 from 127.0.0.1
tcpserver: ok 1924 centos-qmail.local:127.0.0.1:25 localhost:127.0.0.1::49868
tcpserver: warning: dropping connection, unable to run /var/qmail/bin/qmail-smtpd: out of memory
tcpserver: end 1924 status 28416
tcpserver: status: 0/20
^C
[root@centos-qmail ~]# /service/qmail-smtpd/run
/usr/local/bin/softlimit -m 10000000 /usr/local/bin/tcpserver -v -R -l centos-qmail.local -x /etc/tcp.smtp.cdb -c 20 -u 503 -g 502 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
tcpserver: status: 0/20
tcpserver: status: 1/20
tcpserver: pid 2647 from 127.0.0.1
tcpserver: ok 2647 centos-qmail.local:127.0.0.1:25 localhost:127.0.0.1::51690
tcpserver: end 2647 status 0
tcpserver: status: 0/20
最后得到一个结论是sh还是需要一句一句来调度.否则,有些错误根本不懂怎么回事
-------------
ubuntu调试
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# vi run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
#can empty rcpthosts
# exit 1
fi
exec /usr/local/bin/softlimit -m 2000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 25 /var/qmail/bin/qmail-smtpd 2>&1
~
~
~
~
~
~
~
~
~
~
~
~
"run" 25L, 782C written
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# ./run
Segmentation fault
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# vi run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
#can empty rcpthosts
# exit 1
fi
exec /usr/local/bin/softlimit -m 4000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 25 /var/qmail/bin/qmail-smtpd 2>&1
~
~
~
~
~
~
~
~
~
~
~
~
"run" 25L, 782C written
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# ./run
/usr/local/bin/tcpserver: error while loading shared libraries: libc.so.6: failed to map segment from shared object: Cannot allocate memory
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# vi run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
#can empty rcpthosts
# exit 1
fi
exec /usr/local/bin/softlimit -m 3000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 25 /var/qmail/bin/qmail-smtpd 2>&1
~
~
~
~
~
~
~
~
~
~
~
~
"run" 25L, 782C written
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# ./run
/usr/local/bin/tcpserver: error while loading shared libraries: libc.so.6: failed to map segment from shared object: Cannot allocate memory
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# vi run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
#can empty rcpthosts
# exit 1
fi
exec /usr/local/bin/softlimit -m 5000000\
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp/var/qmail/bin/qmail-smtpd 2>&1
~
~
~
~
~
~
~
~
~
~
~
~
"run" 25L, 784C written
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# ./run
tcpserver: fatal: unable to figure out port number for smtp
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# vi run
#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
#can empty rcpthosts
# exit 1
fi
exec /usr/local/bin/softlimit -m 5000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 25/var/qmail/bin/qmail-smtpd 2>&1
~
~
~
~
~
~
~
~
~
~
~
~
"run" 25L, 782C written
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# ./run
tcpserver: status: 0/20
^C
运行成功
root@chrd-edm:/var/qmail/supervise/qmail-smtpd# ls