diff options
Diffstat (limited to '')
39 files changed, 218 insertions, 108 deletions
diff --git a/sca-cpp/trunk/modules/http/Makefile.am b/sca-cpp/trunk/modules/http/Makefile.am index 161279a73f..4fd7cc0818 100644 --- a/sca-cpp/trunk/modules/http/Makefile.am +++ b/sca-cpp/trunk/modules/http/Makefile.am @@ -76,7 +76,7 @@ if WANT_MODSECURITY modsecurity.prefix: $(top_builddir)/config.status echo ${MODSECURITY_PREFIX} >modsecurity.prefix -dist_modsecurity_SCRIPTS = mod-security-conf +dist_modsecurity_SCRIPTS = mod-security-conf mod-security-audit-conf modsecurity_DATA = modsecurity.prefix modsecuritydir = $(prefix)/modules/http diff --git a/sca-cpp/trunk/modules/http/http-test b/sca-cpp/trunk/modules/http/http-test index 73cfe700a6..956b13a516 100755 --- a/sca-cpp/trunk/modules/http/http-test +++ b/sca-cpp/trunk/modules/http/http-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ./httpd-conf tmp localhost 8090 htdocs ./httpd-event-conf tmp ./httpd-start tmp diff --git a/sca-cpp/trunk/modules/http/http.hpp b/sca-cpp/trunk/modules/http/http.hpp index eb7a8d506f..e8c88f8a83 100644 --- a/sca-cpp/trunk/modules/http/http.hpp +++ b/sca-cpp/trunk/modules/http/http.hpp @@ -371,7 +371,7 @@ template<typename R> const failable<list<R> > apply(const list<list<string> >& h // Setup the CURL session const failable<CURL*> fch = setup(url, cs); if (!hasContent(fch)) - return mkfailure<list<R>>(reason(fch)); + return mkfailure<list<R>>(fch); CURL* ch = content(fch); // Set the request headers @@ -440,19 +440,19 @@ const failable<value> evalExpr(const value& expr, const string& url, const CURLS js::JSContext cx; const failable<list<string> > jsreq = json::jsonRequest(1, car<value>(expr), cdr<value>(expr), cx); if (!hasContent(jsreq)) - return mkfailure<value>(reason(jsreq)); + return mkfailure<value>(jsreq); // POST it to the URL const list<string> h = mklist<string>("Content-Type: application/json-rpc"); const failable<list<list<string> > > res = apply<list<string> >(mklist<list<string> >(h, content(jsreq)), rcons<string>, list<string>(), url, "POST", cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); // Parse and return JSON-RPC result const failable<value> rval = json::jsonResultValue(cadr<list<string> >(content(res)), cx); debug(rval, "http::evalExpr::result"); if (!hasContent(rval)) - return mkfailure<value>(reason(rval)); + return mkfailure<value>(rval); return content(rval); } @@ -513,7 +513,7 @@ const failable<value> getcontent(const string& url, const CURLSession& cs) { // Get the contents of the resource at the given URL const failable<list<list<string> > > res = get<list<string>>(rcons<string>, list<string>(), url, cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); const list<string> ls(reverse(cadr(content(res)))); // Return the content as a list of values @@ -597,7 +597,7 @@ const failable<value> get(const string& url, const CURLSession& cs) { // Get the contents of the resource at the given URL const failable<list<list<string> > > res = get<list<string> >(rcons<string>, list<string>(), url, cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); // Parse the returned content return responseValue(content(res)); @@ -608,7 +608,7 @@ const failable<value> get(const string& url, const CURLSession& cs) { */ const failable<list<list<string> > > writeRequest(const failable<list<string> >& ls, const string& ct) { if (!hasContent(ls)) - return mkfailure<list<list<string> > >(reason(ls)); + return mkfailure<list<list<string> > >(ls); const list<list<string> > req = mklist<list<string> >(mklist<string>(string("Content-Type: ") + ct), content(ls)); debug(req, "http::writeRequest::req"); return req; @@ -695,13 +695,13 @@ const failable<value> post(const value& val, const string& url, const CURLSessio // Convert value to a content request const failable<list<list<string> > > req = contentRequest(val, url); if (!hasContent(req)) - return mkfailure<value>(reason(req)); + return mkfailure<value>(req); debug(content(req), "http::post::input"); // POST it to the URL const failable<list<list<string> > > res = apply<list<string>>(content(req), rcons<string>, list<string>(), url, "POST", cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); // Return the new entry id from the HTTP location header, if any const string loc = location(car(content(res))); @@ -724,13 +724,13 @@ const failable<value> put(const value& val, const string& url, const CURLSession // Convert value to a content request const failable<list<list<string> > > req = contentRequest(val, url); if (!hasContent(req)) - return mkfailure<value>(reason(req)); + return mkfailure<value>(req); debug(content(req), "http::put::input"); // PUT it to the URL const failable<list<list<string> > > res = apply<list<string> >(content(req), rcons<string>, list<string>(), url, "PUT", cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); debug(true, "http::put::result"); return value(true); @@ -745,13 +745,13 @@ const failable<value> patch(const value& val, const string& url, const CURLSessi // Convert value to a content request const failable<list<list<string> > > req = contentRequest(val, url); if (!hasContent(req)) - return mkfailure<value>(reason(req)); + return mkfailure<value>(req); debug(content(req), "http::patch::input"); // PATCH it to the URL const failable<list<list<string> > > res = apply<list<string> >(content(req), rcons<string>, list<string>(), url, "PATCH", cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); debug(true, "http::patch::result"); return value(true); @@ -766,7 +766,7 @@ const failable<value, string> del(const string& url, const CURLSession& cs) { const list<list<string> > req = mklist(list<string>(), list<string>()); const failable<list<list<string> > > res = apply<list<string> >(req, rcons<string>, list<string>(), url, "DELETE", cs); if (!hasContent(res)) - return mkfailure<value>(reason(res)); + return mkfailure<value>(res); debug(true, "http::delete::result"); return value(true); @@ -805,7 +805,7 @@ const failable<bool> connect(const string& url, CURLSession& cs) { // Setup the CURL session const failable<CURL*> fch = setup(url, cs); if (!hasContent(fch)) - return mkfailure<bool>(reason(fch)); + return mkfailure<bool>(fch); CURL* ch = content(fch); // Connect diff --git a/sca-cpp/trunk/modules/http/httpd-test b/sca-cpp/trunk/modules/http/httpd-test index 2b151d0e12..ab6ab5ad41 100755 --- a/sca-cpp/trunk/modules/http/httpd-test +++ b/sca-cpp/trunk/modules/http/httpd-test @@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h curl_prefix=`cat $here/../http/curl.prefix` # Setup +rm -rf tmp ./httpd-conf tmp localhost 8090 htdocs ./httpd-event-conf tmp ./httpd-start tmp diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index 718ed6e52b..7147e8839c 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -402,7 +402,7 @@ const list<string> read(request_rec* r) { */ const failable<int> writeResult(const failable<list<string> >& ls, const string& ct, request_rec* r) { if (!hasContent(ls)) - return mkfailure<int>(reason(ls)); + return mkfailure<int>(ls); ostringstream os; write(content(ls), os); const string ob(str(os)); @@ -437,8 +437,10 @@ const failable<int> writeResult(const failable<list<string> >& ls, const string& */ const int reportStatus(const failable<int>& rc) { debug(rc, "httpd::reportStatus::rc"); - if (!hasContent(rc)) - return HTTP_INTERNAL_SERVER_ERROR; + if (!hasContent(rc)) { + const int r = rcode(rc); + return r == -1 ? HTTP_INTERNAL_SERVER_ERROR : r; + } return content(rc); } @@ -725,7 +727,7 @@ const bool debugRequest(request_rec* r, const string& msg) { return true; } -#define debug_httpdRequest(r, msg) if (debug_islogging()) httpd::debugRequest(r, msg) +#define debug_httpdRequest(r, msg) do { if (debug_islogging()) httpd::debugRequest(r, msg); } while(0) #else diff --git a/sca-cpp/trunk/modules/http/mod-security-audit-conf b/sca-cpp/trunk/modules/http/mod-security-audit-conf new file mode 100755 index 0000000000..5914bd1df4 --- /dev/null +++ b/sca-cpp/trunk/modules/http/mod-security-audit-conf @@ -0,0 +1,44 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Generate a minimal mod-security audit configuration. +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +mkdir -p $1 +root=`echo "import os; print os.path.realpath('$1')" | python` + +mkdir -p $root/tmp + +cat >>$root/conf/mod-security.conf <<EOF +# Generated by: mod-security-audit-conf $* +# Enable mod-security audit log +SecAuditEngine RelevantOnly +SecAuditLogRelevantStatus "^(?:5|4(?!04))" +SecAuditLogParts ABIJDEFHKZ +SecAuditLogType Serial +Include conf/mod-security-audit-log.conf + +EOF + +# Configure audit logging +cat >$root/conf/mod-security-audit-log.conf <<EOF +# Generated by: mod-security-audit-conf $* +SecAuditLog $root/logs/secaudit_log + +EOF + diff --git a/sca-cpp/trunk/modules/http/mod-security-conf b/sca-cpp/trunk/modules/http/mod-security-conf index fdc4d8e24d..4d978a01cb 100755 --- a/sca-cpp/trunk/modules/http/mod-security-conf +++ b/sca-cpp/trunk/modules/http/mod-security-conf @@ -81,8 +81,8 @@ IH %{MULTIPART_FILE_LIMIT_EXCEEDED}'" SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" "phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'" # Avoid a potential RegEx DoS condition -SecPcreMatchLimit 10000 -SecPcreMatchLimitRecursion 10000 +SecPcreMatchLimit 50000 +SecPcreMatchLimitRecursion 50000 SecRule TX:/^MSC_/ "!@streq 0" "phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'" # Detect slow DoS attacks @@ -100,13 +100,6 @@ SecResponseBodyLimitAction ProcessPartial SecTmpDir $root/tmp/ SecDataDir $root/tmp/ -# Enable mod-security audit log -SecAuditEngine RelevantOnly -SecAuditLogRelevantStatus "^(?:5|4(?!04))" -SecAuditLogParts ABIJDEFHKZ -SecAuditLogType Serial -Include conf/mod-security-log.conf - # Use & as application/x-www-form-urlencoded parameter separator SecArgumentSeparator & @@ -120,8 +113,8 @@ setvar:tx.critical_anomaly_score=5, \ setvar:tx.error_anomaly_score=4, \ setvar:tx.warning_anomaly_score=3, \ setvar:tx.notice_anomaly_score=2" -SecAction "phase:1,id:'981208',t:none,nolog,pass,setvar:tx.inbound_anomaly_score_level=5" -SecAction "phase:1,id:'981209',t:none,nolog,pass,setvar:tx.outbound_anomaly_score_level=4" +SecAction "phase:1,id:'981208',t:none,nolog,pass,setvar:tx.inbound_anomaly_score_level=10" +SecAction "phase:1,id:'981209',t:none,nolog,pass,setvar:tx.outbound_anomaly_score_level=8" # Paranoid mode SecAction "phase:1,id:'981210',t:none,nolog,pass,setvar:tx.paranoid_mode=0" @@ -186,12 +179,6 @@ Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_25_cc_known.conf Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_42_comment_spam.conf Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_47_skip_outbound_checks.conf Include ${modsecurity_prefix}/optional_rules/modsecurity_crs_55_application_defects.conf -EOF - -# Configure audit logging -cat >$root/conf/mod-security-log.conf <<EOF -# Generated by: mod-security-conf $* -SecAuditLog $root/logs/modsec_audit_log EOF diff --git a/sca-cpp/trunk/modules/http/proxy-test b/sca-cpp/trunk/modules/http/proxy-test index 9f3d248fdf..0333dd280b 100755 --- a/sca-cpp/trunk/modules/http/proxy-test +++ b/sca-cpp/trunk/modules/http/proxy-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ./httpd-conf tmp localhost 8091/8090 htdocs ./httpd-event-conf tmp ./httpd-start tmp diff --git a/sca-cpp/trunk/modules/java/mod-java.cpp b/sca-cpp/trunk/modules/java/mod-java.cpp index 8c25f6f8ef..d96861cc6d 100644 --- a/sca-cpp/trunk/modules/java/mod-java.cpp +++ b/sca-cpp/trunk/modules/java/mod-java.cpp @@ -73,6 +73,8 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri } if (contains(itype, ".cpp")) return modcpp::evalImplementation(path, impl, px); + if (contains(itype, ".widget")) + return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false); return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype); } diff --git a/sca-cpp/trunk/modules/java/mod-java.hpp b/sca-cpp/trunk/modules/java/mod-java.hpp index e7da06e930..b68f17aa3f 100644 --- a/sca-cpp/trunk/modules/java/mod-java.hpp +++ b/sca-cpp/trunk/modules/java/mod-java.hpp @@ -52,7 +52,7 @@ struct applyImplementation { const value expr = append<value>(params, px); debug(expr, "modeval::java::applyImplementation::input"); const failable<value> res = java::evalClass(jr, expr, impl); - const value val = !hasContent(res)? mklist<value>(value(), reason(res)) : mklist<value>(content(res)); + const value val = !hasContent(res)? mklist<value>(value(), reason(res), rcode(res)) : mklist<value>(content(res)); debug(val, "modeval::java::applyImplementation::result"); return val; } @@ -66,7 +66,7 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri const string cn(attributeValue("class", impl)); const failable<java::JavaClass> jc = java::readClass(jr, path, cn); if (!hasContent(jc)) - return mkfailure<lambda<value(const list<value>&)> >(reason(jc)); + return mkfailure<lambda<value(const list<value>&)> >(jc); return lambda<value(const list<value>&)>(applyImplementation(content(jc), px, jr)); } diff --git a/sca-cpp/trunk/modules/java/server-test b/sca-cpp/trunk/modules/java/server-test index 40e52d7153..0b45649ace 100755 --- a/sca-cpp/trunk/modules/java/server-test +++ b/sca-cpp/trunk/modules/java/server-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 ../server/htdocs ../server/server-conf tmp ./java-conf tmp diff --git a/sca-cpp/trunk/modules/java/wiring-test b/sca-cpp/trunk/modules/java/wiring-test index 941a75bc32..dd865c4c66 100755 --- a/sca-cpp/trunk/modules/java/wiring-test +++ b/sca-cpp/trunk/modules/java/wiring-test @@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h curl_prefix=`cat $here/../http/curl.prefix` # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 ../server/htdocs ../server/server-conf tmp ./java-conf tmp diff --git a/sca-cpp/trunk/modules/js/eval.hpp b/sca-cpp/trunk/modules/js/eval.hpp index 149716e4ca..21fa274d2c 100644 --- a/sca-cpp/trunk/modules/js/eval.hpp +++ b/sca-cpp/trunk/modules/js/eval.hpp @@ -36,7 +36,7 @@ #ifdef WANT_MAINTAINER_WARNINGS #pragma GCC diagnostic warning "-Wunused-parameter" #pragma GCC diagnostic warning "-Wsign-compare" -#pragma GCC diagnostic ignored "-Wredundant-decls" +#pragma GCC diagnostic warning "-Wredundant-decls" #endif #include "string.hpp" #include "list.hpp" diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp index 39c56b6863..85579c1b28 100644 --- a/sca-cpp/trunk/modules/json/json.hpp +++ b/sca-cpp/trunk/modules/json/json.hpp @@ -72,7 +72,7 @@ const failable<list<value> > readJSON(const list<string>& ilist, const js::JSCon if(!JS_FinishJSONParse(cx, parser, JSVAL_NULL)) return mkfailure<list<value> >("JS_FinishJSONParse failed"); if(!hasContent(consumed)) - return mkfailure<list<value> >(reason(consumed)); + return mkfailure<list<value> >(consumed); return list<value>(js::jsValToValue(val, cx)); } @@ -149,7 +149,7 @@ const failable<list<string> > jsonResult(const value& id, const value& val, js:: const failable<value> jsonResultValue(const list<string>& s, js::JSContext& cx) { const failable<list<value> > jsres = json::readJSON(s, cx); if (!hasContent(jsres)) - return mkfailure<value>(reason(jsres)); + return mkfailure<value>(jsres); const list<value> rval(cadr<value>(elementsToValues(content(jsres)))); const value val = cadr(rval); if (isList(val) && !js::isJSArray(val)) diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp index b927315393..eb23443491 100644 --- a/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp +++ b/sca-cpp/trunk/modules/oauth/mod-oauth1.cpp @@ -235,7 +235,7 @@ const failable<int> authorize(const list<list<value> >& args, request_rec* r, co // Store the request token in memcached const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1Token", cadr(tv)), cadr(sv), mc); if (!hasContent(prc)) - return mkfailure<int>(reason(prc)); + return mkfailure<int>(prc); // Redirect to the authorize URI const string authuri = httpd::unescape(cadr(auth)) + string("?") + http::queryString(mklist<list<value> >(tv)); @@ -327,7 +327,7 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r, // Retrieve the request token from memcached const failable<value> sv = memcache::get(mklist<value>("tuscanyOAuth1Token", cadr(tv)), mc); if (!hasContent(sv)) - return mkfailure<int>(reason(sv)); + return mkfailure<int>(sv); // Build and sign access token request URI const string tokuri = httpd::unescape(cadr(tok)) + string("?") + http::queryString(mklist<list<value> >(vv)); @@ -374,13 +374,13 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r, // Retrieve the user info from the profile const failable<list<value> > iv = profileUserInfo(cadr(cid), profres); if (!hasContent(iv)) - return mkfailure<int>(reason(iv)); + return mkfailure<int>(iv); // Store user info in memcached keyed by session ID const value sid = string("OAuth1_") + mkrand(); const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1", sid), content(iv), mc); if (!hasContent(prc)) - return mkfailure<int>(reason(prc)); + return mkfailure<int>(prc); // Send session ID to the client in a cookie debug(c_str(openauth::cookie("TuscanyOAuth1", sid, httpd::hostName(r))), "modoauth1::access_token::setcookie"); diff --git a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp index 05ad77d646..cbece191aa 100644 --- a/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp +++ b/sca-cpp/trunk/modules/oauth/mod-oauth2.cpp @@ -222,7 +222,7 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r, const value tval = mklist<value>(string("application/x-www-form-urlencoded;charset=UTF-8"), mklist<value>(tqs)); const failable<value> ftr = http::post(tval, turi, *(cs)); if (!hasContent(ftr)) - return mkfailure<int>(reason(ftr)); + return mkfailure<int>(ftr); const value tr = content(ftr); debug(tr, "modoauth2::access_token::response"); if (!isList(tr) || isNil(tr)) @@ -247,13 +247,13 @@ const failable<int> accessToken(const list<list<value> >& args, request_rec* r, // Retrieve the user info from the profile const failable<list<value> > iv = profileUserInfo(cadr(cid), content(profres)); if (!hasContent(iv)) - return mkfailure<int>(reason(iv)); + return mkfailure<int>(iv); // Store user info in memcached keyed by session ID const value sid = string("OAuth2_") + mkrand(); const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth2", sid), content(iv), mc); if (!hasContent(prc)) - return mkfailure<int>(reason(prc)); + return mkfailure<int>(prc); // Send session ID to the client in a cookie debug(c_str(openauth::cookie("TuscanyOAuth2", sid, httpd::hostName(r))), "modoauth2::access_token::setcookie"); diff --git a/sca-cpp/trunk/modules/oauth/start-mixed-test b/sca-cpp/trunk/modules/oauth/start-mixed-test index 11bba42ef0..e5a8837354 100755 --- a/sca-cpp/trunk/modules/oauth/start-mixed-test +++ b/sca-cpp/trunk/modules/oauth/start-mixed-test @@ -24,6 +24,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` # Setup +rm -rf tmp ../../components/cache/memcached-start tmp 11212 ../../components/cache/memcached-start tmp 11213 diff --git a/sca-cpp/trunk/modules/oauth/start-test b/sca-cpp/trunk/modules/oauth/start-test index 21e1e005bd..8fc41cdb9a 100755 --- a/sca-cpp/trunk/modules/oauth/start-test +++ b/sca-cpp/trunk/modules/oauth/start-test @@ -21,6 +21,7 @@ # 127.0.0.1 www.example.com # Setup +rm -rf tmp #../../ubuntu/ip-redirect-all 80 8090 #../../ubuntu/ip-redirect-all 443 8453 diff --git a/sca-cpp/trunk/modules/opencl/eval.hpp b/sca-cpp/trunk/modules/opencl/eval.hpp index 82706ff0f2..5606b2f57a 100644 --- a/sca-cpp/trunk/modules/opencl/eval.hpp +++ b/sca-cpp/trunk/modules/opencl/eval.hpp @@ -475,7 +475,7 @@ const failable<list<OpenCLBuffer>> valuesToKernelArgsListHelper(const list<value return list<OpenCLBuffer>(); const failable<OpenCLBuffer> a = valueToKernelArg(car(v), i, kernel, cl, cq); if (!hasContent(a)) - return mkfailure<list<OpenCLBuffer>>(reason(a)); + return mkfailure<list<OpenCLBuffer>>(a); const failable<list<OpenCLBuffer>> al = valuesToKernelArgsListHelper(cdr(v), i + 1, kernel, cl, cq); if (!hasContent(al)) return al; @@ -600,7 +600,7 @@ const failable<value> evalKernel(const failable<OpenCLKernel>& fkernel, const va #endif if (!hasContent(fkernel)) - return mkfailure<value>(reason(fkernel)); + return mkfailure<value>(fkernel); const OpenCLKernel kernel = content(fkernel); // Get a command queue for the specified device type @@ -609,7 +609,7 @@ const failable<value> evalKernel(const failable<OpenCLKernel>& fkernel, const va // Set the kernel input args const failable<list<OpenCLBuffer>> args = valuesToKernelArgs(cdr<value>(expr), kernel, cl, cq); if (!hasContent(args)) { - return mkfailure<value>(reason(args)); + return mkfailure<value>(args); } // Allocate result buffer in device memory @@ -618,13 +618,13 @@ const failable<value> evalKernel(const failable<OpenCLKernel>& fkernel, const va const size_t rsize = rtype.n * rtype.size; const failable<OpenCLBuffer> rbuf = writeOnlyBuffer(rsize, cl); if (!hasContent(rbuf)) - return mkfailure<value>(reason(rbuf)); + return mkfailure<value>(rbuf); // Set it as a kernel output arg const cl_mem rmem = content(rbuf).mem; const failable<OpenCLBuffer> rarg = valueToKernelArg((cl_uint)length(cdr<value>(expr)), sizeof(cl_mem), &rmem, rbuf, kernel); if (!hasContent(rarg)) - return mkfailure<value>(reason(rarg)); + return mkfailure<value>(rarg); // Enqueue the kernel, to be executed after all the writes complete cl_event wevt[32]; @@ -715,7 +715,7 @@ const failable<OpenCLProgram> readProgram(const string& path, istream& is, const const failable<value> evalKernel(const value& expr, istream& is, const OpenCLContext& cl) { failable<OpenCLProgram> clprog = readProgram("program.cl", is, cl); if (!hasContent(clprog)) - return mkfailure<value>(reason(clprog)); + return mkfailure<value>(clprog); return evalKernel(createKernel(expr, content(clprog)), expr, 1, value::Nil, 0, cl); } diff --git a/sca-cpp/trunk/modules/opencl/server-test b/sca-cpp/trunk/modules/opencl/server-test index e623599b39..c103c45487 100755 --- a/sca-cpp/trunk/modules/opencl/server-test +++ b/sca-cpp/trunk/modules/opencl/server-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 ../server/htdocs ../server/server-conf tmp ./opencl-conf tmp diff --git a/sca-cpp/trunk/modules/openid/start-test b/sca-cpp/trunk/modules/openid/start-test index 5cac1dbe14..f0d27d16be 100755 --- a/sca-cpp/trunk/modules/openid/start-test +++ b/sca-cpp/trunk/modules/openid/start-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ../../components/cache/memcached-start tmp 11212 ../../components/cache/memcached-start tmp 11213 diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp index 89a2db1b33..956edf1059 100644 --- a/sca-cpp/trunk/modules/python/mod-python.cpp +++ b/sca-cpp/trunk/modules/python/mod-python.cpp @@ -73,6 +73,8 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri } if (contains(itype, ".cpp")) return modcpp::evalImplementation(path, impl, px); + if (contains(itype, ".widget")) + return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false); return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype); } diff --git a/sca-cpp/trunk/modules/python/mod-python.hpp b/sca-cpp/trunk/modules/python/mod-python.hpp index a4d77775a5..e6effb985b 100644 --- a/sca-cpp/trunk/modules/python/mod-python.hpp +++ b/sca-cpp/trunk/modules/python/mod-python.hpp @@ -52,7 +52,7 @@ struct applyImplementation { const value expr = append<value>(params, px); debug(expr, "modeval::python::applyImplementation::input"); const failable<value> res = python::evalScript(expr, impl, py); - const value val = !hasContent(res)? mklist<value>(value(), reason(res)) : mklist<value>(content(res)); + const value val = !hasContent(res)? mklist<value>(value(), reason(res), rcode(res)) : mklist<value>(content(res)); debug(val, "modeval::python::applyImplementation::result"); return val; } @@ -70,7 +70,7 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath); const failable<PyObject*> script = python::readScript(python::moduleName(spath), fpath, is, py); if (!hasContent(script)) - return mkfailure<lambda<value(const list<value>&)> >(reason(script)); + return mkfailure<lambda<value(const list<value>&)> >(script); return lambda<value(const list<value>&)>(applyImplementation(content(script), px, py)); } diff --git a/sca-cpp/trunk/modules/python/server-test b/sca-cpp/trunk/modules/python/server-test index ecde5ca8ad..6ab5823643 100755 --- a/sca-cpp/trunk/modules/python/server-test +++ b/sca-cpp/trunk/modules/python/server-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 ../server/htdocs ../http/httpd-event-conf tmp ../server/server-conf tmp diff --git a/sca-cpp/trunk/modules/python/wiring-test b/sca-cpp/trunk/modules/python/wiring-test index 4dd3ca7228..899c3eb5a1 100755 --- a/sca-cpp/trunk/modules/python/wiring-test +++ b/sca-cpp/trunk/modules/python/wiring-test @@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h curl_prefix=`cat $here/../http/curl.prefix` # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 ../server/htdocs ../http/httpd-event-conf tmp ../server/server-conf tmp diff --git a/sca-cpp/trunk/modules/scheme/json-value.cpp b/sca-cpp/trunk/modules/scheme/json-value.cpp index d7ffc2b37b..4bdf8bd37f 100644 --- a/sca-cpp/trunk/modules/scheme/json-value.cpp +++ b/sca-cpp/trunk/modules/scheme/json-value.cpp @@ -36,7 +36,7 @@ int jsonValue() { const js::JSContext cx; const failable<list<value> > lv = json::readJSON(streamList(cin), cx); if (!hasContent(lv)) { - cerr << reason(lv); + cerr << reason(lv) << " : " << rcode(lv); return 1; } cout << writeValue(content(lv)); diff --git a/sca-cpp/trunk/modules/scheme/value-json.cpp b/sca-cpp/trunk/modules/scheme/value-json.cpp index 5045226db9..a8c875fcc8 100644 --- a/sca-cpp/trunk/modules/scheme/value-json.cpp +++ b/sca-cpp/trunk/modules/scheme/value-json.cpp @@ -36,7 +36,7 @@ int valueJSON() { const js::JSContext cx; failable<list<string> > s = json::writeJSON(readValue(cin), cx); if (!hasContent(s)) { - cerr << reason(s); + cerr << reason(s) << " : " << rcode(s); return 1; } write(content(s), cout); diff --git a/sca-cpp/trunk/modules/scheme/value-xml.cpp b/sca-cpp/trunk/modules/scheme/value-xml.cpp index 7091d5c8ba..ff785899c6 100644 --- a/sca-cpp/trunk/modules/scheme/value-xml.cpp +++ b/sca-cpp/trunk/modules/scheme/value-xml.cpp @@ -35,7 +35,7 @@ namespace scheme { int valueXML() { failable<list<string> > s = writeXML(readValue(cin)); if (!hasContent(s)) { - cerr << reason(s); + cerr << reason(s) << " : " << rcode(s); return 1; } write(content(s), cout); diff --git a/sca-cpp/trunk/modules/server/httpd-test b/sca-cpp/trunk/modules/server/httpd-test index 63b268d7b3..195caa4562 100755 --- a/sca-cpp/trunk/modules/server/httpd-test +++ b/sca-cpp/trunk/modules/server/httpd-test @@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h curl_prefix=`cat $here/../http/curl.prefix` # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 htdocs ../http/httpd-event-conf tmp ./server-conf tmp diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp index fcc4981ec0..3fd69c1fea 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.cpp +++ b/sca-cpp/trunk/modules/server/mod-eval.cpp @@ -55,6 +55,8 @@ const failable<lambda<value(const list<value>&)> > evalImplementation(const stri return modscheme::evalImplementation(path, impl, px); if (contains(itype, ".cpp")) return modcpp::evalImplementation(path, impl, px); + if (contains(itype, ".widget")) + return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false); return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype); } diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index ef2a2f6575..ac5bf55698 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -151,7 +151,7 @@ public: const failable<value> failableResult(const list<value>& v) { if (isNil(cdr(v))) return car(v); - return mkfailure<value>(string(cadr(v)), false); + return mkfailure<value>(string(cadr(v)), isNil(cddr(v))? -1 : (int)caddr(v), false); } /** @@ -191,7 +191,7 @@ public: } const value callImpl(const value& cname, const list<value>& aparams) const { - debug(impls, "modeval::implProxy::callImpl::impls"); + //debug(impls, "modeval::implProxy::callImpl::impls"); // Lookup the component implementation const list<value> impl(assoctree<value>(cname, impls)); @@ -345,9 +345,11 @@ struct hostPropProxy { hostPropProxy(const value& v) : v(v) { } const value operator()(unused const list<value>& params) const { - const value r = httpd::hostName(currentRequest, v); - debug(r, "modeval::hostPropProxy::value"); - return r; + if (currentRequest == NULL) + return http::hostName(); + const value h = httpd::hostName(currentRequest, v); + debug(h, "modeval::hostPropProxy::value"); + return h; } }; @@ -356,6 +358,8 @@ struct appPropProxy { appPropProxy(const value& v) : v(v) { } const value operator()(unused const list<value>& params) const { + if (currentRequest == NULL) + return v; const RequestConf& reqc = httpd::requestConf<RequestConf>(currentRequest, &mod_tuscany_eval); const value a = isNil(reqc.vpath)? v : car(reqc.vpath); debug(a, "modeval::appPropProxy::value"); @@ -364,23 +368,29 @@ struct appPropProxy { }; struct pathPropProxy { - pathPropProxy(unused const value& v) { + const value v; + pathPropProxy(const value& v) : v(v) { } const value operator()(unused const list<value>& params) const { + if (currentRequest == NULL) + return v; const RequestConf& reqc = httpd::requestConf<RequestConf>(currentRequest, &mod_tuscany_eval); - const value v = reqc.rpath; - debug(v, "modeval::pathPropProxy::value"); - return v; + const value p = reqc.rpath; + debug(p, "modeval::pathPropProxy::value"); + return p; } }; struct queryPropProxy { - queryPropProxy(unused const value& v) { + const value v; + queryPropProxy(const value& v) : v(v) { } const value operator()(unused const list<value>& params) const { - const value v = httpd::unescapeArgs(httpd::queryArgs(currentRequest)); - debug(v, "modeval::queryPropProxy::value"); - return v; + if (currentRequest == NULL) + return v; + const value q = httpd::unescapeArgs(httpd::queryArgs(currentRequest)); + debug(q, "modeval::queryPropProxy::value"); + return q; } }; @@ -390,10 +400,34 @@ struct envPropProxy { envPropProxy(const string& name, const value& v) : name(name), v(v) { } const value operator()(unused const list<value>& params) const { + if (currentRequest == NULL) + return v; const char* env = apr_table_get(currentRequest->subprocess_env, c_str(name)); if (env == NULL || *env == '\0') return v; - return string(env); + debug(name, "modeval::envPropProxy::name"); + const value e = string(env); + debug(e, "modeval::envPropProxy::value"); + return e; + } +}; + +struct realmPropProxy { + const value v; + realmPropProxy(const value& v) : v(v) { + } + const value operator()(unused const list<value>& params) const { + if (currentRequest == NULL) + return v; + const char* env = apr_table_get(currentRequest->subprocess_env, "REALM"); + if (env == NULL) + return v; + const char* realm = strncmp(env, "www.", 4) == 0? env + 4 : env; + if (*realm == '\0') + return v; + const value r = string(realm); + debug(r, "modeval::realmPropProxy::value"); + return r; } }; @@ -402,9 +436,13 @@ struct userPropProxy { userPropProxy(const value& v) : v(v) { } const value operator()(unused const list<value>& params) const { + if (currentRequest == NULL) + return v; if (currentRequest->user == NULL) return v; - return string(currentRequest->user); + const value u = string(currentRequest->user); + debug(u, "modeval::userPropProxy::value"); + return u; } }; @@ -422,7 +460,7 @@ const value mkpropProxy(const value& prop) { if (n == "user") return lambda<value(const list<value>&)>(userPropProxy(v)); if (n == "realm") - return lambda<value(const list<value>&)>(envPropProxy("REALM", v)); + return lambda<value(const list<value>&)>(realmPropProxy(v)); if (n == "email") return lambda<value(const list<value>&)>(envPropProxy("EMAIL", v)); if (n == "nickname") @@ -508,13 +546,13 @@ const failable<list<value> > readComponents(const string& path) { const failable<list<value> > getComponents(const lambda<value(const list<value>&)>& provider, const string& name) { const failable<value> val = failableResult(provider(cons<value>("get", mklist<value>(mklist<value>(name))))); if (!hasContent(val)) - return mkfailure<list<value> >(reason(val)); + return mkfailure<list<value> >(val); const list<value> c = assoc<value>(value("content"), (list<list<value> >)cdr<value>(content(val))); if (isNil(c)) return mkfailure<list<value> >(string("Could not get composite: ") + name); const failable<list<string> > x = writeXML(car<value>(valuesToElements(mklist<value>(mklist<value>(cadr(c)))))); if (!hasContent(x)) - return mkfailure<list<value> >(reason(x)); + return mkfailure<list<value> >(x); return scdl::components(readXML(content(x))); } @@ -530,7 +568,7 @@ const failable<list<value> > applyLifecycleExpr(const list<value>& impls, const const lambda<value(const list<value>&)> l = cadr<value>(car(impls)); const failable<value> r = failableResult(l(expr)); if (!hasContent(r)) - return mkfailure<list<value> >(reason(r)); + return mkfailure<list<value> >(r); const lambda<value(const list<value>&)> rl = content(r); // Use the returned lambda function, if any, from now on @@ -604,7 +642,7 @@ const failable<Composite> confComponents(const string& contribPath, const string readComponents(scdl::resourcePath(length(vhost) != 0? contribPath + vhost + "/" : contribPath, composName)) : getComponents(provider, vhost); if (!hasContent(fcomps)) - return mkfailure<Composite>(reason(fcomps)); + return mkfailure<Composite>(fcomps); const list<value> comps = content(fcomps); debug(comps, "modeval::confComponents::comps"); @@ -630,7 +668,7 @@ const failable<list<value> > startComponents(const list<value>& impls) { debug(flatten(impls), "modeval::startComponents::impls"); const failable<list<value> > fsimpls = applyLifecycleExpr(flatten(impls), mklist<value>("start")); if (!hasContent(fsimpls)) - return mkfailure<list<value> >(reason(fsimpls)); + return mkfailure<list<value> >(fsimpls); const list<value> simpls = content(fsimpls); debug(impls, "modeval::startComponents::simpls"); @@ -667,7 +705,7 @@ const failable<int> get(const list<value>& rpath, request_rec* r, const lambda<v // Apply the requested function const failable<value> val = failableResult(impl(cons(func, json::queryParams(args)))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); // Return JSON result js::JSContext cx; @@ -678,7 +716,7 @@ const failable<int> get(const list<value>& rpath, request_rec* r, const lambda<v const list<value> params(cddr(rpath)); const failable<value> val = failableResult(impl(cons<value>("get", mklist<value>(params)))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); const value c = content(val); debug(c, "modeval::get::content"); @@ -776,7 +814,7 @@ const failable<int> post(const list<value>& rpath, request_rec* r, const lambda< // Evaluate the request expression const failable<value> val = failableResult(impl(cons<value>(func, params))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); // Return JSON result return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc; charset=utf-8", r); @@ -796,7 +834,7 @@ const failable<int> post(const list<value>& rpath, request_rec* r, const lambda< // Evaluate the POST expression const failable<value> val = failableResult(impl(cons<value>("post", mklist<value>(cddr(rpath), aval)))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); // Return the created resource location debug(content(val), "modeval::post::location"); @@ -809,7 +847,7 @@ const failable<int> post(const list<value>& rpath, request_rec* r, const lambda< // the component implementation function const failable<value> val = failableResult(impl(cons<value>("handle", mklist<value>(httpd::requestValue(r))))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); return (int)content(val); } @@ -830,7 +868,7 @@ const failable<int> put(const list<value>& rpath, request_rec* r, const lambda<v // Evaluate the PUT expression and update the corresponding resource const failable<value> val = failableResult(impl(cons<value>("put", mklist<value>(cddr(rpath), aval)))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); if (val == value(false)) return HTTP_NOT_FOUND; return OK; @@ -845,7 +883,7 @@ const failable<int> del(const list<value>& rpath, request_rec* r, const lambda<v // Evaluate an ATOM delete request const failable<value> val = failableResult(impl(cons<value>("delete", mklist<value>(cddr(rpath))))); if (!hasContent(val)) - return mkfailure<int>(reason(val)); + return mkfailure<int>(val); if (val == value(false)) return HTTP_NOT_FOUND; return OK; @@ -854,7 +892,12 @@ const failable<int> del(const list<value>& rpath, request_rec* r, const lambda<v /** * Proceed to handle a service component request. */ -int proceedToHandler(request_rec* r, const bool valias, const list<value>& rpath, const list<value>& vpath, const list<value>& impls) { +int proceedToHandler(request_rec* r, const int rc) { + r->handler = "mod_tuscany_eval"; + return rc; +} + +int proceedToHandler(request_rec* r, const int rc, const bool valias, const list<value>& rpath, const list<value>& vpath, const list<value>& impls) { r->handler = "mod_tuscany_eval"; r->filename = apr_pstrdup(r->pool, c_str(string("/redirect:") + r->uri)); @@ -864,7 +907,7 @@ int proceedToHandler(request_rec* r, const bool valias, const list<value>& rpath reqc.rpath = rpath; reqc.vpath = vpath; reqc.impls = impls; - return OK; + return rc; } /** @@ -882,7 +925,7 @@ int translateComponent(request_rec *r, const list<value>& rpath, const list<valu return HTTP_NOT_FOUND; debug(impl, "modeval::translateComponent::impl"); - return proceedToHandler(r, false, rpath, vpath, impls);; + return proceedToHandler(r, OK, false, rpath, vpath, impls);; } /** @@ -928,7 +971,7 @@ int translateReference(request_rec *r, const list<value>& rpath, const list<valu const value tname = substr(target, 0, find(target, '/')); const list<value> redir = cons<value>(string("c"), cons(tname, pathInfo)); debug(redir, "modeval::translateReference::redirect"); - return proceedToHandler(r, false, redir, vpath, impls);; + return proceedToHandler(r, OK, false, redir, vpath, impls);; } /** @@ -973,7 +1016,7 @@ int translateService(request_rec *r, const list<value>& rpath, const list<value> // / c / target component name / request path info const list<value> redir = cons<value>(string("c"), cons<value>(cadr(svc), httpd::pathInfo(rpath, car(svc)))); debug(redir, "modeval::translateService::redirect"); - return proceedToHandler(r, false, redir, vpath, impls); + return proceedToHandler(r, OK, false, redir, vpath, impls); } /** @@ -986,15 +1029,15 @@ const int translateRequest(request_rec* r, const list<value>& rpath, const list< // Translate a component request if ((prefix == string("components") || prefix == string("c")) && translateComponent(r, rpath, vpath, impls) == OK) - return OK; + return proceedToHandler(r, OK); // Translate a component reference request if ((prefix == string("references") || prefix == string("r")) && translateReference(r, rpath, vpath, refs, impls) == OK) - return OK; + return proceedToHandler(r, OK); // Attempt to translate the request to a service request if (translateService(r, rpath, vpath, svcs, impls) == OK) - return OK; + return proceedToHandler(r, OK); // Attempt to map a request targeting the main host to an actual file if (isNil(vpath)) { @@ -1019,15 +1062,14 @@ const int translateRequest(request_rec* r, const list<value>& rpath, const list< if (isNil(rpath) && r->uri[strlen(r->uri) - 1] != '/') { const string target = string(r->uri) + string("/") + (r->args != NULL? string("?") + string(r->args) : string("")); debug(target, "modeval::translateRequest::location"); - r->handler = "mod_tuscany_eval"; - return httpd::externalRedirect(target, r); + return proceedToHandler(r, httpd::externalRedirect(target, r)); } // If the request didn't match a service, reference or component, // redirect it to / v / app / path. This will allow mapping to // the actual app resource using HTTPD aliases. debug(true, "modeval::translateRequest::valias"); - return proceedToHandler(r, true, rpath, vpath, impls); + return proceedToHandler(r, OK, true, rpath, vpath, impls); } return HTTP_NOT_FOUND; @@ -1093,7 +1135,6 @@ int translate(request_rec *r) { reqc.impls = vcompos.impls; return translateRequest(r, cdr(rpath), mklist<value>(vname), vcompos.refs, vcompos.svcs, reqc.impls); } - return DECLINED; } @@ -1129,15 +1170,18 @@ const int handleRequest(const list<value>& rpath, request_rec *r, const list<val * HTTP request handler. */ int handler(request_rec *r) { - if(r->method_number != M_GET && r->method_number != M_POST && r->method_number != M_PUT && r->method_number != M_DELETE) + if (r->handler != NULL && r->handler[0] != '\0') return DECLINED; + + // Attempt to translate the request + const int trc = translate(r); + + // Pass if we couldn't translate the request + if(trc != OK) + return trc; if(strcmp(r->handler, "mod_tuscany_eval")) return DECLINED; - // Nothing to do for an external redirect - if (r->status == HTTP_MOVED_TEMPORARILY) - return OK; - // Create a scoped memory pool and a scope for the current request gc_scoped_pool pool(r->pool); ScopedRequest sr(r); @@ -1397,7 +1441,6 @@ void registerHooks(unused apr_pool_t *p) { ap_hook_post_config(postConfig, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_child_init(childInit, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(handler, NULL, NULL, APR_HOOK_MIDDLE); - ap_hook_translate_name(translate, NULL, NULL, APR_HOOK_LAST); } } diff --git a/sca-cpp/trunk/modules/server/server-test b/sca-cpp/trunk/modules/server/server-test index 43557e7f7b..6b48d13e83 100755 --- a/sca-cpp/trunk/modules/server/server-test +++ b/sca-cpp/trunk/modules/server/server-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 htdocs ../http/httpd-event-conf tmp ./server-conf tmp diff --git a/sca-cpp/trunk/modules/server/wiring-test b/sca-cpp/trunk/modules/server/wiring-test index 8bbcd684f2..7e1aea22b1 100755 --- a/sca-cpp/trunk/modules/server/wiring-test +++ b/sca-cpp/trunk/modules/server/wiring-test @@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h curl_prefix=`cat $here/../http/curl.prefix` # Setup +rm -rf tmp ../http/httpd-conf tmp localhost 8090 htdocs ../http/httpd-event-conf tmp ./server-conf tmp diff --git a/sca-cpp/trunk/modules/wsgi/gae-stop b/sca-cpp/trunk/modules/wsgi/gae-stop index c0ff29cfaa..5bb2965515 100755 --- a/sca-cpp/trunk/modules/wsgi/gae-stop +++ b/sca-cpp/trunk/modules/wsgi/gae-stop @@ -26,4 +26,8 @@ python_prefix=`cat $here/../python/python.prefix` gae_prefix=`cat $here/gae.prefix` py="$python_prefix/bin/python $gae_prefix/dev_appserver.py -a 0.0.0.0 -p $port $root" -kill `ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'` +k=`ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'` +if [ "$k" != "" ]; then + kill $k +fi + diff --git a/sca-cpp/trunk/modules/wsgi/http-test b/sca-cpp/trunk/modules/wsgi/http-test index aef76d47c4..d6c608571e 100755 --- a/sca-cpp/trunk/modules/wsgi/http-test +++ b/sca-cpp/trunk/modules/wsgi/http-test @@ -18,6 +18,7 @@ # under the License. # Setup +rm -rf tmp mkdir -p tmp ./wsgi-start target 8090 2>/dev/null sleep 2 @@ -25,6 +26,8 @@ sleep 2 # Test JSON-RPC here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` python_prefix=`cat $here/../python/python.prefix` +export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH + $python_prefix/bin/python http-test.py rc=$? diff --git a/sca-cpp/trunk/modules/wsgi/util-test b/sca-cpp/trunk/modules/wsgi/util-test index 184eb1c788..3bdfc018ff 100755 --- a/sca-cpp/trunk/modules/wsgi/util-test +++ b/sca-cpp/trunk/modules/wsgi/util-test @@ -20,6 +20,7 @@ # Run Python util test cases here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` python_prefix=`cat $here/../python/python.prefix` +export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH $python_prefix/bin/python stream-test.py rc=$? diff --git a/sca-cpp/trunk/modules/wsgi/wiring-test b/sca-cpp/trunk/modules/wsgi/wiring-test index 35d96a3889..cbecc201e8 100755 --- a/sca-cpp/trunk/modules/wsgi/wiring-test +++ b/sca-cpp/trunk/modules/wsgi/wiring-test @@ -26,6 +26,7 @@ if [ "$uri" = "" ]; then fi # Setup +rm -rf tmp mkdir -p tmp ./wsgi-start target 8090 2>/dev/null sleep 2 diff --git a/sca-cpp/trunk/modules/wsgi/wsgi-stop b/sca-cpp/trunk/modules/wsgi/wsgi-stop index e47967e528..3d388ac313 100755 --- a/sca-cpp/trunk/modules/wsgi/wsgi-stop +++ b/sca-cpp/trunk/modules/wsgi/wsgi-stop @@ -25,4 +25,8 @@ port=$2 python_prefix=`cat $here/../python/python.prefix` py="$python_prefix/bin/python composite.py $port" -kill `ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'` +k=`ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'` +if [ "$k" != "" ]; then + kill $k +fi + diff --git a/sca-cpp/trunk/modules/wsgi/wsgi-test b/sca-cpp/trunk/modules/wsgi/wsgi-test index c17e29047d..f8334b33ad 100755 --- a/sca-cpp/trunk/modules/wsgi/wsgi-test +++ b/sca-cpp/trunk/modules/wsgi/wsgi-test @@ -22,6 +22,7 @@ here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $h curl_prefix=`cat $here/../http/curl.prefix` # Setup +rm -rf tmp mkdir -p tmp ./wsgi-start target 8090 2>/dev/null sleep 2 |