From eae9f81553dc2753bb1101de8564bf72dcd5b243 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 22 Nov 2011 14:46:36 -0500 Subject: [PATCH] Repaired other cases of auth mode failure. ICS calendar sync works better now. --- webcit/context_loop.c | 34 ++++++++++++++++++---------------- webcit/tcp_sockets.c | 24 ------------------------ webcit/webcit.h | 9 --------- webcit/webserver.c | 2 +- 4 files changed, 19 insertions(+), 50 deletions(-) diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 4b0208204..8295fff75 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -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); diff --git a/webcit/tcp_sockets.c b/webcit/tcp_sockets.c index da483deab..c9d053f2f 100644 --- a/webcit/tcp_sockets.c +++ b/webcit/tcp_sockets.c @@ -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); diff --git a/webcit/webcit.h b/webcit/webcit.h index 5166d0e86..bfad76107 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -70,20 +70,11 @@ #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 #endif diff --git a/webcit/webserver.c b/webcit/webserver.c index db7c19305..ab523489b 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -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; -- 2.30.2