I'm attaching a modified version of the patch to add 
drac support to Cyrus imapd/pop3d daemons.

It is based in the one included in the contrib 
directory of the 2.0.12 distribution.

I have modified the configuration variables 
used in imapd.conf to be able to specify at runtime 
if one wants to use (or not) drac even when the binary 
used is compiled with drac support (before it was always 
enabled).

Also the interval in minutes between submissions 
to the dracd daemon made by imapd during a user's   
IMAP session is now configurable (previously it was 
fixed to 5 minutes). It is then now possible to 
play with this setting and the -e switch parameter 
passed to the dracd daemon.

The relevant imapd.conf options are

dracinterval: 0
If nonzero it enables drac support for imapd and pop3d 
indicating then the amount of time in minutes 
between submissions to the dracd daemon made by 
imapd.

drachost: localhost
The host where the dracd daemon is running.

The instructions to apply it are the same to the 
ones included with the original patch. Just 
take in account the configuration file you modify 
is imapd.conf and not cyrus.conf.

Excuse me for my English.

--
Ramiro



____________________________________________________________________
Get free email and a permanent address at http://www.amexmail.com/?A=1
diff -ruN cyrus-imapd-2.0.12-orig/acconfig.h cyrus-imapd-2.0.12/acconfig.h
--- cyrus-imapd-2.0.12-orig/acconfig.h  Thu Feb  8 00:46:56 2001
+++ cyrus-imapd-2.0.12/acconfig.h       Sun Mar  4 14:56:19 2001
@@ -78,6 +78,9 @@
 /* the TCP control package */
 #undef HAVE_LIBWRAP
 
+/* the Dynamic Relay Authorization Control package */
+#undef DRAC_AUTH
+
 /* do we have OpenSSL? */
 #undef HAVE_SSL
 
diff -ruN cyrus-imapd-2.0.12-orig/configure.in cyrus-imapd-2.0.12/configure.in
--- cyrus-imapd-2.0.12-orig/configure.in        Mon Feb 19 20:54:42 2001
+++ cyrus-imapd-2.0.12/configure.in     Sun Mar  4 14:56:19 2001
@@ -714,6 +714,21 @@
 SNMP_SUBDIRS=""
 AC_SUBST(SNMP_SUBDIRS)
 
+
+
+dnl
+dnl Test for DRAC
+dnl
+AC_ARG_WITH(drac, [  --with-drac=DIR         use DRAC library in <DIR> [no] ],
+       if test -d "$withval"; then
+               LDFLAGS="$LDFLAGS -L${withval}"
+               AC_CHECK_LIB(drac, dracauth,
+                       AC_DEFINE(DRAC_AUTH)
+                       LIBS="${LIBS} -ldrac")
+       fi)
+
+
+
 CMU_SOCKETS
 CMU_LIBWRAP
 CMU_UCDSNMP
diff -ruN cyrus-imapd-2.0.12-orig/imap/imapd.c cyrus-imapd-2.0.12/imap/imapd.c
--- cyrus-imapd-2.0.12-orig/imap/imapd.c        Fri Feb 16 21:55:10 2001
+++ cyrus-imapd-2.0.12/imap/imapd.c     Fri Mar  2 09:12:42 2001
@@ -119,6 +119,9 @@
     "jul", "aug", "sep", "oct", "nov", "dec"
 };
 
+static int drac_interval;
+static int drac_isconn;
+
 void shutdown_file(int fd);
 void motd_file(int fd);
 void shut_down(int code);
@@ -486,6 +489,22 @@
        TLS negotiation immediately */
     if (imaps == 1) cmd_starttls(NULL, 1);
 
+#ifdef DRAC_AUTH
+    {
+       char *err;
+       drac_interval = config_getint("dracinterval", 0);
+       if (drac_interval < 0)
+           drac_interval = 0;
+       drac_isconn = 0;
+       if (drac_interval) {
+           if (dracconn(config_getstring("drachost", "localhost"), &err) != 0)
+               syslog(LOG_NOTICE, "dracconn: %s", err);
+           else
+               drac_isconn = 1;
+       }
+    }
+#endif /* DRAC_AUTH */
+
     snmp_increment(TOTAL_CONNECTIONS, 1);
     snmp_increment(ACTIVE_CONNECTIONS, 1);
 
@@ -561,6 +580,12 @@
     prot_flush(imapd_out);
     /* one less active connection */
     snmp_increment(ACTIVE_CONNECTIONS, -1);
