if ((*sessions_to_kill)->cache_fold != NULL) {
free((*sessions_to_kill)->cache_fold);
}
+ DeleteServInfo(&((*sessions_to_kill)->serv_info));
DeleteHash(&((*sessions_to_kill)->attachments));
free_march_list((*sessions_to_kill));
DeleteHash(&((*sessions_to_kill)->hash_prefs));
- DeleteHash(&((*sessions_to_kill)->IconBarSetttings));
+ DeleteHash(&((*sessions_to_kill)->IconBarSettings));
DeleteHash(&((*sessions_to_kill)->ServCfg));
+ FreeStrBuf(&((*sessions_to_kill)->ReadBuf));
FreeStrBuf(&((*sessions_to_kill)->UrlFragment1));
FreeStrBuf(&((*sessions_to_kill)->UrlFragment2));
FreeStrBuf(&((*sessions_to_kill)->UrlFragment3));
+ FreeStrBuf(&((*sessions_to_kill)->UrlFragment4));
FreeStrBuf(&((*sessions_to_kill)->WBuf));
FreeStrBuf(&((*sessions_to_kill)->HBuf));
FreeStrBuf(&((*sessions_to_kill)->CLineBuf));
+ FreeStrBuf(&((*sessions_to_kill)->wc_username));
+ FreeStrBuf(&((*sessions_to_kill)->wc_fullname));
+ FreeStrBuf(&((*sessions_to_kill)->wc_password));
+ FreeStrBuf(&((*sessions_to_kill)->wc_roomname));
+ FreeStrBuf(&((*sessions_to_kill)->httpauth_user));
+ FreeStrBuf(&((*sessions_to_kill)->httpauth_pass));
+ FreeStrBuf(&((*sessions_to_kill)->ImportantMsg));
+ FreeStrBuf(&((*sessions_to_kill)->cs_inet_email));
+ FreeStrBuf(&((*sessions_to_kill)->MigrateReadLineBuf));
free((*sessions_to_kill));
(*sessions_to_kill) = NULL;
}
}
-/**
- * \brief Wake up occasionally and clean house
+/*
+ * Wake up occasionally and clean house
*/
void housekeeping_loop(void)
{
}
-/**
- * \brief Create a Session id
+/*
+ * Create a Session id
* Generate a unique WebCit session ID (which is not the same thing as the
* Citadel session ID).
- *
- * \todo FIXME ... ensure that session number is truly unique
- *
*/
int GenerateSessionID(void)
{
return ++seq;
}
-/*
- * Collapse multiple cookies on one line
- */
-int ReqGetStrBuf(int *sock, StrBuf *Target, StrBuf *buf)
-{
-
- return ClientGetLine(sock, Target, buf);
-}
-
-
/*
* lingering_close() a`la Apache. see
const char *nix(void *vptr) {return ChrPtr( (StrBuf*)vptr);}
-/**
- * \brief handle one request
+/*
+ * handle one request
+ *
* This loop gets called once for every HTTP connection made to WebCit. At
* this entry point we have an HTTP socket with a browser allegedly on the
* other end, but we have not yet bound to a WebCit session.
* transaction loop. Afterwards, we unbind from the session. When this
* function returns, the worker thread is then free to handle another
* transaction.
- * \param sock the socket we will put our answer to
*/
void context_loop(int *sock)
{
+ const char *Pos = NULL;
const char *buf;
int desired_session = 0;
int got_cookie = 0;
char httpauth_string[1024];
char httpauth_user[1024];
char httpauth_pass[1024];
- char *ptr = NULL;
int session_is_new = 0;
int nLine = 0;
int LineLen;
strcpy(httpauth_user, DEFAULT_HTTPAUTH_USER);
strcpy(httpauth_pass, DEFAULT_HTTPAUTH_PASS);
- /**
+ /*
* Find out what it is that the web browser is asking for
*/
HeaderName = NewStrBuf();
Buf = NewStrBuf();
LastLine = NULL;
HTTPHeaders = NewHash(1, NULL);
- /**
+
+ /*
* Read in the request
*/
do {
nLine ++;
Line = NewStrBuf();
- if (ReqGetStrBuf(sock, Line, Buf) < 0) return;
+
+
+ if (ClientGetLine(sock, Line, Buf, &Pos) < 0) return;
LineLen = StrLength(Line);
continue;
}
- /** Do we need to Unfold? */
+ /* Do we need to Unfold? */
if ((LastLine != NULL) &&
(isspace(*ChrPtr(Line)))) {
pch = pchs = ChrPtr(Line);
continue;
}
+ StrBufSanitizeAscii(Line, 'ยง');
StrBufExtract_token(HeaderName, Line, 0, ':');
- /*/// TODO: filter bad chars! */
pchs = ChrPtr(Line);
pch = pchs + StrLength(HeaderName) + 1;
} while (LineLen > 0);
FreeStrBuf(&HeaderName);
-/*/// dbg_PrintHash(HTTPHeaders, nix, NULL); */
+/* dbg_PrintHash(HTTPHeaders, nix, NULL); */
- /**
+ /*
* Can we compress?
*/
if (GetHash(HTTPHeaders, HKEY("ACCEPT-ENCODING"), &vLine) &&
}
}
- /**
- * Browser-based sessions use cookies for session
-
-authentication
+ /*
+ * Browser-based sessions use cookies for session authentication
*/
if (GetHash(HTTPHeaders, HKEY("COOKIE"), &vLine) &&
(vLine != NULL)) {
cookie_to_stuff(vLine, &desired_session,
- NULL, 0, NULL, 0, NULL, 0);
+ NULL, NULL, NULL);
got_cookie = 1;
}
- /**
+ /*
* GroupDAV-based sessions use HTTP authentication
*/
if (GetHash(HTTPHeaders, HKEY("AUTHORIZATION"), &vLine) &&
}
- /**
- * If the request is prefixed by "/webcit" then chop that off. This
- * allows a front end web server to forward all /webcit requests to us
- * while still using the same web server port for other things.
- */
-
ReqType = NewStrBuf();
HTTPVersion = NewStrBuf();
StrBufExtract_token(HTTPVersion, ReqLine, 2, ' ');
StrBufCutLeft(ReqLine, StrLength(ReqType) + 1);
StrBufCutRight(ReqLine, StrLength(HTTPVersion) + 1);
- if ((follow_xff == 1) && (StrLength(ReqLine) >= 8) &&
- (ptr = strstr(ChrPtr(ReqLine), "/webcit/"), /*< Handle "/webcit/" */
- (ptr != NULL))) {
+ /*
+ * If the request is prefixed by "/webcit" then chop that off. This
+ * allows a front end web server to forward all /webcit requests to us
+ * while still using the same web server port for other things.
+ */
+ if ( (StrLength(ReqLine) >= 8) && (strstr(ChrPtr(ReqLine), "/webcit/")) ) {
StrBufCutLeft(ReqLine, 7);
}
- /** Begin parsing the request. */
+ /* Begin parsing the request. */
#ifdef TECH_PREVIEW
if ((strncmp(ChrPtr(ReqLine), "/sslg", 5) != 0) &&
(strncmp(ChrPtr(ReqLine), "/static/", 8) != 0) &&
/** If HTTP-AUTH, look for a session with matching credentials */
if ( (!IsEmptyStr(httpauth_user))
- &&(!strcasecmp(sptr->httpauth_user, httpauth_user))
- &&(!strcasecmp(sptr->httpauth_pass, httpauth_pass)) ) {
+ &&(!strcasecmp(ChrPtr(sptr->httpauth_user), httpauth_user))
+ &&(!strcasecmp(ChrPtr(sptr->httpauth_pass), httpauth_pass)) ) {
TheSession = sptr;
}
TheSession->wc_session = desired_session;
}
- strcpy(TheSession->httpauth_user, httpauth_user);
- strcpy(TheSession->httpauth_pass, httpauth_pass);
+ if (TheSession->httpauth_user != NULL){
+ FlushStrBuf(TheSession->httpauth_user);
+ StrBufAppendBufPlain(TheSession->httpauth_user, httpauth_user, -1, 0);
+ }
+ else TheSession->httpauth_user = NewStrBufPlain(httpauth_user, -1);
+ if (TheSession->httpauth_user != NULL){
+ FlushStrBuf(TheSession->httpauth_pass);
+ StrBufAppendBufPlain(TheSession->httpauth_pass, httpauth_user, -1, 0);
+ }
+ else TheSession->httpauth_pass = NewStrBufPlain(httpauth_user, -1);
+
+ if (TheSession->MigrateReadLineBuf != NULL)
+ FlushStrBuf(TheSession->MigrateReadLineBuf);
+ else TheSession->MigrateReadLineBuf = NewStrBuf();
+ TheSession->CLineBuf = NewStrBuf();
TheSession->hash_prefs = NewHash(1,NULL); /* Get a hash table for the user preferences */
pthread_mutex_init(&TheSession->SessionMutex, NULL);
pthread_mutex_lock(&SessionListMutex);
- TheSession->urlstrings = NULL;
- TheSession->vars = NULL;
TheSession->nonce = rand();
- TheSession->WBuf = NULL;
- TheSession->CLineBuf = NewStrBuf();
TheSession->next = SessionList;
TheSession->is_mobile = -1;
SessionList = TheSession;
pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
pthread_setspecific(MyConKey, (void *)TheSession);
+ if (TheSession->ImportantMsg == NULL)
+ TheSession->ImportantMsg = NewStrBuf();
TheSession->urlstrings = NewHash(1,NULL);
TheSession->vars = NewHash(1,NULL);
TheSession->http_sock = *sock;
}
go_selected_language(); /* set locale */
#endif
- session_loop(HTTPHeaders, ReqLine, ReqType, Buf); /* do transaction */
+ session_loop(HTTPHeaders, ReqLine, ReqType, Buf, &Pos); /* do transaction */
#ifdef ENABLE_NLS
stop_selected_language(); /* unset locale */
#endif
}
-void tmpl_nonce(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%ld",
(WCC != NULL)? WCC->nonce:0);
}
+void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
+}
+
+void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
+}
+
+
+
void
InitModule_CONTEXT
(void)
{
- RegisterNamespace("NONCE", 0, 0, tmpl_nonce, 0);
+ RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, CTX_NONE);
+ RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, CTX_NONE);
+ RegisterNamespace("NONCE", 0, 0, tmplput_nonce, 0);
}