Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorArt Cancro <ajc@uncensored.citadel.org>
Fri, 27 Jan 2012 16:38:34 +0000 (11:38 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Fri, 27 Jan 2012 16:38:34 +0000 (11:38 -0500)
15 files changed:
citadel/modules/listsub/serv_listsub.c
citadel/modules/network/serv_network.c
citadel/modules/network/serv_networkclient.c
citadel/modules/smtp/serv_smtpeventclient.c
citadel/modules/smtp/serv_smtpqueue.c
citadel/modules/smtp/smtpqueue.h
webcit/debian/rules
webcit/roomops.c
webcit/roomtokens.c
webcit/serv_func.c
webcit/static/t/room/edit/tab_access.html
webcit/static/t/room/edit/tab_config.html
webcit/static/t/room/edit/tab_expire.html
webcit/tcp_sockets.c
webcit/webcit.c

index 19fe74ee62507a8b2d245032ed522d0714cfae44..495fc0f9aed1582d696df88a8e830b835bf382ca 100644 (file)
@@ -379,18 +379,16 @@ void do_confirm(char *room, char *token) {
        int line_length;
        char buf[512];
        char cmd[256];
-       char email[256];
+       char email[256] = "";
        char subtype[128];
        int success = 0;
-       char address_to_unsubscribe[256];
+       char address_to_unsubscribe[256] = "";
        char scancmd[256];
        char scanemail[256];
        char *holdbuf = NULL;
        int linelen = 0;
        int buflen = 0;
 
-       strcpy(address_to_unsubscribe, "");
-
        if (CtdlGetRoom(&qrbuf, room) != 0) {
                cprintf("%d There is no list called '%s'\n",
                        ERROR + ROOM_NOT_FOUND, room);
index 599b90d1d8d820070b514c442973b03e71dcc0a1..ba87cca5e4ce42d43f563e7bed570154a704f741 100644 (file)
@@ -112,7 +112,7 @@ int GetNetworkedRoomNumbers(const char *DirName, HashList *DirList)
        struct dirent *d;
        struct dirent *filedir_entry;
        long RoomNR;
-       long Count;
+       long Count = 0;
                
        filedir = opendir (DirName);
        if (filedir == NULL) {
@@ -306,7 +306,7 @@ void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data) {
                ptr->namelen = ROOMNAMELEN - 1;
 
        memcpy (ptr->name, qrbuf->QRname, ptr->namelen);
-       ptr->name[ptr->namelen] = 0;
+       ptr->name[ptr->namelen] = '\0';
        ptr->QRNum = qrbuf->QRnumber;
 
        for (i = 0; i < ptr->namelen; i++)
@@ -314,6 +314,7 @@ void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data) {
                ptr->lcname[i] = tolower(ptr->name[i]);
        }
 
+       ptr->lcname[ptr->namelen] = '\0';
        ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345);
        ptr->next = RP->rplist;
        RP->rplist = ptr;
@@ -334,15 +335,16 @@ void network_queue_room(struct ctdlroom *qrbuf, void *data) {
                ptr->namelen = ROOMNAMELEN - 1;
 
        memcpy (ptr->name, qrbuf->QRname, ptr->namelen);
-       ptr->name[ptr->namelen] = 0;
+       ptr->name[ptr->namelen] = '\0';
        ptr->QRNum = qrbuf->QRnumber;
 
        for (i = 0; i < ptr->namelen; i++)
        {
                ptr->lcname[i] = tolower(ptr->name[i]);
        }
-
+       ptr->lcname[ptr->namelen] = '\0';
        ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345);
+
        begin_critical_section(S_RPLIST);
        ptr->next = rplist;
        rplist = ptr;
@@ -524,7 +526,8 @@ void network_do_queue(void) {
        end_critical_section(S_RPLIST);
 
        RL.RoomsInterestedIn = NewHash(1, lFlathash);
-       if (!GetNetworkedRoomNumbers(ctdl_netcfg_dir, RL.RoomsInterestedIn))
+       if (full_processing &&
+           (GetNetworkedRoomNumbers(ctdl_netcfg_dir, RL.RoomsInterestedIn)==0))
        {
                doing_queue = 0;
                DeleteHash(&RL.RoomsInterestedIn);
index 190121a9867f9269406b40bbf91652b7f82b740d..24e354a5c37e2006f124baa55f99389ff3c5308d 100644 (file)
@@ -437,6 +437,7 @@ eNextState NWC_SendNUOP(AsyncNetworker *NW)
                NW->State = eQUIT;
                rc = NWC_SendQUIT(NW);
                NWC_DBG_SEND();
+               return rc;
        }
 
        if (fstat(fd, &statbuf) == -1) {
index b38320d2a64b1923c0d4a92103b9cc93913c3178..518c00a335374df7cde766798d7bcf359a1c4c56 100644 (file)
@@ -627,6 +627,7 @@ eNextState SMTP_C_Timeout(AsyncIO *IO)
 {
        SmtpOutMsg *pMsg = IO->Data;
 
+       pMsg->MyQEntry->Status = 4;
        EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
        return FailOneAttempt(IO);
@@ -635,12 +636,15 @@ eNextState SMTP_C_ConnFail(AsyncIO *IO)
 {
        SmtpOutMsg *pMsg = IO->Data;
 
+       pMsg->MyQEntry->Status = 4;
        EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
        return FailOneAttempt(IO);
 }
 eNextState SMTP_C_DNSFail(AsyncIO *IO)
 {
+       SmtpOutMsg *pMsg = IO->Data;
+       pMsg->MyQEntry->Status = 4;
        EVS_syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        return FailOneAttempt(IO);
 }
index 3e20779a1476d843b1ed4b408653e8371520f654..72b73bf1a27580410c0739ebcdc3a3d2cde3b8e0 100644 (file)
@@ -94,6 +94,7 @@ pthread_mutex_t ActiveQItemsLock;
 HashList *ActiveQItems  = NULL;
 HashList *QItemHandlers = NULL;
 
+static const long MaxRetry = SMTP_RETRY_INTERVAL * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;
 int MsgCount            = 0;
 int run_queue_now       = 0;   /* Set to 1 to ignore SMTP send retry times */
 
@@ -217,7 +218,7 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
 
        Item = (OneQueItem*)malloc(sizeof(OneQueItem));
        memset(Item, 0, sizeof(OneQueItem));
-       Item->LastAttempt.retry = SMTP_RETRY_INTERVAL;
+       Item->Retry = SMTP_RETRY_INTERVAL;
        Item->MessageID = -1;
        Item->QueMsgID = QueMsgID;
 
@@ -240,6 +241,9 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
        FreeStrBuf(&Line);
        FreeStrBuf(&Token);
 
+       if (Item->Retry >= MaxRetry)
+               Item->FailNow = 1;
+
        pthread_mutex_lock(&ActiveQItemsLock);
        if (GetHash(ActiveQItems,
                    LKEY(Item->MessageID),
@@ -289,30 +293,24 @@ StrBuf *SerializeQueueItem(OneQueItem *MyQItem)
                StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0);
        }
 
+       StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
+       StrBufAppendPrintf(QMessage, "%ld",
+                          MyQItem->Retry);
+
+       StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0);
+       StrBufAppendPrintf(QMessage, "%ld",
+                          MyQItem->ReattemptWhen);
+
        It = GetNewHashPos(MyQItem->MailQEntries, 0);
        while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE))
        {
                MailQEntry *ThisItem = vQE;
-               int i;
 
                if (!ThisItem->Active)
                {
                        /* skip already sent ones from the spoolfile. */
                        continue;
                }
-
-               for (i=0; i < ThisItem->nAttempts; i++) {
-                       /* TODO: most probably
-                        * there is just one retry/attempted per message!
-                        */
-                       StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
-                       StrBufAppendPrintf(QMessage, "%ld",
-                                          ThisItem->Attempts[i].retry);
-
-                       StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0);
-                       StrBufAppendPrintf(QMessage, "%ld",
-                                          ThisItem->Attempts[i].when);
-               }
                StrBufAppendBufPlain(QMessage, HKEY("\nremote|"), 0);
                StrBufAppendBuf(QMessage, ThisItem->Recipient, 0);
                StrBufAppendBufPlain(QMessage, HKEY("|"), 0);
@@ -378,16 +376,9 @@ void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
 
 void QItem_Handle_retry(OneQueItem *Item, StrBuf *Line, const char **Pos)
 {
-       if (Item->Current == NULL)
-               NewMailQEntry(Item);
-       if (Item->Current->Attempts[Item->Current->nAttempts].retry != 0)
-               Item->Current->nAttempts++;
-       if (Item->Current->nAttempts > MaxAttempts) {
-               Item->FailNow = 1;
-               return;
-       }
-       Item->Current->Attempts[Item->Current->nAttempts].retry =
+       Item->Retry =
                StrBufExtractNext_int(Line, Pos, '|');
+       Item->Retry *= 2;
 }
 
 
@@ -399,31 +390,7 @@ void QItem_Handle_Submitted(OneQueItem *Item, StrBuf *Line, const char **Pos)
 
 void QItem_Handle_Attempted(OneQueItem *Item, StrBuf *Line, const char **Pos)
 {
-       if (Item->Current == NULL)
-               NewMailQEntry(Item);
-       if (Item->Current->Attempts[Item->Current->nAttempts].when != 0)
-               Item->Current->nAttempts++;
-       if (Item->Current->nAttempts > MaxAttempts) {
-               Item->FailNow = 1;
-               return;
-       }
-
-       Item->Current->Attempts[Item->Current->nAttempts].when =
-               StrBufExtractNext_int(Line, Pos, '|');
-       if (Item->Current->Attempts[Item->Current->nAttempts].when >
-           Item->LastAttempt.when)
-       {
-               Item->LastAttempt.when =
-                       Item->Current->Attempts[Item->Current->nAttempts].when;
-
-               Item->LastAttempt.retry =
-                       Item->Current->Attempts[
-                               Item->Current->nAttempts
-                               ].retry * 2;
-
-               if (Item->LastAttempt.retry > SMTP_RETRY_MAX)
-                       Item->LastAttempt.retry = SMTP_RETRY_MAX;
-       }
+       Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|');
 }
 
 
@@ -694,8 +661,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        /*
         * Postpone delivery if we've already tried recently.
         */
-       if (((time(NULL) - MyQItem->LastAttempt.when) <
-            MyQItem->LastAttempt.retry) &&
+       if (((time(NULL) - MyQItem->ReattemptWhen) > 0) &&
            (run_queue_now == 0))
        {
                syslog(LOG_DEBUG, "SMTP client: Retry time not yet reached.\n");
index 12b2ad387f1591e32f56996ea0411c211107d2f6..97b76e7901518838e9f00b6294a030c940bca048 100644 (file)
 /*               SMTP CLIENT (Queue Management) STUFF                        */
 /*****************************************************************************/
 
-
-
 #define MaxAttempts 15
-typedef struct _delivery_attempt {
-       time_t when;
-       time_t retry;
-}DeliveryAttempt;
 
 typedef struct _mailq_entry {
-       DeliveryAttempt Attempts[MaxAttempts];
-       int nAttempts;
        StrBuf *Recipient;
        StrBuf *StatusMessage;
        int Status;
@@ -58,7 +50,9 @@ typedef struct queueitem {
  * if null add a new one.
  */
        MailQEntry *Current;
-       DeliveryAttempt LastAttempt;
+       time_t ReattemptWhen;
+       time_t Retry;
+
        long ActiveDeliveries;
        StrBuf *EnvelopeFrom;
        StrBuf *BounceTo;
index 12301764bc0ee6bfc7dc2b9b92b94b8354b0b387..cd0a58efb6ba21143fa8755eec7df37de41fbf46 100755 (executable)
@@ -52,7 +52,7 @@ endif
 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
        cp -f /usr/share/misc/config.guess config.guess
 endif
-       CC=$(COMPILER); exportCFLAGS=" -Wformat -Werror=format-security $(CFLAGS)" ./configure \
+       export CC=$(COMPILER); export CFLAGS=" -Wformat -Werror=format-security $(CFLAGS)"; ./configure \
                --host=$(DEB_HOST_GNU_TYPE) \
                --build=$(DEB_BUILD_GNU_TYPE) \
                --prefix=/usr/sbin/ \
index 85e998bcb77f1bcf52f0c7e6f7df2a3ead0ba8d4..b6fdaa8df8113f5154a3bddd45c2e60050fcb920 100644 (file)
@@ -481,7 +481,7 @@ int SaveRoomAide(folder *Room)
 }
 
 
-int GetCurrentRoomFlags(folder *Room)
+int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
 {
        StrBuf *Buf;
 
@@ -492,8 +492,10 @@ int GetCurrentRoomFlags(folder *Room)
                FlushStrBuf(Room->XAPass);
                FlushStrBuf(Room->Directory);
                StrBufCutLeft(Buf, 4);
-               AppendImportantMessage (SKEY(Buf));
+               if (CareForStatusMessage)
+                       AppendImportantMessage (SKEY(Buf));
                FreeStrBuf(&Buf);
+               Room->XALoaded = 2;
                return 0;
        } else {
                const char *Pos;
@@ -560,10 +562,10 @@ void LoadRoomXA (void)
 {
        wcsession *WCC = WC;
                
-       if (WCC->CurRoom.XALoaded)
+       if (WCC->CurRoom.XALoaded > 0)
                return;
 
-       GetCurrentRoomFlags(&WCC->CurRoom);
+       GetCurrentRoomFlags(&WCC->CurRoom, 0);
 }
 
 
@@ -658,7 +660,7 @@ void LoadXRoomXCountFiles(void)
 void toggle_self_service(void) {
        wcsession *WCC = WC;
 
-       if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
+       if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0)
                return;
 
        if (yesbstr("QR2_SelfList")) 
@@ -707,8 +709,10 @@ void editroom(void)
                http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
                return;
        }
-       if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
+       if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) {
+               http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
                return;
+       }
 
        LoadRoomAide();
 
@@ -849,7 +853,7 @@ void do_invt_kick(void)
        wcsession *WCC = WC;
 
 
-       if (GetCurrentRoomFlags(&WCC->CurRoom) == 1)
+       if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1)
        {
                const char *Pos;
                UserNames = sbstr("username");
index d41b36af1a5e52a717f36fdab5670dae4471bbf0..21b8cc4a3a11d270f986643918183cff3fa733d7 100644 (file)
@@ -266,6 +266,15 @@ int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP)
 
 
 /****** Properties ******/
+int ConditionalRoom_MayEdit(StrBuf *Target, WCTemplputParams *TP)
+{
+       wcsession *WCC = WC;
+
+       LoadRoomXA ();
+
+       return WCC->CurRoom.XALoaded == 1;
+}
+
 int ConditionalThisRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
 {
        long QR_CheckFlag;
@@ -613,6 +622,7 @@ InitModule_ROOMTOKENS
        /****** Properties ******/
        RegisterNamespace("ROOM:INFO:QRFLAGS", 0, 1, tmplput_ROOM_QRFLAGS, NULL, CTX_ROOMS);
        RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalThisRoomHas_QRFlag, CTX_NONE);
+       RegisterConditional(HKEY("COND:THISROOM:EDIT"), 0, ConditionalRoom_MayEdit, CTX_NONE);
        RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
 
        RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalThisRoomHas_QRFlag2, CTX_NONE);
index 71d5d57daa6eafd1ab2fdf2c7560381e40aea209..873a3ffde67114687c9492af222b5273a31a1e0a 100644 (file)
@@ -172,6 +172,7 @@ int GetConnected (void)
                WCC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
        
        if (WCC->serv_sock < 0) {
+               WCC->connected = 0;
                FreeStrBuf(&WCC->ReadBuf);
                return 1;
        }
index 3048972f4bb3a6530859b344dbd84029cbe10422..8cad949fe37d6aa38c37e3741551b0aef0ab29a1 100644 (file)
@@ -1,4 +1,4 @@
-<div class="tabcontent">
+<?!("COND:THISROOM:EDIT", 1)><div class="tabcontent">
        <table border="0" cellspacing="10">
                <tr valign="top">
                        <td>
@@ -39,3 +39,4 @@
                </tr>
        </table>
 </div>
+<?!("X", 1)><??("COND:THISROOM:EDIT", 20)><div class="tabcontent"><?_("Higher access is required to access this function.")></div><??("X", 20)>
index 0a6891c4a2df66424b88461faeef1e575603b18c..7c45b6ec76fce126cc07568099f8570ed8ac4c94 100644 (file)
@@ -1,4 +1,4 @@
-<div class="tabcontent">
+<?!("COND:THISROOM:EDIT", 1)><div class="tabcontent">
        <form method="post" action="editroom">
                <input type="hidden" name="nonce" value="<?NONCE>" />
                <ul>   
        </center>
        </form>
 </div>
+<?!("X", 1)><??("COND:THISROOM:EDIT", 20)><div class="tabcontent"><?_("Higher access is required to access this function.")></div><??("X", 20)>
index dc4e61c215a94f8f56923597706cc9d746905fb5..fb958151b1971075f69e1b5ec462c06661bfe849 100644 (file)
@@ -1,4 +1,4 @@
-<div class="tabcontent">
+<?!("COND:THISROOM:EDIT", 1)><div class="tabcontent">
        <br />
        <form method="post" action="set_room_policy">
                <input type="hidden" name="nonce" value="<?NONCE>" />
@@ -69,3 +69,4 @@
                <input type="hidden" name="last_tabsel" value="<?TAB:N>" />
        </form>
 </div>
+<?!("X", 1)><??("COND:THISROOM:EDIT", 20)><div class="tabcontent"><?_("Higher access is required to access this function.")></div><??("X", 20)>
index 735899dbe4d48f1e082e8ea3d909fbb97907c328..9952fd9ab081057539640bec98177487fbb39de0 100644 (file)
@@ -911,10 +911,12 @@ SessionDestroyModule_TCPSOCKETS
 {
        FreeStrBuf(&sess->CLineBuf);
        FreeStrBuf(&sess->ReadBuf);
+       sess->connected = 0;
        sess->ReadPos = NULL;
        FreeStrBuf(&sess->MigrateReadLineBuf);
        if (sess->serv_sock > 0) {
                syslog(LOG_DEBUG, "Closing socket %d", sess->serv_sock);
                close(sess->serv_sock);
        }
+       sess->serv_sock = -1;
 }
index 94ff1e22e9177b35062ecbf596a779cebaac2c17..944b457c86ab0caf1a5dc2cf536bbc601a0ab605 100644 (file)
@@ -31,7 +31,7 @@ StrBuf *csslocal = NULL;
 HashList *HandlerHash = NULL;
 
 void stuff_to_cookie(int unset_cookie);
-int GetConnected(void);
+extern int GetConnected(void);
 
 
 void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)