+
+#ifdef DRAC_AUTH
+    if (drac_interval && drac_isconn)
+       (void) dracdisc((char **)NULL);
+#endif /* DRAC_AUTH */
+
     exit(code);
 }
 
@@ -581,6 +606,23 @@
 
 }
 
+#ifdef DRAC_AUTH
+/*
+ * Ping dracd every drac_interval min to let it know that we are still connected
+ */
+struct prot_waitevent *drac_ping(struct protstream *s,
+                               struct prot_waitevent *ev, void *rock)
+{
+    char *err;
+
+    if (dracsend(imapd_remoteaddr.sin_addr.s_addr, &err) != 0)
+       syslog(LOG_NOTICE, "dracsend: %s", err);
+
+    ev->mark = time(NULL) + (drac_interval * 60);
+    return ev;
+}
+#endif /* DRAC_AUTH */
+
 /*
  * Top-level command loop parsing
  */
@@ -1429,6 +1471,11 @@
 
     if (!reply) reply = "User logged in";
 
+#ifdef DRAC_AUTH
+    if (drac_interval && drac_isconn)
+       prot_addwaitevent(imapd_in, 0 /* ping now */, drac_ping, NULL);
+#endif /* DRAC_AUTH */
+
     /* Create telemetry log */
     sprintf(buf, "%s%s%s/%lu", config_dir, FNAME_LOGDIR, imapd_userid,
            (unsigned long) getpid());
@@ -1585,6 +1632,11 @@
 
     prot_setsasl(imapd_in,  imapd_saslconn);
     prot_setsasl(imapd_out, imapd_saslconn);
+
+#ifdef DRAC_AUTH
+    if (drac_interval && drac_isconn)
+       prot_addwaitevent(imapd_in, 0 /* ping now */, drac_ping, NULL);
+#endif /* DRAC_AUTH */
 
     /* Create telemetry log */
     sprintf(buf, "%s%s%s/%lu", config_dir, FNAME_LOGDIR, imapd_userid,
diff -ruN cyrus-imapd-2.0.12-orig/imap/pop3d.c cyrus-imapd-2.0.12/imap/pop3d.c
--- cyrus-imapd-2.0.12-orig/imap/pop3d.c        Fri Feb 16 21:55:10 2001
+++ cyrus-imapd-2.0.12/imap/pop3d.c     Tue Feb 27 09:57:19 2001
@@ -1111,6 +1111,19 @@
     popd_mailbox = &mboxstruct;
     proc_register("pop3d", popd_clienthost, popd_userid, popd_mailbox->name);
 
+#ifdef DRAC_AUTH
+    {
+       char *err;
+       int use_drac;
+       use_drac = config_getswitch("usedrac", 0);
+       if (use_drac) {
+           if (dracauth(config_getstring("drachost", "localhost"),
+                        popd_remoteaddr.sin_addr.s_addr, &err) != 0)
+               syslog(LOG_NOTICE, "dracauth: %s", err);
+       }
+    }
+#endif /* DRAC_AUTH */
+
     /* Create telemetry log */
     sprintf(buf, "%s%s%s/%lu", config_dir, FNAME_LOGDIR, popd_userid,
            (long unsigned) getpid());
diff -ruN cyrus-imapd-2.0.12-orig/man/imapd.conf.5 cyrus-imapd-2.0.12/man/imapd.conf.5
--- cyrus-imapd-2.0.12-orig/man/imapd.conf.5    Mon Feb 19 22:39:37 2001
+++ cyrus-imapd-2.0.12/man/imapd.conf.5 Sun Mar  4 19:58:29 2001
@@ -217,6 +217,13 @@
 file overrides the SASL configuration file.
 .IP "\fBlmtpsocket:\fR /var/imap/socket/lmtp" 5
 Unix domain socket that lmtpd listens on.
+.IP "\fBdracinterval:\fR 0" 5
+If nonzero it enables the use of drac (dynamic relay authorization control)
+by the pop3d and imapd daemons, then it sets the amount of time between 
+re-authorization queries made by imapd, in minutes.
+.IP "\fBdrachost:\fR localhost" 5
+Hostname of the dracd server. This option is only relevant if
+\fBdracinterval\fR is nonzero.
 .SH SEE ALSO
 .PP
 \fBimapd(8)\fR, \fBpop3d(8)\fR, \fBlmtpd(8)\fR, \fBtimsieved(8)\fR,

Reply via email to