Whashington Univ. のimapdはそのままではdracdに対応していない。
http://mail.cc.umanitoba.ca/drac/uw-imap2001-drac.txt
辺りを参考にvine seeds のimap-2001aにパッチを当てる。インストール後、
/etc/mail/dracd.hostに一行だけ
localhost
と書く。このファイルはimapアクセスがあったときに設定更新するサーバーを
書くらしい。inetを再起動、dracdを再起動して、
strings /etc/mail/dracd.db
がアドレスを表示せず、imapdが任意サーバーからアクセスすることで
strings /etc/mail/dracd.db
にアドレスが現れることを確認する。
imap-2001a-10vl3用パッチファイル
diff -pr imap-orig/Makefile imap-2001a/Makefile *** imap-orig/Makefile 2005-02-13 22:08:29.000000000 +0900 --- imap-2001a/Makefile 2005-02-13 21:51:42.000000000 +0900 *************** SSLTYPE=none *** 212,223 **** # gradually-increasing intervals, starting at 2800-2900, and becoming # permanent at 48,300. ! EXTRACFLAGS= # Extra linker flags (additional/alternative libraries, etc.) ! EXTRALDFLAGS= # Special make flags (e.g. to override make environment variables) --- 212,223 ---- # gradually-increasing intervals, starting at 2800-2900, and becoming # permanent at 48,300. ! EXTRACFLAGS=-DDRAC_AUTH # Extra linker flags (additional/alternative libraries, etc.) ! EXTRALDFLAGS=-ldrac # Special make flags (e.g. to override make environment variables) diff -pr imap-orig/src/imapd/imapd.c imap-2001a/src/imapd/imapd.c *** imap-orig/src/imapd/imapd.c 2005-02-13 22:08:29.000000000 +0900 --- imap-2001a/src/imapd/imapd.c 2005-02-13 21:38:52.000000000 +0900 *************** extern int errno; /* just in case */ *** 28,34 **** #include <time.h> #include "c-client.h" #include <sys/stat.h> ! #define CRLF PSOUT ("\015\012") /* primary output terpri */ --- 28,38 ---- #include <time.h> #include "c-client.h" #include <sys/stat.h> ! #ifdef DRAC_AUTH ! #include <netinet/in.h> ! #include <arpa/inet.h> ! #include <stdlib.h> ! #endif /* DRAC_AUTH */ #define CRLF PSOUT ("\015\012") /* primary output terpri */ *************** char *lasterror (void); *** 173,178 **** --- 177,188 ---- /* Global storage */ + #ifdef DRAC_AUTH + #define DRACTIMEOUT 10*60/* check every 10 minutes */ + time_t lastdrac = 0;/* time of last drac check */ + extern char *getenv (); + #endif /* DRAC_AUTH */ + char *version = "2001.315rh"; /* version number of this server */ time_t alerttime = 0; /* time of last alert */ time_t sysalerttime = 0; /* time of last system alert */ *************** void ping_mailbox (unsigned long uid) *** 1226,1231 **** --- 1236,1281 ---- lasterror ()); return; } + + + #ifdef DRAC_AUTH + if (time (0) > lastdrac + DRACTIMEOUT) + { + FILE *dracconf; + char host[100]; + char *drachost; + char *err; + char *p; + + if ( (dracconf = fopen("/etc/mail/dracd.host", "r")) == NULL) + { + syslog (LOG_INFO, "dracd: error opening /etc/mail/dracd.host config file"); + exit(1); + } + + fgets(host, 100, dracconf); + p = strchr(host, '\n'); + if(p != NULL) + *p = '\0'; + fclose(dracconf); + if( drachost = (host) ) + { + struct sockaddr_in sin; + int sinlen = sizeof (struct sockaddr_in); + char *client = getpeername (0,(struct sockaddr *) &sin,(void *) &sinlen) ? + "UNKNOWN" : inet_ntoa (sin.sin_addr); + + lastdrac = time(0); + + if (dracauth(drachost, inet_addr(client), &err) != 0) + syslog (LOG_INFO, err); + else + syslog (LOG_INFO, "dracd: authorized ip %s", client); + } + } + #endif /* DRAC_AUTH */ + + /* change in number of messages? */ if (existsquelled || (nmsgs != stream->nmsgs)) { PSOUT ("* "); diff -pr imap-orig/src/ipopd/ipop3d.c imap-2001a/src/ipopd/ipop3d.c *** imap-orig/src/ipopd/ipop3d.c 2005-02-13 22:11:39.000000000 +0900 --- imap-2001a/src/ipopd/ipop3d.c 2005-02-13 21:54:21.000000000 +0900 *************** extern int errno; /* just in case */ *** 27,32 **** --- 27,38 ---- #include <signal.h> #include <time.h> #include "c-client.h" + #ifdef DRAC_AUTH + #include <netinet/in.h> + #include <arpa/inet.h> + #include <stdlib.h> + #endif /* DRAC_AUTH */ + #define CRLF PSOUT ("\015\012") /* primary output terpri */ *************** extern int errno; /* just in case */ *** 57,62 **** --- 63,74 ---- /* Global storage */ + #ifdef DRAC_AUTH + #define DRACTIMEOUT 10*60/* check every 10 minutes */ + time_t lastdrac = 0;/* time of last drac check */ + extern char *getenv (); + #endif /* DRAC_AUTH */ + char *version = "2001.78rh"; /* server version */ short state = AUTHORIZATION; /* server state */ short critical = NIL; /* non-zero if in critical code */ *************** int main (int argc,char *argv[]) *** 206,213 **** tcp_clienthost ()); } else if ((state = mbxopen ("INBOX")) == TRANSACTION) ! syslog (LOG_INFO,"Auth user=%.80s host=%.80s nmsgs=%ld/%ld", ! user,tcp_clienthost (),nmsgs,stream->nmsgs); else syslog (LOG_INFO,"Auth user=%.80s host=%.80s no mailbox", user,tcp_clienthost ()); } --- 218,263 ---- tcp_clienthost ()); } else if ((state = mbxopen ("INBOX")) == TRANSACTION) ! { ! #ifdef DRAC_AUTH ! if (time (0) > lastdrac + DRACTIMEOUT) ! { ! FILE *dracconf; ! char host[100]; ! char *drachost; ! char *err; ! char *p; ! ! if ( (dracconf = fopen("/etc/mail/dracd.host", "r")) == NULL) ! { ! syslog (LOG_INFO, "dracd: error opening /etc/mail/dracd.host config file"); ! exit(1); ! } ! ! fgets(host, 100, dracconf); ! p = strchr(host, '\n'); ! if(p != NULL) ! *p = '\0'; ! fclose(dracconf); ! ! if( drachost = (host) ) ! { ! struct sockaddr_in sin; ! int sinlen = sizeof (struct sockaddr_in); ! char *client = getpeername (0,(struct sockaddr *) &sin,(void *) &sinlen) ? ! "UNKNOWN" : inet_ntoa (sin.sin_addr); ! ! lastdrac = time(0); ! if (dracauth(drachost, inet_addr(client), &err) != 0) ! syslog (LOG_INFO, err); ! else ! syslog (LOG_INFO, "dracd: authorized ip %s", client); ! } ! } ! #endif /* DRAC_AUTH */ ! syslog (LOG_INFO,"Auth user=%.80s host=%.80s nmsgs=%ld/%ld", ! user,tcp_clienthost (),nmsgs,stream->nmsgs); ! } else syslog (LOG_INFO,"Auth user=%.80s host=%.80s no mailbox", user,tcp_clienthost ()); } *************** int main (int argc,char *argv[]) *** 245,252 **** --- 295,340 ---- else if (!(user = apop_login (challenge,s,t,argc,argv))) PSOUT ("-ERR Bad APOP\015\012"); else if ((state = mbxopen ("INBOX")) == TRANSACTION) + { + #ifdef DRAC_AUTH + if (time (0) > lastdrac + DRACTIMEOUT) + { + FILE *dracconf; + char host[100]; + char *drachost; + char *err; + char *p; + + if ( (dracconf = fopen("/etc/mail/dracd.host", "r")) == NULL) + { + syslog (LOG_INFO, "dracd: error opening /etc/mail/dracd.host config file"); + exit(1); + } + + fgets(host, 100, dracconf); + p = strchr(host, '\n'); + if(p != NULL) + *p = '\0'; + fclose(dracconf); + + if( drachost = (host) ) + { + struct sockaddr_in sin; + int sinlen = sizeof (struct sockaddr_in); + char *client = getpeername (0,(struct sockaddr *) &sin,(void *) &sinlen) ? + "UNKNOWN" : inet_ntoa (sin.sin_addr); + + lastdrac = time(0); + if (dracauth(drachost, inet_addr(client), &err) != 0) + syslog (LOG_INFO, err); + else + syslog (LOG_INFO, "dracd: authorized ip %s", client); + } + } + #endif /* DRAC_AUTH */ syslog (LOG_INFO,"APOP user=%.80s host=%.80s nmsgs=%ld/%ld", user,tcp_clienthost (),nmsgs,stream->nmsgs); + } else syslog (LOG_INFO,"APOP user=%.80s host=%.80s no mailbox", user,tcp_clienthost ()); }