Repaired other cases of auth mode failure. ICS calendar sync works better now.
authorArt Cancro <ajc@uncensored.citadel.org>
Tue, 22 Nov 2011 19:46:36 +0000 (14:46 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 5 Dec 2011 21:59:45 +0000 (22:59 +0100)
webcit/context_loop.c
webcit/tcp_sockets.c
webcit/webcit.h
webcit/webserver.c

index 4b0208204f31d6820aea0d3e580f018301795240..8295fff75885ab992b873b9fddb1956af083744f 100644 (file)
@@ -178,7 +178,7 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
                                && (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password)))
                                && (sptr->killthis == 0)
                        ) {
-                               syslog(LOG_DEBUG, "\033[32m-- matched a session with the same http-auth\033[0m");
+                               syslog(LOG_DEBUG, "Matched a session with the same http-auth");
                                TheSession = sptr;
                        }
                        break;
@@ -187,14 +187,14 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
                        if (    (Hdr->HR.desired_session != 0)
                                && (sptr->wc_session == Hdr->HR.desired_session)
                        ) {
-                               syslog(LOG_DEBUG, "\033[32m-- matched a session with the same cookie\033[0m");
+                               syslog(LOG_DEBUG, "Matched a session with the same cookie");
                                TheSession = sptr;
                        }
                        break;                       
                case NO_AUTH:
                        /* Any unbound session is a candidate */
                        if ( (sptr->wc_session == 0) && (sptr->inuse == 0) ) {
-                               syslog(LOG_DEBUG, "\033[32m-- reusing an unbound session\033[0m");
+                               syslog(LOG_DEBUG, "Reusing an unbound session");
                                TheSession = sptr;
                        }
                        break;
@@ -202,7 +202,7 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
        }
        CtdlLogResult(pthread_mutex_unlock(ListMutex));
        if (TheSession == NULL) {
-               syslog(LOG_DEBUG, "\033[32m-- no existing session was matched\033[0m");
+               syslog(LOG_DEBUG, "No existing session was matched");
        }
        return TheSession;
 }
@@ -562,15 +562,6 @@ void context_loop(ParsedHttpHdrs *Hdr)
                TheSession = CreateSession(1, 0, &SessionList, Hdr, &SessionListMutex);
        }
 
-       /*
-        * If a language was requested via a cookie, select that language now.
-        */
-       if (StrLength(Hdr->c_language) > 0) {
-               syslog(9, "Session cookie requests language '%s'", ChrPtr(Hdr->c_language));
-               set_selected_language(ChrPtr(Hdr->c_language));
-               go_selected_language();
-       }
-
        /*
         * Reject transactions which require http-auth, if http-auth was not provided
         */
@@ -579,10 +570,9 @@ void context_loop(ParsedHttpHdrs *Hdr)
                && (Hdr->HR.Handler != NULL)
                && ((XHTTP_COMMANDS & Hdr->HR.Handler->Flags) == XHTTP_COMMANDS)
        ) {
-               syslog(LOG_DEBUG, "\033[35m -- http-auth required but not provided\033[0m");
+               syslog(LOG_DEBUG, "http-auth required but not provided");
                OverrideRequest(Hdr, HKEY("GET /401 HTTP/1.0"));
                Hdr->HR.prohibit_caching = 1;                           
-               /* FIXME -- we have to clear the cookie here */
        }
 
        /*
@@ -600,8 +590,20 @@ void context_loop(ParsedHttpHdrs *Hdr)
        TheSession->lastreq = time(NULL);                       /* log */
        TheSession->Hdr = Hdr;
 
+       /*
+        * If a language was requested via a cookie, select that language now.
+        */
+       if (StrLength(Hdr->c_language) > 0) {
+               syslog(LOG_DEBUG, "Session cookie requests language '%s'", ChrPtr(Hdr->c_language));
+               set_selected_language(ChrPtr(Hdr->c_language));
+               go_selected_language();
+       }
+
+       /*
+        * do the transaction
+        */
        session_attach_modules(TheSession);
-       session_loop();                         /* do transaction */
+       session_loop();
 
        /* How long did this transaction take? */
        gettimeofday(&tx_finish, NULL);
index da483deabceab4b9c1f0162169495d69411b738b..c9d053f2f796b1ca4bf897e2e347675d506d0201 100644 (file)
@@ -690,11 +690,6 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
                                retval = client_read_sslbuffer(Hdr->ReadBuf, timeout);
                        if (retval >= 0) {
                                StrBufAppendBuf(Target, Hdr->ReadBuf, 0); /* todo: Buf > bytes? */
-#ifdef HTTP_TRACING
-                               write(2, "\033[32m", 5);
-                               write(2, buf, bytes);
-                               write(2, "\033[30m", 5);
-#endif
                                return 1;
                        }
                        else {
@@ -722,11 +717,6 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
                return retval;
        }
 
-#ifdef HTTP_TRACING
-       write(2, "\033[32m", 5);
-       write(2, buf, bytes);
-       write(2, "\033[30m", 5);
-#endif
        return 1;
 }
 
@@ -785,13 +775,6 @@ long end_burst(void)
        }
 #endif
 
-       
-#ifdef HTTP_TRACING
-       
-       write(2, "\033[34m", 5);
-       write(2, ptr, StrLength(WCC->WBuf));
-       write(2, "\033[30m", 5);
-#endif
        if (WCC->Hdr->http_sock == -1)
                return -1;
        fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
@@ -822,13 +805,6 @@ long end_burst(void)
        count = StrLength(WCC->WBuf);
        eptr = ptr + count;
 
-#ifdef HTTP_TRACING
-       
-       write(2, "\033[34m", 5);
-       write(2, ptr, StrLength(WCC->WBuf));
-       write(2, "\033[30m", 5);
-#endif
-
         while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)) {
                 if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
                         FD_ZERO(&wset);
index 5166d0e8605fb8da0ca278284fdb02076e9f29c0..bfad761078615c157be9d30a51d39be0566b6296 100644 (file)
 #endif
 
 #define IsEmptyStr(a) ((a)[0] == '\0')
-/*
- * Uncomment to dump an HTTP trace to stderr
-#define HTTP_TRACING 1
- */
 
 #define DO_DBG_QR 0
 #define DBG_QR(x) if(DO_DBG_QR) _DBG_QR(x)
 #define DBG_QR2(x) if(DO_DBG_QR) _DBG_QR2(x)
 
-#ifdef HTTP_TRACING
-#undef HAVE_ZLIB_H
-#undef HAVE_ZLIB
-#endif
-
 #ifdef HAVE_ZLIB_H
 #include <zlib.h>
 #endif
index db7c193054ab2cee606d3ea8c517b783571ed64f..ab523489bda8bd4fe2bd9efcc2297ac943165b0e 100644 (file)
@@ -29,7 +29,7 @@ extern char static_icon_dir[PATH_MAX];          /* where should we find our mime
 int is_https = 0;                              /* Nonzero if I am an HTTPS service */
 int follow_xff = 0;                            /* Follow X-Forwarded-For: header? */
 int DisableGzip = 0;
-char *default_landing_page = NULL;             /* FIXME we need to populate this somehow */
+char *default_landing_page = NULL;
 extern pthread_mutex_t SessionListMutex;
 extern pthread_key_t MyConKey;