imapext-2007
changeset 4:d741b3ecc917
imapext-2007f
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 30 Oct 2014 00:03:05 +0900 |
parents | 2366b362676d |
children | 2410c62d4b4f |
files | APOPtools/Makefile APOPtools/apopcall.c APOPtools/apoppasswd APOPtools/deapop APOPtools/deapop.gzip APOPtools/index.html APOPtools/pop3-age APOPtools/pop3-record APOPtools/pop3-record.postfix APOPtools/pop3-update APOPtools/qmapmore.html APOPtools/with-tcpserver/0README APOPtools/with-tcpserver/Makefile APOPtools/with-tcpserver/log/run APOPtools/with-tcpserver/pop APOPtools/with-tcpserver/run Makefile README.maildir README.qmailapop src/c-client/auth_log.c src/c-client/auth_md5.c src/c-client/mail.c src/c-client/mail.h src/imapd/imapd.c src/ipopd/ipop3d.c src/osdep/unix/Makefile src/osdep/unix/env_unix.c src/osdep/unix/tcp_unix.c src/osdep/unix/unix.c |
diffstat | 29 files changed, 1851 insertions(+), 136 deletions(-) [+] |
line diff
1.1 --- a/APOPtools/Makefile Thu Oct 30 00:00:57 2014 +0900 1.2 +++ b/APOPtools/Makefile Thu Oct 30 00:03:05 2014 +0900 1.3 @@ -28,3 +28,33 @@ 1.4 1.5 clean: 1.6 rm apopcall 1.7 +# 1.8 +# install script 1.9 +# 1.10 +PERMSMTPDIR = /usr/local/etc 1.11 +DEAPOPDIR = /usr/local/sbin 1.12 +BINDIR = /usr/local/bin 1.13 +CGIDIR = /usr/local/apache/cgi-bin 1.14 + 1.15 + 1.16 +all: apopcall 1.17 + 1.18 +LDFLAGS = -lcrypt 1.19 + 1.20 +apopcall: apopcall.c 1.21 + 1.22 + 1.23 +install: 1.24 + -@[ -d ${PERMSMTPDIR} ] || mkdir -p ${PERMSMTPDIR} 1.25 + install -c -m 700 pop3-record ${PERMSMTPDIR} 1.26 + csh -c 'ln -f ${PERMSMTPDIR}/pop3-{record,age}' 1.27 + csh -c 'ln -f ${PERMSMTPDIR}/pop3-{record,update}' 1.28 + -@[ -d ${DEAPOPDIR} ] || mkdir -p ${DEAPOPDIR} 1.29 + install -c -m 700 deapop ${DEAPOPDIR} 1.30 + install -c -m 755 apoppasswd ${BINDIR} 1.31 + 1.32 +install-cgi: apopcall 1.33 + install -cs -m 4755 -o 0 apopcall ${CGIDIR}/apopcall.cgi 1.34 + 1.35 +clean: 1.36 + rm apopcall
2.1 --- a/APOPtools/apopcall.c Thu Oct 30 00:00:57 2014 +0900 2.2 +++ b/APOPtools/apopcall.c Thu Oct 30 00:03:05 2014 +0900 2.3 @@ -524,3 +524,529 @@ 2.4 printf("このユーティリティはSSL接続時のみ有効です.<br>\n"); 2.5 } 2.6 } 2.7 +#include <stdio.h> 2.8 +#include <stdlib.h> 2.9 +#include <string.h> 2.10 +#include <unistd.h> 2.11 +#include <sys/types.h> 2.12 +#include <sys/wait.h> 2.13 +#include <sys/stat.h> 2.14 +#include <pwd.h> 2.15 +#ifdef SHADOW_PASSWD 2.16 +#include <shadow.h> 2.17 +#endif 2.18 + 2.19 +#ifndef APOPPASSWD 2.20 +#define APOPPASSWD "/usr/local/bin/apoppasswd" 2.21 +#endif 2.22 +#ifndef APOPFILEBASE 2.23 +#define APOPFILEBASE ".apop" 2.24 +#endif 2.25 +#ifndef XADDR_DELIM 2.26 +#define XADDR_DELIM ('-') 2.27 +#endif 2.28 + 2.29 +char *myname; 2.30 + 2.31 +int ishexa(int c) { 2.32 + strchr("0123456789ABCDFabcdef", c) ? 1 : 0; 2.33 +} 2.34 + 2.35 +put_form(email, pass, new, new2, suffix, hidden, auth, force) 2.36 + char *email, *pass, *new, *new2, *suffix; 2.37 + int hidden, auth, force; 2.38 + /* auth = 0: old password 2.39 + 1: base addresse's mail password 2.40 + 2: unix password */ 2.41 +{ 2.42 + char *authtype[] = {"old", "base", "unix"}; 2.43 + char *var[] = {"email", "pass", "new", "new2", "auth", ""}; 2.44 + char *val[] = {email, pass, new, new2, authtype[auth]}; 2.45 + char *prm[] = {"", /* "ユーザ名", */ 2.46 + auth ? 2.47 + ((auth==1) 2.48 + ? "基本メイルアドレス用パスワード<br>Password for Basic Mail address" 2.49 + : "UNIXログインパスワード<br>UNIX login Password") 2.50 + : "古いメイルパスワード<br>Old Mail Password", 2.51 + "新しいメイルパスワード<br>New Mail Password", 2.52 + "新パスワードをもう一回(確認)<br>New Mail Password Again", 2.53 + ""}; 2.54 + int h=0, i; 2.55 + 2.56 + printf("<form method=POST action\"./%s\">\n", myname); 2.57 + printf(" <table border=1>\n"); 2.58 + for (i=0; var[i][0]; i++) { 2.59 + h = hidden || strstr("email,suffix,auth", var[i]); 2.60 + if (prm[i][0]) { 2.61 + printf("<tr><td>%s</td><td>", prm[i]); 2.62 + } else { 2.63 + } 2.64 + printf("<input name=%s %svalue=\"%s\" length=40 maxlength=40>\n", 2.65 + var[i], 2.66 + h ? "type=hidden " 2.67 + : (strstr(prm[i], "パスワード") ? "type=password " : "<br>"), 2.68 + val[i]); 2.69 + if (!strcmp(var[i], "suffix")) { 2.70 + /* ここでは suffix を入れさせない方がいいかも */ 2.71 + /* 表向きのメイルアドレスを表示しておく */ 2.72 + printf("%s", email); 2.73 + /* if (suffix[0]) { 2.74 + printf("-%s", suffix); 2.75 + } */ 2.76 + if (auth) 2.77 + printf("<br>(新規作成:New Account)"); 2.78 + } 2.79 + if (prm[i][0]) 2.80 + printf("</td></tr>"); 2.81 + printf("\n"); 2.82 + } 2.83 + 2.84 + printf("</table>\n"); 2.85 + if (force) 2.86 + printf("<input name=force type=hidden value=ON>\n"); 2.87 + if (auth) { 2.88 + char *a[] = {"basic", "unix"}; 2.89 + printf("<input type=hidden name=auth value=\"%s\">\n", a[auth-1]); 2.90 + } 2.91 + printf("<input name=OK value=OK type=submit>\n"); 2.92 + printf("<input name=RESET value=RESET type=reset>\n"); 2.93 + printf("</form>\n"); 2.94 + fflush(stdout); 2.95 +} 2.96 + 2.97 +char *decode(char *code) { 2.98 + int l=1+strlen(code); 2.99 + int i, c, d; 2.100 + char *ret = (char*)malloc(l*sizeof(char)); 2.101 + char *p = code; 2.102 + memset(ret, 0, l); 2.103 + for (i=0; i<strlen(code); i++) { 2.104 + if (code[i] == '+') code[i] = ' '; 2.105 + } 2.106 + while (code[0] && (p=strchr(code, '%')) 2.107 + && ishexa(*(p+1)) && ishexa(*(p+2))) { 2.108 + *(p++) = '\0'; 2.109 + strncat(ret, code, l); 2.110 + c = (islower(*p) ? toupper(*p) : *p) - '0'; 2.111 + p++; 2.112 + d = (islower(*p) ? toupper(*p) : *p) - '0'; 2.113 + if (c > 9) c -= ('A'-'9'-1); 2.114 + if (d > 9) d -= ('A'-'9'-1); 2.115 + ret[strlen(ret)] = c*16+d; 2.116 + code = p+1; 2.117 + } 2.118 + if (code[0]) strncat(ret, code, l); 2.119 + return ret; 2.120 +} 2.121 + 2.122 +#define BSIZE 8192 2.123 +char **decode_post() { 2.124 + char *buf = (char*)malloc(BSIZE*sizeof(char)); 2.125 + char **post, *p = buf; 2.126 + int n=0, i; 2.127 + post = (char**)calloc(1, sizeof(char*)); 2.128 + *buf = '\0'; 2.129 + fgets(buf, BSIZE, stdin); 2.130 + if (strchr("\n\r", buf[strlen(buf)-1])) /* chop */ 2.131 + buf[strlen(buf)-1] = '\0'; 2.132 + while (buf[0] && NULL != (p=strchr(buf, '&'))) { 2.133 + *p = '\0'; 2.134 + post[n] = (char*)malloc((p-buf+1)*sizeof(char)); 2.135 + strcpy(post[n], buf); 2.136 + n++; 2.137 + post = (char**)realloc(post, (1+n)*sizeof(char*)); 2.138 + buf = 1+p; 2.139 + } 2.140 + if (buf[0]) post[n++] = buf; 2.141 + /* decode URL encoded */ 2.142 + for (i=0; i < n; i++) { 2.143 + char *p; 2.144 + p=post[i]; 2.145 + post[i] = decode(p); 2.146 + } 2.147 + post[i] = ""; /* terminator */ 2.148 + return post; 2.149 +} 2.150 + 2.151 +void footer() { 2.152 + puts("</body>\n</html>"); 2.153 + fflush(stdout); 2.154 +} 2.155 + 2.156 +void fail() { 2.157 + printf("パスワード更新に失敗しました<br>\n"); 2.158 + printf("<a href=\"./\">やり直し</a><br>\n"); 2.159 + footer(); 2.160 + exit(1); 2.161 +} 2.162 +void success(char *email) { 2.163 + printf("<hr>メイルアカウント %s 用のパスワード更新は完了しました。<br>\n", 2.164 + email); 2.165 + footer(); 2.166 + exit(0); 2.167 +} 2.168 + 2.169 +int apopfile_existp(char *home, char *suffix, uid_t uid) { 2.170 + struct stat st; 2.171 + int s; 2.172 + int len = strlen(home) + 1 2.173 + + strlen(APOPFILEBASE) + strlen(suffix) + 3; 2.174 + char *apopfile = (char*)malloc(len); 2.175 + if (suffix[0]) { 2.176 + snprintf(apopfile, len, "%s/%s%c%s%c", 2.177 + home, APOPFILEBASE, XADDR_DELIM, suffix, 0); 2.178 + } else { 2.179 + snprintf(apopfile, len, "%s/%s%c", home, APOPFILEBASE, 0); 2.180 + } 2.181 + seteuid(uid); 2.182 + s = stat(apopfile, &st); 2.183 + seteuid(0); 2.184 + memset(apopfile, '\0', strlen(apopfile)); 2.185 + free(apopfile); 2.186 + return !s; 2.187 +} 2.188 + 2.189 +#ifndef QMAILCONTROL 2.190 +# define QMAILCONTROL "/var/qmail/control" 2.191 +#endif 2.192 +#ifndef MAILTMPLEN 2.193 +# define MAILTMPLEN 1024 2.194 +#endif 2.195 + 2.196 +/* Convert virtual domain user 2.197 + */ 2.198 +char* conv_virtualdomain(char *account) { 2.199 + char *dom = strchr(account, '@'), *p; 2.200 + char vd[MAILTMPLEN+1], rewrite[MAILTMPLEN+1], previous[MAILTMPLEN+1]; 2.201 + FILE *vdfd; 2.202 + int match=0; 2.203 + char buf[MAILTMPLEN+1], *s; 2.204 + snprintf(vd, MAILTMPLEN, "%s/%s", QMAILCONTROL, "virtualdomains"); 2.205 + if (NULL == dom) return account; 2.206 + dom++; /* set position of domain part beginning */ 2.207 + if (dom && NULL != (vdfd = fopen (vd, "r"))) { 2.208 + int l = strlen(dom); 2.209 + int L = strlen(account); 2.210 + while ((s=fgets(buf, MAILTMPLEN, vdfd))) { 2.211 + if (p=strchr(s, '#')) 2.212 + *p = '\0'; /* zap comments */ 2.213 + if (!strchr(buf, ':')) 2.214 + continue; 2.215 + while (s && (strrchr(s, '\n') || strrchr(s, '\r') || strrchr(s, ' '))) 2.216 + s[strlen(s)-1] = '\0'; 2.217 + if (!strncmp(account, s, L) && s[L] == ':' && s[L+1]) { /* user matches */ 2.218 + match = 3; 2.219 + snprintf(rewrite, MAILTMPLEN, "%s-%s", s+L+1, account); 2.220 + break; 2.221 + } 2.222 + if (!strncmp(dom, s, l) && s[l] == ':' && s[l+1]) { /* domain matches */ 2.223 + match = 2; 2.224 + snprintf(rewrite, MAILTMPLEN, "%s%c%s", s+l+1, XADDR_DELIM, account); 2.225 + continue; 2.226 + } 2.227 + if (match < 2 && s[0] == '.') { /* if domain described in wildcard */ 2.228 + if (p=strchr(s, ':')) { 2.229 + *p = '\0'; 2.230 + if (!strcmp(dom+(strlen(dom)-strlen(s)), s)) { 2.231 + if (match == 0 2.232 + || strlen(previous) < strlen(s)) { 2.233 + match = 1; 2.234 + strncpy(previous, s, MAILTMPLEN); 2.235 + snprintf(rewrite, MAILTMPLEN, "%s%c%s", p+1, XADDR_DELIM, account); 2.236 + } 2.237 + } 2.238 + } 2.239 + } 2.240 + } 2.241 + fclose(vdfd); 2.242 + if (match) { 2.243 + p = strchr(rewrite, '@'); 2.244 + /* fprintf(stderr, "m=%d, rwr=[%s]\n", match, rewrite); */ 2.245 + if (p) { 2.246 + *p = '\0'; 2.247 + } 2.248 + /* fprintf(stderr, "rwr=[%s]\n", rewrite); */ 2.249 + s = malloc(strlen(rewrite)+1); 2.250 + strncpy(s, rewrite, strlen(rewrite)+1); 2.251 + memset(vd, 0, sizeof(vd)); 2.252 + memset(rewrite, 0, sizeof(rewrite)); 2.253 + memset(previous, 0, sizeof(previous)); 2.254 + return s; 2.255 + } 2.256 + } 2.257 + /* Then, compare with locals */ 2.258 + snprintf(vd, MAILTMPLEN, "%s/%s", QMAILCONTROL, "locals"); 2.259 + if (NULL != (vdfd=fopen(vd, "r"))) { 2.260 + while (s=fgets(buf, MAILTMPLEN, vdfd)) { 2.261 + if (p=strchr(s, '#')) *p = '\0'; /* zap after comment mark # */ 2.262 + while (*s && (strrchr(s, '\r')||strrchr(s, '\n') 2.263 + ||strrchr(s, ' ')||strrchr(s, '\t'))) { 2.264 + *(s+strlen(s)-1) = '\0'; 2.265 + } 2.266 + while (*s && (*s == '\t' || *s == ' ')) s++; 2.267 + if (!strncmp(s, dom, strlen(s))) { /* matches with local domain */ 2.268 + int len = dom-account-1; 2.269 + p = (char*)malloc(len+1); 2.270 + memset(p, '\0', len+1); 2.271 + strncpy(p, account, len); 2.272 + return p; 2.273 + } 2.274 + } 2.275 + } 2.276 + return NULL; /* invalid domain */ 2.277 + /* return account; return itself */ 2.278 +} 2.279 + 2.280 +void apopcall(char **args) { 2.281 + int i=0, sc=0; 2.282 + pid_t pid; 2.283 + char *email="", *suffix="", *pass="", *new="", *new2 = "", *home=""; 2.284 + char buf[BUFSIZ], auth, *user; 2.285 + FILE *child, *result; 2.286 + while (args[i][0]) { 2.287 + /* printf("[%s]<br>\n", args[i]); */ 2.288 + if (!strncmp("email=", args[i], 6)) { 2.289 + email = args[i]+6; 2.290 + } else if (!strncmp("suffix=", args[i], 7)) { 2.291 + suffix = args[i]+7; 2.292 + } else if (!strncmp("pass=", args[i], 5)) { 2.293 + pass = args[i]+5; 2.294 + } else if (!strncmp("new=", args[i], 4)) { 2.295 + new = args[i]+4; 2.296 + } else if (!strncmp("new2=", args[i], 5)) { 2.297 + new2 = args[i]+5; 2.298 + } else if (!strncmp("auth=", args[i], 5)) { 2.299 + /* "this" or "base" or "unix" */ 2.300 + auth = args[i][5]; 2.301 + } 2.302 + i++; 2.303 + } 2.304 + /* Make a backup of original e-mail address */ 2.305 + /* user = (char*)malloc(1+strlen(email)); 2.306 + strcpy(user, email); 2.307 + */ 2.308 + user = conv_virtualdomain(email); 2.309 + if (NULL == user) { 2.310 + printf("そのようなドメインは無効です(%s)<br>\n", strchr(email, '@')); 2.311 + printf("入力したメイルアドレスを確認してやり直してください.<br>\n"); 2.312 + fail(); 2.313 + } 2.314 + if (strchr(user, XADDR_DELIM)) { 2.315 + char *p = malloc(1+strlen(user)); 2.316 + char *q = NULL; 2.317 + struct passwd *pwd; 2.318 + /* printf("user=[%s]<br>\n", user); */ 2.319 + 2.320 + memset(p, '\0', 1+strlen(user)); 2.321 + strcpy(p, user); 2.322 + while (!(pwd=getpwnam(p)) && (q=strrchr(p, XADDR_DELIM))) { 2.323 + fflush(stdout); 2.324 + *q = '\0'; 2.325 + } 2.326 + if (pwd && q) { 2.327 + q = user+(q-p)+1; 2.328 + user=p; 2.329 + suffix=q; 2.330 + } 2.331 + } 2.332 + if (user[0] && new[0] && new2[0]) { 2.333 + int tochild[2], toparent[2]; 2.334 + pid_t pid; 2.335 + int argc=0; 2.336 + char **argv; 2.337 + struct passwd *pswd; 2.338 + char *pstr; 2.339 + 2.340 + if (!(pswd=getpwnam(user))) { 2.341 + printf("Unkown user %s.\n", user); 2.342 + fflush(stdout); 2.343 + fail(); 2.344 + } 2.345 + pstr = pswd->pw_passwd; 2.346 +#ifdef SHADOW_PASSWD 2.347 + { struct spwd *ss = getspnam(user); 2.348 + pstr = (char*)ss->sp_pwdp; 2.349 + } 2.350 +#endif 2.351 + home=pswd->pw_dir; 2.352 + argv = (char**)calloc(4, sizeof(char*)); 2.353 + argv[argc++] = "apoppasswd"; 2.354 + argv[argc++] = "-s"; 2.355 + argv[argc++] = "-c"; 2.356 + /* if old password does not exist, 2.357 + then check UNIX password */ 2.358 +#if 0 2.359 + if (apopfile_existp(home, suffix, pswd->pw_uid)) { /* no apop-ext exists */ 2.360 + /* そのまま */ 2.361 + } else if (apopfile_existp(home, "", pswd->pw_uid)) {/* check base mail password */ 2.362 + argv = (char**)realloc(argv, (argc+2)*sizeof(char*)); 2.363 + argv[argc++] = "-b"; 2.364 + } 2.365 +#endif 2.366 + switch (auth) { 2.367 + case 'b': case 'B': 2.368 + if (apopfile_existp(home, "", pswd->pw_uid)) { 2.369 + argv = (char**)realloc(argv, (argc+2)*sizeof(char*)); 2.370 + argv[argc++] = "-b"; 2.371 + } else { 2.372 + printf("基本アドレスのパスワードファイルがありません<br>\n"); 2.373 + fail(); 2.374 + } 2.375 + break; 2.376 + case 'u': case 'U': 2.377 + if (strcmp(pstr, (char*)crypt(pass, pstr))) { 2.378 + printf("UNIX Password not correct.<br>\n"); 2.379 + /* printf("[%s]vs.[%s]<br>\n", 2.380 + pswd->pw_passwd, crypt(pass, pswd->pw_passwd)); */ 2.381 + printf("UNIXパスワードと一致しません.<br>\n"); 2.382 + fflush(stdout); 2.383 + fail(); 2.384 + } 2.385 + } 2.386 + 2.387 + if (strlen(new) < 8 || strlen(new2) < 8) { 2.388 + printf("New mail password must be more than 7 characters.<br>\n"); 2.389 + printf("メイルパスワードは8文字以上にしてください。<br>\n"); 2.390 + fflush(stdout); 2.391 + fail(); 2.392 + } 2.393 + if (suffix[0]) { 2.394 + argv = (char**)realloc(argv, (argc+3)*sizeof(char*)); 2.395 + argv[argc++] = "-e"; 2.396 + argv[argc++] = suffix; 2.397 + 2.398 + } 2.399 + argv[argc++] = NULL; 2.400 + if (setgid(pswd->pw_gid) || 0 != setuid(pswd->pw_uid)) { 2.401 + printf("Cannot switch to %s\n", user); 2.402 + printf("uid=%d, gid=%d<br>\n", pswd->pw_gid, pswd->pw_uid); 2.403 + printf("メイルパスワード変更サーバの設定不良の可能性があるので<br>\n"); 2.404 + printf("お手数ですがこの画面のコピーを添えてシステム管理者"); 2.405 + printf("まで御連絡下さい。<br>\n"); 2.406 + fflush(stdout); 2.407 + fail(); 2.408 + } 2.409 + 2.410 + /* OK, start apopasswd */ 2.411 + if (pipe(tochild)+pipe(toparent)) { 2.412 + printf("Cannot create pipe\n"); 2.413 + fail(); 2.414 + } 2.415 + if ((pid=fork()) > 0) { 2.416 + FILE *child = fdopen(tochild[1], "w"); 2.417 + close(tochild[0]); 2.418 + close(toparent[1]); 2.419 + fprintf(child, "PASS %s\nNEW %s\nNEW2 %s\n", 2.420 + pass, new, new2); 2.421 + fflush(child); 2.422 + fclose(child); 2.423 + 2.424 + } else if (pid == -1) { 2.425 + printf("Cannot fork\n"); 2.426 + fail(); 2.427 + } else { 2.428 + char *pe = malloc(6+strlen(pswd->pw_dir)); 2.429 + close(tochild[1]); 2.430 + close(toparent[0]); 2.431 + dup2(tochild[0], 0); 2.432 + dup2(toparent[1], 1); 2.433 + 2.434 + /* setuid section */ 2.435 + 2.436 + strcpy(pe, "HOME="); 2.437 + strcat(pe, pswd->pw_dir); 2.438 + if (putenv(pe)) { 2.439 + puts("ga-n! arichan gakkari<br>"); 2.440 + } 2.441 + execv(APOPPASSWD, argv); 2.442 + 2.443 + /* setuid section ends */ 2.444 + fprintf(stderr, "Cannot exec %s\n", APOPPASSWD); 2.445 + fail(); 2.446 + } 2.447 + result = fdopen(toparent[0], "r"); 2.448 + while (fgets(buf, BUFSIZ, result)) { 2.449 + printf("%s<br>", buf); 2.450 + fflush(stdout); 2.451 + if (strstr(buf, "Success!")) { 2.452 + printf("<br>Mail Password changed successfully!<br>\n"); 2.453 + sc++; 2.454 + break; 2.455 + } else if (strstr(buf, "mismatch")) { 2.456 + printf("二個入れた新パスワードが一致しません.<br>\n"); 2.457 + break; 2.458 + } else if (strstr(buf, "Illegal")) { 2.459 + printf("照合用パスワードが違います.<br>--\n"); 2.460 + break; 2.461 + } else if (strstr(buf, "does not exist")) { 2.462 + /* try_overwrite(user, pass, new, new2, suffix); */ 2.463 + if (suffix[0]) { 2.464 + printf("%s-%s", user, suffix); 2.465 + } else { 2.466 + printf("%s", user); 2.467 + } 2.468 + /* ここは来ないことになった(のはず) */ 2.469 + printf("というメイルアカウントは未作成です<br>\n"); 2.470 + printf("新規に作る場合はOKボタンをクリック\n"); 2.471 + put_form(email, pass, new, new2, suffix, 1, 0, 1); 2.472 + fflush(stdout); 2.473 + } 2.474 + } 2.475 + fclose(result); 2.476 + while (wait(0) != pid) {sleep(1);fputc('.', stderr);} 2.477 + if (sc) success(email); else fail(); 2.478 + } else if (user[0]) { 2.479 + struct passwd *pw = getpwnam(user); 2.480 + int auth=0; 2.481 + if (!pw) { 2.482 + printf("そのようなユーザはいません %s<br>\n", user); 2.483 + fail(); 2.484 + } 2.485 + home=pw->pw_dir; 2.486 + 2.487 + printf("%s というメイルアドレスの<br>\n", email); 2.488 + printf("メイル専用パスワードを変更します.<br>\n"); 2.489 + printf("メイルパスワードとUNIXパスワードの違いに気をつけてください.<br>\n"); 2.490 + printf("新パスワードは8文字以上にしてください.<br>\n"); 2.491 + printf("New password must be more than or equal to 8 characters.<br>\n"); 2.492 + if (apopfile_existp(home, suffix, pw->pw_uid)) { 2.493 + auth = 0; /* this password file */ 2.494 + printf("「古いメイルパスワード」には、現在<br>\n"); 2.495 + printf("<tt>%s</tt><br>\n", email); 2.496 + printf("を読むために指定しているパスワードを入力します。"); 2.497 + } else if (apopfile_existp(home, "", pw->pw_uid)) { 2.498 + auth = 1; /* basic mail address password */ 2.499 + printf("今回は本人認証として基本メイルアドレスのパスワードを"); 2.500 + printf("入力しますが、新しくパスワードを設定するのは<br>\n"); 2.501 + printf("<tt>%s</tt><br>\n", email); 2.502 + printf("用のパスワードです。基本メイルアドレスのパスワードは"); 2.503 + printf("変わりませんので注意してください。"); 2.504 + } else { 2.505 + auth = 2; /* UNIX login */ 2.506 + } 2.507 + put_form(email, "", "", "", suffix, 0, auth, 0); 2.508 + footer(); 2.509 + exit(0); 2.510 + } 2.511 + printf("user=[%s]\n", user); 2.512 +} 2.513 + 2.514 +int main(int argc, char* argv[]) { 2.515 + char *method = getenv("REQUEST_METHOD"); 2.516 + char **args; 2.517 + myname = argv[0]; 2.518 + if (method && strcmp(method, "POST") != 0) { 2.519 + printf("This program should be used in method:POST.\n"); 2.520 + fail(); 2.521 + } 2.522 + printf("Content-type: text/html; charset=EUC-JP\n\n"); 2.523 + printf("<html>\n<head><title>Change Password</title></head>\n"); 2.524 + printf("<body style=\"background: #f0ffff;\">\n"); 2.525 + if (getenv("SSL_CIPHER") && getenv("SSL_PROTOCOL")) { 2.526 + args = decode_post(); 2.527 + apopcall(args); 2.528 + } else { 2.529 + printf("This program can be used only via SSL connection.<br>\n"); 2.530 + printf("このユーティリティはSSL接続時のみ有効です.<br>\n"); 2.531 + } 2.532 +}
3.1 --- a/APOPtools/apoppasswd Thu Oct 30 00:00:57 2014 +0900 3.2 +++ b/APOPtools/apoppasswd Thu Oct 30 00:03:05 2014 +0900 3.3 @@ -208,3 +208,213 @@ 3.4 } 3.5 exit 0; 3.6 } 3.7 +#!/usr/local/bin/perl 3.8 +# Customize these variables. 3.9 +# If you change APOPFILEBASE, change the same variable in apopcall.c too. 3.10 +# See http://www.gentei.org/~yuuji/software/imapext/ 3.11 + 3.12 +$HOME=$ENV{"HOME"}; 3.13 + 3.14 +$DEFAULTMAILDIR = "Maildir"; # Must be same as ../src/osdep/unix/Makefile 3.15 + 3.16 +$APOPFILEBASE = ".apop"; # "$HOME/$APOPFILEBASE" is the password file 3.17 +# $APOPFILEBASE = "$DEFAULTMAILDIR/apop"; 3.18 +# $APOPFILEBASE = "Mail/apop"; 3.19 + 3.20 +$ENCODER = "cat"; 3.21 +# $ENCODER = "gzip"; 3.22 +# $ENCODER = "uuencode $$|gzip"; 3.23 + 3.24 +$DECODER = "cat"; 3.25 +# $DECODER = "gzip -dc"; 3.26 +# $DECODER = "gzip -dc | uudecode"; 3.27 + 3.28 +$DOTQMAIL = ".qmail"; # qmail 3.29 +# $DOTQMAIL = ".forward"; # Postfix 3.30 + 3.31 +$XADDR_DELIM = "-"; # qmail 3.32 +# $XADDR_DELIM = "+"; # Postfix 3.33 + 3.34 +$HERE = "."; # qmail 3.35 +# $HERE = "~"; # Postfix 3.36 + 3.37 +$EXT = ""; 3.38 +$force = 0; 3.39 +$base = 0; 3.40 + 3.41 +$APOPFILE = "$HOME/$APOPFILEBASE"; 3.42 + 3.43 +sub handler { 3.44 + system "stty echo"; 3.45 + print STDERR "Abort:\n"; 3.46 + exit 1; 3.47 +} 3.48 + 3.49 +$SIG{'INT'} = $SIG{'KILL'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'handler'; 3.50 + 3.51 +while ($_=$ARGV[0], /^-.+/ && shift) { 3.52 + if (/^-e/) { 3.53 + $APOPFILE .= $XADDR_DELIM . ($EXT=shift); 3.54 + } elsif (/^-b/) { 3.55 + $base++; 3.56 + } elsif (/^-c/) { 3.57 + $create++; 3.58 + } elsif (/^-s/) { 3.59 + $stream++; 3.60 + # and exit; 3.61 + } elsif (/^-h/) { 3.62 + &usage; # and exit 3.63 + } 3.64 +} 3.65 + 3.66 +sub checkmaildir { 3.67 + local($dotqmail) = ("$HOME/$DOTQMAIL"); 3.68 + local($maildir) = ($DEFAULTMAILDIR); # default 3.69 + $dotqmail .= "$XADDR_DELIM$EXT" if $EXT; 3.70 + $maildir .= "-$EXT" if $EXT; 3.71 + unless (-f "$dotqmail") { 3.72 + if ($create) { 3.73 + if (open(DQMAIL, "> $dotqmail")) { 3.74 + print DQMAIL "$HERE/$maildir/\n"; 3.75 + print "File [$dotqmail] created\n"; 3.76 + close(DQMAIL); 3.77 + } 3.78 + } else { 3.79 + print "$dotqmail file does not exist.\n"; # should go to stdout 3.80 + print "Your should create $maildir first!\n"; 3.81 + print "(-c option automatically makes it)\n"; 3.82 + exit 1; 3.83 + } 3.84 + } 3.85 + if (-s $dotqmail) { 3.86 + $maildir=''; 3.87 + if (open(DQMAIL, "< $dotqmail")) { 3.88 + while (<DQMAIL>) { 3.89 + s/[\r\n \t]*$//g; 3.90 + next if /#/; 3.91 + next unless m,\./.*/,; 3.92 + chop; # strip trailing "/" 3.93 + $maildir = $_; 3.94 + last; 3.95 + } 3.96 + close(DQMAIL); 3.97 + $maildir = $DEFAULTMAILDIR if $maildir eq ''; 3.98 + unless (-d "$HOME/$maildir" 3.99 + && -d "$HOME/$maildir/new" 3.100 + && -d "$HOME/$maildir/cur" 3.101 + && -d "$HOME/$maildir/tmp") { 3.102 + if ($create) { 3.103 + mkdir "$HOME/$maildir", 0700; 3.104 + mkdir "$HOME/$maildir/new", 0700; 3.105 + mkdir "$HOME/$maildir/cur", 0700; 3.106 + mkdir "$HOME/$maildir/tmp", 0700; 3.107 + print "Maildir [$maildir/] created\n"; 3.108 + } else { 3.109 + print "Maildir($maildir) does not exist\n"; 3.110 + print "Your should do maildirmake $maildir first!\n"; 3.111 + print "(-c option automatically makes it)\n"; 3.112 + exit 1; 3.113 + } 3.114 + } 3.115 + } 3.116 + } 3.117 +} 3.118 + 3.119 +sub usage { 3.120 + local($mydir, $myname) = ($0 =~ m,(.*)/(.*),); 3.121 + print<<_EOU_; 3.122 +$myname Change Mail password for imap-4.7+qmailapop 3.123 +Usage: $myname [options] 3.124 +Options are... 3.125 + -e EXT Set target email address to "user-EXT" 3.126 + -c If no .qmail file and Maildir, create them 3.127 + 3.128 +_EOU_ 3.129 + exit 0; 3.130 +} 3.131 + 3.132 +if ($stream) { 3.133 + &stream; 3.134 + exit; # not reached 3.135 +} 3.136 +$OK=0; 3.137 +until ($OK) { 3.138 + system "stty -echo"; 3.139 + print STDERR "Enter APOP Password: "; 3.140 + $new1 = <>; 3.141 + print STDERR "\n"; 3.142 + if (length($new1) == 1) { 3.143 + print STDERR "Canceled\n"; 3.144 + exit 1; 3.145 + } elsif (length($new1) < 9) { 3.146 + print STDERR "Password is too short! Please use more than 8 chars.\n"; 3.147 + next; 3.148 + } 3.149 + print STDERR "Again APOP Password: "; 3.150 + $new2 = <>; 3.151 + if ($new1 eq $new2) { 3.152 + $OK=1; 3.153 + } else { 3.154 + print STDERR "\nPassword mismatch! Try again.\n"; 3.155 + } 3.156 +} 3.157 +#OK 3.158 +&checkmaildir; 3.159 +system "stty echo"; 3.160 +open(NP, "| $ENCODER > $APOPFILE") || die "Cannot write on $APOPFILE\n"; 3.161 +print NP "$new1"; 3.162 +close(NP); 3.163 +chmod 0600, $APOPFILE; 3.164 +print STDERR "\nUpdated APOP password successfully.\n"; 3.165 + 3.166 +sub stream { # Must match with old password 3.167 + local($PASS, $old, $new1, $new2, $master) = (0); 3.168 + local($masterfile) = ($APOPFILE); 3.169 + $masterfile = "$HOME/$APOPFILEBASE" if $base; 3.170 + exit 1 if ($> == 0); 3.171 + while (<>) { 3.172 + chop; 3.173 + if (/^PASS (.*)$/i) { 3.174 + $old = $1; 3.175 + } elsif (/^NEW (.*)/i) { 3.176 + $new1 = $1; 3.177 + } elsif (/^NEW2 (.*)/i) { 3.178 + $new2 = $1; 3.179 + } 3.180 + last if ("$new1" ne "" && "$new2" ne ""); 3.181 + } 3.182 + if (-s $APOPFILE || ($base && -f $masterfile)) { # Already exist 3.183 + if (open(OLD, "$DECODER $masterfile |")) { 3.184 + ($master = <OLD>) =~ s/[\n\r]$//g; 3.185 + close(OLD); 3.186 + } else { 3.187 + print "Old password file corrupted.\n"; 3.188 + print "Please ask to administrator.\n"; 3.189 + exit 1; 3.190 + } 3.191 + if ($master ne $old) { 3.192 + print "Illegal password\nBye\n"; 3.193 + exit 1; 3.194 + } 3.195 + } 3.196 + if ($new1 ne $new2) { 3.197 + print "Password(new) mismatch\nBye\n"; 3.198 + exit 1; 3.199 + } 3.200 + # OK, now begin to create! 3.201 + &checkmaildir; 3.202 + if (open(P, "| $ENCODER > $APOPFILE")) { 3.203 + # open success 3.204 + print P "$new1\n"; 3.205 + close(P); 3.206 + chmod 0600, $APOPFILE; 3.207 + if (-s $APOPFILE) { 3.208 + print "Success!\n"; 3.209 + exit 0; 3.210 + } 3.211 + } else { 3.212 + print "Cannot output to $APOPFILE\nBye\n"; 3.213 + exit 1; 3.214 + } 3.215 + exit 0; 3.216 +}
4.1 --- a/APOPtools/deapop Thu Oct 30 00:00:57 2014 +0900 4.2 +++ b/APOPtools/deapop Thu Oct 30 00:03:05 2014 +0900 4.3 @@ -2,3 +2,7 @@ 4.4 # deapop script for plain password file 4.5 cat "$@" 4.6 4.7 +#!/bin/sh 4.8 +# deapop script for plain password file 4.9 +cat "$@" 4.10 +
5.1 --- a/APOPtools/deapop.gzip Thu Oct 30 00:00:57 2014 +0900 5.2 +++ b/APOPtools/deapop.gzip Thu Oct 30 00:03:05 2014 +0900 5.3 @@ -2,3 +2,7 @@ 5.4 # deapop script for gzipped password file 5.5 gzcat "$@" 5.6 5.7 +#!/bin/sh 5.8 +# deapop script for gzipped password file 5.9 +gzcat "$@" 5.10 +
6.1 --- a/APOPtools/index.html Thu Oct 30 00:00:57 2014 +0900 6.2 +++ b/APOPtools/index.html Thu Oct 30 00:03:05 2014 +0900 6.3 @@ -63,3 +63,68 @@ 6.4 <!--#include virtual="/~yuuji/signature.html"--> 6.5 </body> 6.6 </html> 6.7 +<html> 6.8 +<head> 6.9 +<title> 6.10 +APOP Password 6.11 +</title> 6.12 +<style type="text/css"> 6.13 +<!-- 6.14 +.e {color: red; text-decoretion: underline;} 6.15 +--> 6.16 +</style> 6.17 +</head> 6.18 + 6.19 +<body bgcolor="azure"> 6.20 +<p>$B$"$J$?$N%a%$%k%"%I%l%9@lMQ$N%Q%9%o!<%I$r@_Dj$^$?$O99?7$7$^$9!#(B</p> 6.21 +<form method=POST action="./apopcall.cgi"> 6.22 +<table border="1"> 6.23 +<tr><td>$B%a%$%k%"%I%l%9(B:<br>User Name:</td> 6.24 + <td><input name="email" size="40" maxlength="40"></td></tr> 6.25 +</table> 6.26 +<input name="OK" type="submit" value="OK"> 6.27 +<input name="OK" type="reset" value="Clear"> 6.28 +</form> 6.29 +<ul> 6.30 + <li> $B=i$a$FMxMQ$9$k>l9g(B 6.31 + <p>$B%Q%9%o!<%I$r@_Dj$7$?$$%a%$%k%"%I%l%9$rF~NO$7$F$/$@$5$$!#(B 6.32 + $B%a%$%k@lMQ$N%Q%9%o!<%I$r2a5n$K@_Dj$7$F$$$J$$>l9g$O!"(B 6.33 + $B<!$N2hLL$GK\?MG'>Z$H$7$F(BUNIX$B%Q%9%o!<%I(B($B%5!<%P$K(B 6.34 + $B%m%0%$%s$9$k$H$-$N$b$N(B)$B$rF~NO$7$F$/$@$5$$!#(B</p> 6.35 + <li> $B3HD%%a%$%k%"%I%l%9$N;XDj(B 6.36 + <p>$B4pK\%a%$%k%"%I%l%9$N%f!<%6L>$N8e$m$K(B<span class="e">-$B3HD%;R(B 6.37 + </span> ($B%O%$%U%s(B+$B3HD%;R(B)$B$r2C$($?%"%I%l%9$,3HD%%a%$%k%"%I%l%9$K$J(B 6.38 + $B$j$^$9!#(B<br> 6.39 + $BNc(B:<br> 6.40 + $B4pK\%"%I%l%9(B : user@xxx.hogehoge.ac.jp<br> 6.41 + $B3HD%%"%I%l%9(B : user-foo@xxx.hogehoge.ac.jp<br> 6.42 + ($B$3$N>l9g$N3HD%;R$O(B foo) 6.43 + </p> 6.44 + <p>$B3HD%%a%$%k%"%I%l%9$O!"3HD%;RItJ,$rJQ$($k$3$H$G(B 6.45 + $B2?8D$G$b:n$k$3$H$,$G$-$^$9!#(B 6.46 + $B?75,$K:n@.$7$?$$$H$-$O!"3HD%%a%$%k%"%I%l%9$rF~NO$7$F(BOK$B$r(B 6.47 + $B2!$7$F$/$@$5$$!#?7$7$$%a%$%k%\%C%/%9$r<+F0E*$K:n@.(B 6.48 + $B$9$k$HF1;~$K?73HD%%a%$%k%"%I%l%9@lMQ$N%Q%9%o!<%I$b9T$J$$$^$9!#(B 6.49 + </p> 6.50 +</ul> 6.51 +<p>$B!Z(B<a href="qmapmore.html"> 6.52 +$B$3$N%5!<%P$GMxMQ$G$-$k%a%$%k%"%I%l%9$K$D$$$F(B</a>$B![(B</p> 6.53 +<hr> 6.54 +<ul> 6.55 + <li> At your first trial to set mail password 6.56 + <p>Push [OK] button with your mail address. We call your 6.57 + mail address <em>YourName</em>@xxx.yyy.jp as `basic email address'.<p> 6.58 + 6.59 + <li> To create extensional email address<br> 6.60 + 6.61 + <p>On our system, you can have more than one email addresses. You 6.62 + can create any (mail)account name "YourName-xxx"(where xxx is 6.63 + any extensional word you might give) which will be delivered to you. To 6.64 + create an extesional email address and/or change the password for 6.65 + it, put the extensional email address in the input window.</p> 6.66 +</ul> 6.67 + 6.68 +<hr> 6.69 +<!--#include virtual="/~yuuji/signature.html"--> 6.70 +</body> 6.71 +</html>
7.1 --- a/APOPtools/pop3-age Thu Oct 30 00:00:57 2014 +0900 7.2 +++ b/APOPtools/pop3-age Thu Oct 30 00:03:05 2014 +0900 7.3 @@ -1,62 +1,1 @@ 7.4 -#!/bin/sh - 7.5 -# A sample "POP before SMTP"-enabler script for tcp_wrappers 7.6 -# This script should be installed in /usr/local/etc 7.7 -# If you are thinking of using this script on heavily loaded host, 7.8 -# you had better to choose tcpserver instead of tcp_wrappers. 7.9 -# 7.10 -ALLOWTMP="/var/log/ATMP" 7.11 -if [ -f /usr/local/etc/hosts.allow ]; then 7.12 - ALLOW="/usr/local/etc/hosts.allow" 7.13 -else 7.14 - ALLOW=/etc/hosts.allow 7.15 -fi 7.16 -ALLOWSRC=${ALLOW}.src 7.17 -ALLOWNEW=${ALLOW}.new 7.18 - 7.19 -# for debug 7.20 -# (env;echo "1=$1") | Mail -s pop3access yuuji 7.21 - 7.22 -case $0 in 7.23 - *record) 7.24 - echo "tcp-env : $RELAYCLIENT : setenv = RELAYCLIENT" >> $ALLOWTMP.1 7.25 - ;; 7.26 - *age) 7.27 - rm -f $ALLOWTMP.2 7.28 - [ -f $ALLOWTMP.1 ] && mv -f $ALLOWTMP.1 $ALLOWTMP.2 7.29 - ;; 7.30 - *) 7.31 - # else generate master hosts.allow file 7.32 - ;; 7.33 -esac 7.34 -touch $ALLOWTMP.1 $ALLOWTMP.2 7.35 -echo "# 7.36 -# DO NOT EDIT THIS FILE! 7.37 -# This file is generated from $ALLOWSRC file. 7.38 -# Edit it! 7.39 -#" > $ALLOWNEW 7.40 -(cat $ALLOWTMP.[12] | sort -u; cat $ALLOWSRC) >> $ALLOWNEW 7.41 -/bin/mv -f $ALLOWNEW $ALLOW 7.42 - 7.43 -# pop3-{age,update,record} for tcp_wrappers ends here 7.44 -# The following section is the sample routine for tcpserver(ucsp-tcp) 7.45 -# If you use tcpserver, replace the above section after "case $0...esac" 7.46 -# by the following section. 7.47 -# Sample code was contributed by pirozeau(pirozeau@banana-fish.com). 7.48 - 7.49 -#TCPREMOTEIP=${TCPREMOTEIP:-undefined} 7.50 -#RELAYCLIENT=${RELAYCLIENT:-$TCPREMOTEIP} 7.51 -#ALLOW=/usr/local/etc/smtprule 7.52 -#case $0 in 7.53 -# *record) 7.54 -# echo "$RELAYCLIENT:allow,RELAYCLIENT=\"\"" >> $ALLOWTMP.1 7.55 -# ;; 7.56 -# *age) 7.57 -# rm -f $ALLOWTMP.2 7.58 -# [ -f $ALLOWTMP.1 ] && mv -f $ALLOWTMP.1 $ALLOWTMP.2 7.59 -# ;; 7.60 -# *) 7.61 -# # else generate master tcprule file 7.62 -# ;; 7.63 -#esac 7.64 -#touch $ALLOWTMP.1 $ALLOWTMP.2 7.65 -#(cat $ALLOWTMP.[12] | sort -u; cat ${ALLOW}) | /usr/local/bin/tcprules ${ALLOW}.cdb ${ALLOW}.tmp 7.66 +pop3-record 7.67 \ No newline at end of file
8.1 --- a/APOPtools/pop3-record Thu Oct 30 00:00:57 2014 +0900 8.2 +++ b/APOPtools/pop3-record Thu Oct 30 00:03:05 2014 +0900 8.3 @@ -60,3 +60,65 @@ 8.4 #esac 8.5 #touch $ALLOWTMP.1 $ALLOWTMP.2 8.6 #(cat $ALLOWTMP.[12] | sort -u; cat ${ALLOW}) | /usr/local/bin/tcprules ${ALLOW}.cdb ${ALLOW}.tmp 8.7 +#!/bin/sh - 8.8 +# A sample "POP before SMTP"-enabler script for tcp_wrappers 8.9 +# This script should be installed in /usr/local/etc 8.10 +# If you are thinking of using this script on heavily loaded host, 8.11 +# you had better to choose tcpserver instead of tcp_wrappers. 8.12 +# 8.13 +ALLOWTMP="/var/log/ATMP" 8.14 +if [ -f /usr/local/etc/hosts.allow ]; then 8.15 + ALLOW="/usr/local/etc/hosts.allow" 8.16 +else 8.17 + ALLOW=/etc/hosts.allow 8.18 +fi 8.19 +ALLOWSRC=${ALLOW}.src 8.20 +ALLOWNEW=${ALLOW}.new 8.21 + 8.22 +# for debug 8.23 +# (env;echo "1=$1") | Mail -s pop3access yuuji 8.24 + 8.25 +case $0 in 8.26 + *record) 8.27 + echo "tcp-env : $RELAYCLIENT : setenv = RELAYCLIENT" >> $ALLOWTMP.1 8.28 + ;; 8.29 + *age) 8.30 + rm -f $ALLOWTMP.2 8.31 + [ -f $ALLOWTMP.1 ] && mv -f $ALLOWTMP.1 $ALLOWTMP.2 8.32 + ;; 8.33 + *) 8.34 + # else generate master hosts.allow file 8.35 + ;; 8.36 +esac 8.37 +touch $ALLOWTMP.1 $ALLOWTMP.2 8.38 +echo "# 8.39 +# DO NOT EDIT THIS FILE! 8.40 +# This file is generated from $ALLOWSRC file. 8.41 +# Edit it! 8.42 +#" > $ALLOWNEW 8.43 +(cat $ALLOWTMP.[12] | sort -u; cat $ALLOWSRC) >> $ALLOWNEW 8.44 +/bin/mv -f $ALLOWNEW $ALLOW 8.45 + 8.46 +# pop3-{age,update,record} for tcp_wrappers ends here 8.47 +# The following section is the sample routine for tcpserver(ucsp-tcp) 8.48 +# If you use tcpserver, replace the above section after "case $0...esac" 8.49 +# by the following section. 8.50 +# Sample code was contributed by pirozeau(pirozeau@banana-fish.com). 8.51 + 8.52 +#TCPREMOTEIP=${TCPREMOTEIP:-undefined} 8.53 +#RELAYCLIENT=${RELAYCLIENT:-$TCPREMOTEIP} 8.54 +#ALLOW=/usr/local/etc/smtprule 8.55 +#case $0 in 8.56 +# *record) 8.57 +# echo "$RELAYCLIENT:allow,RELAYCLIENT=\"\"" >> $ALLOWTMP.1 8.58 +# ;; 8.59 +# *age) 8.60 +# rm -f $ALLOWTMP.2 8.61 +# [ -f $ALLOWTMP.1 ] && mv -f $ALLOWTMP.1 $ALLOWTMP.2 8.62 +# ;; 8.63 +# *) 8.64 +# # else generate master tcprule file 8.65 +# ;; 8.66 +#esac 8.67 +#touch $ALLOWTMP.1 $ALLOWTMP.2 8.68 +#(cat $ALLOWTMP.[12] | sort -u; cat ${ALLOW}) | /usr/local/bin/tcprules ${ALLOW}.cdb ${ALLOW}.tmp
9.1 --- a/APOPtools/pop3-record.postfix Thu Oct 30 00:00:57 2014 +0900 9.2 +++ b/APOPtools/pop3-record.postfix Thu Oct 30 00:03:05 2014 +0900 9.3 @@ -27,3 +27,32 @@ 9.4 esac 9.5 touch $OKCLIENT.1 $OKCLIENT.2 9.6 cat $OKCLIENT.1 $OKCLIENT.2 | postmap -r -i hash:$CLIENTACCESS 9.7 +#!/bin/sh - 9.8 +# A sample "POP before SMTP"-enabler script for Postfix 9.9 +# This script should be installed in /usr/local/etc. 9.10 +# This script assumes 9.11 +# 9.12 +POSTFIXDIR=/etc/postfix 9.13 +POSTFIXBIN=/usr/libexec/postfix 9.14 +PATH=$POSTFIXBIN\:$PATH 9.15 +OKDIR=/var/log 9.16 +OKCLIENT=$OKDIR/ATMP 9.17 +CLIENTACCESS=$POSTFIXDIR/client_access 9.18 + 9.19 +case $0 in 9.20 + *record) 9.21 + echo "$RELAYCLIENT OK" >> $OKCLIENT.1 9.22 + ;; 9.23 + *age) 9.24 + rm -f $OKCLIENT.2 9.25 + [ -f $OKCLIENT.1 ] && mv -f $OKCLIENT.1 $OKCLIENT.2 9.26 + echo '' > $CLIENTACCESS 9.27 + # rm -f $CLIENTACCESS.db 9.28 + postmap hash:$CLIENTACCESS 9.29 + ;; 9.30 + *) 9.31 + # else generate master client_access.db 9.32 + ;; 9.33 +esac 9.34 +touch $OKCLIENT.1 $OKCLIENT.2 9.35 +cat $OKCLIENT.1 $OKCLIENT.2 | postmap -r -i hash:$CLIENTACCESS
10.1 --- a/APOPtools/pop3-update Thu Oct 30 00:00:57 2014 +0900 10.2 +++ b/APOPtools/pop3-update Thu Oct 30 00:03:05 2014 +0900 10.3 @@ -1,62 +1,1 @@ 10.4 -#!/bin/sh - 10.5 -# A sample "POP before SMTP"-enabler script for tcp_wrappers 10.6 -# This script should be installed in /usr/local/etc 10.7 -# If you are thinking of using this script on heavily loaded host, 10.8 -# you had better to choose tcpserver instead of tcp_wrappers. 10.9 -# 10.10 -ALLOWTMP="/var/log/ATMP" 10.11 -if [ -f /usr/local/etc/hosts.allow ]; then 10.12 - ALLOW="/usr/local/etc/hosts.allow" 10.13 -else 10.14 - ALLOW=/etc/hosts.allow 10.15 -fi 10.16 -ALLOWSRC=${ALLOW}.src 10.17 -ALLOWNEW=${ALLOW}.new 10.18 - 10.19 -# for debug 10.20 -# (env;echo "1=$1") | Mail -s pop3access yuuji 10.21 - 10.22 -case $0 in 10.23 - *record) 10.24 - echo "tcp-env : $RELAYCLIENT : setenv = RELAYCLIENT" >> $ALLOWTMP.1 10.25 - ;; 10.26 - *age) 10.27 - rm -f $ALLOWTMP.2 10.28 - [ -f $ALLOWTMP.1 ] && mv -f $ALLOWTMP.1 $ALLOWTMP.2 10.29 - ;; 10.30 - *) 10.31 - # else generate master hosts.allow file 10.32 - ;; 10.33 -esac 10.34 -touch $ALLOWTMP.1 $ALLOWTMP.2 10.35 -echo "# 10.36 -# DO NOT EDIT THIS FILE! 10.37 -# This file is generated from $ALLOWSRC file. 10.38 -# Edit it! 10.39 -#" > $ALLOWNEW 10.40 -(cat $ALLOWTMP.[12] | sort -u; cat $ALLOWSRC) >> $ALLOWNEW 10.41 -/bin/mv -f $ALLOWNEW $ALLOW 10.42 - 10.43 -# pop3-{age,update,record} for tcp_wrappers ends here 10.44 -# The following section is the sample routine for tcpserver(ucsp-tcp) 10.45 -# If you use tcpserver, replace the above section after "case $0...esac" 10.46 -# by the following section. 10.47 -# Sample code was contributed by pirozeau(pirozeau@banana-fish.com). 10.48 - 10.49 -#TCPREMOTEIP=${TCPREMOTEIP:-undefined} 10.50 -#RELAYCLIENT=${RELAYCLIENT:-$TCPREMOTEIP} 10.51 -#ALLOW=/usr/local/etc/smtprule 10.52 -#case $0 in 10.53 -# *record) 10.54 -# echo "$RELAYCLIENT:allow,RELAYCLIENT=\"\"" >> $ALLOWTMP.1 10.55 -# ;; 10.56 -# *age) 10.57 -# rm -f $ALLOWTMP.2 10.58 -# [ -f $ALLOWTMP.1 ] && mv -f $ALLOWTMP.1 $ALLOWTMP.2 10.59 -# ;; 10.60 -# *) 10.61 -# # else generate master tcprule file 10.62 -# ;; 10.63 -#esac 10.64 -#touch $ALLOWTMP.1 $ALLOWTMP.2 10.65 -#(cat $ALLOWTMP.[12] | sort -u; cat ${ALLOW}) | /usr/local/bin/tcprules ${ALLOW}.cdb ${ALLOW}.tmp 10.66 +pop3-record 10.67 \ No newline at end of file
11.1 --- a/APOPtools/qmapmore.html Thu Oct 30 00:00:57 2014 +0900 11.2 +++ b/APOPtools/qmapmore.html Thu Oct 30 00:03:05 2014 +0900 11.3 @@ -185,3 +185,190 @@ 11.4 <hr> 11.5 </body> 11.6 </html> 11.7 +<html> 11.8 +<head> 11.9 +<title> 11.10 +APOP Password 11.11 +</title> 11.12 +<style type="text/css"> 11.13 +<!-- 11.14 +h1 {text-align: center; text-decoration: underline;} 11.15 +h2 {color: navy; background-color: lavender;} 11.16 +.e {color: red; text-decoretion: underline;} 11.17 +dt (background-color: yellow;} 11.18 +--> 11.19 +</style> 11.20 +</head> 11.21 + 11.22 +<body bgcolor="azure"> 11.23 +<h1> 11.24 + $BK\%a%$%k%5!<%P$K4X$9$kMxMQ<T>\:Y>pJs(B 11.25 +</h1> 11.26 +<p>$BL\<!(B</p> 11.27 +<ul> 11.28 + <li> <a href="#extaddress">$BK\%5!<%P$GMxMQ$G$-$k%a%$%k%"%I%l%9(B</a> 11.29 + <li> <a href="#APOP">$B%a%$%k<u?.;~$N%W%m%H%3%k$K$D$$$F(B</a> 11.30 + <li> <a href="#forward">$BB>$N%a%$%k%5!<%P$X$NE>Aw(B</a> 11.31 +</ul> 11.32 +<hr> 11.33 + 11.34 +<h2> 11.35 + <a name="extaddress">$BK\%5!<%P$GMxMQ$G$-$k%a%$%k%"%I%l%9(B</a> 11.36 +</h2> 11.37 +<p>$BK\%5!<%P$G$O%a%$%kG[Aw%7%9%F%`$H$7$F(Bqmail$B$rMxMQ$7$F$$$k$N$G!"(B 11.38 +$BMxMQ<T$N3'$5$s$O2?8D$G$b%a%$%k%"%I%l%9$r:n$k$3$H$,$G$-$^$9!#(B 11.39 +$B0J2<$N@bL@$G$O!"8D?M$N%a%$%k%"%I%l%9$N%"%+%&%s%HL>ItJ,$r(B 11.40 +<var>user</var>$B!"%I%a%$%sL>ItJ,$r(B <var>dokkano.ac.jp</var> $B$H(B 11.41 +$BI=$9$3$H$K$7$^$9!#$D$^$j!"Nc$G;HMQ$9$k%a%$%k%"%I%l%9$O(B 11.42 +<var>user@dokkano.ac.jp</var>$B$H$J$j$^$9!#$3$N%"%I%l%9$O8f<+?H$N$b$N$HCV(B 11.43 +$B$-49$($F@bL@$rFI$_?J$a$F$/$@$5$$!#(B</p> 11.44 + 11.45 +<dl> 11.46 + <dt> $B!Z4pK\%a%$%k%"%I%l%9![(B 11.47 + <dd> <p><var>user@dokkano.ac.jp</var>$B$r4pK\%a%$%k%"%I%l%9$H8F$S$^$9!#%"(B 11.48 + $B%+%&%s%H:n@.$HF1;~$KL5>r7o$GMxMQ$G$-$k%a%$%k%"%I%l%9$G$9!#$3$N%"%I(B 11.49 + $B%l%9$KFO$$$?%a%$%k$O%5!<%P>e$N$"$J$?@lMQ$N%a%$%k%\%C%/%9$KC_$($i$l(B 11.50 + $B$^$9!#JL$N%"%I%l%9$KE>Aw$9$k$3$H$b2DG=$G$9$,!"J}K!$O8e=R$7$^$9!#(B</p> 11.51 + 11.52 + <dt> $B!Z3HD%%a%$%k%"%I%l%9![(B 11.53 + <dd> <p><var>user<span class="e">-xxx</span>@dokkano.ac.jp</var>$B$H$$$&(B 11.54 + $B7A<0$N%"%I%l%9$r3HD%%a%$%k%"%I%l%9$H8F$S$^$9!#$"$J$?$N%"%+%&%s%HL>(B 11.55 + $B$G;O$^$j!"$=$ND>8e$K%O%$%U%s(B(<span class="e">-</span>)$B$G6h@Z$C$FG$(B 11.56 + $B0U$NJ8;zNs$,Mh$k%a%$%k%"%I%l%9$O!"A4$F$"$J$?08$KG[Aw$5$l$^$9!#(B 11.57 + <var>user<span class="e">-xxx</span></var>$B$N(B<var>xxx</var>$B$NItJ,$O(B 11.58 + <span class="e">$B3HD%;R(B</span>$B$H8F$S!"$I$s$JC18l$G$b9=$$$^$;$s!#(B 11.59 + <var>user-123@dokkano.ac.jp, user-job@dokkano.ac.jp, 11.60 + user-meeting@dokkano.ac.jp, ...</var>$B$J$I$J$I!"$I$s$J%a%$%k%"%I%l(B 11.61 + $B%9$G$b<+J,MQ$K:n@.$9$k$3$H$,$G$-$^$9!#(B 11.62 + </p> 11.63 +</dl> 11.64 + 11.65 +<p>$B3HD%%a%$%k%"%I%l%9$rMxMQ$9$k>l9g$O!":G=i$K$=$N%"%I%l%9$r<u$1<h$k%a%$(B 11.66 +$B%k%\%C%/%9$r:n$j$H$=$N%"%I%l%9<u?.MQ$N%Q%9%o!<%I$r@_Dj$9$kI,MW$,$"$j$^$9!#(B 11.67 +<a href="index.html">$B%a%$%k%Q%9%o!<%I@_Dj2hLL(B</a>$B$K$F!"$3$l$+$i<u$1<h$j(B 11.68 +$B$?$$%a%$%k%"%I%l%9$r(B<var>user<span 11.69 +class="e">-xxx</span>@dokkano.ac.jp</var> $B$N7A<0$GF~NO$7$F@h$K?J$a$P<+F0(B 11.70 +$BE*$K%a%$%k%\%C%/%9$N:n@.$^$G40N;$7$^$9!#$3$N$H$-!"$"$J$?K\?M$N3NG'$H$7$F(B 11.71 +$B4{B8$N(B<span class="e">$B4pK\%a%$%k%"%I%l%9$N%Q%9%o!<%I(B</span>$B$rF~NO$7$F$/(B 11.72 +$B$@$5$$!#(B</p> 11.73 + 11.74 +<h2> 11.75 + <a name="APOP">$B%a%$%k<u?.;~$N%W%m%H%3%k$K$D$$$F(B</a> 11.76 +</h2> 11.77 +<p>$B8=:_9-$/MxMQ$5$l$F$$$k%a%$%k<u?.%W%m%H%3%k$G$"$k(BPOP3$B$O!"(B 11.78 +$B%Q%9%o!<%I$r$=$N$^$^$N7A(B($BJ?J8(B:$B%W%l%$%s%F%-%9%H(B)$B$G%M%C%H%o!<%/$KN.$7$F$7(B 11.79 +$B$^$&$N$G!"4JC1$KK5<u$5$l$k$*$=$l$,$"$j$^$9(B($B8=6b<+F0;YJ'5!$NA0$G0E>ZHV9f(B 11.80 +$B$r@<$K=P$7$J$,$i2!$7$F$$$k;Q$rA[A|$7$F$/$@$5$$(B)$B!#(B</p> 11.81 + 11.82 +<p>$B$=$N$h$&$J4m81@-$r9MN8$7$FK\%5!<%P$G$O0J2<$N@_Dj$r9T$J$C$F$$$^$9!#(B</p> 11.83 +<ul> 11.84 + <li> POP3$B$O2f!9$NAH?%Fb%M%C%H%o!<%/$+$i$N$_MxMQ$r5v2D(B<br> 11.85 + ($BFbIt%M%C%H%o!<%/$K$OIt30<T$O4JC1$K$OF'$_9~$a$J$$$N$G4vJ,0BA4$G$9(B) 11.86 + <li> $B$=$l0J30$N>l=j$+$i$N<u?.$G$O(BAPOP$B$N$_$r5v2D(B 11.87 +</ul> 11.88 +<p>APOP$B$H$O%Q%9%o!<%I$r0E9f2=$7$F$d$j$H$j$9$k$h$&$K3HD%$7$?(BPOP3$B$G!"2>$K(B 11.89 +$BK5<u$5$l$?$H$7$F$b85$N%Q%9%o!<%I$O2rFI$G$-$^$;$s!#(BAPOP$B$rMxMQ$9$k>l9g$O$"(B 11.90 +$B$i$f$k>l=j$+$i$N%a%$%k$N<u?.$,2DG=$K$J$j$^$9!#0BA4@-$r9M$($k$H!"2>$KFbIt(B 11.91 +$B$+$i$7$+MxMQ$7$J$$>l9g$G$b(BAPOP$B$rMxMQ$5$l$k$3$H$r6/$/$*4+$a$7$^$9!#(B</p> 11.92 + 11.93 +<p>APOP$B$rMxMQ$9$k$?$a$NJ}K!$r@bL@$7$^$9!#$J$*!"0J2<$N%a%$%k%j!<%@$G$O(B 11.94 +APOP$B$,(B<span class="e">$BMxMQ$G$-$^$;$s(B</span>$B$N$G$4Cm0U$/$@$5$$!#(B</p> 11.95 +<dl> 11.96 + <dt> $B!Z(BAPOP$B$K(B<span class="e">$BBP1~$7$F$$$J$$(B</span>$B<g$J%a%$%k%j!<%@![(B 11.97 + <dd> Microsoft Outlook Express<br> 11.98 + Microsoft Outlook<br> 11.99 + Netscape Messenger 11.100 + <dt> $B!Z(BAPOP$B$KBP1~$7$F$$$k<g$J%a%$%k%j!<%@![(B 11.101 + <dd> <ul> 11.102 + <li> Windows$BMQ(B<br> 11.103 + <a href="http://www.almail.com/">AL-Mail</a> 11.104 + ($B%7%'%"%&%'%"(B/$B3X@8!&3X=Q5!4XMxMQ$N$_L5NA(B),<br> 11.105 + <a href="http://www.rimarts.co.jp/becky-j.htm">Becky!</a> 11.106 + ($B%7%'%"%&%'%"(B),<br> 11.107 + <a href="http://denshin8.esprix.net/">$BEE?.H,9f(B</a> 11.108 + ($B%U%j!<%=%U%H%&%'%"(B),<br> 11.109 + <a href="http://www.eudora.ne.jp/">Eudora</a> 11.110 + (3$B<oN`$N%i%$%;%s%97ABV(B) 11.111 + <li> UNIX$BMQ(B($B0J2<A4$F%U%j!<%=%U%H(B)<br> 11.112 + <a href="http://www.mew.org/index-j.html">Mew</a>,<br> 11.113 + <a href="http://www.gohome.org/wl/index.ja.html"> 11.114 + Wanderlust</a> 11.115 + </ul> 11.116 +</dl> 11.117 +<p>$B0J2<$K$$$/$D$+$N%a%$%k%j!<%@$N(BAPOP$B@_DjJ}K!$r<($7$^$9!#(B</p> 11.118 +<dl> 11.119 + <dt> $B!L(BAL-Mail$B!M(B 11.120 + <dd> <ol> 11.121 + <li> $B@_Dj$7$?$$%"%+%&%s%H$rA*$V(B 11.122 + <li> $B!V%D!<%k(B(T)$B!W"*!V%*%W%7%g%s(B(O)$B!W$G=P$FMh$k%"%+%&%s%H@_Dj%a(B 11.123 + $B%K%e!<$N!"!V%"%+%&%s%H!W2hLL$K$F1&2<$N!V9bEY$J@_Dj!W$r%/%j%C(B 11.124 + $B%/(B 11.125 + <li> $B!V9bEY$J@_Dj!W%&%#%s%I%&$N:82<!V(BAPOP$B$GG'>Z!W$r%A%'%C%/(B 11.126 + </ol> 11.127 + <dt> $B!L(BBecky!$B!M(B 11.128 + <dd> <ol> 11.129 + <li> $B!V%D!<%k(B(T)$B!W"*!V@_Dj!W$G=P$k%&%#%s%I%&$G(B [$B%"%+%&%s%H(B] 11.130 + $B$rA*Br(B 11.131 + <li> [$B%"%+%&%s%H(B]$B@_Dj%&%#%s%I%&$N2<$K$"$k(B [$B$=$NB>(B] $B$r(B 11.132 + $B%/%j%C%/(B 11.133 + <li> $B%&%#%s%I%&2<It$N(B [APOP$B$r;H$&(B] $B$r%A%'%C%/(B 11.134 + </ol> 11.135 + <dt> $B!L(BEudora 4$B!M(B 11.136 + <dd> <ol> 11.137 + <li> $B!V%D!<%k(B(T)$B!W"*!V%Q!<%=%J%j%F%#(B(P)$B!W$G%"%+%&%s%HA*Br2hLL$r:8(B 11.138 + $BB&%&%#%s%I%&$K=P$9(B 11.139 + <li> APOP$B@_Dj$7$?$$%"%+%&%s%H$r1&%/%j%C%/$7!VJQ99(B(P)$B!W$rA*$V(B 11.140 + <li> $B!V%a!<%k$N<u?.!W%a%K%e!<$rA*Br(B 11.141 + <li> $B%&%#%s%I%&$N0lHV2<$N(B [$BG'>ZJ}<0(B] $B$G(BAPOP$B$r%A%'%C%/(B 11.142 + </ol> 11.143 + 11.144 + <dt> $B!L(BMew$B!M(B 11.145 + <dd> <p>~/.im/Config $B$N(B Imget.Src $B9T$N@_Dj$r0J2<$N$h$&$KJQ$($^$9!#(B</p> 11.146 + <blockquote> 11.147 + <p><tt>Imget.Src=pop/<span class="e">APOP</span>:user@$B%5!<%PL>(B</tt></p> 11.148 + </blockquote> 11.149 + <dt> $B!L(BWanderlust$B!M(B 11.150 + <dd> <p>$B%U%)%k%@%P%C%U%!$G(B m a $B$7$F0J2<$N$h$&$K%U%)%k%@$rDI2C$7$^$9!#(B</p> 11.151 + <blockquote> 11.152 + <p><tt>&user<span class="e">/apop</span>@$B%5!<%PL>(B</tt></p> 11.153 + </blockquote> 11.154 + <hr> 11.155 +</dl> 11.156 +<p>$B0J>e$N$$$:$l$N>l9g$b!"3HD%%a%$%k%"%I%l%9$r<u?.$7$?$$$H$-$O%f!<%6L>$H(B 11.157 +$B$7$F(B user-xxx $B$N$h$&$J3HD%;RIU$NL>A0$r;XDj$7$^$9!#(B</p> 11.158 + 11.159 +<h2> 11.160 + <a name="forward">$BB>$N%a%$%k%5!<%P$X$NE>Aw(B</a> 11.161 +</h2> 11.162 +<p>$BK\%5!<%P$KFO$$$?$"$J$?08$N%a%$%k$r!"JL$N%5!<%P$G4IM}$7$F$$$k%a%$%k%"(B 11.163 +$B%I%l%9$KE>Aw$9$k>l9g$O!"%[!<%`%G%#%l%/%H%j$K$"$k(B .qmail $B$H$$$&%U%!%$%k$K(B 11.164 +$BE>Aw@h$r=q$-$^$9!#(B</p> 11.165 +<ol> 11.166 + <li> FTP$B%/%i%$%"%s%H%=%U%H$rMxMQ$7$F$3$N%5!<%P$K%m%0%$%s$9$k(B 11.167 + <li> $B%m%0%$%s8e:G=i$K$D$J$,$k%G%#%l%/%H%j(B($B%U%)%k%@(B)$B$K(B .qmail $B$H$$$&%U%!(B 11.168 + $B%$%k$,$"$k$N$G$3$l$r<j85$N(BPC$B$K%3%T!<$9$k(B 11.169 + <li> $B%a%bD"(B(Notepad.exe)$B$J$IE,Ev$J%F%-%9%H%(%G%#%?$rMxMQ$7$F$3$N%U%!%$(B 11.170 + $B%k$rJT=8$70J2<$N$h$&$K=q$-49$($F%;!<%V$9$k(B 11.171 + <blockquote> 11.172 + <tt>&user2@tensosaki.co.jp</tt> 11.173 + </blockquote> 11.174 + ($B>e5-$NNc$G$O(B <tt>user2@tensosaki.co.jp</tt> $B$,E>Aw@h%"%I%l%9(B) 11.175 + <li> FTP$B%/%i%$%"%s%H%=%U%H$G:FEY(B .qmail $B%U%!%$%k$r%5!<%P>e$KE>Aw$9$k(B 11.176 +</ol> 11.177 +<p>$BB>%"%I%l%9$KE>Aw$7!"$J$*$+$D$3$N%5!<%P>e$N%a%$%k%\%C%/%9$K$b%a%$%k$r(B 11.178 +$B;D$7$?$$>l9g$O(B .qmail $B%U%!%$%k$K85!9$"$C$?(B ./Maildir/ $B$H$$$&9T$r>C$5$:$K(B 11.179 +$BE>AwMQ$N9T$rDI2C$7$^$9!#(B</p> 11.180 +<blockquote> 11.181 +<pre>./Maildir/ 11.182 +&user2@tensosaki.co.jp</pre> 11.183 +</blockquote> 11.184 +<h3> 11.185 + $BCm0U(B! 11.186 +</h3> 11.187 +<p>FTP$B$b(BPOP3$B$HF1MMJ?J8%Q%9%o!<%I$r%M%C%H%o!<%/$KN.$94m81$J$b$N$J$N$G!"(B 11.188 +ftp$B@\B3$bFbIt$+$i$NMxMQ$N$_$K@)8B$7$F$$$^$9!#$I$&$7$F$b30It%M%C%H%o!<%/(B 11.189 +$B$+$i(BFTP$B$rMxMQ$9$kI,MW$,$"$k>l9g$O4IM}<T$^$G$4AjCL$/$@$5$$!#(B</p> 11.190 + 11.191 +<hr> 11.192 +</body> 11.193 +</html>
12.1 --- a/APOPtools/with-tcpserver/0README Thu Oct 30 00:00:57 2014 +0900 12.2 +++ b/APOPtools/with-tcpserver/0README Thu Oct 30 00:03:05 2014 +0900 12.3 @@ -1,3 +1,13 @@ 12.4 + 12.5 +This directory contains sample files for maintaining ipop3d via daemontools. 12.6 + 12.7 + 12.8 +# mkdir /var/qmail/ipopd 12.9 +# cp -r * /var/qmail-ipopd 12.10 + 12.11 +Edit copied files and change the loggin user-id in log/run. 12.12 + 12.13 +# ln -s /var/qmail/ipopd /service 12.14 12.15 This directory contains sample files for maintaining ipop3d via daemontools. 12.16
13.1 --- a/APOPtools/with-tcpserver/Makefile Thu Oct 30 00:00:57 2014 +0900 13.2 +++ b/APOPtools/with-tcpserver/Makefile Thu Oct 30 00:03:05 2014 +0900 13.3 @@ -1,3 +1,11 @@ 13.4 +# 13.5 +TCPDIR=/usr/local/bin 13.6 +TR=${TCPDIR}/tcprules 13.7 + 13.8 +all: pop.cdb 13.9 + 13.10 +pop.cdb: pop 13.11 + cat $> | ${TR} $@ pop.tmp 13.12 # 13.13 TCPDIR=/usr/local/bin 13.14 TR=${TCPDIR}/tcprules
14.1 --- a/APOPtools/with-tcpserver/log/run Thu Oct 30 00:00:57 2014 +0900 14.2 +++ b/APOPtools/with-tcpserver/log/run Thu Oct 30 00:03:05 2014 +0900 14.3 @@ -3,3 +3,8 @@ 14.4 PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin \ 14.5 setuidgid nobody \ 14.6 multilog t ./main 14.7 +#!/bin/sh 14.8 +exec env - \ 14.9 +PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/bin \ 14.10 +setuidgid nobody \ 14.11 +multilog t ./main
15.1 --- a/APOPtools/with-tcpserver/pop Thu Oct 30 00:00:57 2014 +0900 15.2 +++ b/APOPtools/with-tcpserver/pop Thu Oct 30 00:03:05 2014 +0900 15.3 @@ -1,3 +1,6 @@ 15.4 127.0.0.:allow,INTRANET="" 15.5 10.0.0.0-127:allow,INTRANET="" 15.6 all:allow 15.7 +127.0.0.:allow,INTRANET="" 15.8 +10.0.0.0-127:allow,INTRANET="" 15.9 +all:allow
16.1 --- a/APOPtools/with-tcpserver/run Thu Oct 30 00:00:57 2014 +0900 16.2 +++ b/APOPtools/with-tcpserver/run Thu Oct 30 00:03:05 2014 +0900 16.3 @@ -3,3 +3,8 @@ 16.4 exec env - \ 16.5 PATH=/bin:/usr/bin:/usr/sbin:/var/qmail/ipopd:/usr/local/bin:/usr/local/etc \ 16.6 tcpserver -HR -c40 -x/var/qmail/ipopd/pop.cdb 0 pop3 ipop3d 2>&1 16.7 +#!/bin/sh 16.8 +# ipoper should be located in one of the $PATH elements. 16.9 +exec env - \ 16.10 +PATH=/bin:/usr/bin:/usr/sbin:/var/qmail/ipopd:/usr/local/bin:/usr/local/etc \ 16.11 +tcpserver -HR -c40 -x/var/qmail/ipopd/pop.cdb 0 pop3 ipop3d 2>&1
17.1 --- a/Makefile Thu Oct 30 00:00:57 2014 +0900 17.2 +++ b/Makefile Thu Oct 30 00:03:05 2014 +0900 17.3 @@ -253,7 +253,9 @@ 17.4 # British. As of 2005, the Julian calendar and the Gregorian calendar 17.5 # diverge by 15 days. 17.6 17.7 -EXTRACFLAGS= 17.8 +# EXTRACFLAGS=-DQMAIL -DRESTRICT_POP -DXADDR_DELIM="+" -DDOTQMAIL=".forward" 17.9 +## EXTRACFLAGS=-DQMAIL -DRESTRICT_POP 17.10 +EXTRACFLAGS=-DQMAIL -DRESTRICT_POP -DINET6 17.11 17.12 17.13 # Extra linker flags (additional/alternative libraries, etc.) 17.14 @@ -729,6 +731,7 @@ 17.15 clean: 17.16 @echo Removing old processed sources and binaries... 17.17 $(SH) -c '$(RM) an ua OSTYPE SPECIALS c-client mtest imapd ipopd mailutil mlock dmail tmail || true' 17.18 + $(SH) -c '$(RM) ip6 || true' 17.19 $(CD) tools;$(MAKE) clean 17.20 17.21
18.1 --- a/README.maildir Thu Oct 30 00:00:57 2014 +0900 18.2 +++ b/README.maildir Thu Oct 30 00:03:05 2014 +0900 18.3 @@ -91,3 +91,96 @@ 18.4 Industrivagen 4 18.5 SE-194 77 Upplands Vasby 18.6 SWEDEN 18.7 +Pine 4.0x Maildir c-client module 18.8 +--------------------------------- 18.9 + 18.10 +Written by Mattias Larsson <ml@techno.org> <mta@freeit.com> 18.11 + 18.12 +This is the second release of my Maildir driver for Pine 4. It is based 18.13 +on Eric Greens IMAP2bis Maildir driver. 18.14 + 18.15 +PLEASE NOTE that this driver has only been tested in the IMAP4rev1 daemon 18.16 +before. It was just put into Pine 4.00, and it looks like it works, but it 18.17 +has not been extensively tested. It has been running for 8 months in 18.18 +production in our IMAP4 daemon though. 18.19 + 18.20 +PLEASE NOTE: 18.21 + 18.22 +This driver needs to store the UID's of the message in the file somehow. In 18.23 +the earlier versions of this driver this was done by adding a new maildir 18.24 +flag (the ,3 flag), however, this solution was not very good since most 18.25 +other clients could not handle it. Thus I had to find another solution. In 18.26 +this driver I use a pretty radical method. Any file in the maildir with the 18.27 +execute bit set has its UID set in the mtime of the file. So you should not 18.28 +edit the files in here, or in any otherway update the mtime, because then 18.29 +the UID gets changed. Most clients should not do this, so I think this 18.30 +solution is compatible with most other clients (if you find one that isn't, 18.31 +let me know). If you for some reason have to edit a file in the Maildir, 18.32 +delete the ".uidvalidity" file in the root of the Maildir (ie, the dir where 18.33 +you find cur/ new/ and tmp/). Alternatively, edit maildir.c and define the 18.34 +NO_UID_VALIDITY option, which will cause the Maildir to get set new UID's on 18.35 +every start up. Note that if you are running IMAP and Netscape as a client, 18.36 +you can't change the UID's, because Netscape do not support the UID validity 18.37 +flag in the IMAP protocol. So use this with care. 18.38 + 18.39 +Please edit the maildir.c file in any case. There are 3 options you can 18.40 +set yourself. The default configuration is not suitable for ISPs. If you are 18.41 +an ISP, or system with many users, you might want to consider setting some 18.42 +of the options different. 18.43 + 18.44 +Ohh, if there are problems compiling it, let me know, and please let me know 18.45 +what you did to fix it. This thing was developed on Solaris (using both GCC 18.46 +and SunCC, should work with both), but I haven't tried it on any other 18.47 +platform. It is also known to compile cleanly on Linux RH5.1 18.48 + 18.49 +CONFIGURATION 18.50 +------------- 18.51 + 18.52 +There are a few configurable options. You find these at the top of the 18.53 +maildir.c file (and it can be found in imap/src/osdep/unix if I'm not all 18.54 +mistaken). Right now, two options are configurable. By default it is 18.55 +configured for ISP use, something that you might want to change if you use 18.56 +it at home. 18.57 + 18.58 +HOW TO USE 18.59 +---------- 18.60 + 18.61 +Use it as any other c-client driver. There is some option you want to change 18.62 +if you want all folders to be created as Maildirs (and I can't remember what 18.63 +the option is from the top of my head). Read the pine documentation. 18.64 + 18.65 +CHANGES 18.66 +------- 18.67 + 18.68 +Rel 4. Coredump problem fixed. In release 3 I decided to user the sparep 18.69 + in the message cache so no patching of mail.h would be necessary, 18.70 + however, PINE uses this pointer internally for other things, causing 18.71 + coredumps when used with the Rel 3. patch. 18.72 + 18.73 +Rel 3. New way of storing UID's (compatible with ,2 clients). 18.74 + Multiple inbox patches applied 18.75 + 18.76 +Rel 2. Pine 4 changes. 18.77 + 18.78 +Rel 1. Imap4rev 1 driver 18.79 + 18.80 +FINAL NOTES 18.81 +----------- 18.82 + 18.83 +I'll try to maintain and release new versions as soon as I have time over, 18.84 +which unfortunately does not happen very often in this business ;) 18.85 + 18.86 +You can (might) find newer versions of this driver at: 18.87 + 18.88 +http://www.freeit.com/mta/ 18.89 + 18.90 + 18.91 +Regards, 18.92 +Daniel Mattias Larsson 18.93 + 18.94 +e-mail: ml@techno.org 18.95 +ph: +46-707-268785 18.96 +snail-mail: 18.97 +Industrivagen 4 18.98 +SE-194 77 Upplands Vasby 18.99 +SWEDEN
19.1 --- a/README.qmailapop Thu Oct 30 00:00:57 2014 +0900 19.2 +++ b/README.qmailapop Thu Oct 30 00:03:05 2014 +0900 19.3 @@ -364,3 +364,369 @@ 19.4 用いて生じた如何なる結果に対しても著作権者は責任を負いません。 19.5 19.6 2009/9/14 yuuji@gentei.org 19.7 +// 19.8 +// qmail+maildir+apop+virtualdomain+POPbeforeSMTP extensions to uw-imapd 19.9 +// Japanese Document below 19.10 +// 19.11 + 19.12 +[Comentary] 19.13 +This patch kit enables uw-imapd to handle; 19.14 + * maildir 19.15 + * qmail's extended mail addresses of user (~/.qmail-ext) 19.16 + * Postfix's extended mail addresses of user (~/.forward+ext) 19.17 + * Accesses to extended mail addresses (authenticated with ~/.apop-ext) 19.18 + * Virtual domain user switching 19.19 + 19.20 +Because this package is produced those who want to avail all features above, 19.21 +we recommend you to turn on all switches for every extension. 19.22 +Please let me recommend you not to use plain POP3 with this package. 19.23 +If you want to cling onto POP3, please use qmail-pop3d which comes with 19.24 +qmail distribution. 19.25 + 19.26 +[Configuration] 19.27 +You can select these compilation switches. 19.28 + 19.29 + Where: ./Makefile 19.30 + Switch: QMAIL 19.31 + What: Support maildir and user's address extension. 19.32 + This switch is requisite. 19.33 + 19.34 + Where: ./Makefile 19.35 + Switch: INET6 19.36 + What: Support IPv6 address 19.37 + WORKS fine only via ucspi-tcp+ipv6patch 19.38 + If you are using tcpserver-ipv6, set this. 19.39 + 19.40 + Where: ./Makefile 19.41 + Switch: POSTFIX 19.42 + What: Defaults user address file to ~/.forward and 19.43 + extension delimiter to "+". 19.44 + Setting this flag on is equavalent to declare 19.45 + -DQMAIL -DDOTQMAIL=".forward" -DXADDR_DELIM="+" 19.46 + in ./Makefile. 19.47 + 19.48 + Where: ./Makefile 19.49 + Switch: RESTRICT_POP 19.50 + What: Restrict POP3 access from unsafe network. Allow 19.51 + normal pop3 access only when environment variable 19.52 + INTRANET is set. This can be controled by tcpd with 19.53 + /etc/hosts.allow. 19.54 + 19.55 + Where: ./src/osdep/unix/Makefile 19.56 + Switch: DEFAULTMAILDIR (quoted string) 19.57 + What: Default users' maildir directory when a user does not 19.58 + have ~/.qmail file. 19.59 + The default value is null. If null, the default value in 19.60 + osdep/unix/maildir.c("Maildir") will be taken. 19.61 + 19.62 + Where: ./src/osdep/unix/Makefile 19.63 + Switch: QMAILCONTROL (quoted string) 19.64 + What: Default qmail/control directory. 19.65 + The default value is "/var/qmail/control" 19.66 + 19.67 + Where: ./src/osdep/unix/Makefile 19.68 + Switch: USERAPOPFILE (string) 19.69 + What: User's APOP password file relative to their home dir. 19.70 + ".apop" is set by default. 19.71 + One of recommended values is "Mail/.apop". 19.72 + NOTE THAT USERAPOPFILE should NOT be readable by others. 19.73 + Do chmod 600 USERAPOPFILE. 19.74 + 19.75 + Where: ./src/osdep/unix/Makefile 19.76 + Switch: APOPOPEN (string) 19.77 + What: Command name to decode APOP password from USERAPOPFILE 19.78 + "/usr/local/sbin/deapop" is set by default. 19.79 + NOTE THAT you should install deapop command too. 19.80 + If you don't want to think about this, 19.81 + install the following shell script into /usr/local/sbin/deapop 19.82 + 19.83 + #!/bin/sh 19.84 + cat "$@" 19.85 + 19.86 + Where: ./src/osdep/unix/Makefile 19.87 + Switch: POPBEFORESMTP 19.88 + What: Turn on `POP before SMTP' feature. 19.89 + The next variable POP3RECORDER takes effect when 19.90 + this variable is defined. 19.91 + 19.92 + Where: ./src/osdep/unix/Makefile 19.93 + Switch: POP3RECORDER (string) 19.94 + What: Command name to achieve `POP before SMTP'. 19.95 + "/usr/local/etc/pop3-record" is set by default. 19.96 + This recorder program should take one argument of 19.97 + fully qualified hostname (or IP address) where the POP 19.98 + authentication is passed to. 19.99 + 19.100 +[NO WARRANTY] 19.101 + 19.102 + This package comes from absolutely NO WARRANTY. The author of 19.103 + this package is not responsible for any result caused by using 19.104 + this software. The copyright of the extension part is held by 19.105 + HIROSE, Yuuji [yuuji@gentei.org]. 19.106 + 19.107 +[COPYING] 19.108 + 19.109 + You can re-distribute this package without any cost except some 19.110 + practical cost(magnetical media or so). Although this package 19.111 + basically obeys the license terms in a file CPYRIGHT in this 19.112 + directory, there is one exception; when you modify the code 19.113 + against the extensional part (over uw-imapd) and that 19.114 + modification is a kind of bug-fix, modification should be telled 19.115 + to the author of extensional part if you are thinking of 19.116 + re-distribute your modification to the public. This limitation 19.117 + is to aim to make this extensional package reasonably safe 19.118 + always in any time. Please feel free to hack and distribute it! 19.119 + 19.120 + 19.121 +-- Japanese document follows... 19.122 + 19.123 +【qmail+maildir+APOP用POPサーバ】 19.124 + 19.125 + このimapパッケージは、qmailとIMAPを組み合わせて使うこと *ではな 19.126 + く* qmail+maildir+APOPを柔軟に利用しようということを目的として作 19.127 + られましたのでIMAPでのテストは十分に行なわれていません。このパッ 19.128 + ケージは以下のような方を満足させるでしょう。 19.129 + 19.130 + * qmailを利用している 19.131 + * mail spool には安全性の高い Maildir 形式を利用し(させ)ている 19.132 + * ~/.qmail-ext ファイルによるqmailの拡張アドレスをよく利用している 19.133 + * virtual domain を活用しまくっている 19.134 + 19.135 + 上記のようなことができるqmailですが、この機能を使いこなすために 19.136 + はUNIXマシンにログインしてローカルファイルを見に行くメイルリーダ 19.137 + を使うという方法しかありませんでした。これでは不便なので、上記の 19.138 + 使い分けを認識するPOPサーバを作ろうということで作成したのがこの 19.139 + パッケージです。またPOPのみのサーバ利用が多い昨今、リモートから 19.140 + の認証にログインパスワードを使わずにメイル専用パスワードを利用さ 19.141 + せる変更も行なっています。これによりPOPもAPOP(POPのパスワード認 19.142 + 証の暗号化版)も共通のパスワードを利用できるようにしました。また、 19.143 + POP の場合は既存ユーザのパスワード管理を考えて、認証時にUNIXパス 19.144 + ワードも参照するようにしています。 19.145 + 19.146 + もう一点、POPはパスワードをプレインテキストで流すため、外部ネッ 19.147 + トワークからの利用は危険です。そこでPOPの利用を一部のネットワー 19.148 + クに限定する機能もつけました(tcp_wrappersやtcpserverが必要)。 19.149 + 19.150 +【インストール】 19.151 + 19.152 + デフォルト設定では 19.153 + 19.154 + * POP3は拒否する 19.155 + * ユーザのパスワード設定ファイルは ~/.apop 19.156 + * ~/.apop のデコードプログラムは /usr/local/sbin/deapop 19.157 + 19.158 + となっています。APOP認証はサーバ側で必ず元のパスワードを知る必要 19.159 + があります。これまでのAPOPサーバは全てのユーザ毎に管理者権限でパ 19.160 + スワードを設定する必要がありました。一見安全そうですが、じつはユー 19.161 + ザがパスワードを変更する頻度を限りなくゼロに近づけているだけです。 19.162 + そもそもAPOPはサーバ側で元パスワードを取得する必要があるので必ず 19.163 + 復元可能な形で保存されなければなりません。ということはどんなに凝っ 19.164 + た方法で保存しても結局は復号できるのですから、複雑な方法で暗号化 19.165 + &格納をすることは手間を増やすだけです。いずれにしてもroot権限さ 19.166 + えあれば元のパスワードは簡単に読めるわけですから、最初からユーザ 19.167 + 自身にパスワード管理をさせてしまっても何ら問題は無く、むしろその 19.168 + 方がパスワードをこまめに変えてくれる可能性が(ちょりっと)上がりま 19.169 + す。ただし、誰にでもパスワードが読めては困るので、パスワードファ 19.170 + イルを chmod 600 しておかないとメイルの取り込みが出来ないように 19.171 + なっています。またどうしても平文でファイルに保存するのだけはいや 19.172 + だーという場合のために、APOPパスワードファイルは 19.173 + /usr/local/sbin/deapop というコマンドを経由して読み込むようになっ 19.174 + ています。これにデコードする処理を書いておきます。もし、とくにエ 19.175 + ンコードしなくてもいいという場合は 19.176 + 19.177 + #!/bin/sh 19.178 + cat "$@" 19.179 + 19.180 + というシェルスクリプトでも入れておいてください。このパスワードは 19.181 + ログインパスワードとは独立しているのでこれで大きな問題は起こらな 19.182 + いでしょう(責任は持ちませんが:-)。 19.183 + 19.184 + コンパイル時の変数は上記英文解説の場所を読んでください。 19.185 + 19.186 +【ユーザから見た使い方】 19.187 + 19.188 + まず、~/.qmail に正しくmaildirが設定されていることを確認します。 19.189 + maildirをまだ作っていない場合は、 19.190 + 19.191 + % /var/qmail/bin/maildirmake ~/maildir 19.192 + 19.193 + とし、~/.qmail に 19.194 + 19.195 + ./maildir/ 19.196 + 19.197 + と書きます。またメイル専用パスワードを ~/.apop に記録します。 19.198 + これは apoppasswd コマンドで行ないます。 19.199 + 19.200 + % apoppasswd 19.201 + 19.202 + これで完了です。apoppasswdコマンドは APOPtools/apoppasswd にある 19.203 + ので管理者がサイトの環境に手直しした上で一般ユーザのPATHの通る場 19.204 + 所にインストールして使って下さい。 19.205 + 19.206 + さて、拡張アドレスを使いましょう。ログイン名を login とします。 19.207 + login-isogi@hogehoge.co.jp のようなアドレスは ~/.qmail-isogi とい 19.208 + うファイルで作成できます。login-isogi 用のmaildirを作ります。 19.209 + 19.210 + % /var/qmail/bin/maildirmake ~/isogidir 19.211 + 19.212 + これを ~/.qmail-isogi に登録します。 19.213 + 19.214 + ./isogidir/ 19.215 + 19.216 + 最後に login-isogi 用のパスワードを設定します。 19.217 + 19.218 + % apoppasswd -e isogi -c 19.219 + Enter APOP Password: 19.220 + 19.221 + とすると、maildirの作成とパスワードの設定が同時に行えます。 19.222 + maildirとパスワードの作成が完了したら、利用してるメイルリーダの 19.223 + APOP アカウントの「アカウント名」をlogin-isogi にして接続します。 19.224 + 19.225 +【POP before SMTPについて】 19.226 + 19.227 + まず tcp_wrappers を利用している場合について説明します。 19.228 + tcpserverを利用する場合も原理は同じなので仕組みだけ理解してくだ 19.229 + さい。 19.230 + 19.231 + tcp_wrapperとtcp-envを組み合わせてSMTPサーバを中継用に使うドメイ 19.232 + ンを限定して使っていると思います。これの発展形でPOP接続して来た 19.233 + ドメインだけにSMTPサーバを使わせる手法のことを "POP before SMTP" 19.234 + と呼びます。このパッケージでも APOP 接続をしたドメインに対して 19.235 + SMTPの中継許可を与えることが出来ます。本パッケージの ./APOPtools 19.236 + ディレクトリにある pop3-* を /usr/local/etc にインストールします。 19.237 + 3つのファイルの実体は同じです。さらに以下の作業をします。 19.238 + 19.239 + * 原本となる /etc/hosts.allow を /etc/hosts.allow.src にコピー 19.240 + * crontab で10分毎に /usr/local/etc/pop3-age を起動させる 19.241 + 19.242 + 後者は、大抵のOSの場合 root の crontab に 19.243 + 19.244 + */10 * * * * root /usr/local/etc/pop3-age 19.245 + 19.246 + などと書けば設定できます。pop3-* スクリプトは自身の環境に合わせ 19.247 + て適宜修正して下さい。この段階で、tcp_wrapper の定義ファイルは 19.248 + /etc/hosts.allow.src が大元で、/etc/hosts.allow はcronによって自 19.249 + 動生成されるものとなります。hosts.allowをいじっても自動的に上書 19.250 + きされてしまうので、設定を変えるときは *必ず hosts.allow.src を 19.251 + 編集する* ことに注意して下さい。 19.252 + 19.253 + さらにipop3dを起動するときに接続してきたホストが環境変数 19.254 + RELAYCLIENT に入るようにしておきます。/etc/inetd.conf でipop3dを 19.255 + 起動するときに tcp_wrapper 経由となることを確認します。 19.256 + 19.257 + [/etc/inetd.conf] 19.258 + pop3 stream tcp nowait root /usr/libexec/tcpd /usr/libexec/ipop3d 19.259 + 19.260 + 1999年頃以降のPC-UNIXではinetdにデフォルトでtcpdが組み込まれてい 19.261 + ることが多いので、inetd.confにtcpdははさまなくて良いこともありま 19.262 + す。続いて /etc/hosts.allow.src で環境変数の設定が起きるようにし 19.263 + ます。 19.264 + 19.265 + [/etc/hosts.allow.src] 19.266 + ipop3d : all : setenv RELAYCLIENT %h 19.267 + 19.268 + これで POPサービスを利用しに来たクライアントのアドレスが環境変数 19.269 + に入ります。 19.270 + 19.271 + tcpserverの場合は、付属の pop3-record スクリプトの後半に例がある 19.272 + のでそれを利用してください。 19.273 + 19.274 + なお、tcp_wrappers 用の pop3-age スクリプトは負荷の高いマシンで 19.275 + は hosts.allow ファイルが空になる可能性があります。lockすれば多 19.276 + 少ましになるでしょうが完ぺきではありません。もし、hosts.allowの 19.277 + 書き換えに失敗するような負荷の高い環境で使う場合は tcp_wrappers 19.278 + ではなく、tcpserverでのアクセス制御をすることを強く勧めます。こ 19.279 + ちらはロックの必要もなく、安全にアクセス制御ファイルの更新ができ 19.280 + ます。 19.281 + 19.282 +【POPアクセス制御について】 19.283 + 19.284 + POP3とAPOPは同じポートを使うので「外部からはAPOPだけ許す」などの 19.285 + 制御はルータやtcp_wrappersなどだけではできません。このipop3dでは、 19.286 + 生のPOP3は環境変数INTRANETが定義されているときだけに利用を制限す 19.287 + ることができます。tcp_wrappers の例を示します。 19.288 + 19.289 + ipop3d : localhost .localnet.hoge.jp \ 19.290 + : setenv INTRANET : setenv RELAYCLIENT %h 19.291 + ipop3d : all : setenv RELAYCLIENT %h 19.292 + 19.293 + としておけば、ローカルネットワーク内だけで生POP3を使うことができ 19.294 + ます。 19.295 + 19.296 +【virtualdomain機能について】 19.297 + 19.298 + qmailでは /var/qmail/control/virtualdomains を使うことで、ユーザ 19.299 + が任意のメイルドメインを持つことができます。これを解釈するように 19.300 + しました。/var/qmail/control/virtualdomain ファイルで 19.301 + 19.302 + virtual.hoge.co.jp:user1 19.303 + dokan.hoge.co.jp:user2-dokan 19.304 + 19.305 + としておくと、XX@virtual.hoge.co.jp は ~user1/.qmail-XX に配送さ 19.306 + れ、YY@dokan.hoge.co.jp は ~user2/.qmail-dokan-YY に配送されます。 19.307 + それがMaildirスプールを含む場合、本パッケージのIMAP/POPで取り込 19.308 + むことができます。デフォルトではこのためのパスワードはそれぞれ 19.309 + 19.310 + ~user1/.apop-XX 19.311 + ~user2/.apop-dokan-YY 19.312 + 19.313 + ファイルに保存しておかなければなりません。 19.314 + 19.315 +【Postfixの拡張アドレス対応について】 19.316 + 19.317 + Postfixによる ~/.forward+ext で発生する拡張アドレスは、その配送 19.318 + 先がMaildirであれば本パッケージでも利用できます。Postfix のデフォ 19.319 + ルト設定の 19.320 + forward_path = $home/.forward$recipient_delimiter$extension, 19.321 + $home/.forward 19.322 + recipient_delimiter = + 19.323 + 19.324 + のまま Postfix を動かしている場合はトップレベルのMakefileの 19.325 + EXTRACFLAGS に -DPOSTFIX を追加して下さい(-DQMAILも必要です)。こ 19.326 + れにより、拡張アドレスを決めるファイルが ".forward" に、拡張部分 19.327 + を区切る文字列が "+" になります。いずれかを変更している場合はた 19.328 + とえば、 19.329 + 19.330 + -DDOTQMAIL=".postfix" -DXADDR_DELIM="-" 19.331 + 19.332 + のように変更できます。もし、Postfix の .forward+ext を利用する場 19.333 + 合は周辺ツールの APOPtools/apoppasswd, APOPtools/apopcall.c の対 19.334 + 応する変数も変更する必要があることに注意して下さい。また、パスワー 19.335 + ドファイルも ~/.apop-ext ではなく~ /.apop+ext となることに注意が 19.336 + 必要です。これらが面倒な場合は、Postfix の設定の方で .qmail-ext 19.337 + を見るようにしてしまうのも手です。この場合は 19.338 + 19.339 + recipient_delimiter = - 19.340 + forward_path = $home/.forward$recipient_delimiter$extension, 19.341 + $home/.qmail$recipient_delimiter$extension, 19.342 + $home/.forward 19.343 + 19.344 + とすると ~/.qmail-ext も参照するようになり、デフォルト状態の本パッ 19.345 + ケージのまま利用することができるでしょう。 19.346 + 19.347 +【Postfixの POP before SMTPについて】 19.348 + 19.349 + main.cf で たとえば次のようにします。 19.350 + 19.351 + smtpd_recipient_restrictions = 19.352 + permit_mynetworks 19.353 + check_client_access hash:/etc/postfix/client_access 19.354 + 19.355 + ここで /etc/postfix/client_access は POP before SMTP の許可ホス 19.356 + トリストを保持するためのファイル名で、既に使われてはいないものに 19.357 + します。配布ディレクトリの APOPtools/pop3-record.postfix は 19.358 + /etc/postfix/client_access ファイルをリレー許可判定に使うことを 19.359 + 前提とした Postfix 用のスクリプトです。 19.360 + 19.361 +【謝辞】 19.362 + 19.363 + 安井卓さん(tach@debian.or.jp)にはsyslog関係のパッチを頂きました。 19.364 + ここに感謝の意を表します。 19.365 + 19.366 +【免責】 19.367 + 19.368 + IMAPパッケージに本ドキュメントで説明した拡張機能を追加する部分の 19.369 + 著作権は広瀬雄二[yuuji@gentei.org]が保持します。このプログラムを 19.370 + 用いて生じた如何なる結果に対しても著作権者は責任を負いません。 19.371 + 19.372 + 2009/9/14 yuuji@gentei.org
20.1 --- a/src/c-client/auth_log.c Thu Oct 30 00:00:57 2014 +0900 20.2 +++ b/src/c-client/auth_log.c Thu Oct 30 00:03:05 2014 +0900 20.3 @@ -105,6 +105,10 @@ 20.4 char *ret = NIL; 20.5 char *user,*pass,*authuser; 20.6 if (user = (*responder) (PWD_USER,sizeof (PWD_USER),NIL)) { 20.7 +#ifdef QMAIL 20.8 + extern char* conv_virtualdomain(char*); 20.9 + user = conv_virtualdomain(user); 20.10 +#endif 20.11 if (pass = (*responder) (PWD_PWD,sizeof (PWD_PWD),NIL)) { 20.12 /* delimit user from possible admin */ 20.13 if (authuser = strchr (user,'*')) *authuser++ = '\0';
21.1 --- a/src/c-client/auth_md5.c Thu Oct 30 00:00:57 2014 +0900 21.2 +++ b/src/c-client/auth_md5.c Thu Oct 30 00:03:05 2014 +0900 21.3 @@ -75,9 +75,11 @@ 21.4 21.5 long auth_md5_valid (void) 21.6 { 21.7 +#ifndef QMAIL /* qmail extension can always handle MD5 */ 21.8 struct stat sbuf; 21.9 /* server forbids MD5 if no MD5 enable file */ 21.10 if (stat (MD5ENABLE,&sbuf)) auth_md5.server = NIL; 21.11 +#endif 21.12 return T; /* MD5 is otherwise valid */ 21.13 } 21.14 21.15 @@ -186,6 +188,7 @@ 21.16 char *auth_md5_pwd (char *user) 21.17 { 21.18 struct stat sbuf; 21.19 +#ifndef QMAIL 21.20 int fd = open (MD5ENABLE,O_RDONLY,NIL); 21.21 unsigned char *s,*t,*buf,*lusr,*lret; 21.22 char *r; 21.23 @@ -214,6 +217,77 @@ 21.24 fs_give ((void **) &buf); /* flush the buffer */ 21.25 close (fd); /* don't need file any longer */ 21.26 } 21.27 +#else 21.28 +# ifndef USERAPOPFILE 21.29 +# define USERAPOPFILE ".apop" 21.30 +# endif 21.31 +# ifndef XADDR_DELIM 21.32 +# ifdef POSTFIX /* Same if-condition is in maildir.c.. sorry */ 21.33 +# define XADDR_DELIM "+" 21.34 +# else 21.35 +# define XADDR_DELIM "-" 21.36 +# endif 21.37 +# endif 21.38 + extern char *myMailSuffix; 21.39 + char mycrypt[BUFSIZ+1]; 21.40 + char *ret = NIL, *tmp=NIL; 21.41 + FILE *apopfile = NIL; 21.42 + struct passwd *pw = getpwnam(user); 21.43 + if (!pw) pw = getpwnam(lcase(tmp=cpystr(user))); 21.44 + if (!pw && strstr(user, XADDR_DELIM)) { /* Check qmail alias */ 21.45 + char tmp[BUFSIZ]; 21.46 + char *s = user; 21.47 + memset(tmp, 0, BUFSIZ); 21.48 + while (*s && s && !pw) { 21.49 + s = strstr(s, XADDR_DELIM); 21.50 + if (!s) break; 21.51 + strncpy(tmp, user, s-user); 21.52 + s++; 21.53 + pw = getpwnam(tmp); 21.54 + } 21.55 + if (pw) { 21.56 + myMailSuffix = lcase(cpystr(s-1)); 21.57 + user[strlen(tmp)] = '\0'; /* zap suffix */ 21.58 + } 21.59 + } 21.60 + if (pw) { 21.61 + snprintf(mycrypt, BUFSIZ, "%s/%s", pw->pw_dir, USERAPOPFILE); 21.62 + if (NIL != myMailSuffix) strcat(mycrypt, myMailSuffix); 21.63 + if (stat(mycrypt, &sbuf) < 0) { 21.64 + /* printf("Cannot stat [%s]\015\n", mycrypt); */ 21.65 + return ret; 21.66 + } 21.67 + if (sbuf.st_mode & ~(S_IFREG | S_IREAD | S_IWRITE)) { 21.68 + /* printf("Your apoppassword file is readable by others. Do chmod 600 %s%c\n", mycrypt, 015); */ 21.69 + return ret; 21.70 + } 21.71 +#ifdef APOPOPEN 21.72 + if (stat(APOPOPEN, &sbuf) >= 0) { /* if APPOPEN exists */ 21.73 + /* read apop password via APOPOPEN program */ 21.74 + int bytes = 3+strlen(APOPOPEN)+strlen(mycrypt); 21.75 + char *aproc = (char*) fs_get(bytes); 21.76 + snprintf(aproc, bytes, "%s %s%c", APOPOPEN, mycrypt, '\0'); 21.77 + apopfile = popen(aproc, "r"); 21.78 + memset(aproc, 0, bytes); 21.79 + fs_give((void**)&aproc); 21.80 + } 21.81 +#endif /* APOPOPEN */ 21.82 + if ((NIL!=apopfile) || (apopfile = fopen( mycrypt, "r" ))) { 21.83 + fgets(mycrypt, sizeof(mycrypt) - 1, apopfile); 21.84 + fclose(apopfile); 21.85 + if (mycrypt[0]) { 21.86 + char p = strlen(mycrypt); 21.87 + while (p > 0 && (mycrypt[p-1] == '\n' || mycrypt[p-1] == '\r')) { 21.88 + mycrypt[--p] = '\0'; /* zap trailing newlines */ 21.89 + } 21.90 + } 21.91 + } else { 21.92 + return ret; 21.93 + } 21.94 + ret = cpystr(mycrypt); 21.95 + memset(mycrypt, 0, sizeof(mycrypt)); 21.96 + } 21.97 +#endif /* if QMAIL */ 21.98 return ret; /* return password */ 21.99 } 21.100 21.101 @@ -231,6 +305,9 @@ 21.102 int i,j; 21.103 char *ret = NIL; 21.104 char *s,*authuser,tmp[MAILTMPLEN]; 21.105 +#ifdef QMAIL 21.106 + char *userback = cpystr(user); 21.107 +#endif 21.108 unsigned char digest[MD5DIGLEN]; 21.109 MD5CONTEXT ctx; 21.110 char *hex = "0123456789abcdef"; 21.111 @@ -260,7 +337,15 @@ 21.112 memset (tmp,0,MAILTMPLEN); /* erase sensitive information */ 21.113 } 21.114 if (!ret) sleep (3); /* slow down possible cracker */ 21.115 + else { 21.116 + extern void permitsmtp(); 21.117 + /* permitsmtp();*/ 21.118 + } 21.119 +#ifdef QMAIL 21.120 + return (ret) ? userback : ret; 21.121 +#else 21.122 return ret; 21.123 +#endif 21.124 } 21.125 21.126 /*
22.1 --- a/src/c-client/mail.c Thu Oct 30 00:00:57 2014 +0900 22.2 +++ b/src/c-client/mail.c Thu Oct 30 00:03:05 2014 +0900 22.3 @@ -6081,6 +6081,9 @@ 22.4 if (auth->server && !compare_cstring (auth->name,mechanism)) 22.5 return (!(auth->flags & AU_DISABLE) && 22.6 ((auth->flags & AU_SECURE) || 22.7 +#ifdef QMAIL 22.8 + getenv("INTRANET") || 22.9 +#endif 22.10 !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL))) ? 22.11 (*auth->server) (resp,argc,argv) : NIL; 22.12 return NIL; /* no authenticator found */
23.1 --- a/src/c-client/mail.h Thu Oct 30 00:00:57 2014 +0900 23.2 +++ b/src/c-client/mail.h Thu Oct 30 00:03:05 2014 +0900 23.3 @@ -858,6 +858,7 @@ 23.4 unsigned int spare7 : 1; /* seventh spare bit */ 23.5 unsigned int spare8 : 1; /* eighth spare bit */ 23.6 void *sparep; /* spare pointer */ 23.7 + void *maildirp; /* for the Maildir driver */ 23.8 unsigned long user_flags; /* user-assignable flags */ 23.9 } MESSAGECACHE; 23.10
24.1 --- a/src/imapd/imapd.c Thu Oct 30 00:00:57 2014 +0900 24.2 +++ b/src/imapd/imapd.c Thu Oct 30 00:03:05 2014 +0900 24.3 @@ -553,6 +553,9 @@ 24.4 24.5 /* plaintext login with password */ 24.6 else if (!strcmp (cmd,"LOGIN")) { 24.7 + #ifdef QMAIL 24.8 + extern char* conv_virtualdomain(char*); 24.9 + #endif 24.10 if (user) fs_give ((void **) &user); 24.11 if (pass) fs_give ((void **) &pass); 24.12 /* two arguments */ 24.13 @@ -573,7 +576,11 @@ 24.14 else { /* delimit user from possible admin */ 24.15 if (s = strchr (user,'*')) *s++ ='\0'; 24.16 /* see if username and password are OK */ 24.17 +#ifdef QMAIL 24.18 + if (server_login (conv_virtualdomain(user),pass,s,argc,argv)) { 24.19 +#else 24.20 if (server_login (user,pass,s,argc,argv)) { 24.21 +#endif 24.22 state = SELECT; /* make select */ 24.23 alerttime = 0; /* force alert */ 24.24 response = logwin;/* return logged-in capabilities */
25.1 --- a/src/ipopd/ipop3d.c Thu Oct 30 00:00:57 2014 +0900 25.2 +++ b/src/ipopd/ipop3d.c Thu Oct 30 00:03:05 2014 +0900 25.3 @@ -96,6 +96,9 @@ 25.4 void trmint (); 25.5 int pass_login (char *t,int argc,char *argv[]); 25.6 char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]); 25.7 +#ifdef QMAIL 25.8 +char* conv_virtualdomain(char *account); 25.9 +#endif 25.10 char *responder (void *challenge,unsigned long clen,unsigned long *rlen); 25.11 int mbxopen (char *mailbox); 25.12 long blat (char *text,long lines,unsigned long size,STRING *st); 25.13 @@ -128,7 +131,11 @@ 25.14 AUTHENTICATOR *auth = mail_lookup_auth (1); 25.15 while (auth && compare_cstring (auth->name,"CRAM-MD5")) auth = auth->next; 25.16 /* build challenge -- less than 128 chars */ 25.17 +#ifndef QMAIL 25.18 + if (!(auth->flags & AU_DISABLE)) 25.19 +#else 25.20 if (auth && auth->server && !(auth->flags & AU_DISABLE)) 25.21 +#endif 25.22 sprintf (challenge,"<%lx.%lx@%.64s>",(unsigned long) getpid (), 25.23 (unsigned long) time (0),tcp_serverhost ()); 25.24 else challenge[0] = '\0'; /* no MD5 authentication */ 25.25 @@ -258,10 +265,17 @@ 25.26 /* get user name */ 25.27 if (!(t && *t && (s = strtok (t," ")) && (t = strtok(NIL,"\012")))) 25.28 PSOUT ("-ERR Missing APOP argument\015\012"); 25.29 - else if (!(user = apop_login (challenge,s,t,argc,argv))) 25.30 - PSOUT ("-ERR Bad APOP\015\012"); 25.31 - else if ((state = mbxopen ("INBOX")) == TRANSACTION) 25.32 - syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%lu/%lu", 25.33 + #ifdef QMAIL 25.34 + else if (!(user = apop_login (challenge,conv_virtualdomain(s),t,argc,argv))) { 25.35 + #else /* !QMAIL */ 25.36 + else if (!(user = apop_login (challenge,s,t,argc,argv))) { 25.37 + #endif /* QMAIL */ 25.38 + PSOUT ("-ERR Bad APOP (Maybe your password is expired)\015\012"); 25.39 + user = cpystr (s); 25.40 + syslog (LOG_INFO,"APOP login failure user=%.80s host=%.80s", 25.41 + user,tcp_clienthost ()); 25.42 + } else if ((state = mbxopen ("INBOX")) == TRANSACTION) 25.43 + syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%ld/%ld", 25.44 user,tcp_clienthost (),nmsgs,stream->nmsgs); 25.45 else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox", 25.46 user,tcp_clienthost ()); 25.47 @@ -279,8 +293,20 @@ 25.48 } 25.49 else PSOUT ("+OK STLS completed\015\012"); 25.50 } 25.51 +#ifndef RESTRICT_POP 25.52 else if (!mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL) && 25.53 !strcmp (s,"USER")) { 25.54 +#else /* !RESTRICT_POP */ 25.55 + else if (!strcmp (s,"USER")) { 25.56 + if (getenv("INTRANET") == NIL) { 25.57 + PSOUT("-ERR Sorry, we don't allow POP3 from your network. Use APOP instead.\015\012"); 25.58 + user = cpystr(t); 25.59 + syslog (LOG_INFO,"Plain POP3 is restricted user=%.80s host=%.80s", 25.60 + user,tcp_clienthost ()); 25.61 + memset(user, '\0', strlen(user)); 25.62 + break; 25.63 + } 25.64 +#endif 25.65 if (host) fs_give ((void **) &host); 25.66 if (user) fs_give ((void **) &user); 25.67 if (pass) fs_give ((void **) &pass); 25.68 @@ -294,7 +320,11 @@ 25.69 user = cpystr (s);/* copy user name */ 25.70 } 25.71 /* local user name */ 25.72 +#ifdef QMAIL 25.73 + else user = conv_virtualdomain(cpystr (t)); 25.74 +#else 25.75 else user = cpystr (t); 25.76 +#endif 25.77 PSOUT ("+OK User name accepted, password please\015\012"); 25.78 } 25.79 else PSOUT ("-ERR Missing username argument\015\012");
26.1 --- a/src/osdep/unix/Makefile Thu Oct 30 00:00:57 2014 +0900 26.2 +++ b/src/osdep/unix/Makefile Thu Oct 30 00:03:05 2014 +0900 26.3 @@ -27,7 +27,7 @@ 26.4 # Command line build parameters 26.5 26.6 EXTRAAUTHENTICATORS= 26.7 -EXTRADRIVERS=mbox 26.8 +EXTRADRIVERS=maildir mbox 26.9 PASSWDTYPE=std 26.10 SSLTYPE=nopwd 26.11 IP=4 26.12 @@ -102,6 +102,7 @@ 26.13 NEWSSPOOL=$(SPOOLDIR)/news 26.14 RSHPATH=/usr/ucb/rsh 26.15 MD5PWD=/etc/cram-md5.pwd 26.16 +MD5CFLAGS= -DAPOPOPEN=\"/usr/local/sbin/deapop\" -DUSERAPOPFILE=\".apop\" -DPOPBEFORESMTP -DPOP3RECORDER=\"/usr/local/etc/pop3-record\" 26.17 # Tries one of the test alternatives below if not specified. 26.18 LOCKPGM= 26.19 # Test alternatives if LOCKPGM not specified 26.20 @@ -144,17 +145,21 @@ 26.21 # However, mh needs to be before any sysinbox formats (such as mmdf or unix) 26.22 # since otherwise INBOX won't work correctly when mh_allow_inbox is set. 26.23 # 26.24 -DEFAULTDRIVERS=imap nntp pop3 mix mx mbx tenex mtx mh mmdf unix news phile 26.25 +DEFAULTDRIVERS=maildir imap nntp pop3 mix mx mbx tenex mtx mh mmdf unix news phile 26.26 CHUNKSIZE=65536 26.27 26.28 # Normally no need to change any of these 26.29 +EXTRACFLAGS=-DQMAIL 26.30 +# Next variable controls default maildir when user has no ~/.qmail 26.31 +#MAILDIRCFLAGS=-DDEFAULTMAILDIR="maildir" -DQMAILCONTROL="/var/qmail/control" 26.32 +MAILDIRCFLAGS=-DQMAILCONTROL="/var/qmail/control" 26.33 26.34 ARCHIVE=c-client.a 26.35 BINARIES=osdep.o mail.o misc.o newsrc.o smanager.o utf8.o utf8aux.o siglocal.o \ 26.36 dummy.o pseudo.o netmsg.o flstring.o fdstring.o \ 26.37 rfc822.o nntp.o smtp.o imap4r1.o pop3.o \ 26.38 - unix.o mbx.o mmdf.o tenex.o mtx.o news.o phile.o mh.o mx.o mix.o 26.39 -CFLAGS=-g 26.40 + unix.o mbx.o mmdf.o tenex.o mtx.o news.o phile.o mh.o mx.o mix.o maildir.o 26.41 +CFLAGS=-g $(EXTRACFLAGS) 26.42 26.43 CAT=cat 26.44 MAKE=make 26.45 @@ -900,6 +905,7 @@ 26.46 unix.o: mail.h misc.h osdep.h unix.h pseudo.h dummy.h 26.47 utf8.o: mail.h misc.h osdep.h utf8.h tmap.c widths.c 26.48 utf8aux.o: mail.h misc.h osdep.h utf8.h 26.49 +maildir.o: mail.h misc.h osdep.h maildir.h dummy.h 26.50 26.51 26.52 # OS-dependent 26.53 @@ -968,6 +974,7 @@ 26.54 @echo Once-only environment setup... 26.55 echo $(CC) > CCTYPE 26.56 echo $(BASECFLAGS) '$(EXTRACFLAGS)' -DCHUNKSIZE=$(CHUNKSIZE) > CFLAGS 26.57 + echo '$(MAILDIRCFLAGS)' >> CFLAGS 26.58 echo -DCREATEPROTO=$(CREATEPROTO) -DEMPTYPROTO=$(EMPTYPROTO) \ 26.59 -DMD5ENABLE=\"$(MD5PWD)\" -DMAILSPOOL=\"$(MAILSPOOL)\" \ 26.60 -DANONYMOUSHOME=\"$(MAILSPOOL)/anonymous\" \ 26.61 @@ -975,6 +982,7 @@ 26.62 -DRSHPATH=\"$(RSHPATH)\" -DLOCKPGM=\"$(LOCKPGM)\" \ 26.63 -DLOCKPGM1=\"$(LOCKPGM1)\" -DLOCKPGM2=\"$(LOCKPGM2)\" \ 26.64 -DLOCKPGM3=\"$(LOCKPGM3)\" > OSCFLAGS 26.65 + echo $(MD5CFLAGS) >> OSCFLAGS 26.66 echo $(BASELDFLAGS) $(EXTRALDFLAGS) > LDFLAGS 26.67 echo "$(ARRC) $(ARCHIVE) $(BINARIES);$(RANLIB) $(ARCHIVE)" > ARCHIVE 26.68 echo $(OS) > OSTYPE
27.1 --- a/src/osdep/unix/env_unix.c Thu Oct 30 00:00:57 2014 +0900 27.2 +++ b/src/osdep/unix/env_unix.c Thu Oct 30 00:03:05 2014 +0900 27.3 @@ -422,6 +422,10 @@ 27.4 case SET_DISABLEPLAINTEXT: 27.5 disablePlaintext = (long) value; 27.6 case GET_DISABLEPLAINTEXT: 27.7 +#ifdef RESTRICT_POP 27.8 + if (getenv("INTRANET") == NIL) disablePlaintext = 1; 27.9 + else disablePlaintext = NIL; 27.10 +#endif 27.11 ret = (void *) disablePlaintext; 27.12 break; 27.13 case SET_CHROOTSERVER: 27.14 @@ -665,6 +669,7 @@ 27.15 char *s; 27.16 struct passwd *pw; 27.17 struct passwd *ret = NIL; 27.18 +#ifndef QMAIL /* imapext md5 checker run previously. no need to do here */ 27.19 if (auth_md5.server) { /* using CRAM-MD5 authentication? */ 27.20 if (s = auth_md5_pwd (user)) { 27.21 if (!strcmp (s,pwd) || ((*pwd == ' ') && pwd[1] && !strcmp (s,pwd+1))) 27.22 @@ -673,7 +678,9 @@ 27.23 fs_give ((void **) &s); 27.24 } 27.25 } 27.26 - else if (pw = pwuser (user)) {/* can get user? */ 27.27 + else 27.28 +#endif 27.29 + if (pw = pwuser (user)) {/* can get user? */ 27.30 s = cpystr (pw->pw_name); /* copy returned name in case we need it */ 27.31 if (*pwd && !(ret = checkpw (pw,pwd,argc,argv)) && 27.32 (*pwd == ' ') && pwd[1] && (ret = pwuser (s))) 27.33 @@ -697,6 +704,10 @@ 27.34 struct passwd *pw = NIL; 27.35 int level = LOG_NOTICE; 27.36 char *err = "failed"; 27.37 +#ifdef QMAIL 27.38 + char usr[MAILTMPLEN], *apoppswd; 27.39 + strncpy(usr, user, MAILTMPLEN-1); 27.40 +#endif 27.41 /* cretins still haven't given up */ 27.42 if ((strlen (user) >= NETMAXUSER) || 27.43 (authuser && (strlen (authuser) >= NETMAXUSER))) { 27.44 @@ -706,6 +717,16 @@ 27.45 } 27.46 else if (logtry-- <= 0) err = "excessive login failures"; 27.47 else if (disablePlaintext) err = "disabled"; 27.48 +#ifdef QMAIL 27.49 + else if ((logtry > 0) && 27.50 + (apoppswd = auth_md5_pwd(usr)) 27.51 + && !strcmp(apoppswd, pwd) 27.52 + && (pw = getpwnam(usr))) { 27.53 + memset(apoppswd, 0, strlen(apoppswd)); 27.54 + fs_give((void**) &apoppswd); 27.55 + return pw_login(pw, usr, pw->pw_name, pw->pw_dir, argc, argv); 27.56 + } 27.57 +#endif 27.58 else if (!(authuser && *authuser)) pw = valpwd (user,pwd,argc,argv); 27.59 else if (valpwd (authuser,pwd,argc,argv)) pw = pwuser (user); 27.60 if (pw && pw_login (pw,authuser,pw->pw_name,NIL,argc,argv)) return T; 27.61 @@ -728,6 +749,34 @@ 27.62 return pw_login (pwuser (user),authuser,user,NIL,argc,argv); 27.63 } 27.64 27.65 +void permitsmtp() /* to update tcp permission */ 27.66 +{ 27.67 +#ifdef POPBEFORESMTP 27.68 + #include <sys/types.h> 27.69 + #include <sys/wait.h> 27.70 + #ifndef POP3RECORDER 27.71 + # define POP3RECORDER "/usr/local/etc/pop3-record" 27.72 + #endif 27.73 + int child; 27.74 + int wstat; 27.75 + char *permsmtp = POP3RECORDER; 27.76 + 27.77 + switch(child = fork()) 27.78 + { 27.79 + case -1: 27.80 + syslog (LOG_INFO,"Cannot exec %s", permsmtp); 27.81 + _exit(111); 27.82 + break; 27.83 + case 0: 27.84 + execl(permsmtp, permsmtp, 0); 27.85 + syslog (LOG_INFO,"Cannot exec %s", permsmtp); 27.86 + _exit(111); break; 27.87 + } 27.88 + waitpid(child, &wstat, 0); 27.89 +#endif 27.90 +} 27.91 + 27.92 + 27.93 27.94 /* Log in as anonymous daemon 27.95 * Accepts: argument count 27.96 @@ -781,8 +830,14 @@ 27.97 else fatal ("Login failed after chroot"); 27.98 } 27.99 /* normal login */ 27.100 +#ifdef QMAIL 27.101 + else if (((pw->pw_uid == geteuid ()) || (permitsmtp(), loginpw (pw,argc,argv 27.102 +))) && 27.103 + (ret = env_init (user,home))) chdir (myhomedir ()); 27.104 +#else 27.105 else if (((pw->pw_uid == geteuid ()) || loginpw (pw,argc,argv)) && 27.106 - (ret = env_init (user,home))) chdir (myhomedir ()); 27.107 + (ret = env_init (user,home))) chdir (myhomedir ()); 27.108 +#endif 27.109 fs_give ((void **) &home); /* clean up */ 27.110 if (user) fs_give ((void **) &user); 27.111 }
28.1 --- a/src/osdep/unix/tcp_unix.c Thu Oct 30 00:00:57 2014 +0900 28.2 +++ b/src/osdep/unix/tcp_unix.c Thu Oct 30 00:03:05 2014 +0900 28.3 @@ -820,6 +820,20 @@ 28.4 return stream->localhost; /* return local host name */ 28.5 } 28.6 28.7 +/* Get $TCPREMOTEHOST || $TCPREMOTEHOST 28.8 + * If invoked via tcpserver or couriertcpd, consult $TCPREMOTEHOST 28.9 + * or $TCPREMOTEIP 28.10 + */ 28.11 +char* gettcpremoteip() 28.12 +{ 28.13 + if (getenv("TCPREMOTEHOST") && strcmp("0", getenv("TCPREMOTEHOST"))) { 28.14 + return getenv("TCPREMOTEHOST"); 28.15 + } else if (getenv("TCPREMOTEIP")) { 28.16 + return getenv("TCPREMOTEIP"); 28.17 + } 28.18 + return "NON-IPv4"; 28.19 +} 28.20 + 28.21 /* TCP/IP get client host address (server calls only) 28.22 * Returns: client host address 28.23 */ 28.24 @@ -850,6 +864,15 @@ 28.25 if (!myClientHost) { 28.26 size_t sadrlen; 28.27 struct sockaddr *sadr = ip_newsockaddr (&sadrlen); 28.28 +#ifdef INET6 28.29 + if (getenv("TCPREMOTEIP")) { 28.30 + myClientHost = 28.31 + cpystr((getenv("TCPREMOTEHOST") 28.32 + && strcasecmp("UNKNOWN", getenv("TCPREMOTEHOST"))) 28.33 + ? getenv("TCPREMOTEHOST") 28.34 + : getenv("TCPREMOTEIP")); 28.35 + } else 28.36 +#endif 28.37 if (getpeername (0,sadr,(void *) &sadrlen)) { 28.38 char *s,*t,*v,tmp[MAILTMPLEN]; 28.39 if ((s = getenv (t = "SSH_CLIENT")) || 28.40 @@ -913,7 +936,8 @@ 28.41 size_t sadrlen; 28.42 struct sockaddr *sadr = ip_newsockaddr (&sadrlen); 28.43 /* get stdin's name */ 28.44 - if (getsockname (0,sadr,(void *) &sadrlen)) 28.45 + if (getsockname (0,sadr,(void *) &sadrlen) || 28.46 + (myServerPort = ip_sockaddrtoport (sadr)) < 0) 28.47 myServerHost = cpystr (mylocalhost ()); 28.48 else { /* get stdin's name */ 28.49 myServerHost = tcp_name (sadr,NIL);
29.1 --- a/src/osdep/unix/unix.c Thu Oct 30 00:00:57 2014 +0900 29.2 +++ b/src/osdep/unix/unix.c Thu Oct 30 00:03:05 2014 +0900 29.3 @@ -202,6 +202,7 @@ 29.4 29.5 /* driver parameters */ 29.6 static long unix_fromwidget = T; 29.7 +char *myMailSuffix =NIL; /* home directory name */ 29.8 29.9 /* UNIX mail validate mailbox 29.10 * Accepts: mailbox name 29.11 @@ -2401,6 +2402,15 @@ 29.12 } 29.13 f->filepos += size; /* update file position */ 29.14 } 29.15 + 29.16 +/* Return my mail suffix(of qmail or Postfix) 29.17 + * Returns: my mail address extensional suffix 29.18 + */ 29.19 + 29.20 +char *mymailsuffix () 29.21 +{ 29.22 + return myMailSuffix ? myMailSuffix : ""; 29.23 +} 29.24 29.25 /* MBOX mail routines */ 29.26