While working on scaling problems I needed to match spamc's debugging output with spamd's. That is laborious when you've got multiple MX hosts connecting to multiple spamd hosts.
This patch to spamc.c reveals the port number from which spamc connects to spamd. Spamd already logs the same, so matching them up is a doddle. The patch isn't portable, and you'll need a fair bit of fuzz to get it to apply. But I expect you will already have worked on spamc.c a fair bit to get it to compile with DO_CONNECT_DEBUG_SYSLOGS, so muscling this patch in won't be a challenge to you. I felt it should be in the archive. @@ -438,8 +440,18 @@ } else { #ifdef DO_CONNECT_DEBUG_SYSLOGS - libspamc_log(tp->flags, DEBUG_LEVEL, + struct sockaddr_in namebuf; + socklen_t namesize = sizeof(namebuf); + + memset(&namebuf, 0, sizeof(namebuf)); + if (getsockname(mysock, (struct sockaddr *) &namebuf, &namesize)) { + libspamc_log(tp->flags, LOG_DEBUG, "dbg: connect(AF_INET) to spamd at %s done", ipaddr); + } else { + libspamc_log(tp->flags, LOG_DEBUG, + "dbg: connect(AF_INET) to spamd at %s done, local port %d", + ipaddr, ntohs(namebuf.sin_port)); + } #endif *sockptr = mysock;