This applies cleanly to imap-2001.BETA.SNAP-0103052234 (the most current relase of UW IMAP when I made the patch). Note that you will have to include 2 additional definitions on the make command line, one for EXTRACFLAGS and one for EXTRALDFLAGS. For example, if you were compiling for linux with pam: % make lnp EXTRACFLAGS=-DDRAC_AUTH EXTRALDFLAGS=-ldrac You will also have to create a file called /etc/mail/dracd.host -- this file should contain the hostname of the drac server (or localhost if it's run on the same host as the imap server). *** imap-2001.BETA.SNAP-0103052234/src/imapd/imapd.c_ORIG Tue Feb 20 21:23:50 2001 --- imap-2001.BETA.SNAP-0103052234/src/imapd/imapd.c Wed Mar 7 10:46:18 2001 *************** *** 29,34 **** --- 29,39 ---- #include "c-client.h" #include + #ifdef DRAC_AUTH + #include + #include + #include + #endif /* DRAC_AUTH */ #define CRLF PSOUT ("\015\012") /* primary output terpri */ *************** *** 170,175 **** --- 175,186 ---- /* 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.292"; /* version number of this server */ time_t alerttime = 0; /* time of last alert */ time_t sysalerttime = 0; /* time of last system alert */ *************** *** 1127,1132 **** --- 1138,1181 ---- 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-2001.BETA.SNAP-0103052234/src/ipopd/ipop3d.c_ORIG Tue Feb 20 21:23:01 2001 --- imap-2001.BETA.SNAP-0103052234/src/ipopd/ipop3d.c Wed Mar 7 10:13:29 2001 *************** *** 28,33 **** --- 28,38 ---- #include #include "c-client.h" + #ifdef DRAC_AUTH + #include + #include + #include + #endif /* DRAC_AUTH */ #define CRLF PSOUT ("\015\012") /* primary output terpri */ *************** *** 57,62 **** --- 62,73 ---- /* 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.75"; /* server version */ short state = AUTHORIZATION; /* server state */ short critical = NIL; /* non-zero if in critical code */ *************** *** 227,234 **** --- 238,284 ---- 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 ()); }