diff --git a/include/bongoagent.h b/include/bongoagent.h index 5d40f4c..5ff5780 100644 --- a/include/bongoagent.h +++ b/include/bongoagent.h @@ -187,6 +187,19 @@ void BongoAgentShutdownFunc (BongoJsonRpcServer *server, BongoArray *args, void *userData); +static struct { + char *hostname; + char *hostaddr; + char *postmaster; +} Globals; + +static BongoConfigItem GlobalConfig[] = { + { BONGO_JSON_STRING, "o:hostname/s", &Globals.hostname }, + { BONGO_JSON_STRING, "o:hostaddr/s", &Globals.hostaddr }, + { BONGO_JSON_STRING, "o:postmaster/s", &Globals.postmaster }, + { BONGO_JSON_NULL, NULL, NULL } +}; + #define BONGO_ENVELOPE_NEXT(p) \ { (p) = (p) + strlen(p) + 1; \ if (*(p) == '\0') (p)++; \ diff --git a/src/agents/imap/fetch.c b/src/agents/imap/fetch.c index c73b509..a2b7e39 100644 --- a/src/agents/imap/fetch.c +++ b/src/agents/imap/fetch.c @@ -870,10 +870,11 @@ FetchFlagResponderXSender(void *param1, void *param2, void *param3) authLen = strlen(session->store.response); if (!strchr(session->store.response, '@')) { - if ((ConnWriteF(session->client.conn, "XSENDER {%lu}\r\n", authLen + 1 + Imap.server.hostnameLen) != -1) && + size_t hostlen = strlen(Globals.hostname); + if ((ConnWriteF(session->client.conn, "XSENDER {%lu}\r\n", authLen + 1 + hostlen) != -1) && (ConnWrite(session->client.conn, session->store.response, authLen) != -1) && (ConnWrite(session->client.conn, "@", 1) != -1) && - (ConnWrite(session->client.conn, Imap.server.hostname, Imap.server.hostnameLen) != -1)) { + (ConnWrite(session->client.conn, Globals.hostname, hostlen) != -1)) { return(STATUS_CONTINUE); } return(STATUS_ABORT); diff --git a/src/agents/imap/imapd.c b/src/agents/imap/imapd.c index 63927c2..4725410 100644 --- a/src/agents/imap/imapd.c +++ b/src/agents/imap/imapd.c @@ -41,8 +41,6 @@ #include -#include - #include "imapd.h" ImapGlobal Imap; @@ -3190,7 +3188,7 @@ HandleConnection(void *param) LoggerEvent(Imap.logHandle, LOGGER_SUBSYSTEM_AUTH, LOGGER_EVENT_SSL_CONNECTION, LOG_INFO, 0, NULL, NULL, XplHostToLittle(session->client.conn->socketAddress.sin_addr.s_addr), 0, NULL, 0); } - if ((ConnWriteF(session->client.conn, "* OK %s %s server ready <%ud.%lu@%s>\r\n",Imap.server.hostname, PRODUCT_NAME, (unsigned int)XplGetThreadID(),time(NULL),Imap.server.hostname) != -1) && (ConnFlush(session->client.conn) != -1)) { + if ((ConnWriteF(session->client.conn, "* OK %s %s server ready <%ud.%lu@%s>\r\n",Globals.hostname, PRODUCT_NAME, (unsigned int)XplGetThreadID(),time(NULL),Globals.hostname) != -1) && (ConnFlush(session->client.conn) != -1)) { while (TRUE) { ccode = ReadCommandLine(session->client.conn, &(session->command.buffer), &(session->command.bufferLen)); if (ccode == STATUS_CONTINUE) { @@ -3392,8 +3390,6 @@ InitializeImapGlobals() Imap.server.ssl.config.options |= SSL_ALLOW_CHAIN; Imap.server.ssl.config.options |= SSL_ALLOW_SSL3; Imap.server.threadGroupId = XplGetThreadGroupID(); - Imap.server.hostname[0] = '\0'; - Imap.server.hostnameLen = 0; strcpy(Imap.server.postmaster, "admin"); /* Imap.command. */ @@ -3741,12 +3737,14 @@ ReadConfiguration(void) localtime_r(&time_of_day, <m); gm_time_of_day=mktime(&gm); - gethostname(Imap.server.hostname, sizeof(Imap.server.hostname)); - Imap.server.hostnameLen = strlen(Imap.server.hostname); - // Imap.server.postmaster needs to be set to something? - if (! ReadBongoConfiguration(IMAPConfig, "imap")) + if (! ReadBongoConfiguration(IMAPConfig, "imap")) { return FALSE; + } + + if (! ReadBongoConfiguration(GlobalConfig, "global")) { + return FALSE; + } return(TRUE); } diff --git a/src/agents/imap/imapd.h b/src/agents/imap/imapd.h index 5022345..bafbf62 100755 --- a/src/agents/imap/imapd.h +++ b/src/agents/imap/imapd.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -369,8 +370,6 @@ typedef struct { struct sockaddr_in addr; - char hostname[256]; - unsigned long hostnameLen; unsigned short port; int threadGroupId; BOOL disabled; diff --git a/src/agents/pop/pop3.c b/src/agents/pop/pop3.c index f64e6da..bfa4603 100644 --- a/src/agents/pop/pop3.c +++ b/src/agents/pop/pop3.c @@ -260,7 +260,6 @@ struct { XplAtomic badPasswords; } stats; - unsigned char hostName[MAXEMAILNAMESIZE]; unsigned char managementURL[256]; void *loggingHandle; @@ -914,7 +913,7 @@ POP3CommandPass(void *param) Log(LOG_INFO, "User %s logged in from host %s", client->user, LOGIP(client->conn->socketAddress)); } else { if (ccode == POP3_NMAP_SERVER_DOWN) { - ConnWriteF(client->conn, "-ERR [SYS/PERM] %s %s\r\n", POP3.hostName, MSGERRNONMAP); + ConnWriteF(client->conn, "-ERR [SYS/PERM] %s %s\r\n", Globals.hostname, MSGERRNONMAP); } else if (ccode != POP3_NMAP_FEATURE_DISABLED) { XplDelay(2000); client->loginCount++; @@ -957,7 +956,7 @@ POP3CommandPass(void *param) } default: { - ConnWriteF(client->conn, "-ERR [SYS/PERM] %s %s\r\n", POP3.hostName, MSGERRNONMAP); + ConnWriteF(client->conn, "-ERR [SYS/PERM] %s %s\r\n", Globals.hostname, MSGERRNONMAP); break; } } @@ -984,7 +983,7 @@ POP3CommandPass(void *param) } default: { - ConnWriteF(client->conn, "-ERR [SYS/PERM] %s %s\r\n", POP3.hostName, MSGERRNONMAP); + ConnWriteF(client->conn, "-ERR [SYS/PERM] %s %s\r\n", Globals.hostname, MSGERRNONMAP); break; } } @@ -1044,7 +1043,7 @@ POP3CommandQuit(void *param) } if(lastccode == 0) - ConnWriteF(client->conn, "+OK %s %s\r\n", POP3.hostName,MSGOKBYE); + ConnWriteF(client->conn, "+OK %s %s\r\n", Globals.hostname,MSGOKBYE); else ConnWriteF(client->conn, "-ERR %s %d, %s\r\n", MSGERRINTERNAL, lastccode, MSGOKBYE); @@ -1525,7 +1524,7 @@ HandleConnection(void *param) LOGIP(client->conn->socketAddress)); } - ccode = ConnWriteF(client->conn, "+OK %s %s %s\r\n", POP3.hostName, PRODUCT_NAME, PRODUCT_VERSION); + ccode = ConnWriteF(client->conn, "+OK %s %s %s\r\n", Globals.hostname, PRODUCT_NAME, PRODUCT_VERSION); if (ccode != -1) { ccode = ConnFlush(client->conn); @@ -1635,7 +1634,6 @@ ServerSocketInit (void) if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) { Log(LOG_ERROR, "Couldn't drop to unprivileged user %s", MsgGetUnprivilegedUser()); - XplConsolePrintf("bongopop3: Could not drop to unprivileged user '%s'\n", MsgGetUnprivilegedUser()); return -1; } @@ -1643,13 +1641,11 @@ ServerSocketInit (void) if (POP3.server.conn->socket == -1) { int ret = POP3.server.conn->socket; Log(LOG_ERROR, "Unable to bind to port %ld", POP3ServerPort); - XplConsolePrintf("bongopop3: Could not bind to port %ld\n", POP3ServerPort); ConnFree(POP3.server.conn); return ret; } } else { Log(LOG_ERROR, "Unable to allocate create server socket"); - XplConsolePrintf("bongopop3: Could not allocate connection.\n"); return -1; } @@ -1673,14 +1669,12 @@ ServerSocketSSLInit (void) if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) { Log(LOG_ERROR, "Could not drop to unprivileged user %s", MsgGetUnprivilegedUser()); - XplConsolePrintf("bongopop3: Could not drop to unprivileged user '%s'\n", MsgGetUnprivilegedUser()); return -1; } if (POP3.server.ssl.conn->socket == -1) { int ret = POP3.server.ssl.conn->socket; Log(LOG_ERROR, "Could not bind to secure port %ld", POP3ServerPortSSL); - XplConsolePrintf("bongopop3: Could not bind to SSL port %ld\n", POP3ServerPortSSL); ConnFree(POP3.server.conn); ConnFree(POP3.server.ssl.conn); @@ -1688,7 +1682,6 @@ ServerSocketSSLInit (void) } } else { Log(LOG_ERROR, "Could not allocate secure socket"); - XplConsolePrintf("bongopop3: Could not allocate connection.\n"); ConnFree(POP3.server.conn); return -1; } @@ -1778,7 +1771,6 @@ POP3Server(void *ignored) default: { if (POP3.state < POP3_STOPPING) { Log(LOG_ERROR, "Exiting after an accept() failure (%d)", errno); - XplConsolePrintf("POP3D: Exiting after an accept() failure; error %d\n", errno); } POP3.state = POP3_STOPPING; @@ -1790,10 +1782,7 @@ POP3Server(void *ignored) break; } -#if VERBOSE - /* Shutting down */ - XplConsolePrintf("POP3D: Shutdown started.\r\n"); -#endif + Log(LOG_DEBUG, "Shutdown started"); POP3.state = POP3_STOPPING; @@ -1805,9 +1794,7 @@ POP3Server(void *ignored) POP3.server.conn = NULL; } -#if VERBOSE - XplConsolePrintf("POP3D: Standard listener down\r\n"); -#endif + Log(LOG_DEBUG, "Standard listener down."); /* fixme - we need connection management flags for ConnClose to force the shutdown */ ConnCloseAll(1); @@ -1825,12 +1812,10 @@ POP3Server(void *ignored) } if (XplSafeRead(POP3.server.active) > 1) { - XplConsolePrintf("POP3D: %d server threads outstanding; attempting forceful unload.\r\n", XplSafeRead(POP3.server.active) - 1); + Log(LOG_INFO, "%d server threads outstanding; attempting forceful unload.", XplSafeRead(POP3.server.active)-1); } -#if VERBOSE - XplConsolePrintf("\rPOP3D: Shutting down %d client threads\r\n", XplSafeRead(POP3.client.worker.active)); -#endif + Log(LOG_DEBUG, "Shutting down %d client threads.", XplSafeRead(POP3.client.worker.active)); /* Make sure the kids have flown the coop. */ for (ccode = 0; XplSafeRead(POP3.client.worker.active) && (ccode < 60); ccode++) { @@ -1838,7 +1823,7 @@ POP3Server(void *ignored) } if (XplSafeRead(POP3.client.worker.active)) { - XplConsolePrintf("\rPOP3D: %d threads outstanding; attempting forceful unload.\r\n", XplSafeRead(POP3.client.worker.active)); + Log(LOG_INFO, "%d threads outstanding; attempting forceful unload.", XplSafeRead(POP3.client.worker.active)); } if (POP3.server.ssl.enable) { @@ -1882,9 +1867,7 @@ POP3Server(void *ignored) MemPrivatePoolFree(POP3.client.pool); MemoryManagerClose(MSGSRV_AGENT_POP); -#if VERBOSE - XplConsolePrintf("\rPOP3D: Shutdown complete\r\n"); -#endif + Log(LOG_DEBUG, "Shutdown complete."); XplSignalLocalSemaphore(POP3.sem.main); XplWaitOnLocalSemaphore(POP3.sem.shutdown); @@ -1988,7 +1971,6 @@ client->CSSL = NULL; default: { if (POP3.state < POP3_STOPPING) { Log(LOG_ERROR, "Secure server exiting after an accept() failure (%d)", errno); - XplConsolePrintf("POP3D: Exiting after an accept() failure; error %d\n", errno); POP3.state = POP3_STOPPING; } @@ -2024,15 +2006,12 @@ client->CSSL = NULL; XplSafeDecrement(POP3.server.active); -#if VERBOSE - XplConsolePrintf("\rPOP3D: SSL listener down.\r\n"); -#endif + Log(LOG_DEBUG, "SSL listener down."); return; } static BongoConfigItem POP3Config[] = { - { BONGO_JSON_STRING, "o:hostname/s", &POP3.hostName }, { BONGO_JSON_INT, "o:port/i", &POP3ServerPort }, { BONGO_JSON_INT, "o:port_ssl/i", &POP3ServerPortSSL }, { BONGO_JSON_NULL, NULL, NULL } @@ -2049,11 +2028,13 @@ ReadConfiguration(void) if (! MsgGetServerCredential(POP3.nmap.hash)) return FALSE; - if (! ReadBongoConfiguration(POP3Config, "pop3")) + if (! ReadBongoConfiguration(POP3Config, "pop3")) { return FALSE; + } - // FIXME: override the hostname for now, until we store this somewhere sane - gethostname(POP3.hostName, sizeof(POP3.hostName)); + if (! ReadBongoConfiguration(GlobalConfig, "global")) { + return FALSE; + } return(TRUE); } @@ -2067,8 +2048,8 @@ XplServiceMain(int argc, char *argv[]) XplThreadID id; if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) { - XplConsolePrintf("bongopop3: Could not drop to unprivileged user '%s', exiting.\n", MsgGetUnprivilegedUser()); - return 1; + Log(LOG_ERROR, "Could not drop to unprivileged user '%s'.", MsgGetUnprivilegedUser()); + return 1; } XplInit(); @@ -2117,11 +2098,11 @@ XplServiceMain(int argc, char *argv[]) } else { MemoryManagerClose(MSGSRV_AGENT_POP); - XplConsolePrintf("POP3D: Unable to create connection pool; shutting down.\r\n"); + Log(LOG_ERROR, "Unable to create connection pool; shutting down."); return(-1); } } else { - XplConsolePrintf("POP3D: Unable to initialize memory manager; shutting down.\r\n"); + Log(LOG_ERROR, "Unable to initialize memory manager; shutting down."); return(-1); } @@ -2142,7 +2123,7 @@ XplServiceMain(int argc, char *argv[]) if (ServerSocketInit () < 0) { - XplConsolePrintf("bongopop3: Exiting.\n"); + Log(LOG_ERROR, "Server Initialization failed."); return -1; } @@ -2166,7 +2147,7 @@ XplServiceMain(int argc, char *argv[]) /* Done binding, drop privs permanently */ if (XplSetRealUser(MsgGetUnprivilegedUser()) < 0) { - XplConsolePrintf("bongopop3: Could not drop to unprivileged user '%s', exiting.\n", MsgGetUnprivilegedUser()); + Log(LOG_ERROR, "Could not drop to unprivileged user '%s'.", MsgGetUnprivilegedUser()); return -1; } diff --git a/src/agents/queue/conf.c b/src/agents/queue/conf.c index 9f8e6af..1a2a56d 100644 --- a/src/agents/queue/conf.c +++ b/src/agents/queue/conf.c @@ -79,8 +79,6 @@ static BongoConfigItem hostedDomainsConfig[] = { static BongoConfigItem QueueConfig[] = { { BONGO_JSON_BOOL, "o:debug/b", &Conf.debug }, { BONGO_JSON_ARRAY, "o:hosteddomains/a", &hostedDomainsConfig }, - { BONGO_JSON_STRING, "o:postmaster/s", &Conf.postMaster }, - { BONGO_JSON_STRING, "o:officialname/s", &Conf.officialName }, { BONGO_JSON_BOOL, "o:limitremoteprocessing/b", &Conf.deferEnabled }, { BONGO_JSON_INT, "o:limitremotebegweekday/i", &Conf.i_deferStartWD }, { BONGO_JSON_INT, "o:limitremotebegweekend/i", &Conf.i_deferStartWE }, @@ -123,6 +121,10 @@ ReadConfiguration (BOOL *recover) if (!ReadBongoConfiguration(QueueConfig, "queue")) { return FALSE; } + + if (!ReadBongoConfiguration(GlobalConfig, "global")) { + return FALSE; + } *recover = MsgGetRecoveryFlag("queue"); diff --git a/src/agents/queue/conf.h b/src/agents/queue/conf.h index d920cdf..1ddbc98 100644 --- a/src/agents/queue/conf.h +++ b/src/agents/queue/conf.h @@ -41,10 +41,7 @@ typedef struct _QueueConfiguration { XplRWLock lock; /* Server info */ - char *hostname; - char *postMaster; char serverHash[NMAP_HASH_SIZE]; - char *officialName; /* Quotas */ char *quotaMessage; diff --git a/src/agents/queue/queue.c b/src/agents/queue/queue.c index e50a796..21bd814 100644 --- a/src/agents/queue/queue.c +++ b/src/agents/queue/queue.c @@ -294,7 +294,7 @@ SpoolEntryIDLock(unsigned long id) XplSignalLocalSemaphore(Queue.spoolLocks.semaphores[SPOOL_LOCK_ARRAY_MASK & id]); - Log(LOG_INFO, "Unable to lock spool entry %x, table full", (unsigned int) id); + Log(LOG_ERROR, "Unable to lock spool entry %x, table full", (unsigned int) id); } return(NULL); @@ -356,7 +356,7 @@ AddPushAgent(QueueClient *client, int count; QueuePushClient *temp; - Log(LOG_INFO, "Adding client on host %s:%d to queue %d", LOGIP(client->conn->socketAddress), port, queue); + Log(LOG_INFO, "Adding client (%s) on host %s:%d to queue %d", identifier, LOGIP(client->conn->socketAddress), port, queue); XplMutexLock(Queue.pushClients.lock); @@ -499,7 +499,7 @@ GetNMAPConnection(NMAPConnections *list, conn = NMAPConnect(NULL, address); if (conn == NULL) { - XplConsolePrintf("bongoqueue: Couldn't connect to NMAP\r\n"); + Log(LOG_ERROR, "Could not connect to bongoqueue."); return DELIVER_TRY_LATER; } @@ -1649,10 +1649,7 @@ StartOver: /* fixme - evaluate this section. Clean up behind us ? */ if (client->entry.work) { - if (Agent.flags & QUEUE_AGENT_DEBUG) { - XplConsolePrintf("bongoqueue: Ran into queue resend [C%s.%03d]!\r\n", entry, queue); - XplConsolePrintf("bongoqueue: Last command:%s\r\n", client->buffer); - } + Log(LOG_DEBUG, "Ran into queue resend [C%s.%03d] Last Command: %s", entry, queue, client->buffer); FCLOSE_CHECK(client->entry.work); client->entry.work = NULL; @@ -2088,7 +2085,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO return(FALSE); } - sprintf(postmaster, "%s@%s", Conf.postMaster, Conf.officialName); + sprintf(postmaster, "%s@%s", Globals.postmaster, Globals.hostname); handling = Conf.bounceHandling; /* We're guaranteed to have a recipient */ @@ -2135,9 +2132,9 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO fprintf(rtsData, "Date: %s\r\n", timeLine); fprintf(rtsData, "From: Mail Delivery System <%s>\r\n", postmaster); - fprintf(rtsData, "Message-Id: <%lu-%lu@%s>\r\n", now, (long unsigned int)XplGetThreadID(), Conf.officialName); + fprintf(rtsData, "Message-Id: <%lu-%lu@%s>\r\n", now, (long unsigned int)XplGetThreadID(), Globals.hostname); fprintf(rtsData, "To: <%s>\r\n", sender); - fprintf(rtsData, "MIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary=\"%lu-%lu-%s\"\r\n", now, (long unsigned int)XplGetThreadID(), Conf.officialName); + fprintf(rtsData, "MIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary=\"%lu-%lu-%s\"\r\n", now, (long unsigned int)XplGetThreadID(), Globals.hostname); switch (reason) { case DELIVER_FAILURE: fprintf(rtsData, "Subject: Returned mail: Delivery failure\r\n"); break; case DELIVER_HOST_UNKNOWN: fprintf(rtsData, "Subject: Returned mail: Host unknown\r\n"); break; @@ -2162,7 +2159,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO fprintf(rtsData, "Precedence: bulk\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n"); /* First section, human readable */ - fprintf(rtsData, "--%lu-%lu-%s\r\nContent-type: text/plain; charset=US-ASCII\r\n\r\n", now, (long unsigned int)XplGetThreadID(), Conf.officialName); + fprintf(rtsData, "--%lu-%lu-%s\r\nContent-type: text/plain; charset=US-ASCII\r\n\r\n", now, (long unsigned int)XplGetThreadID(), Globals.hostname); MsgGetRFC822Date(-1, received, timeLine); fprintf(rtsData, "The original message was received %s\r\nfrom %s\r\n\r\n", timeLine, aSender[0]!='\0' ? aSender : sender); @@ -2330,14 +2327,14 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO } while (!feof(control) && !ferror(control)); /* Second section, computer readable */ - fprintf(rtsData, "--%lu-%lu-%s\r\nContent-type: message/delivery-status\r\n\r\n", now, (long unsigned int)XplGetThreadID(), Conf.officialName); + fprintf(rtsData, "--%lu-%lu-%s\r\nContent-type: message/delivery-status\r\n\r\n", now, (long unsigned int)XplGetThreadID(), Globals.hostname); /* Per message fields */ if (envID[0]!='\0') { fprintf(rtsData, "Original-Envelope-Id: %s\r\n", envID); } - fprintf(rtsData, "Reporting-MTA: dns; %s\r\n", Conf.officialName); + fprintf(rtsData, "Reporting-MTA: dns; %s\r\n", Globals.hostname); MsgGetRFC822Date(-1, received, timeLine); fprintf(rtsData, "Arrival-Date: %s\r\n", timeLine); @@ -2398,7 +2395,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO } while (!feof(control) && !ferror(control)); /* Third section, original message */ - fprintf(rtsData, "--%lu-%lu-%s\r\nContent-type: message/rfc822\r\n\r\n", now, (long unsigned int)XplGetThreadID(), Conf.officialName); + fprintf(rtsData, "--%lu-%lu-%s\r\nContent-type: message/rfc822\r\n\r\n", now, (long unsigned int)XplGetThreadID(), Globals.hostname); header = TRUE; maxBodySize = -1; @@ -2436,7 +2433,7 @@ CreateDSNMessage(FILE *data, FILE *control, FILE *rtsData, FILE *rtsControl, BOO } /* End of message */ - fprintf(rtsData, "\r\n--%lu-%lu-%s--\r\n", now, (long unsigned int)XplGetThreadID(), Conf.officialName); + fprintf(rtsData, "\r\n--%lu-%lu-%s--\r\n", now, (long unsigned int)XplGetThreadID(), Globals.hostname); /* Now create the control file */ fprintf(rtsControl, "D%lu\r\n", now); @@ -2552,17 +2549,13 @@ CheckQueue(void *queueIn) Queue.restartNeeded = Queue.flushNeeded = FALSE; if (flushing) { - XplConsolePrintf ("bongoqueue: flushing the queue\n"); - } - - if (Agent.flags & QUEUE_AGENT_DEBUG) { - XplConsolePrintf("bongoqueue: Restarting queue:"); - } - - if (!flushing) { + Log(LOG_INFO, "Flushing the queue."); + } else { now = time(NULL) - Conf.queueInterval + 60; } + Log(LOG_DEBUG, "Restarting the queue"); + dirP = XplOpenDir(Conf.spoolPath); if (dirP == NULL) { goto delayQueue; @@ -2606,12 +2599,10 @@ CheckQueue(void *queueIn) } XplCloseDir(dirP); - if (Agent.flags & QUEUE_AGENT_DEBUG) { - XplConsolePrintf(" Entries found: %4lu, handled:%4lu, %srestart\r\n", found, handled, Queue.restartNeeded ? "Have " : "No "); - } + Log(LOG_DEBUG, "Entries found: %4lu, handled: %4lu, %srestart", found, handled, Queue.restartNeeded ? "Have " : "No "); if (flushing) { - XplConsolePrintf ("bongoqueue: finished flushing the queue\n"); + Log(LOG_INFO, "Finished flushing the queue."); } delayQueue: @@ -2626,9 +2617,7 @@ CheckQueue(void *queueIn) XplSafeDecrement(Queue.activeWorkers); -#if VERBOSE - XplConsolePrintf("bongoqueue: Message queue monitor done.\r\n"); -#endif + Log(LOG_DEBUG, "Message queue monitor done."); XplExitThread(EXIT_THREAD, 0); @@ -2639,7 +2628,7 @@ BOOL QueueInit(void) { if (!InitSpoolEntryIDLocks()) { - XplConsolePrintf(AGENT_NAME ": Couldn't create spool locks.\r\n"); + Log(LOG_ERROR, "Could not create spool locks."); return FALSE; } @@ -2661,9 +2650,7 @@ QueueInit(void) void QueueShutdown(void) { -#if VERBOSE - XplConsolePrintf("bongoqueue: Writing queue agent list\r\n"); -#endif + Log(LOG_DEBUG, "Writing queue agent list."); RemoveAllPushAgents(); QDBShutdown(); @@ -2693,13 +2680,10 @@ CreateQueueThreads(BOOL failed) } if (failed) { - XplConsolePrintf("bongoqueue: System not shut down properly, verifying queue integrity.\r\n"); + Log(LOG_INFO, "System not shut down properly, verifying queue integrity."); + } else { + Log(LOG_DEBUG, "Verifying queue integrity, quick mode."); } -#if VERBOSE - else { - XplConsolePrintf("bongoqueue: Verifying queue integrity, quick mode.\r\n"); - } -#endif sprintf(path, "%s", Conf.spoolPath); @@ -2828,14 +2812,12 @@ CreateQueueThreads(BOOL failed) killFile=NULL; } -#if VERBOSE - XplConsolePrintf("bongoqueue: Queue integrity check complete, now cleaning irrelevant entries.\r\n"); -#endif + Log(LOG_DEBUG, "Queue integrity check complete, now cleaning irrelevant entries."); sprintf(path, "%s/fragfile", MsgGetDir(MSGAPI_DIR_DBF, NULL, 0)); FOPEN_CHECK(killFile, path, "rb"); if (!killFile) { - XplConsolePrintf("bongoqueue: Could not re-open killfile.\r\n"); + Log(LOG_ERROR, "Could not re-open killfile."); } else { current = 0; while (!feof(killFile) && !ferror(killFile)) { @@ -2889,9 +2871,7 @@ CreateQueueThreads(BOOL failed) } } -#if VERBOSE - XplConsolePrintf("bongoqueue: Queue integrity check complete, starting Queue Monitor [%d].\r\n", XplSafeRead(Queue.queuedLocal)); -#endif + Log(LOG_DEBUG, "Queue integrity check complete, starting Queue Monitor [%d].", XplSafeRead(Queue.queuedLocal)); XplSafeWrite(Queue.activeWorkers, 0); @@ -4693,7 +4673,7 @@ CommandQstorMessage(void *param) client->conn->socketAddress.sin_addr.s_lh, client->conn->socketAddress.sin_addr.s_impno, - Agent.agent.officialName, + Globals.hostname, AGENT_NAME, TimeBuf); diff --git a/src/agents/queue/queued.c b/src/agents/queue/queued.c index cec30f9..7a392f8 100644 --- a/src/agents/queue/queued.c +++ b/src/agents/queue/queued.c @@ -397,7 +397,7 @@ HandleCommand(QueueClient *client) ccode = ConnWrite(client->conn, MSG3240NOAUTH, sizeof(MSG3240NOAUTH) - 1); } - Log(LOG_INFO, "Handled command from %s", LOGIP(client->conn->socketAddress)); + Log(LOG_DEBUG, "Handled command from %s", LOGIP(client->conn->socketAddress)); } } else if (ccode == -1) { break; @@ -421,10 +421,10 @@ ProcessClient(void *clientp, Connection *conn) client->authorized = CheckTrustedHost(client); if (!client->authorized) { - sprintf(client->authChallenge, "%x%s%x", (unsigned int)XplGetThreadID(), Conf.hostname, (unsigned int)time(NULL)); + sprintf(client->authChallenge, "%x%s%x", (unsigned int)XplGetThreadID(), Globals.hostname, (unsigned int)time(NULL)); ccode = ConnWriteF(client->conn, MSG4242AUTHREQUIRED, client->authChallenge); } else { - ccode = ConnWriteF(client->conn, "1000 %s %s\r\n", Conf.hostname, MSG1000READY); + ccode = ConnWriteF(client->conn, "1000 %s %s\r\n", Globals.hostname, MSG1000READY); } if (ccode == -1) { @@ -460,18 +460,13 @@ QueueServer(void *ignored) Agent.clientListener = NULL; } -#if VERBOSE - XplConsolePrintf("bongoqueue: Closing queue database\r\n"); -#endif + Log(LOG_DEBUG, "Closing queue database."); QueueShutdown(); XplRWLockDestroy(&Conf.lock); -#if VERBOSE - /* Shutting down */ - XplConsolePrintf(AGENT_NAME ": Shutting down.\r\n"); -#endif + Log(LOG_DEBUG, "Shutting down."); BongoThreadPoolShutdown(Agent.clientThreadPool); @@ -479,9 +474,7 @@ QueueServer(void *ignored) BongoAgentShutdown(&Agent.agent); -#if VERBOSE - XplConsolePrintf(AGENT_NAME ": Shutdown complete\r\n"); -#endif + Log(LOG_DEBUG, "Shutdown complete"); } @@ -501,18 +494,18 @@ ServerSocketInit(int port) conn->socket = ConnServerSocket(conn, 2048); if (XplSetEffectiveUser(MsgGetUnprivilegedUser()) < 0) { - XplConsolePrintf("bongoqueue: Could not drop to unprivileged user '%s'\n", MsgGetUnprivilegedUser()); + Log(LOG_ERROR, "Could not drop to unprivileged user '%s'.", MsgGetUnprivilegedUser()); ConnFree(conn); return NULL; } if (conn->socket == -1) { - XplConsolePrintf("bongoqueue: Could not bind to port %d\n", port); + Log(LOG_ERROR, "Could not bind to port %d.", port); ConnFree(conn); return NULL; } } else { - XplConsolePrintf("bongoqueue: Could not allocate connection\n"); + Log(LOG_ERROR, "Could not allocate connection."); return NULL; } @@ -609,7 +602,7 @@ XplServiceMain(int argc, char *argv[]) LogStart(); if (XplSetRealUser(MsgGetUnprivilegedUser()) < 0) { - XplConsolePrintf(AGENT_NAME ": Could not drop to unprivileged user '%s'\r\n" AGENT_NAME ": exiting.\n", MsgGetUnprivilegedUser()); + Log(LOG_ERROR, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser()); return -1; } @@ -622,7 +615,7 @@ XplServiceMain(int argc, char *argv[]) startupOpts = BA_STARTUP_CONNIO | BA_STARTUP_NMAP | BA_STARTUP_MSGLIB | BA_STARTUP_MSGAUTH; ccode = BongoAgentInit(&Agent.agent, AGENT_NAME, MSGSRV_AGENT_QUEUE, DEFAULT_CONNECTION_TIMEOUT, startupOpts); if (ccode == -1) { - XplConsolePrintf(AGENT_NAME ": Exiting.\r\n"); + Log(LOG_ERROR, "Initialization failed exiting."); return -1; } @@ -637,12 +630,12 @@ XplServiceMain(int argc, char *argv[]) Agent.clientListener = ServerSocketInit(Agent.agent.port); if (Agent.clientListener == NULL) { - XplConsolePrintf(AGENT_NAME ": Exiting.\r\n"); + Log(LOG_ERROR, "Server Initialization failed exiting."); return -1; } if (QueueInit() == FALSE) { - XplConsolePrintf(AGENT_NAME ": Exiting.\r\n"); + Log(LOG_ERROR, "Queue Initialization failed exiting."); return -1; } diff --git a/src/agents/smtp/smtpd.c b/src/agents/smtp/smtpd.c index 98c9efe..866835c 100644 --- a/src/agents/smtp/smtpd.c +++ b/src/agents/smtp/smtpd.c @@ -48,8 +48,6 @@ struct { int port; int port_ssl; - char *hostname; - char *hostaddr; BOOL allow_client_ssl; BOOL allow_expn; BOOL allow_auth; @@ -59,7 +57,6 @@ struct { BOOL accept_etrn; BOOL send_etrn; int max_recips; - char *postmaster; int message_limit; BOOL use_relay; BOOL relay_local; @@ -75,8 +72,6 @@ struct { static BongoConfigItem SMTPConfig[] = { { BONGO_JSON_INT, "o:port/i", &SMTP.port }, { BONGO_JSON_INT, "o:port_ssl/i", &SMTP.port_ssl }, - { BONGO_JSON_STRING, "o:hostname/s", &SMTP.hostname }, - { BONGO_JSON_STRING, "o:hostaddr/s", &SMTP.hostaddr }, { BONGO_JSON_BOOL, "o:allow_client_ssl/b", &SMTP.allow_client_ssl }, { BONGO_JSON_BOOL, "o:allow_expn/b", &SMTP.allow_expn }, { BONGO_JSON_BOOL, "o:allow_vrfy/b", &SMTP.allow_vrfy }, @@ -85,7 +80,6 @@ static BongoConfigItem SMTPConfig[] = { { BONGO_JSON_BOOL, "o:accept_etrn/b", &SMTP.accept_etrn }, { BONGO_JSON_BOOL, "o:send_etrn/b", &SMTP.send_etrn }, { BONGO_JSON_INT, "o:maximum_recipients/i", &SMTP.max_recips }, - { BONGO_JSON_STRING, "o:postmaster/s", &SMTP.postmaster }, { BONGO_JSON_INT, "o:message_size_limit/i", &SMTP.message_limit }, { BONGO_JSON_BOOL, "o:use_relay_host/b", &SMTP.use_relay }, { BONGO_JSON_STRING, "o:relay_host/s", &SMTP.relay_host }, @@ -118,7 +112,6 @@ int TGid; XplRWLock ConfigLock; BOOL SMTPReceiverStopped = FALSE; -unsigned char OfficialName[MAXEMAILNAMESIZE + 1] = ""; BOOL Notify = FALSE; BOOL AllowClientSSL = FALSE; BOOL DomainUsernames = TRUE; @@ -410,15 +403,14 @@ HandleConnection (void *param) LOGIP(Client->client.conn->socketAddress), ReplyInt); } - count = snprintf(Reply, sizeof(Reply), "421 %s %s\r\n", SMTP.hostname, MSG421SHUTDOWN); + count = snprintf(Reply, sizeof(Reply), "421 %s %s\r\n", Globals.hostname, MSG421SHUTDOWN); ConnWrite (Client->client.conn, Reply, count); ConnFlush (Client->client.conn); return (EndClientConnection (Client)); } - snprintf (Answer, sizeof (Answer), "220 %s %s %s\r\n", SMTP.hostname, - MSG220READY, PRODUCT_VERSION); + snprintf (Answer, sizeof (Answer), "220 %s %s %s\r\n", Globals.hostname, MSG220READY, PRODUCT_VERSION); ConnWrite (Client->client.conn, Answer, strlen (Answer)); ConnFlush (Client->client.conn); @@ -428,8 +420,7 @@ HandleConnection (void *param) if (Exiting == FALSE) { count = ConnReadToAllocatedBuffer(Client->client.conn, &(Client->client.buffer), &(Client->client.buflen)); } else { - snprintf (Answer, sizeof (Answer), "421 %s %s\r\n", - SMTP.hostname, MSG421SHUTDOWN); + snprintf (Answer, sizeof (Answer), "421 %s %s\r\n", Globals.hostname, MSG421SHUTDOWN); ConnWrite (Client->client.conn, Answer, strlen (Answer)); ConnFlush(Client->client.conn); return (EndClientConnection (Client)); @@ -444,8 +435,7 @@ HandleConnection (void *param) LOGIP(soc_address), time(NULL) - connectionTime); return (EndClientConnection (Client)); } else if (count < 1) { - snprintf (Answer, sizeof (Answer), "421 %s %s\r\n", - SMTP.hostname, MSG421SHUTDOWN); + snprintf (Answer, sizeof (Answer), "421 %s %s\r\n", Globals.hostname, MSG421SHUTDOWN); ConnWrite (Client->client.conn, Answer, strlen (Answer)); ConnFlush(Client->client.conn); return (EndClientConnection (Client)); @@ -457,8 +447,7 @@ HandleConnection (void *param) switch (toupper (Client->Command[3])) { case 'O': /* HELO */ if (Client->State == STATE_FRESH) { - snprintf (Answer, sizeof (Answer), "250 %s %s\r\n", - SMTP.hostname, MSG250HELLO); + snprintf (Answer, sizeof (Answer), "250 %s %s\r\n", Globals.hostname, MSG250HELLO); ConnWrite (Client->client.conn, Answer, strlen (Answer)); strncpy (Client->RemoteHost, Client->Command + 5, sizeof (Client->RemoteHost)); @@ -1277,7 +1266,7 @@ HandleConnection (void *param) Client->client.conn->socketAddress.sin_addr.s_lh, Client->client.conn->socketAddress.sin_addr.s_impno, - SMTP.hostname, + Globals.hostname, WithProtocol, PRODUCT_NAME, PRODUCT_VERSION, @@ -1360,8 +1349,7 @@ HandleConnection (void *param) } } } - snprintf (Answer, sizeof (Answer), "221 %s %s\r\n", SMTP.hostname, - MSG221QUIT); + snprintf (Answer, sizeof (Answer), "221 %s %s\r\n", Globals.hostname, MSG221QUIT); ConnWrite (Client->client.conn, Answer, strlen (Answer)); return (EndClientConnection (Client)); break; @@ -1378,7 +1366,7 @@ HandleConnection (void *param) if (SMTP.message_limit > 0) { snprintf (Answer, sizeof (Answer), "250-%s %s\r\n%s%s%s%s %lu\r\n", - SMTP.hostname, MSG250HELLO, + Globals.hostname, MSG250HELLO, SMTP.accept_etrn ? MSG250ETRN : "", (SMTP.allow_client_ssl && !Client->client.conn->ssl.enable) ? MSG250TLS : "", @@ -1389,7 +1377,7 @@ HandleConnection (void *param) else { snprintf (Answer, sizeof (Answer), "250-%s %s\r\n%s%s%s%s\r\n", - SMTP.hostname, MSG250HELLO, + Globals.hostname, MSG250HELLO, SMTP.accept_etrn ? MSG250ETRN : "", (SMTP.allow_client_ssl && !Client->client.conn->ssl.enable) ? MSG250TLS : "", @@ -1697,7 +1685,7 @@ DeliverSMTPMessage (ConnectionStruct * Client, unsigned char *Sender, status = GetAnswer (Client, Reply, sizeof (Reply)); HandleFailure (220); - snprintf (Answer, sizeof (Answer), "EHLO %s\r\n", SMTP.hostname); + snprintf (Answer, sizeof (Answer), "EHLO %s\r\n", Globals.hostname); if (ConnWrite(Client->remotesmtp.conn, Answer, strlen(Answer)) < 1) { DELIVER_ERROR (DELIVER_TRY_LATER); } @@ -1705,7 +1693,7 @@ DeliverSMTPMessage (ConnectionStruct * Client, unsigned char *Sender, status = GetEHLO (Client, &Extensions, &Size); if (status != 250) { - snprintf (Answer, sizeof (Answer), "HELO %s\r\n", SMTP.hostname); + snprintf (Answer, sizeof (Answer), "HELO %s\r\n", Globals.hostname); if (ConnWrite(Client->remotesmtp.conn, Answer, strlen(Answer)) < 1) { DELIVER_ERROR (DELIVER_TRY_LATER); } @@ -1728,7 +1716,7 @@ DeliverSMTPMessage (ConnectionStruct * Client, unsigned char *Sender, if(ConnEncrypt(Client->remotesmtp.conn, SSLContext) < 0) { DELIVER_ERROR (DELIVER_FAILURE); } - status = snprintf (Answer, sizeof (Answer), "EHLO %s\r\n", SMTP.hostname); + status = snprintf (Answer, sizeof (Answer), "EHLO %s\r\n", Globals.hostname); if (ConnWrite(Client->remotesmtp.conn, Answer, status) < 1) { DELIVER_ERROR (DELIVER_TRY_LATER); } @@ -2065,7 +2053,7 @@ DeliverSMTPMessage (ConnectionStruct * Client, unsigned char *Sender, Client->client.conn->socketAddress.sin_addr.s_host, Client->client.conn->socketAddress.sin_addr.s_lh, Client->client.conn->socketAddress.sin_addr.s_impno, - SMTP.hostname, + Globals.hostname, PRODUCT_NAME, PRODUCT_VERSION, TimeBuf); @@ -3574,6 +3562,7 @@ QueueServerStartup (void *ignored) ConnectionStruct *client; int ccode; XplThreadID id = 0; + BOOL qd = FALSE, qo = FALSE; XplRenameThread (XplGetThreadID (), "SMTP NMAP Q Monitor"); @@ -3595,13 +3584,23 @@ QueueServerStartup (void *ignored) } /* register on the two queues we need to be on */ - if (QueueRegister(MSGSRV_AGENT_SMTP, Q_DELIVER, SMTPQServerConnection->socketAddress.sin_port) != REGISTRATION_COMPLETED || - QueueRegister(MSGSRV_AGENT_SMTP, Q_OUTGOING, SMTPQServerConnection->socketAddress.sin_port) != REGISTRATION_COMPLETED) { - XplConsolePrintf("bongosmtp: Could not register with bongonmap\r\n"); - ConnFree(SMTPQServerConnection); - raise(SIGTERM); - return; - } + while (!qd && !qo) { + if (!qd) { + qd = (QueueRegister(MSGSRV_AGENT_SMTP, Q_DELIVER, SMTPQServerConnection->socketAddress.sin_port) == REGISTRATION_COMPLETED); + } + if (!qo) { + qo = (QueueRegister(MSGSRV_AGENT_SMTP, Q_OUTGOING, SMTPQServerConnection->socketAddress.sin_port) == REGISTRATION_COMPLETED); + } + if (Exiting) { + ConnFree(SMTPQServerConnection); + raise(SIGTERM); + return; + } + if (!qd || !qo) { + Log(LOG_ERROR, "Could not register with bongoqueue, sleeping for 3 seconds"); + XplDelay(3000); + } + }; while (!Exiting) { if (ConnAccept(SMTPQServerConnection, &conn) != -1) { @@ -3629,9 +3628,7 @@ QueueServerStartup (void *ignored) XplSafeDecrement (SMTPServerThreads); -#if VERBOSE - XplConsolePrintf ("SMTPD: Queue monitor thread done.\r\n"); -#endif + Log(LOG_DEBUG, "Queue monitor thread done."); return; } @@ -3665,7 +3662,7 @@ ServerSocketInit (void) SMTPServerConnection = ConnAlloc(FALSE); if (!SMTPServerConnection) { - XplConsolePrintf("bongoimap: Could not allocate the connection\n"); + Log(LOG_ERROR, "Could not allocate the connection."); return -1; } @@ -3681,15 +3678,13 @@ ServerSocketInit (void) /* drop the privs back */ if (XplSetEffectiveUser (MsgGetUnprivilegedUser ()) < 0) { - Log(LOG_ERROR, "Priv failure User %s", MsgGetUnprivilegedUser ()); - XplConsolePrintf ("bongosmtp: Could not drop to unprivileged user '%s'\n", MsgGetUnprivilegedUser ()); + Log(LOG_ERROR, "Could not drop to unprivileged user '%s'", MsgGetUnprivilegedUser ()); return -1; } if (SMTPServerConnection->socket < 0) { ccode = SMTPServerConnection->socket; - Log(LOG_ERROR, "Create socket failed %s Line %d", "", __LINE__); - XplConsolePrintf ("bongosmtp: Could not allocate socket.\n"); + Log(LOG_ERROR, "Could not allocate SMTP socket"); ConnFree(SMTPServerConnection); return ccode; } @@ -3703,7 +3698,7 @@ ServerSocketSSLInit (void) SMTPServerConnectionSSL = ConnAlloc(FALSE); if (SMTPServerConnectionSSL == NULL) { - XplConsolePrintf("bongoimap: Could not allocate the connection\n"); + Log(LOG_ERROR, "Could not allocate the SSL connection"); ConnFree(SMTPServerConnection); return -1; } @@ -3719,15 +3714,13 @@ ServerSocketSSLInit (void) SMTPServerConnectionSSL->socket = ConnServerSocket(SMTPServerConnectionSSL, 2048); /* drop the privs back */ if (XplSetEffectiveUser (MsgGetUnprivilegedUser ()) < 0) { - Log(LOG_ERROR, "Priv failure User %s", MsgGetUnprivilegedUser ()); - XplConsolePrintf ("bongosmtp: Could not drop to unprivileged user '%s'\n", MsgGetUnprivilegedUser ()); + Log(LOG_ERROR, "Could not drop to unprivileged user '%s' for SSL", MsgGetUnprivilegedUser ()); return -1; } if (SMTPServerConnectionSSL->socket < 0) { ccode = SMTPServerConnectionSSL->socket; - Log(LOG_ERROR, "Create socket failed %s Line %d", "", __LINE__); - XplConsolePrintf ("bongosmtp: Could not allocate socket.\n"); + Log(LOG_ERROR, "Could not allocate SSL socket"); ConnFree(SMTPServerConnection); return ccode; } @@ -3804,10 +3797,7 @@ SMTPServer (void *ignored) } default:{ - arg = errno; - - Log(LOG_ALERT, "Accept failure %s Errno %d", "Server", arg); - XplConsolePrintf ("SMTPD: Exiting after an accept() failure with an errno: %d\n", arg); + Log(LOG_ALERT, "Accept failure: Errno %d", errno); break; } @@ -3825,9 +3815,8 @@ SMTPServer (void *ignored) oldTGID = XplSetThreadGroupID (TGid); -#if VERBOSE - XplConsolePrintf ("\rSMTPD: Closing server sockets\r\n"); -#endif + Log(LOG_DEBUG, "Closing server socket"); + if (SMTPServerConnection) { ConnClose(SMTPServerConnection, 1); ConnFree(SMTPServerConnection); @@ -3860,12 +3849,10 @@ SMTPServer (void *ignored) } if (XplSafeRead (SMTPServerThreads) > 1) { - XplConsolePrintf ("SMTPD: %d server threads outstanding; attempting forceful unload.\r\n", XplSafeRead (SMTPServerThreads) - 1); + Log(LOG_ERROR, "%d server threads outstanding; attempting forceful unload.", XplSafeRead(SMTPServerThreads)-1); } -#if VERBOSE - XplConsolePrintf ("SMTPD: Shutting down %d conn client threads and %d queue client threads\r\n", XplSafeRead (SMTPConnThreads), XplSafeRead (SMTPQueueThreads)); -#endif + Log(LOG_DEBUG, "Shutting down %d conn client threads and %d queue client threads.", XplSafeRead(SMTPConnThreads), XplSafeRead(SMTPQueueThreads)); /* Make sure the kids have flown the coop. */ for (arg = 0; (XplSafeRead (SMTPConnThreads) + XplSafeRead (SMTPQueueThreads)) && (arg < 3 * 60); arg++) { @@ -3873,12 +3860,10 @@ SMTPServer (void *ignored) } if (XplSafeRead (SMTPConnThreads) + XplSafeRead (SMTPQueueThreads)) { - XplConsolePrintf ("SMTPD: %d threads outstanding; attempting forceful unload.\r\n", XplSafeRead (SMTPConnThreads) + XplSafeRead (SMTPQueueThreads)); + Log(LOG_ERROR, "%d threads outstanding; attempting forceful unload.", XplSafeRead(SMTPConnThreads)+XplSafeRead(SMTPQueueThreads)); } -#if VERBOSE - XplConsolePrintf ("SMTPD: Removing SSL data\r\n"); -#endif + Log(LOG_DEBUG, "Removing SSL data"); /* Cleanup SSL */ if (SSLContext) { @@ -3896,9 +3881,7 @@ SMTPServer (void *ignored) MemPrivatePoolFree (SMTPConnectionPool); MemoryManagerClose (MSGSRV_AGENT_SMTP); -#if VERBOSE - XplConsolePrintf ("SMTPD: Shutdown complete.\r\n"); -#endif + Log(LOG_DEBUG, "Shutdown complete."); XplSignalLocalSemaphore (SMTPServerSemaphore); XplWaitOnLocalSemaphore (SMTPShutdownSemaphore); @@ -3990,9 +3973,7 @@ SMTPSSLServer (void *ignored) break; } default:{ - arg = errno; - Log(LOG_ALERT, "Accept failure %s Errno %d", "Server", arg); - XplConsolePrintf ("SMTPD: Exiting after an accept() failure with an errno: %d\n", arg); + Log(LOG_ALERT, "Accept failure Errno %d", errno); break; } } @@ -4002,9 +3983,7 @@ SMTPSSLServer (void *ignored) XplSafeDecrement (SMTPServerThreads); -#if VERBOSE - XplConsolePrintf ("SMTPD: SSL listening thread done.\r\n"); -#endif + Log(LOG_DEBUG, "SSL Listening thread terminated."); if (SMTPServerConnectionSSL) { ConnFree(SMTPServerConnectionSSL); @@ -4023,16 +4002,14 @@ SMTPSSLServer (void *ignored) static BOOL ReadConfiguration (void) { +/* struct sockaddr_in soc_address; struct sockaddr_in *sin = &soc_address; soc_address.sin_addr.s_addr = XplGetHostIPAddress (); sprintf (SMTP.hostaddr, "[%d.%d.%d.%d]", sin->sin_addr.s_net, sin->sin_addr.s_host, sin->sin_addr.s_lh, sin->sin_addr.s_impno); - if (strlen (SMTP.hostname) < sizeof (OfficialName)) { - strcpy (OfficialName, SMTP.hostname); - } - +*/ // FIXME: Does SMTP need to know about the various domains? Or will queue fix that? /* FIXME. This should be replaced by pulling config from the store. */ @@ -4115,7 +4092,11 @@ int XplServiceMain (int argc, char *argv[]) } if (! ReadBongoConfiguration(SMTPConfig, "smtp")) { - XplConsolePrintf("SMTPD: Unable to read configuration from the store\n"); + Log(LOG_ERROR, "Unable to read SMTP configuration from the store."); + exit(-1); + } + if (! ReadBongoConfiguration(GlobalConfig, "global")) { + Log(LOG_ERROR, "Unable to read Global configration from the store."); exit(-1); } ReadConfiguration (); diff --git a/src/apps/config/Bongo.rules b/src/apps/config/Bongo.rules index bad72a0..57481fb 100644 --- a/src/apps/config/Bongo.rules +++ b/src/apps/config/Bongo.rules @@ -2,6 +2,7 @@ sbin_PROGRAMS += bongo-config conf_defaults = \ + src/apps/config/config/global \ src/apps/config/config/antispam \ src/apps/config/config/antivirus \ src/apps/config/config/imap \ diff --git a/src/apps/config/config/global b/src/apps/config/config/global new file mode 100644 index 0000000..36c9958 --- /dev/null +++ b/src/apps/config/config/global @@ -0,0 +1,5 @@ +{ + "hostname": "localhost", + "hostaddr": "127.0.0.1", + "postmaster": "admin" +} diff --git a/src/apps/config/config/imap b/src/apps/config/config/imap index 3bb5849..387904d 100644 --- a/src/apps/config/config/imap +++ b/src/apps/config/config/imap @@ -3,5 +3,4 @@ "port": 143, "port_ssl": 993, "threads_max": 50, - "hostname": "localhost" } diff --git a/src/apps/config/config/mailproxy b/src/apps/config/config/mailproxy index 23fb75e..8152510 100644 --- a/src/apps/config/config/mailproxy +++ b/src/apps/config/config/mailproxy @@ -1,6 +1,5 @@ { "version": 1, - "postmaster": "admin@localhost", "interval": 3600, "queue": "localhost", "max_threads": 10, diff --git a/src/apps/config/config/pop3 b/src/apps/config/config/pop3 index fa4a2bd..a45153b 100644 --- a/src/apps/config/config/pop3 +++ b/src/apps/config/config/pop3 @@ -2,5 +2,4 @@ "version": 1, "port": 110, "port_ssl": 995, - "hostname": "localhost" } diff --git a/src/apps/config/config/queue b/src/apps/config/config/queue index 58d1fa1..12b4148 100644 --- a/src/apps/config/config/queue +++ b/src/apps/config/config/queue @@ -1,8 +1,6 @@ { "version": 1, "debug" : false, - "postmaster" : "admin", - "officialname" : "admin", "limitremoteprocessing" : false, "limitremotebegweekday" : 0, "limitremotebegweekend" : 0, diff --git a/src/apps/config/config/smtp b/src/apps/config/config/smtp index af8a7eb..9d85bad 100644 --- a/src/apps/config/config/smtp +++ b/src/apps/config/config/smtp @@ -2,8 +2,6 @@ "version": 1, "port": 25, "port_ssl": 465, - "hostname": "localhost", - "hostaddr": "127.0.0.1", "allow_client_ssl": false, "allow_expn": false, "allow_auth": true, @@ -12,7 +10,6 @@ "accept_etrn": false, "send_etrn": false, "maximum_recipients": 15, - "postmaster": "admin", "message_size_limit": 0, "relay_local_mail": false, "use_relay_host": false, diff --git a/src/libs/nmap/nmap.c b/src/libs/nmap/nmap.c index f82cf73..1deefa4 100644 --- a/src/libs/nmap/nmap.c +++ b/src/libs/nmap/nmap.c @@ -46,7 +46,6 @@ struct { REGISTRATION_LOADING, { '\0' }, NULL, - NULL, FALSE }; @@ -1612,7 +1611,7 @@ NMAPQuit(Connection *conn) } __inline static RegistrationStates -RegisterWithQueueServer(char *queueServerIpAddress, unsigned short queueServerPort, unsigned long queueNumber, const char *queueAgentServerDn, const char *queueAgentCn, unsigned long queueAgentPort) +RegisterWithQueueServer(char *queueServerIpAddress, unsigned short queueServerPort, unsigned long queueNumber, const char *queueAgentCn, unsigned long queueAgentPort) { unsigned long j; Connection *conn = NULL; @@ -1634,7 +1633,7 @@ RegisterWithQueueServer(char *queueServerIpAddress, unsigned short queueServerPo if (NMAPLibrary.state == REGISTRATION_REGISTERING) { if (NMAPAuthenticate(conn, response, CONN_BUFSIZE)) { - if (ConnWriteF(conn, "QWAIT %lu %d %s%s%lu\r\n", queueNumber, ntohs(queueAgentPort), queueAgentServerDn, queueAgentCn, queueNumber) > 0) { + if (ConnWriteF(conn, "QWAIT %lu %d %s %lu\r\n", queueNumber, ntohs(queueAgentPort), queueAgentCn, queueNumber) > 0) { if (ConnFlush(conn) > -1) { if (NMAPReadAnswer(conn, response, CONN_BUFSIZE, TRUE) == 1000) { NMAPLibrary.state = REGISTRATION_COMPLETED; @@ -1663,7 +1662,7 @@ QueueRegister(const unsigned char *queueAgentCn, unsigned long queueNumber, unsi NMAPLibrary.state = REGISTRATION_ALLOCATING; - RegisterWithQueueServer("127.0.0.1", BONGO_QUEUE_PORT, queueNumber, MsgGetServerDN(NULL), queueAgentCn, queueAgentPort); + RegisterWithQueueServer("127.0.0.1", BONGO_QUEUE_PORT, queueNumber, queueAgentCn, queueAgentPort); if (NMAPLibrary.state != REGISTRATION_COMPLETED) { NMAPLibrary.state = REGISTRATION_FAILED; }