Here's a newer DRAC patch for courier. I think it's cleaner than the one i found with google... And it works with ::ffff:ip.ip.ip.ip style addresses. No full ipv6 support though, as drac doesn't support it afaik. All drac stuff is in a new .c file.
I'd like to see it in courier with proper #ifdef's and autoconf
detection of the drac libraries...
To use this patch you need to set the DRACHOST environment variable.
Adding DRACHOST=localhost to your config files should be enough.
The patch expects you to have the drac development libraries installed
in the regular directories, as the "drac-dev" debian package does.
Here you go:
--- courier-0.39.3.20020921.orig/imap/Makefile.in
+++ courier-0.39.3.20020921/imap/Makefile.in
@@ -132,7 +132,7 @@
outbox.c outbox.h \
thread.c thread.h \
search.c searchinfo.c searchinfo.h \
- storeinfo.c storeinfo.h
+ storeinfo.c storeinfo.h dracauth.c
imapd_DEPENDENCIES = libimapd.a ../rfc2045/librfc2045.a ../rfc822/librfc822.a \
@@ -143,7 +143,7 @@
imapd_LDADD = libimapd.a ../rfc2045/librfc2045.a ../rfc822/librfc822.a \
../unicode/libunicode.a ../authlib/libauthmod.a ../authlib/libauth.a \
- ../maildir/libmaildir.a ../liblock/liblock.a ../numlib/libnumlib.a \
+ ../maildir/libmaildir.a ../liblock/liblock.a ../numlib/libnumlib.a -ldrac \
@dblibrary@ @LIBDB@ @LIBGDBM@ @DEBUGLIB@
@@ -157,9 +157,9 @@
../rfc2045/librfc2045.a ../tcpd/libspipe.a
-pop3d_SOURCES = pop3dserver.c pop3dcapa.c
+pop3d_SOURCES = pop3dserver.c pop3dcapa.c dracauth.c
pop3d_DEPENDENCIES = ../authlib/libauthmod.a ../authlib/libauth.a
../maildir/libmaildir.a ../numlib/libnumlib.a
-pop3d_LDADD = ../authlib/libauthmod.a ../authlib/libauth.a ../maildir/libmaildir.a
../numlib/libnumlib.a
+pop3d_LDADD = ../authlib/libauthmod.a ../authlib/libauth.a ../maildir/libmaildir.a
+../numlib/libnumlib.a -ldrac
HTML2TXT = `which lynx 2>/dev/null && echo "lynx -dump -nolist" && exit; echo "links
-dump"`
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -185,11 +185,11 @@
imaplogin_LDFLAGS =
imapd_OBJECTS = fetch.o fetchinfo.o imapd.o imapscanclient.o \
mailboxlist.o msgbodystructure.o msgenvelope.o mysignal.o outbox.o \
-thread.o search.o searchinfo.o storeinfo.o
+thread.o search.o searchinfo.o storeinfo.o dracauth.o
imapd_LDFLAGS =
pop3login_OBJECTS = pop3login.o pop3dcapa.o
pop3login_LDFLAGS =
-pop3d_OBJECTS = pop3dserver.o pop3dcapa.o
+pop3d_OBJECTS = pop3dserver.o pop3dcapa.o dracauth.o
pop3d_LDFLAGS =
SCRIPTS = $(noinst_SCRIPTS)
--- courier-0.39.3.20020921.orig/imap/Makefile.am
+++ courier-0.39.3.20020921/imap/Makefile.am
@@ -48,7 +48,7 @@
outbox.c outbox.h \
thread.c thread.h \
search.c searchinfo.c searchinfo.h \
- storeinfo.c storeinfo.h
+ storeinfo.c storeinfo.h dracauth.c
imapd_DEPENDENCIES=libimapd.a ../rfc2045/librfc2045.a ../rfc822/librfc822.a \
../unicode/libunicode.a ../authlib/libauthmod.a ../authlib/libauth.a \
@@ -57,7 +57,7 @@
imapd_LDADD=libimapd.a ../rfc2045/librfc2045.a ../rfc822/librfc822.a \
../unicode/libunicode.a ../authlib/libauthmod.a ../authlib/libauth.a \
- ../maildir/libmaildir.a ../liblock/liblock.a ../numlib/libnumlib.a \
+ ../maildir/libmaildir.a ../liblock/liblock.a ../numlib/libnumlib.a -ldrac \
@dblibrary@ @LIBDB@ @LIBGDBM@ @DEBUGLIB@
pop3login_SOURCES=pop3login.c pop3dcapa.c
@@ -68,9 +68,9 @@
../random128/librandom128.a ../md5/libmd5.a \
../rfc2045/librfc2045.a ../tcpd/libspipe.a
-pop3d_SOURCES=pop3dserver.c pop3dcapa.c
+pop3d_SOURCES=pop3dserver.c pop3dcapa.c dracauth.c
pop3d_DEPENDENCIES=../authlib/libauthmod.a ../authlib/libauth.a
../maildir/libmaildir.a ../numlib/libnumlib.a
-pop3d_LDADD=../authlib/libauthmod.a ../authlib/libauth.a ../maildir/libmaildir.a
../numlib/libnumlib.a
+pop3d_LDADD=../authlib/libauthmod.a ../authlib/libauth.a ../maildir/libmaildir.a
+../numlib/libnumlib.a -ldrac
HTML2TXT=`which lynx 2>/dev/null && echo "lynx -dump -nolist" && exit; echo "links
-dump"`
--- courier-0.39.3.20020921.orig/imap/imapd.c
+++ courier-0.39.3.20020921/imap/imapd.c
@@ -1400,11 +1400,13 @@
{
struct imaptoken *curtoken=nexttoken();
int uid=0;
if (curtoken->tokentype != IT_ATOM) return (-1);
/* Commands that work in authenticated state */
+ drac_update_tcpremoteip();
+
if (strcmp(curtoken->tokenbuf, "CAPABILITY") == 0)
{
if (nexttoken()->tokentype != IT_EOL) return (-1);
@@ -3031,6 +3034,8 @@
emptytrash();
if ((tag=getenv("IMAPLOGINTAG")) != 0)
{
+ drac_update_tcpremoteip();
+
writes(tag);
writes(" OK LOGIN Ok.\r\n");
}
--- courier-0.39.3.20020921.orig/imap/pop3dserver.c
+++ courier-0.39.3.20020921/imap/pop3dserver.c
@@ -680,7 +680,10 @@
scannew();
scancur();
sortmsgs();
printf("+OK logged in.\r\n");
+
+ drac_update_tcpremoteip();
+
fflush(stdout);
loop();
return (0);
--- courier-0.39.3.20020921.orig/imap/dracauth.c
+++ courier-0.39.3.20020921/imap/dracauth.c
@@ -0,0 +1,33 @@
+#include "netinet/in.h"
+#include "arpa/inet.h"
+#include <syslog.h>
+#include <stdlib.h>
+
+extern int dracauth(char *host, unsigned long ip, char **errmsg);
+
+void drac_update_tcpremoteip() {
+ char *err;
+ char *drachost;
+ struct in6_addr ip6;
+ struct in_addr ip4;
+
+ /* if the DRACHOST env is not set, return silently */
+ drachost = getenv("DRACHOST");
+ if (!drachost || !*drachost) return;
+
+ //syslog(LOG_INFO,"drac_update() called: DRACHOST=%s
+user=%s",getenv("DRACHOST"),getenv("TCPREMOTEIP"));
+
+ if (inet_pton(AF_INET6, getenv("TCPREMOTEIP"), &ip6) <= 0) {
+ syslog(LOG_ALERT,"drac_update() Error: could not convert TCPREMOTEIP
+%s",getenv("TCPREMOTEIP"));
+ return;
+ }
+ if (IN6_IS_ADDR_V4MAPPED(&ip6)) {
+ ip4.s_addr=ip6.s6_addr32[3];
+ if (dracauth(getenv("DRACHOST"), ip4.s_addr, &err) != 0)
+ syslog(LOG_ALERT,"dracauth() Error \"%s\" for user
+%s",err,getenv("TCPREMOTEIP"));
+ } else {
+ syslog(LOG_NOTICE,"drac_update() doesn't support IPv6 yet.");
+ }
+ return;
+}
+
--- courier-0.39.3.20020921.orig/README.DRAC
+++ courier-0.39.3.20020921/README.DRAC
@@ -0,0 +1,10 @@
+Dynamic Relay Authorization Control and Courier-IMAP
+
+The patch is NOT WARRANTED to work, compile, solve issues with your significant
+other, or ANYTHING ELSE. If you use it, you are on your own.
+
+The use of DRAC is controlled via the environment variable DRACHOST.
+As DRAC only supports IPv4 ? this patch will only affect IPv4 logins.
+As my courier gets compiled with IPv6 support i don't know if it actually works
+for IPv4-only systems.
+
+Erich Schubert <[EMAIL PROTECTED]>
Gruss,
Erich Schubert
--
erich@(mucl.de|debian.org) -- GPG Key ID: 4B3A135C
The best things in life are free: Friendship and Love.
Die k�rzeste Verbindung zwischen zwei Menschen ist ein L�cheln.
Humor sollte immmer dabeisein, auch bei Problemen.
msg07248/pgp00000.pgp
Description: PGP signature
