The patch has already been updated in CVS.  I _think_ I did it
yesterday.

Ken


Keith Kee wrote:
> 
> I have patched cyrus-imapd-2.1.2 with drac, I thought I contribute the patch
> here. One place in the file imapd.c that I am not certain if these block of
> code should go inside or outside the if(imapd_out) block.
> 
> Hope this is useful.
> 
> Thanks
> keith
> 
> *** cyrus-imapd-2.1.2.orig/acconfig.h   Wed Dec  5 10:23:22 2001
> --- cyrus-imapd-2.1.2/acconfig.h        Thu Feb 21 03:18:39 2002
> ***************
> *** 93,98 ****
> --- 93,101 ----
>   /* do we have SASL support for APOP? */
>   #undef HAVE_APOP
> 
> + /* the Dynamic Relay Authorization Control package */
> + #undef DRAC_AUTH
> +
>   /* do we have OpenSSL? */
>   #undef HAVE_SSL
> 
> *** cyrus-imapd-2.1.2.orig/configure.in Wed Feb 13 16:29:26 2002
> --- cyrus-imapd-2.1.2/configure.in      Thu Feb 21 03:19:50 2002
> ***************
> *** 809,814 ****
> --- 809,827 ----
>   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
> *** cyrus-imapd-2.1.2.orig/imap/imapd.c Wed Feb 13 16:34:37 2002
> --- cyrus-imapd-2.1.2/imap/imapd.c      Thu Feb 21 03:29:11 2002
> ***************
> *** 114,119 ****
> --- 114,127 ----
>   static SSL *tls_conn = NULL;
>   #endif /* HAVE_SSL */
> 
> + #ifdef DRAC_AUTH
> + static struct {
> +     int interval;             /* dracd "ping" interval; 0 = disabled */
> +     unsigned long clientaddr;
> +     struct prot_waitevent *event;
> + } drac;
> + #endif /* DRAC_AUTH */
> +
>   /* current sub-user state */
>   static struct mailbox mboxstruct;
>   static struct mailbox *imapd_mailbox;
> ***************
> *** 448,453 ****
> --- 456,479 ----
>       /* setup for sending IMAP IDLE notifications */
>       idle_enabled();
> 
> + #ifdef DRAC_AUTH
> +     /* setup for sending DRAC "pings" */
> +     drac.event = NULL;
> +     drac.interval = config_getint("dracinterval", 5);
> +     if (drac.interval < 0) drac.interval = 0;
> +
> +      if (drac.interval) {
> +       char *err;
> +
> +       if (dracconn(config_getstring("drachost", "localhost"), &err) != 0)
> {
> +           /* disable DRAC */
> +           drac.interval = 0;
> +           syslog(LOG_NOTICE, "dracconn: %s", err);
> +           syslog(LOG_NOTICE, "DRAC DISABLED");
> +       }
> +     }
> + #endif /* DRAC_AUTH */
> +
>       /* create connection to the SNMP listener, if available. */
>       snmp_connect(); /* ignore return code */
>       snmp_set_str(SERVER_NAME_VERSION,CYRUS_VERSION);
> ***************
> *** 530,535 ****
> --- 556,567 ----
>                   imapd_haveaddr = 1;
>               }
>         }
> +
> + #ifdef DRAC_AUTH
> +       drac.clientaddr = imapd_remoteaddr.sin_addr.s_addr;
> +     } else {
> +       drac.clientaddr = 0;
> + #endif /* DRAC_AUTH */
>       }
> 
>       /* create the SASL connection */
> ***************
> *** 572,577 ****
> --- 604,614 ----
>       prot_flush(imapd_out);
>       snmp_increment(ACTIVE_CONNECTIONS, -1);
> 
> + #ifdef DRAC_AUTH
> +     if (drac.event) prot_removewaitevent(imapd_in, drac.event);
> +     drac.event = NULL;
> + #endif /* DRAC_AUTH */
> +
>       /* cleanup */
>       imapd_reset();
> 
> ***************
> *** 650,655 ****
> --- 687,696 ----
>         snmp_increment(ACTIVE_CONNECTIONS, -1);
>       }
> 
> + #ifdef DRAC_AUTH
> +     if (drac.interval) (void) dracdisc((char **)NULL);
> + #endif /* DRAC_AUTH */
> +
>       exit(code);
>   }
> 
> ***************
> *** 672,677 ****
> --- 713,747 ----
> 
>   }
> 
> + #ifdef DRAC_AUTH
> + /*
> +  * Ping dracd every 'drac.interval' minutes
> +  * 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;
> +     static int nfailure = 0;
> +
> +     if (dracsend(drac.clientaddr, &err) != 0) {
> +       syslog(LOG_NOTICE, "dracsend: %s", err);
> +       if (++nfailure >= 3) {
> +           /* can't contact dracd for 3 consecutive tries - disable DRAC */
> +           prot_removewaitevent(s, ev);
> +           drac.event = NULL;
> +           syslog(LOG_NOTICE, "DRAC DISABLED");
> +           return NULL;
> +       }
> +     }
> +     else
> +       nfailure = 0;
> +
> +     ev->mark = time(NULL) + (drac.interval * 60);
> +     return ev;
> + }
> + #endif /* DRAC_AUTH */
> +
>   /*
>    * Top-level command loop parsing
>    */
> ***************
> *** 1529,1534 ****
> --- 1599,1609 ----
> 
>       prot_printf(imapd_out, "%s OK %s\r\n", tag, reply);
> 
> + #ifdef DRAC_AUTH
> +     if (drac.interval && drac.clientaddr)
> +       drac.event = prot_addwaitevent(imapd_in, 0 /* now */, drac_ping,
> NULL);
> + #endif /* DRAC_AUTH */
> +
>       /* Create telemetry log */
>       imapd_logfd = telemetry_log(imapd_userid, imapd_in, imapd_out);
> 
> ***************
> *** 1682,1687 ****
> --- 1757,1767 ----
> 
>       prot_setsasl(imapd_in,  imapd_saslconn);
>       prot_setsasl(imapd_out, imapd_saslconn);
> +
> + #ifdef DRAC_AUTH
> +     if (drac.interval && drac.clientaddr)
> +       drac.event = prot_addwaitevent(imapd_in, 0 /* now */, drac_ping,
> NULL);
> + #endif /* DRAC_AUTH */
> 
>       /* Create telemetry log */
>       imapd_logfd = telemetry_log(imapd_userid, imapd_in, imapd_out);
> *** cyrus-imapd-2.1.2.orig/imap/pop3d.c Fri Feb 15 12:21:15 2002
> --- cyrus-imapd-2.1.2/imap/pop3d.c      Thu Feb 21 03:31:19 2002
> ***************
> *** 101,106 ****
> --- 101,109 ----
> 
>   extern int errno;
> 
> + #ifdef DRAC_AUTH
> + static int drac_enabled;
> + #endif /* DRAC_AUTH */
> 
>   #ifdef HAVE_SSL
> ***************
> *** 426,431 ****
> --- 429,438 ----
>       prot_settimeout(popd_in, timeout*60);
>       prot_setflushonread(popd_in, popd_out);
> 
> + #ifdef DRAC_AUTH
> +     drac_enabled = (config_getint("dracinterval", 5) > 0);
> + #endif /* DRAC_AUTH */
> +
>       if (kflag) kpop();
> 
>       /* we were connected on pop3s port so we should do
> ***************
> *** 1385,1390 ****
> --- 1392,1410 ----
>       }
>       popd_mailbox = &mboxstruct;
>       proc_register("pop3d", popd_clienthost, popd_userid,
> popd_mailbox->name);
> +
> + #ifdef DRAC_AUTH
> +     if (drac_enabled) {
> +       char *err;
> +
> +       if (dracauth(config_getstring("drachost", "localhost"),
> +                    popd_remoteaddr.sin_addr.s_addr, &err) != 0) {
> +           /* disable DRAC */
> +           drac_enabled = 0;
> +           syslog(LOG_NOTICE, "dracauth: %s (DISABLED)", err);
> +       }
> +     }
> + #endif /* DRAC_AUTH */
> 
>       /* Create telemetry log */
>       telemetry_log(popd_userid, popd_in, popd_out);
> *** cyrus-imapd-2.1.2.orig/imap/version.c       Mon Nov 26 21:25:00 2001
> --- cyrus-imapd-2.1.2/imap/version.c    Thu Feb 21 03:32:03 2002
> ***************
> *** 130,135 ****
> --- 130,139 ----
>       snprintf(env_buf + strlen(env_buf), MAXIDVALUELEN - strlen(env_buf),
>              "; %s", SIEVE_VERSION);
>   #endif
> + #ifdef DRAC_AUTH
> +     snprintf(env_buf + strlen(env_buf), MAXIDVALUELEN - strlen(env_buf),
> +            "; DRAC");
> + #endif
>   #ifdef HAVE_LIBWRAP
>       snprintf(env_buf + strlen(env_buf), MAXIDVALUELEN - strlen(env_buf),
>              "; TCP Wrappers");

-- 
Kenneth Murchison     Oceana Matrix Ltd.
Software Engineer     21 Princeton Place
716-662-8973 x26      Orchard Park, NY 14127
--PGP Public Key--    http://www.oceana.com/~ken/ksm.pgp

Reply via email to