$Log$
+Revision 211.15 2000/04/20 02:42:23 ajc
+* tcp_sockets.c: changed memcpy() to memset() in tcp_connectsock; this was
+ crashing every session, every time. (?)
+* End the session after displaying robots.txt or nocookies.html, to prevent
+ big session logjams when either of these conditions are met
+
Revision 211.14 2000/04/15 15:43:46 nbryant
* warning fix for 64-bit compile on ultrasparc. (kids don't try this at home,
64-bit gcc on sparc is evil)
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
+
}
+/*
+ * Disconnect from the Citadel server, and end this WebCit session
+ */
+void end_webcit_session(void) {
+ serv_puts("QUIT");
+ close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->killthis = 1;
+}
+
+
void do_logout(void)
{
char buf[256];
"<A HREF=\"javascript:window.close();\">Close window</A>"
"</CENTER>\n");
wDumpContent(2);
- serv_puts("QUIT");
- close(WC->serv_sock);
- WC->serv_sock = (-1);
- WC->killthis = 1;
+ end_webcit_session();
}
-
-
/*
* validate new users
*/
* robots.txt file...
*/
if (!strncasecmp(buf, "/robots.txt", 11)) {
- strcpy(req->line, "GET /static/robots.txt HTTP/1.0");
+ strcpy(req->line, "GET /static/robots.txt"
+ "?force_close_session=yes HTTP/1.0");
}
/* Do the non-root-cookie check now. */
else if ( (strcmp(buf, "/")) && (got_cookie == 0)) {
- strcpy(req->line, "GET /static/nocookies.html HTTP/1.0");
+ strcpy(req->line, "GET /static/nocookies.html"
+ "?force_close_session=yes HTTP/1.0");
}
*/
-
/*
* Bind to the session and perform the transaction
*/
struct sockaddr_in sin;
int s;
- memcpy(&sin, 0, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
pse = getservbyname(service, "tcp");
#include <signal.h>
#include "webcit.h"
+/*
+ * String to unset the cookie.
+ * Any date "in the past" will work, so I chose my birthday, right down to
+ * the exact minute. :)
+ */
+static char *unset = "; expires=28-May-1971 18:10:00 GMT";
void unescape_input(char *buf)
{
*/
void output_headers(int controlcode)
{
- static char *unset = "; expires=28-May-1971 18:10:00 GMT";
char cookie[256];
int print_standard_html_head = 0;
int refresh30 = 0;
stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
WC->wc_password, WC->wc_roomname);
if (print_standard_html_head == 2) {
- wprintf("X-WebCit-Session: close\n");
wprintf("Set-cookie: webcit=%s\n", unset);
} else {
wprintf("Set-cookie: webcit=%s\n", cookie);
}
fclose(fp);
}
+ if (!strcasecmp(bstr("force_close_session"), "yes")) {
+ end_webcit_session();
+ }
}
/*
}
else {
/* tcp socket */
+ fprintf(stderr, "FIXME tcp conn\n");
WC->serv_sock = tcp_connectsock(c_host, c_port);
}
/* $Id$ */
+#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
+
#define SLEEPING 180 /* TCP connection timeout */
#define WEBCIT_TIMEOUT 900 /* WebCit session timeout */
#define PORT_NUM 2000 /* port number to listen on */
void *cbcontent, char *cbtype, size_t cblength)
);
void fmt_date(char *buf, time_t thetime);
+void end_webcit_session(void);