From: Wilfried Goesgens Date: Thu, 24 Nov 2011 21:57:19 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel X-Git-Tag: v8.03~22 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=c6ccfb9bc8edb05fdbbccbcc7b0fbc621e287d0b;hp=fa8f7ffba529da2235c4da391fb2047025befed7;p=citadel.git Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel --- diff --git a/citadel/modules/openid/serv_openid_rp.c b/citadel/modules/openid/serv_openid_rp.c index c82a6c286..938e9d1cb 100644 --- a/citadel/modules/openid/serv_openid_rp.c +++ b/citadel/modules/openid/serv_openid_rp.c @@ -1,9 +1,9 @@ /* * This is an implementation of OpenID 1.1 Relying Party support, in stateless mode. * - * Copyright (c) 2007-2010 by the citadel.org team + * Copyright (c) 2007-2011 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. @@ -15,7 +15,7 @@ * * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "sysdep.h" @@ -74,7 +74,7 @@ void openid_cleanup_function(void) { struct CitContext *CCC = CC; /* CachedCitContext - performance boost */ if (CCC->openid_data != NULL) { - syslog(LOG_DEBUG, "Clearing OpenID session state\n"); + syslog(LOG_DEBUG, "Clearing OpenID session state"); Free_ctdl_openid((ctdl_openid **) &CCC->openid_data); } } @@ -125,11 +125,11 @@ int attach_openid(struct ctdluser *who, StrBuf *claimed_id) cdb_free(cdboi); if (fetched_usernum == who->usernum) { - syslog(LOG_INFO, "%s already associated; no action is taken\n", ChrPtr(claimed_id)); + syslog(LOG_INFO, "%s already associated; no action is taken", ChrPtr(claimed_id)); return(0); } else { - syslog(LOG_INFO, "%s already belongs to another user\n", ChrPtr(claimed_id)); + syslog(LOG_INFO, "%s already belongs to another user", ChrPtr(claimed_id)); return(3); } } @@ -170,7 +170,6 @@ void openid_purge(struct ctdluser *usbuf) { keys = NewHash(1, NULL); if (!keys) return; - cdb_rewind(CDB_OPENID); while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) { if (cdboi->len > sizeof(long)) { @@ -188,7 +187,7 @@ void openid_purge(struct ctdluser *usbuf) { HashPos = GetNewHashPos(keys, 0); while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0) { - syslog(LOG_DEBUG, "Deleting associated OpenID <%s>\n", (char*)Value); + syslog(LOG_DEBUG, "Deleting associated OpenID <%s>", (char*)Value); cdb_delete(CDB_OPENID, Value, strlen(Value)); /* note: don't free(Value) -- deleting the hash list will handle this for us */ } @@ -197,7 +196,6 @@ void openid_purge(struct ctdluser *usbuf) { } - /* * List the OpenIDs associated with the currently logged in account */ @@ -367,8 +365,6 @@ void cmd_oidc(char *argbuf) { } - - /* * Detach an OpenID from the currently logged in account */ @@ -421,11 +417,11 @@ int openid_create_user_via_sreg(StrBuf *claimed_id, HashList *sreg_keys) if (CC->logged_in) return(3); if (!GetHash(sreg_keys, "sreg.nickname", 13, (void *) &desired_name)) return(4); - syslog(LOG_DEBUG, "The desired account name is <%s>\n", desired_name); + syslog(LOG_DEBUG, "The desired account name is <%s>", desired_name); len = cutuserkey(desired_name); if (!CtdlGetUser(&CC->user, desired_name)) { - syslog(LOG_DEBUG, "<%s> is already taken by another user.\n", desired_name); + syslog(LOG_DEBUG, "<%s> is already taken by another user.", desired_name); memset(&CC->user, 0, sizeof(struct ctdluser)); return(5); } @@ -567,7 +563,7 @@ int fetch_http(StrBuf *url, StrBuf **target_buf) curl = curl_easy_init(); if (!curl) { - syslog(LOG_ALERT, "Unable to initialize libcurl.\n"); + syslog(LOG_ALERT, "Unable to initialize libcurl."); return(-1); } @@ -596,7 +592,7 @@ int fetch_http(StrBuf *url, StrBuf **target_buf) } res = curl_easy_perform(curl); if (res) { - syslog(LOG_DEBUG, "fetch_http() libcurl error %d: %s\n", res, errmsg); + syslog(LOG_DEBUG, "fetch_http() libcurl error %d: %s", res, errmsg); } curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url); StrBufPlain(url, effective_url, -1); @@ -644,8 +640,7 @@ void cmd_oids(char *argbuf) { oiddata->verified = 0; i = fetch_http(oiddata->claimed_id, &ReplyBuf); - syslog(LOG_DEBUG, "Normalized URL and Claimed ID is: %s\n", - ChrPtr(oiddata->claimed_id)); + syslog(LOG_DEBUG, "Normalized URL and Claimed ID is: %s", ChrPtr(oiddata->claimed_id)); if ((StrLength(ReplyBuf) > 0) && (i > 0)) { openid_delegate = NewStrBuf(); @@ -742,13 +737,13 @@ void cmd_oidf(char *argbuf) { if (len < 0) len = sizeof(thiskey) - 1; extract_token(thisdata, buf, 1, '|', sizeof thisdata); - syslog(LOG_DEBUG, "%s: ["SIZE_T_FMT"] %s\n", thiskey, strlen(thisdata), thisdata); + syslog(LOG_DEBUG, "%s: ["SIZE_T_FMT"] %s", thiskey, strlen(thisdata), thisdata); Put(keys, thiskey, len, strdup(thisdata), NULL); } /* Now that we have all of the parameters, we have to validate the signature against the server */ - syslog(LOG_DEBUG, "About to validate the signature...\n"); + syslog(LOG_DEBUG, "About to validate the signature..."); CURL *curl; CURLcode res; @@ -769,14 +764,14 @@ void cmd_oidf(char *argbuf) { CURLFORM_COPYNAME, "openid.mode", CURLFORM_COPYCONTENTS, "check_authentication", CURLFORM_END); - syslog(LOG_DEBUG, "%25s : %s\n", "openid.mode", "check_authentication"); + syslog(LOG_DEBUG, "%25s : %s", "openid.mode", "check_authentication"); if (GetHash(keys, "assoc_handle", 12, (void *) &o_assoc_handle)) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "openid.assoc_handle", CURLFORM_COPYCONTENTS, o_assoc_handle, CURLFORM_END); - syslog(LOG_DEBUG, "%25s : %s\n", "openid.assoc_handle", o_assoc_handle); + syslog(LOG_DEBUG, "%25s : %s", "openid.assoc_handle", o_assoc_handle); } if (GetHash(keys, "sig", 3, (void *) &o_sig)) { @@ -784,7 +779,7 @@ void cmd_oidf(char *argbuf) { CURLFORM_COPYNAME, "openid.sig", CURLFORM_COPYCONTENTS, o_sig, CURLFORM_END); - syslog(LOG_DEBUG, "%25s : %s\n", "openid.sig", o_sig); + syslog(LOG_DEBUG, "%25s : %s", "openid.sig", o_sig); } if (GetHash(keys, "signed", 6, (void *) &o_signed)) { @@ -792,7 +787,7 @@ void cmd_oidf(char *argbuf) { CURLFORM_COPYNAME, "openid.signed", CURLFORM_COPYCONTENTS, o_signed, CURLFORM_END); - syslog(LOG_DEBUG, "%25s : %s\n", "openid.signed", o_signed); + syslog(LOG_DEBUG, "%25s : %s", "openid.signed", o_signed); num_signed_values = num_tokens(o_signed, ','); for (i=0; iverified ? "succeeded" : "failed") ); + syslog(LOG_DEBUG, "Authentication %s.", (oiddata->verified ? "succeeded" : "failed") ); /* Respond to the client */ @@ -863,11 +858,11 @@ void cmd_oidf(char *argbuf) { if (CC->logged_in) { if (attach_openid(&CC->user, oiddata->claimed_id) == 0) { cprintf("attach\n"); - syslog(LOG_DEBUG, "OpenID attach succeeded\n"); + syslog(LOG_DEBUG, "OpenID attach succeeded"); } else { cprintf("fail\n"); - syslog(LOG_DEBUG, "OpenID attach failed\n"); + syslog(LOG_DEBUG, "OpenID attach failed"); } } @@ -884,7 +879,7 @@ void cmd_oidf(char *argbuf) { if (login_via_openid(oiddata->claimed_id) == 0) { cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password); logged_in_response(); - syslog(LOG_DEBUG, "Logged in using previously claimed OpenID\n"); + syslog(LOG_DEBUG, "Logged in using previously claimed OpenID"); } /* @@ -893,7 +888,7 @@ void cmd_oidf(char *argbuf) { */ else if (config.c_disable_newu) { cprintf("fail\n"); - syslog(LOG_DEBUG, "Creating user failed due to local policy\n"); + syslog(LOG_DEBUG, "Creating user failed due to local policy"); } /* @@ -902,7 +897,7 @@ void cmd_oidf(char *argbuf) { else if (openid_create_user_via_sreg(oiddata->claimed_id, keys) == 0) { cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password); logged_in_response(); - syslog(LOG_DEBUG, "Successfully auto-created new user\n"); + syslog(LOG_DEBUG, "Successfully auto-created new user"); } /* @@ -919,7 +914,7 @@ void cmd_oidf(char *argbuf) { else { cprintf("\n"); } - syslog(LOG_DEBUG, "The desired Simple Registration name is already taken.\n"); + syslog(LOG_DEBUG, "The desired Simple Registration name is already taken."); } } } diff --git a/citadel/server_main.c b/citadel/server_main.c index 55ec9f578..d1b2a4cd3 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -133,11 +133,12 @@ int main(int argc, char **argv) else if (!strncmp(argv[a], "-h", 2)) { relh=argv[a][2]!='/'; - if (!relh) safestrncpy(ctdl_home_directory, &argv[a][2], - sizeof ctdl_home_directory); - else - safestrncpy(relhome, &argv[a][2], - sizeof relhome); + if (!relh) { + safestrncpy(ctdl_home_directory, &argv[a][2], sizeof ctdl_home_directory); + } + else { + safestrncpy(relhome, &argv[a][2], sizeof relhome); + } home=1; } @@ -146,14 +147,7 @@ int main(int argc, char **argv) } else if (!strncmp(argv[a], "-t", 2)) { - if (freopen(&argv[a][2], "w", stderr) != stderr) - { - syslog(LOG_EMERG, - "unable to open your trace log [%s]: %s", - &argv[a][2], - strerror(errno)); - exit(1); - } + /* deprecated */ } else if (!strncmp(argv[a], "-D", 2)) { @@ -163,8 +157,9 @@ int main(int argc, char **argv) /* -r tells the server not to drop root permissions. don't use * this unless you know what you're doing. this should be * removed in the next release if it proves unnecessary. */ - else if (!strcmp(argv[a], "-r")) + else if (!strcmp(argv[a], "-r")) { drop_root_perms = 0; + } /* any other parameter makes it crash and burn */ else { @@ -172,7 +167,6 @@ int main(int argc, char **argv) "citserver " "[-lLogFacility] " "[-d] [-D] [-s] " - "[-tTraceFile] " "[-hHomeDir]\n" ); exit(1); @@ -316,7 +310,7 @@ int main(int argc, char **argv) /* * Load any server-side extensions available here. */ - syslog(LOG_INFO, "Initializing server extensions\n"); + syslog(LOG_INFO, "Initializing server extensions"); initialise_modules(0); @@ -353,18 +347,18 @@ int main(int argc, char **argv) #endif // HAVE_GETPWUID_R if (pwp == NULL) - syslog(LOG_CRIT, "WARNING: getpwuid(%ld): %s\n" + syslog(LOG_CRIT, "WARNING: getpwuid(%ld): %s" "Group IDs will be incorrect.\n", (long)CTDLUID, strerror(errno)); else { initgroups(pw.pw_name, pw.pw_gid); if (setgid(pw.pw_gid)) - syslog(LOG_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid, + syslog(LOG_CRIT, "setgid(%ld): %s", (long)pw.pw_gid, strerror(errno)); } - syslog(LOG_INFO, "Changing uid to %ld\n", (long)CTDLUID); + syslog(LOG_INFO, "Changing uid to %ld", (long)CTDLUID); if (setuid(CTDLUID) != 0) { - syslog(LOG_CRIT, "setuid() failed: %s\n", strerror(errno)); + syslog(LOG_CRIT, "setuid() failed: %s", strerror(errno)); } #if defined (HAVE_SYS_PRCTL_H) && defined (PR_SET_DUMPABLE) prctl(PR_SET_DUMPABLE, 1); diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index d315358be..d4c2f5080 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -622,10 +622,10 @@ void Put(HashList *Hash, const char *HKey, long HKLen, void *Data, DeleteHashDat /** oh, we're brand new... */ if (Hash->LookupTable[HashAt] == NULL) { InsertHashItem(Hash, HashAt, HashBinKey, HKey, HKLen, Data, DeleteIt); - }/** Insert After? */ + }/** Insert Before? */ else if (Hash->LookupTable[HashAt]->Key > HashBinKey) { InsertHashItem(Hash, HashAt, HashBinKey, HKey, HKLen, Data, DeleteIt); - }/** Insert before? */ + }/** Insert After? */ else if (Hash->LookupTable[HashAt]->Key < HashBinKey) { InsertHashItem(Hash, HashAt + 1, HashBinKey, HKey, HKLen, Data, DeleteIt); } @@ -769,7 +769,7 @@ int GetHashPosFromKey(HashList *Hash, const char *HKey, long HKLen, HashPos *At) return 0; } /** GOTCHA! */ - At->Position = Hash->LookupTable[HashAt]->Position; + At->Position = HashAt; return 1; } 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/ical_subst.c b/webcit/ical_subst.c index 5d6259d88..003ce11ec 100644 --- a/webcit/ical_subst.c +++ b/webcit/ical_subst.c @@ -1,11 +1,28 @@ -#include "webcit.h" +/* + * 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. + * + * 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" extern IcalEnumMap icalproperty_kind_map[]; - HashList *IcalComponentMap = NULL; +#if 0 void SortPregetMatter(HashList *Cals) { disp_cal *Cal; @@ -46,7 +63,6 @@ void SortPregetMatter(HashList *Cals) break; } - It = GetNewHashPos(Cals, 0); while (GetNextHashPos(Cals, It, &KLen, &Key, &vCal)) { i = 0; @@ -61,9 +77,8 @@ void SortPregetMatter(HashList *Cals) /****Cal->SortBy = icalcomponent_get_first_property(Cal->SortBy, SortMap[i++]->map); */ } } - - } +#endif void tmplput_ICalItem(StrBuf *Target, WCTemplputParams *TP) 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;