*** imap-2000a/src/imapd/Makefile Tue Oct 24 19:54:32 2000 --- imap-2000a.drac/src/imapd/Makefile Tue Dec 12 13:27:03 2000 *************** *** 30,37 **** CCLIENTLIB = $C/c-client.a CC = `cat $C/CCTYPE` CFLAGS = -I$C `cat $C/CFLAGS` -DANOFILE=\"$(ANO)\" \ ! -DALERTFILE=\"$(ALERT)\" -DUSERALERTFILE=\"$(USERALERT)\" ! LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS` all: imapd --- 30,37 ---- CCLIENTLIB = $C/c-client.a CC = `cat $C/CCTYPE` CFLAGS = -I$C `cat $C/CFLAGS` -DANOFILE=\"$(ANO)\" \ ! -DALERTFILE=\"$(ALERT)\" -DUSERALERTFILE=\"$(USERALERT)\" -DDRAC_AUTH ! LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS` -ldrac all: imapd *** imap-2000a/src/imapd/imapd.c Fri Nov 17 23:16:29 2000 --- imap-2000a.drac/src/imapd/imapd.c Tue Dec 12 13:27:03 2000 *************** *** 18,23 **** --- 18,29 ---- * CPYRIGHT, included with this Distribution. */ + #ifdef DRAC_AUTH + #include + #include + #include + #endif /* DRAC_AUTH */ + /* Primary I/O calls */ #define PBIN getchar /* primary byte input */ *************** *** 181,186 **** --- 187,198 ---- /* 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 = "2000.284"; /* version number of this server */ time_t alerttime = 0; /* time of last alert */ time_t sysalerttime = 0; /* time of last system alert */ *************** *** 1131,1136 **** --- 1143,1186 ---- 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 ("* "); *** imap-2000a/src/ipopd/Makefile Tue Oct 24 19:55:07 2000 --- imap-2000a.drac/src/ipopd/Makefile Tue Dec 12 13:27:03 2000 *************** *** 25,32 **** # Get local definitions from c-client directory CC = `cat $C/CCTYPE` ! CFLAGS = -I$C `cat $C/CFLAGS` ! LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS` ipopd: ipop2d ipop3d --- 25,32 ---- # Get local definitions from c-client directory CC = `cat $C/CCTYPE` ! CFLAGS = -I$C `cat $C/CFLAGS` -DDRAC_AUTH ! LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS` -ldrac ipopd: ipop2d ipop3d *** imap-2000a/src/ipopd/ipop3d.c Tue Oct 24 19:15:46 2000 --- imap-2000a.drac/src/ipopd/ipop3d.c Tue Dec 12 13:29:11 2000 *************** *** 35,41 **** --- 35,47 ---- #include #include "c-client.h" + #ifdef DRAC_AUTH + #include + #include + #include + #endif /* DRAC_AUTH */ + /* Autologout timer */ #define KODTIMEOUT 60*5 #define LOGINTIMEOUT 60*3 *************** *** 61,66 **** --- 67,78 ---- /* 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 = "2000.69"; /* server version */ short state = AUTHORIZATION; /* server state */ short critical = NIL; /* non-zero if in critical code */ *************** *** 230,237 **** --- 242,288 ---- 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 ()); }