Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 22 Dec 2011 20:17:50 +0000 (21:17 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 22 Dec 2011 20:17:50 +0000 (21:17 +0100)
citadel/auth.c
citadel/config.c
citadel/configure.ac
citadel/control.c
citadel/ecrash.c
citadel/event_client.c
webcit/configure.ac
webcit/context_loop.c
webcit/dav_propfind.c
webcit/webcit.h

index f1062a84f923b1d9cbb3f48abdde7306ce03888c..501008633a09cd1b4ac7a947796f8d99a0dd323e 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1999-2009 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
index bc9a4128e9bd0b9c8cc5c0793797cee82d5a8bf1..a3809b28b44350db44adb7bc74ee3b704370cc1f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1987-2009 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
index aa19866afcc29fc0e4406bd655cd2d8b58760144..b5ba642550a9abe8742b9b045aaecfccc45a714c 100644 (file)
@@ -582,7 +582,7 @@ AC_CHECK_LIB(cares, ares_init,
 
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $SERVER_LIBS"
-dnl Check for libevent
+dnl Check for c-ares
 AC_CHECK_HEADER(ares.h,
        [AC_CHECK_LIB(cares, ares_init,
                [
@@ -600,7 +600,7 @@ CFLAGS="$saved_CFLAGS"
 
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $SERVER_LIBS"
-dnl Check for libevent
+dnl Check for libev
 AC_CHECK_HEADER(ev.h,
        [AC_CHECK_LIB(ev, libcitadel_version_string,
                [
@@ -617,6 +617,26 @@ AC_CHECK_HEADER(ev.h,
 )
 CFLAGS="$saved_CFLAGS"
 
+AC_MSG_CHECKING(Checking version of libev)
+AC_TRY_RUN([
+       #include <ev.h>
+       main() {
+               printf("libev is version %d.%d\n", ev_version_major(), ev_version_minor());
+               if (ev_version_major() >= 4) {
+                       exit(0);
+               }
+               exit(1);
+       }
+ ],
+               [
+                       AC_MSG_RESULT(This will do just fine, thank you)
+               ],
+               [ 
+                       AC_MSG_ERROR(Citadel requires a newer version of libev.  More info: http://www.citadel.org/doku.php/installation:start)
+               ]
+)
+
+
 # The big search for OpenSSL
 if test "$with_ssl" != "no"; then
        saved_LIBS="$LIBS"
index e71055c880492596fd8e5f404e1dc4169e8681f5..6ba0f8fe11cb45978c68c0aafe58a9a17fdc6922 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1987-2010 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
index 1c0514a02395b047b6a9fd3120a45649b18a713f..efe071ca5021a7759dabc59355833c76c0204345 100644 (file)
@@ -11,7 +11,7 @@
  *
  * vim: ts=4
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
index f2c44f11bfac520956fb6655b6dad65698563c6f..b5e54b9593047411e3780e60411c49ed2ed14ed8 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Copyright (c) 1998-2009 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
index e41910c47cb264cfd38674e43034a313926fa999..6819bb28a03ad48f3558cec5b3cfec23492aa434 100644 (file)
@@ -248,6 +248,23 @@ AC_CHECK_HEADER(libcitadel.h,
 )
 
 
+dnl Checks for the Expat XML parser.
+AC_CHECK_HEADER(expat.h,
+       [AC_CHECK_LIB(expat, XML_ParserCreateNS,
+               [
+                       LIBS="-lexpat $LIBS"
+               ],
+               [
+                       AC_MSG_ERROR(The Expat XML parser was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
+               ]
+       ,
+       )],
+       [
+               AC_MSG_ERROR(expat.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
+       ]
+)
+
+
 
 found_ssl=no
 # The big search for OpenSSL
index 8295fff75885ab992b873b9fddb1956af083744f..04c5cf0a3ea714ecb6ed959fa97d4aeb5d87e23a 100644 (file)
@@ -7,18 +7,12 @@
  * Copyright (c) 1996-2011 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
+ * modify it under the terms of the GNU General Public License version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "webcit.h"
@@ -267,7 +261,6 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
        void *vLine, *vHandler;
        const char *Pos = NULL;
 
-
        Hdr->HR.ReqLine = Line;
        /* The requesttype... GET, POST... */
        StrBufExtract_token(Buf, Hdr->HR.ReqLine, 0, ' ');
@@ -332,15 +325,23 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
        }
 
        if (Hdr->HR.Handler != NULL) {
-               if ((Hdr->HR.Handler->Flags & BOGUS) != 0)
+               if ((Hdr->HR.Handler->Flags & BOGUS) != 0) {
                        return 1;
+               }
                Hdr->HR.DontNeedAuth = (
                        ((Hdr->HR.Handler->Flags & ISSTATIC) != 0) ||
                        ((Hdr->HR.Handler->Flags & ANONYMOUS) != 0)
-                       );
+               );
        }
        else {
                Hdr->HR.DontNeedAuth = 1; /* Flat request? show him the login screen... */
+               StrBuf *NewLine = NewStrBufPlain(HKEY("GET /readfwd?go="));
+               StrBufUrlescAppend(NewLine, Buf, NULL);
+               StrBufAppendBufPlain(NewLine, HKEY(" HTTP/1.0"), 0);
+               syslog(LOG_DEBUG, "Replacing with: %s", ChrPtr(NewLine));
+               int return_value = ReadHttpSubject(Hdr, NewLine, Buf);
+               FreeStrBuf(&NewLine);
+               return return_value;
        }
 
        return 0;
index 96129045c98b8341573c0d2a61cee7d37ca45039..ebf145291cce8104f6c6b9b4018d3e44a2632dbc 100644 (file)
  *
  * Copyright (c) 2005-2011 by the citadel.org team
  *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "webcit.h"
@@ -80,7 +75,8 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
 
 /*
  * Guess room: if the full URL matches a room, list thats it. We also need to remember direct sub rooms.
- * if the URL is longer, we need to find the "best guess" so we can find the room we're in, and the rest of the URL will be uids and so on.
+ * if the URL is longer, we need to find the "best guess" so we can find the room we're in, and the rest
+ * of the URL will be uids and so on.
  */
        itfl = GetNewHashPos(WCC->Floors, 0);
        urlp = GetCount(WCC->Directory);
@@ -93,7 +89,6 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
                    (ThisFolder->Floor != WCC->CurrentFloor))
                        continue;
 
-
                if (ThisFolder->nRoomNameParts > 1) 
                {
                        /*TODO: is that number all right? */
@@ -432,6 +427,15 @@ void dav_collection_list(void)
 }
 
 
+void propfind_xml_start(void *data, const char *supplied_el, const char **attr) {
+       syslog(LOG_DEBUG, "<%s>", supplied_el);
+}
+
+void propfind_xml_end(void *data, const char *supplied_el) {
+       syslog(LOG_DEBUG, "</%s>", supplied_el);
+}
+
+
 
 /*
  * The pathname is always going to be /groupdav/room_name/msg_num
@@ -452,19 +456,52 @@ void dav_propfind(void)
        char datestring[256];
        time_t now;
 
-       syslog(LOG_DEBUG, "PROPFIND\n\033[31m%s\033[0m", ChrPtr(WCC->upload));
-
        now = time(NULL);
        http_datestring(datestring, sizeof datestring, now);
 
+       int parse_success = 0;
+       XML_Parser xp = XML_ParserCreateNS(NULL, '|');
+       if (xp) {
+               // XML_SetUserData(xp, XXX);
+               XML_SetElementHandler(xp, propfind_xml_start, propfind_xml_end);
+               // XML_SetCharacterDataHandler(xp, xrds_xml_chardata);
+
+               const char *req = ChrPtr(WCC->upload);
+               if (req) {
+                       req = strchr(req, '<');                 /* hunt for the first tag */
+               }
+               if (!req) {
+                       req = "ERROR";                          /* force it to barf */
+               }
+
+               i = XML_Parse(xp, req, strlen(req), 1);
+               if (!i) {
+                       syslog(LOG_DEBUG, "XML_Parse() failed: %s", XML_ErrorString(XML_GetErrorCode(xp)));
+                       XML_ParserFree(xp);
+                       parse_success = 0;
+               }
+               else {
+                       parse_success = 1;
+               }
+       }
+
+       if (!parse_success) {
+               hprintf("HTTP/1.1 500 Internal Server Error\r\n");
+               dav_common_headers();
+               hprintf("Date: %s\r\n", datestring);
+               hprintf("Content-Type: text/plain\r\n");
+               wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__ , __LINE__ );
+               end_burst();
+               return;
+       }
+
        dav_roomname = NewStrBuf();
        dav_uid = NewStrBuf();
        StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
        StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
 
        /*
-        * If the room name is blank, the client is requesting a
-        * folder list.
+        * If the room name is blank, the client is requesting a folder list.
         */
        if (StrLength(dav_roomname) == 0) {
                dav_collection_list();
@@ -482,9 +519,7 @@ void dav_propfind(void)
                dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf("Content-Type: text/plain\r\n");
-               wc_printf("There is no folder called \"%s\" on this server.\r\n",
-                       ChrPtr(dav_roomname)
-               );
+               wc_printf("There is no folder called \"%s\" on this server.\r\n", ChrPtr(dav_roomname));
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
@@ -571,16 +606,19 @@ void dav_propfind(void)
        dav_common_headers();
        hprintf("Date: %s\r\n", datestring);
        hprintf("Content-type: text/xml\r\n");
-       if (DisableGzip || (!WCC->Hdr->HR.gzip_ok))     
+       if (DisableGzip || (!WCC->Hdr->HR.gzip_ok)) {
                hprintf("Content-encoding: identity\r\n");
-
+       }
        begin_burst();
 
        wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-               "<multistatus xmlns=\"DAV:\" xmlns:G=\"http://groupdav.org/\">"
+               "<multistatus "
+                       "xmlns=\"DAV:\" "
+                       "xmlns:G=\"http://groupdav.org/\" "
+                       "xmlns:CALDAV=\"urn:ietf:params:xml:ns:caldav\""
+               ">"
        );
 
-
        /* Transmit the collection resource (FIXME check depth and starting point) */
        wc_printf("<response>");
 
@@ -596,11 +634,14 @@ void dav_propfind(void)
        wc_printf("<displayname>");
        escputs(ChrPtr(WCC->CurRoom.name));
        wc_printf("</displayname>");
-       wc_printf("<resourcetype><collection/>");
 
+       wc_printf("<owner/>");          /* empty owner ought to be legal; see rfc3744 section 5.1 */
+
+       wc_printf("<resourcetype><collection/>");
        switch(WCC->CurRoom.defview) {
                case VIEW_CALENDAR:
                        wc_printf("<G:vevent-collection />");
+                       wc_printf("<CALDAV:calendar />");
                        break;
                case VIEW_TASKS:
                        wc_printf("<G:vtodo-collection />");
@@ -609,8 +650,8 @@ void dav_propfind(void)
                        wc_printf("<G:vcard-collection />");
                        break;
        }
-
        wc_printf("</resourcetype>");
+
        /* FIXME get the mtime
        wc_printf("<getlastmodified>");
                escputs(datestring);
@@ -637,6 +678,7 @@ void dav_propfind(void)
 
        if (num_msgs > 0) for (i=0; i<num_msgs; ++i) {
 
+               syslog(LOG_DEBUG, "PROPFIND enumerating message # %ld", msgs[i]);
                strcpy(uid, "");
                now = (-1);
                serv_printf("MSG0 %ld|3", msgs[i]);
index bfad761078615c157be9d30a51d39be0566b6296..de01cf42b156ab51d80c66909094660767bc5362 100644 (file)
@@ -52,6 +52,7 @@
 #include <signal.h>
 #include <syslog.h>
 #include <sys/utsname.h>
+#include <expat.h>
 #include <libcitadel.h>
 
 #ifdef HAVE_ICONV