Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

PATCH: DRAC + db 4.2.52

2007-01-16 by Carl Swart

Hi All,

Here is a patch I made to get milter-greylist version 3.0.0, the
current stable version, to compile milter-greylist with DRAC enabled
using Berkeley DB (now Oracle Berkeley DB) version 4.2.52.

I am of the opinion that the patch should work for all DB versions
with a major version number >= 4 and a minor version number >= 1.

Without the patch, the DRAC code will only compile for DB versions < 2.

You will need to add '-ldb' to the Makefile to be able to compile
milter-greylist once the patch have been applied.

I hope that the patch can be incorporated into milter-greylist's
future versions.

It is really nice to have greylisting bypassed if the user is in the
DRAC db. It makes lots of our users very happy to have the best of
both worlds.

[root@wist milter-greylist-3.0]# diff -ruN milter-greylist.c.old
milter-greylist.c
--- milter-greylist.c.old       2007-01-16 20:26:40.000000000 +0200
+++ milter-greylist.c   2007-01-16 20:05:59.000000000 +0200
@@ -1342,16 +1342,20 @@
        char ipkey[16];
        int rc;

-       ddb = dbopen(conf.c_dracdb, O_RDONLY | O_SHLOCK, 0666, DB_BTREE, NULL);
-       if (ddb == NULL) {
-               mg_log(LOG_DEBUG, "dbopen \"%s\" failed", conf.c_dracdb);
+       errno = db_create(&ddb, NULL, 0);
+       if (errno != 0) {
+               mg_log(LOG_DEBUG, "db_create \"%s\" failed", conf.c_dracdb);
                return 0;
        }

+       ddb->set_pagesize(ddb, 512);
+       errno = ddb->open(ddb, NULL, conf.c_dracdb, NULL, DB_BTREE,
DB_RDONLY, 0644);
+       memset(&key, 0, sizeof(key));
+       memset(&data, 0, sizeof(data));
        key.data = strncpy(ipkey, dotted_ip, sizeof(ipkey));
        key.size = strlen(ipkey);
-       rc = ddb->get(ddb, &key, &data, 0);
-       ddb->close(ddb);
+       rc = ddb->get(ddb, NULL, &key, &data, 0);
+       (void)ddb->close(ddb, 0);

        switch (rc) {
        case 0:
@@ -1364,12 +1368,12 @@
                return 1;
                break;

-       case 1:
+       case DB_NOTFOUND:
                return 0;
                break;

        default:
-               mg_log(LOG_ERR, "check_drack: errno=%d", errno);
+               mg_log(LOG_ERR, "check_drac: errno=%d", errno);
                break;
        }

I hope that this helps someone.

--
Regards,
-Carl

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.