SMTP-AUTH:Qmail+vpopmail(转)

本文介绍如何让 qmail 增加 smtpd-auth 功能.

1. 安装 qmail-smtpd

下载 qmail-smptd.patch http://www.elysium.pl/members/brush/

在 /usr/ports/mail/qmail 目录下面,patch <qmail-smptd.patch
重新编译 qmail,并拷贝 qmail-smtpd 到 /var/qmail/bin

2. 安装 vpopmail

使用mysql数据库的,需要注意的是一定要改动 vmysql.h 文件中的 mysql密码为你的 vpopmail 用户密码;

然后改动 vchkpw.c 文件中:下面的内容,分别在相应的位置加上 #ifdef AUTHVCHKPW 和 #endif

/* Since the vpopmail system runs under a uid/gid
* file system security, and since qmail-pop3d
* is required to run as the pop users uid/gid
* change to the vpasswds uid and gid
*/

#ifdef AUTHVCHKPW

if (setgid(pwent->pw_gid) == -1) {
log_exit(LOG_NOTICE, 4, "vchkpw: setgid() failed");
}

/* captn' changing group permissions, Eye Eye! */
if (setuid(pwent->pw_uid) == -1) {
log_exit(LOG_NOTICE, 5, "vchkpw: setuid() failed");
}

/* hop into thier email directory */
if (chdir(pwent->pw_dir) == -1) {

/* if the dir does not exist, create it */
if (vmake_maildir(pwent->pw_dir, pwent->pw_uid, pwent->pw_gid)==-1) {
log_exit(LOG_NOTICE, 5, "vchkpw: make user dir failed");
}
}
/* set up some environment variables */
scopy(envbuf1, VCHKPW_USER, MAX_ENV_BUF);
scat(envbuf1, pwent->pw_name, MAX_ENV_BUF);
if (putenv(envbuf1) == -1)  
log_exit(LOG_NOTICE,7,"vchkpw: putenv(USER) failed");  

/* now HOME */
scopy(envbuf2, VCHKPW_HOME, MAX_ENV_BUF);
scat(envbuf2, pwent->pw_dir, MAX_ENV_BUF);
if (putenv(envbuf2) == -1)  
log_exit(LOG_NOTICE, 8, "vchkpw: putenv(HOME) failed");

/* Now shell */
scopy(envbuf3, VCHKPW_SHELL, MAX_ENV_BUF);
if (putenv(envbuf3) == -1)  
log_exit(LOG_NOTICE, 9, "vchkpw: putenv(SHELL) failed");

/* and a vpopuser */
scopy(envbuf4, VCHKPW_VPOPUSER, MAX_ENV_BUF);
scat(envbuf4, name, MAX_ENV_BUF);
if (putenv(envbuf4) == -1)  
log_exit(LOG_NOTICE, 9, "vchkpw: putenv(VPOPUSER) failed");

/* close the auth module connection */

/* kick off the next program and exit */
execvp(argv[1],argv+1);

/* yikes! the exec failed, log error */
log_exit(LOG_NOTICE, 10, "vchkpw: execvp() failed");

#endif  
/* exit code of 0 */
return(0);

然后重新编译 make  

cd work/vpopmail* 目录,cp vchkpw /home/vpopmail/bin/authvchkpw

chmod a+s /home/vpopmail/bin/authvchkpw

 

以下ports安装是在vpopmail老的版本上通过,心版本没有测试,因此不建议采用 ports 安装。

在 /usr/ports/mail/vpopmail/下面增加 files 目录,并建立下面两个 patch 文件

文件patch-aa,内容如下:

+++ vmysql.h
27c27
< #define MYSQL_PASSWD "gipgap"
---
> #define MYSQL_PASSWD "mypassword"

文件 patch-bb,内容如下:
+++ vchkpw.c
310a311
>  
311a313
>  
313a316,317
> #ifdef AUTH_VCHKPW
>  
359a364,365
>  
> #endif

然后make -D WITHOUT_ROAMING -D WITH_MYSQL DEFAULT_DOMAIN=sczg.net,重新编译

cd work/vpopmail* 目录,cp vchkpw /home/vpopmail/bin/authvchkpw

chmod a+s /home/vpopmail/bin/authvchkpw

3. 把 smtp 的 tcpserver 命名改为:

/usr/local/bin/tcpserver -u 82 -g 81 0 smtp /var/qmail/bin/qmail-smtpd \
/usr/local/vpopmail/bin/authvchkpw \
2>&1 | /var/qmail/bin/splogger smtpd 3 &

重新启动相应的 tcpserver即可.

300*300
  • 没有相关文章
  • 没有评论
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00503 秒