Yahoo Groups archive

Milter-greylist

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

Message

Re: [milter-greylist] milter-greylist patch for DRAC

2005-11-30 by Romain Kang

Thanks, the improved patch is informative.

I had to leave this a while, but after looking at sendmail some more,
I determined that it's opening up the DB maps on demand.  I believe
that using dbopen() with O_SHLOCK is the way to go.  If the dbopen()
fails, I think it's OK to let the usual greylist logic take over.
In this mode, I think the "drac timeout" parameter can be removed.

I can't seem to get a clean patch out of the Yahoos Group message
archive, so here's the resulting check_drac().

Strictly speaking, the data retrieved by the get() operation is the
expiration time of the DRAC authorization, but rpc.dracd deletes
old entries on its own, so I punt on this point.

static int
check_drac(char *dotted_ip)
{
	DB *ddb;
	DBT key, data;
	char ipkey[32];
	int rc;

	ddb = dbopen(dracdb, (O_RDONLY | O_SHLOCK), 0666, DB_BTREE, NULL);
	if (ddb == NULL)
		return 0;

	key.data = strncpy(ipkey, dotted_ip, sizeof(ipkey));
	key.size = strlen(ipkey);
	rc = ddb->get(ddb, &key, &data, 0);
	ddb->close(ddb);

	switch (rc) {
	    case 0:
#ifdef TEST
		printf("key.data=%.*s (len=%d)  data.data=%.*s (len=%d)\n",
			key.size, key.data, key.size,
			data.size, data.data, data.size);
#endif /* TEST */
		return 1;
		/*NOTREACHED*/

	    case 1:
		return 0;
		/*NOTREACHED*/

	    case -1:
		fprintf(stderr, "errno=%d\n", errno);
		break;
	}

	return 0;
}

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.