* Began laying the groundwork for http-authenticated GroupDAV sessions.
authorArt Cancro <ajc@citadel.org>
Mon, 24 Jan 2005 03:37:48 +0000 (03:37 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 24 Jan 2005 03:37:48 +0000 (03:37 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/context_loop.c
webcit/groupdav_main.c [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h

index bfab413506cf92593942100f098a7c83dc3ccd7d..370883887ce2fadcb4fbd7ef18c76130424b44c9 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 528.17  2005/01/24 03:37:48  ajc
+* Began laying the groundwork for http-authenticated GroupDAV sessions.
+
 Revision 528.16  2005/01/22 22:50:51  ajc
 * removed descriptions in non-main menus
 
@@ -2212,3 +2215,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index b75b1a66a0e74ae0378be30ca16099c83b3436ef..1edcdf1082f262e93d97948f2a63e79478ea5a8c 100644 (file)
@@ -37,6 +37,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \
        mime_parser.o graphics.o netconf.o siteconfig.o subst.o \
        calendar.o calendar_tools.o calendar_view.o event.o \
        availability.o iconbar.o crypto.o inetconf.o notes.o \
+       groupdav_main.o \
        $(LIBOBJS)
        $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \
        webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \
@@ -45,6 +46,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \
        mime_parser.o graphics.o netconf.o preferences.o html2html.o \
        summary.o calendar.o calendar_tools.o calendar_view.o event.o \
        availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \
+       groupdav_main.o \
        $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webserver
 
 .c.o:
index e9ea3772ac210c8bc348c62a564ce6945b1bc2b1..9667c7d08b0607122115cd80329aca01192d3219 100644 (file)
@@ -327,6 +327,7 @@ void context_loop(int sock)
                && (strncasecmp(buf, "/listsub", 8))
                && (strncasecmp(buf, "/freebusy", 9))
                && (strncasecmp(buf, "/do_logout", 10))
+               && (strncasecmp(buf, "/groupdav", 9))
                && (got_cookie == 0)) {
                strcpy(req->line, "GET /static/nocookies.html"
                                "?force_close_session=yes HTTP/1.0");
diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c
new file mode 100644 (file)
index 0000000..bd7d51d
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * $Id$
+ *
+ * Entry point for GroupDAV functions
+ *
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <limits.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <time.h>
+#include "webcit.h"
+#include "webserver.h"
+
+void groupdav_main(char *cmd) {
+
+       if (!WC->logged_in) {
+               wprintf(
+                       "HTTP/1.1 401 Authorization Required\n"
+                       "WWW-Authenticate: Basic realm=\"GroupDAV\"\n"
+                       "Connection: close\n"
+               );
+               output_headers(0, 0, 0, 0, 0, 0, 0);
+               wprintf("Content-Type: text/plain\n");
+               wprintf("\n");
+               wprintf("GroupDAV sessions require HTTP authentication.\n");
+               wDumpContent(0);
+       }
+
+       output_static("smiley.gif");    /* FIXME */
+}
index 3206e503ee08e5a8c6cc5364a6a7f014cc52f2bc..8de0921483d3e8b0161de9e023e4f01aea37789f 100644 (file)
@@ -815,6 +815,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp,
 void session_loop(struct httprequest *req)
 {
        char cmd[SIZ];
+       char method[SIZ];
        char action[SIZ];
        char buf[SIZ];
        int a, b;
@@ -851,6 +852,7 @@ void session_loop(struct httprequest *req)
 
        strcpy(cmd, hptr->line);
        hptr = hptr->next;
+       extract_token(method, cmd, 0, ' ');
        extract_action(action, cmd);
 
        while (hptr != NULL) {
@@ -888,18 +890,9 @@ void session_loop(struct httprequest *req)
                                ContentType, ContentLength);
                body_start = strlen(content);
 
-/***** old version
-               BytesRead = 0;
-               while (BytesRead < ContentLength) {
-                       a=read(WC->http_sock, &content[BytesRead+body_start],
-                               ContentLength - BytesRead);
-                       if (a <= 0) BytesRead = ContentLength;
-                       else BytesRead += a;
-               }
-*******/
-
-               /* Now we're daring and read it all at once. */
-               client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
+               /* Be daring and read it all at once. */
+               client_read(WC->http_sock, &content[BytesRead+body_start],
+                       ContentLength);
 
                if (!strncasecmp(ContentType,
                              "application/x-www-form-urlencoded", 33)) {
@@ -993,6 +986,14 @@ void session_loop(struct httprequest *req)
                goto SKIP_ALL_THIS_CRAP;
        }
 #endif
+       /* 
+        * The GroupDAV stuff relies on HTTP authentication instead of
+        * our session's authentication.
+        */
+       if (!strncasecmp(action, "groupdav", 8)) {
+               groupdav_main(cmd);
+               goto SKIP_ALL_THIS_CRAP;
+       }
 
        check_for_instant_messages();
 
index 82301a26dabd0f21a1940d1204e0554c15a47274..c131e9b815b577682a138ffc2d010a2f335ab270 100644 (file)
@@ -228,6 +228,8 @@ struct wcsession {
        char ImportantMessage[SIZ];
        char last_chat_user[SIZ];
        int ctdl_pid;                   /* Session ID on the Citadel server */
+       char httpauth_user[SIZ];        /* only for GroupDAV sessions */
+       char httpauth_pass[SIZ];        /* only for GroupDAV sessions */
 };
 
 #define extract(dest,source,parmnum)   extract_token(dest,source,parmnum,'|')
@@ -494,3 +496,5 @@ extern char *ascmonths[];
 #define VIEW_CALENDAR          3       /* Calendar view */
 #define VIEW_TASKS             4       /* Tasks view */
 #define VIEW_NOTES             5       /* Notes view */
+
+void groupdav_main(char *);