谢谢xmubeta的指正。
至于为什么原来的patch在linux不出错,在solaris上出错。
我理解是linux上将结构传入参数,转化成char *的时候,实际上是将第一个结构成员转化了,而这个正好是mailfrom.s。所以没有问题。
而solaris上就有所不同了,所以造成错误。
iceblood, patch我给你重发了。
另外而且还加了一些注释,版本号。方法和前面一样。
我稍微测试了一下。各位测恻看吧。
[code:1:e9fa54356d]
--- qmail-smtpd.c 2003-06-02 18:;34:;51.000000000 -0400
+++ qmail-smtpd.c.new 2003-06-02 18:;42:;31.000000000 -0400
@@ -268,6 +268,7 @@
int r;
r = rcpthosts(addr.s,str_len(addr.s));
if (r == -1) die_control();
+ if (!localauthd()) return 0;
return r;
}
@@ -304,7 +305,11 @@
if (!stralloc_copys(&rcptto,"")) die_nomem();
if (!stralloc_copys(&mailfrom,addr.s)) die_nomem();
if (!stralloc_0(&mailfrom)) die_nomem();
- out("250 ok\r\n");
+ if (smtp_auth_validfrom(mailfrom.s)) {
+ out("250 ok\r\n");
+ } else {
+ out("must use username as From authenticated! (#5.7.1)\r\n");
+ }
}
void smtp_rcpt(arg) char *arg; {
if (!seenmail) { err_wantmail(); return; }
@@ -527,6 +532,89 @@
static stralloc smtpauth = {0};
static char smtpauthlogin[65];
static char smtpauthpass[65];
+static int authd = 0;
+
+/* Author:; gadfly@163.com. Version:; 1.2.
+ * 1. Check consistent between auth user and 'From' user.
+ * 2. Read the LOG_AUTH enviroment variable to determine whether logging the auth info.
+ * LOG_AUTH=1, write the auth smtp info into syslog.
+ * 3. If mail from local, rcpt to local domain, user must auth before send data.
+ */
+#include <syslog.h>
+
+#define SMTP_AUTH_SUCCESS 0
+#define SMTP_AUTH_FAILED 1
+
+int localauthd() {
+
+ if (rcpthosts(mailfrom.s, strlen(mailfrom.s)) && !authd) return 0;
+ return 1;
+}
+
+int smtp_auth_validfrom(from) char * from;
+{
+ stralloc tmplogin={0},mydefaultdomain={0};
+ char authusername[256];
+ int k, userlen;
+
+ if (!authd) return 1;
+
+ authusername[255] = '\0';
+ userlen = k = str_len(smtpauthlogin);
+ k = byte_rchr(smtpauthlogin, k, '@');
+
+ if (k == userlen)
+ {
+ k = byte_rchr(smtpauthlogin, userlen, '%');
+
+ if (k == userlen)
+ {
+ if (control_readfile(&mydefaultdomain,"/var/qmail/control/me",1) != 1)
+ {
+ die_nomem();
+ }
+ if (!stralloc_copys(&tmplogin, smtpauthlogin) )
+ {
+ die_nomem();
+ }
+ if (!stralloc_cats(&tmplogin, "@") )
+ {
本文关键:修正Qmail auth smtp中电子邮件地址任意的patch
相关方案
- 建置安全的ExchangeSe…
- 防火墙环境中DNS的配置…
- 怎么设置Qmail用户邮箱的容…
- 如何做好Exchange200…
- Win2003+IIS6.0环…
- 如何做好Exchange200…
- redhat8.0自带send…
- QQ聊天服务器完全架设指南…
- 针对Win2000优化Web服…
- ExchangeServer2…
- Apache+Tomcat实现…
- BulletProof FTP…
- Exchange2003Ser…
- ExchangeServer2…
- Serv-U3.0的Domai…
- 政府Web网站的创建与管理…
- 使用Exchange2003防…
- 在Linux下建立强大的FTP…
- 如何利用qmail防止垃圾邮件…
- FTP服务器如何实现安全性 上…