]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/pop3client/serv_pop3client.c
POP3Client: Log the Hostname, not sensitive information.
[citadel.git] / citadel / modules / pop3client / serv_pop3client.c
index 599a35e69f396fd994c6621a78cd50f283d0d705..e5ba9bf3e1a30a330296f54596493454dd53be99 100644 (file)
@@ -171,6 +171,7 @@ struct pop3aggr {
        StrBuf          *Url;
        StrBuf *pop3user;
        StrBuf *pop3pass;
+       StrBuf *Host;
        StrBuf *RoomName; // TODO: fill me
        int keep;
        time_t interval;
@@ -188,6 +189,7 @@ void DeletePOP3Aggregator(void *vptr)
 //     FreeStrBuf(&ptr->rooms);
        FreeStrBuf(&ptr->pop3user);
        FreeStrBuf(&ptr->pop3pass);
+       FreeStrBuf(&ptr->Host);
        FreeStrBuf(&ptr->RoomName);
        FreeURL(&ptr->IO.ConnectMe);
        FreeStrBuf(&ptr->Url);
@@ -209,7 +211,7 @@ eNextState FinalizePOP3AggrRun(AsyncIO *IO)
        EVP3C_syslog(LOG_INFO,
                     "%s@%s: fetched %ld new of %d messages in %fs. bye.",
                     ChrPtr(cpptr->pop3user),
-                    ChrPtr(cpptr->pop3pass),
+                    ChrPtr(cpptr->Host),
                     cpptr->count,
                     GetCount(cpptr->MsgNumbers), 
                     IO->Now - cpptr->IOStart 
@@ -359,7 +361,8 @@ eNextState POP3_FetchNetworkUsetableEntry(AsyncIO *IO)
        struct cdbdata *cdbut;
        pop3aggr *RecvMsg = (pop3aggr *) IO->Data;
 
-       if(GetNextHashPos(RecvMsg->MsgNumbers,
+       if((RecvMsg->Pos != NULL) &&
+          GetNextHashPos(RecvMsg->MsgNumbers,
                          RecvMsg->Pos,
                          &HKLen,
                          &HKey,
@@ -423,7 +426,8 @@ eNextState POP3C_GetOneMessagID(pop3aggr *RecvMsg)
        if (rc != 0)
                EVP3CCS_syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
 #endif
-       if(GetNextHashPos(RecvMsg->MsgNumbers,
+       if((RecvMsg->Pos != NULL) &&
+          GetNextHashPos(RecvMsg->MsgNumbers,
                          RecvMsg->Pos,
                          &HKLen, &HKey,
                          &vData))
@@ -437,7 +441,7 @@ eNextState POP3C_GetOneMessagID(pop3aggr *RecvMsg)
        }
        else
        {
-           RecvMsg->State++;
+               RecvMsg->State++;
                DeleteHashPos(&RecvMsg->Pos);
                /// done receiving uidls.. start looking them up now.
                RecvMsg->Pos = GetNewHashPos(RecvMsg->MsgNumbers, 0);
@@ -486,7 +490,8 @@ eNextState POP3C_SendGetOneMsg(pop3aggr *RecvMsg)
        void *vData;
 
        RecvMsg->CurrMsg = NULL;
-       while (GetNextHashPos(RecvMsg->MsgNumbers,
+       while ((RecvMsg->Pos != NULL) && 
+              GetNextHashPos(RecvMsg->MsgNumbers,
                              RecvMsg->Pos,
                              &HKLen, &HKey,
                              &vData) &&
@@ -1056,7 +1061,6 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
                        if (!strcasecmp("pop3client", ChrPtr(CfgType)))
                        {
                                pop3aggr *cptr;
-                               StrBuf *Tmp;
 /*
                                if (Count == NULL)
                                {
@@ -1075,9 +1079,10 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
                                cptr->pop3pass =
                                        NewStrBufPlain(NULL, StrLength(Line));
                                cptr->Url = NewStrBuf();
-                               Tmp = NewStrBuf();
+                               cptr->Host =
+                                       NewStrBufPlain(NULL, StrLength(Line));
 
-                               StrBufExtract_NextToken(Tmp, Line, &lPtr, '|');
+                               StrBufExtract_NextToken(cptr->Host, Line, &lPtr, '|');
                                StrBufExtract_NextToken(cptr->pop3user,
                                                        Line,
                                                        &lPtr,
@@ -1101,11 +1106,10 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
                                StrBufAppendBufPlain(cptr->Url, HKEY(":"), 0);
                                StrBufUrlescUPAppend(cptr->Url, cptr->pop3pass, NULL);
                                StrBufAppendBufPlain(cptr->Url, HKEY("@"), 0);
-                               StrBufAppendBuf(cptr->Url, Tmp, 0);
+                               StrBufAppendBuf(cptr->Url, cptr->Host, 0);
                                StrBufAppendBufPlain(cptr->Url, HKEY("/"), 0);
                                StrBufUrlescAppend(cptr->Url, cptr->RoomName, NULL);
 
-                               FreeStrBuf(&Tmp);
                                ParseURL(&cptr->IO.ConnectMe, cptr->Url, 110);
 
 
@@ -1260,7 +1264,7 @@ CTDL_MODULE_INIT(pop3client)
                pthread_mutex_init(&POP3QueueMutex, NULL);
                POP3QueueRooms = NewHash(1, lFlathash);
                POP3FetchUrls = NewHash(1, NULL);
-               CtdlRegisterSessionHook(pop3client_scan, EVT_TIMER);
+               CtdlRegisterSessionHook(pop3client_scan, EVT_TIMER, PRIO_AGGR + 50);
                CtdlRegisterEVCleanupHook(pop3_cleanup);
                CtdlRegisterDebugFlagHook(HKEY("pop3client"), LogDebugEnablePOP3Client, &POP3ClientDebugEnabled);
        }