*** empty log message ***

svn path=/trunk/boinc/; revision=7492
This commit is contained in:
David Anderson 2005-08-25 23:07:58 +00:00
parent dbcf18b656
commit 041b6f24c6
26 changed files with 775 additions and 515 deletions

View File

@ -309,7 +309,7 @@ unsigned char* getData (FILE *s, int sz, int iBits){
}
unsigned * read_tga_texture(char *name, int *width, int *height, int *components) {
unsigned * read_tga_texture(char *name, int *width, int *height, int*) {
unsigned char type[4];
unsigned char info[7];
unsigned *base;

View File

@ -10964,3 +10964,36 @@ Rom 25 Aug 2005
MainFrame.cpp, .h
ViewProjects.cpp
WizAttachProject.cpp
David 25 Aug 2005
- Unix build fixes from Reinhard Prix.
- remove #ifdefs on _USE_CURL. Pre-curl HTTP code is no longer supported.
- added "donated" field to user table.
NOTE: this update requires a database change. See html/ops/db_update.php
configure.ac
api/
texture.C
client/
Makefile.am
client_state.C,h
file_xfer.h
http_curl.C,h
main.C
net_stats.h
net_xfer_curl.C,h
scheduler_op.h
db/
boinc_db.C,h
schema.sql
html/
inc/
util.inc
ops/
db_update.php
m4/
libcurl.m4
sah_check_lib.m4
sched/
file_deleter.C

View File

@ -61,10 +61,9 @@ boinc_client_SOURCES = \
whetstone.C
boinc_client_DEPENDENCIES = $(LIBRSA)
boinc_client_CPPFLAGS = -D_USE_CURL -I $(srcdir)/win $(AM_CPPFLAGS) -O3
boinc_client_CPPFLAGS = -I $(srcdir)/win $(AM_CPPFLAGS) -O3
boinc_client_LDFLAGS = -static-libgcc
boinc_client_LDADD = -L/usr/local/ssl/lib -lssl -lcurl -L../lib -lboinc $(RSA_LIBS) $(PTHREAD_LIBS)
#boinc_client_LDFLAGS = $(STATIC_FLAGS)
boinc_client_LDADD = -L../lib -lboinc $(PTHREAD_LIBS)
# the following don't do anything
cpu_benchmark_SOURCES = whetstone.C dhrystone.C

View File

@ -56,11 +56,7 @@
#include "hostinfo.h"
#include "hostinfo_network.h"
#include "network.h"
#ifdef _USE_CURL
#include "http_curl.h"
#else
#include "http.h"
#endif
#include "log_flags.h"
#include "client_msgs.h"
#include "client_state.h"
@ -235,9 +231,7 @@ int CLIENT_STATE::init() {
);
#endif
#ifdef _USE_CURL
msg_printf(NULL, MSG_INFO, curl_version());
#endif
if (executing_as_daemon) {
msg_printf(NULL, MSG_INFO, "Executing as a daemon");

View File

@ -41,14 +41,8 @@
#include "scheduler_op.h"
#include "ss_logic.h"
#include "time_stats.h"
#ifdef _USE_CURL
#include "http_curl.h"
#include "net_xfer_curl.h"
#else
#include "http.h"
#include "net_xfer.h"
#endif
#define USER_RUN_REQUEST_ALWAYS 1
#define USER_RUN_REQUEST_AUTO 2

View File

@ -30,11 +30,7 @@
// - upload authentication
#include "client_types.h"
#ifdef _USE_CURL
#include "http_curl.h"
#else
#include "http.h"
#endif
class FILE_XFER : public HTTP_OP {
public:

View File

@ -26,11 +26,7 @@
using std::string;
#ifdef _USE_CURL
#include "http_curl.h"
#else
#include "http.h"
#endif
// base class for various types of ops
//

View File

@ -17,8 +17,6 @@
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifdef _USE_CURL // SSL clients will use https.C
#include "cpp.h"
#ifdef _WIN32
@ -28,7 +26,6 @@
#include <sstream>
#include <algorithm>
#include <sys/stat.h>
//#include <sys/socket.h>
#include <cerrno>
#include <unistd.h>
#endif
@ -85,24 +82,24 @@ http_ops
void parse_url(const char* url, char* host, int &port, char* file) {
char* p;
char buf[256];
bool bSSL = false;
bool bSSL = false;
//const short csiLen = bSSL ? 8 : 7; // get right size of http/s string comparator
//const short csiLen = bSSL ? 8 : 7; // get right size of http/s string comparator
// strip off http:// if present
//
//if (strncmp(url, (bSSL ? "https://" : "http://"), csiLen) == 0) {
if (strncmp(url, "http://", 7) == 0) {
safe_strcpy(buf, url+7);
//if (strncmp(url, (bSSL ? "https://" : "http://"), csiLen) == 0) {
if (strncmp(url, "http://", 7) == 0) {
safe_strcpy(buf, url+7);
} else {
// wait, may be https://
if (strncmp(url, "https://", 8) == 0) {
safe_strcpy(buf, url+8);
bSSL = true; // retain the fact that this was a secure http url
}
else { // no http:// or https:// prepended on url
safe_strcpy(buf, url);
}
// wait, may be https://
if (strncmp(url, "https://", 8) == 0) {
safe_strcpy(buf, url+8);
bSSL = true; // retain the fact that this was a secure http url
}
else { // no http:// or https:// prepended on url
safe_strcpy(buf, url);
}
}
// parse and strip off file part if present
@ -122,10 +119,10 @@ void parse_url(const char* url, char* host, int &port, char* file) {
port = atol(p+1);
*p = 0;
} else {
// CMC note: if they didn't pass in a port #,
// but the url starts with https://, assume they
// want a secure port (HTTPS, port 443)
port = (bSSL ? 443 : 80);
// CMC note: if they didn't pass in a port #,
// but the url starts with https://, assume they
// want a secure port (HTTPS, port 443)
port = (bSSL ? 443 : 80);
}
// what remains is the host
@ -140,7 +137,7 @@ void get_user_agent_string() {
}
HTTP_OP::HTTP_OP() {
strcpy(m_url, ""); // CMC added this to "preserve" the url for libcurl
strcpy(m_url, ""); // CMC added this to "preserve" the url for libcurl
strcpy(url_hostname, "");
strcpy(filename, "");
content_length = 0;
@ -164,18 +161,18 @@ int HTTP_OP::init_get(
if (del_old_file) {
unlink(out);
}
req1 = NULL; // not using req1, but init_post2 uses it
req1 = NULL; // not using req1, but init_post2 uses it
file_offset = off;
safe_strcpy(m_url, url);
safe_strcpy(m_url, url);
parse_url(url, url_hostname, port, filename);
NET_XFER::init(url_hostname, port, HTTP_BLOCKSIZE);
// usually have an outfile on a get
// usually have an outfile on a get
if (off != 0) {
bytes_xferred = off;
}
http_op_type = HTTP_OP_GET;
http_op_state = HTTP_STATE_CONNECTING;
return HTTP_OP::libcurl_exec(url, NULL, out, off, false);
return HTTP_OP::libcurl_exec(url, NULL, out, off, false);
}
// Initialize HTTP POST operation
@ -187,83 +184,84 @@ int HTTP_OP::init_post(
double size;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_HTTP);
req1 = NULL; // not using req1, but init_post2 uses it
req1 = NULL; // not using req1, but init_post2 uses it
strcpy(m_url, url);
strcpy(m_url, url);
parse_url(url, url_hostname, port, filename);
if (in) { // we should pretty much always have an in file for _post, optional in _post2
strcpy(infile, in);
retval = file_size(infile, size);
if (retval) return retval;
content_length = (int)size;
}
if (in) {
// we should pretty much always have an in file for _post, optional in _post2
strcpy(infile, in);
retval = file_size(infile, size);
if (retval) return retval;
content_length = (int)size;
}
//PROXY::init(url_hostname, port);
NET_XFER::init(url_hostname,port, HTTP_BLOCKSIZE);
http_op_type = HTTP_OP_POST;
http_op_state = HTTP_STATE_CONNECTING;
scope_messages.printf("HTTP_OP::init_post(): %p io_done %d\n", this, io_done);
return HTTP_OP::libcurl_exec(url, in, out, 0.0, true);
return HTTP_OP::libcurl_exec(url, in, out, 0.0, true);
}
// the following will do an HTTP GET or POST using libcurl, polling at the net_xfer level
int HTTP_OP::libcurl_exec(const char* url, const char* in, const char* out,
double offset, bool bPost)
{
CURLMcode curlMErr;
CURLcode curlErr;
int HTTP_OP::libcurl_exec(
const char* , const char* in, const char* out, double offset, bool bPost
) {
CURLMcode curlMErr;
CURLcode curlErr;
//char proxy_buf[256];
char strTmp[128];
char strTmp[128];
// get user agent string
if (g_user_agent_string[0] == 0x00)
get_user_agent_string();
// get user agent string
if (g_user_agent_string[0] == 0x00)
get_user_agent_string();
if (in) {
strcpy(infile, in);
strcpy(infile, in);
}
if (out) {
bTempOutfile = false;
strcpy(outfile, out);
} else { //CMC -- I always want an outfile for the server response, delete when op done
bTempOutfile = true;
memset(outfile, 0x00, _MAX_PATH);
if (out) {
bTempOutfile = false;
strcpy(outfile, out);
} else { //CMC -- I always want an outfile for the server response, delete when op done
bTempOutfile = true;
memset(outfile, 0x00, _MAX_PATH);
#ifdef _WIN32
char* ptrName;
ptrName = _tempnam("./", "blc");
if (ptrName) {
strcpy(outfile, ptrName);
free(ptrName);
}
char* ptrName;
ptrName = _tempnam("./", "blc");
if (ptrName) {
strcpy(outfile, ptrName);
free(ptrName);
}
#else // use mkstemp on Mac & Linux due to security issues
strcpy(outfile, "blcXXXXXX"); // a template for the mkstemp
mkstemp(outfile);
strcpy(outfile, "blcXXXXXX"); // a template for the mkstemp
mkstemp(outfile);
#endif
if (outfile[0] == 0x00) {
// oh well we're desparate, use tmpnam!
tmpnam(outfile);
}
}
if (outfile[0] == 0x00) {
// oh well we're desparate, use tmpnam!
tmpnam(outfile);
}
}
// setup libcurl handle
// setup libcurl handle
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_NET_XFER);
// CMC -- init the curlEasy handle and setup options
// the polling will do the actual start of the HTTP/S transaction
// CMC -- init the curlEasy handle and setup options
// the polling will do the actual start of the HTTP/S transaction
curlEasy = curl_easy_init(); // get a curl_easy handle to use
if (!curlEasy) {
curlEasy = curl_easy_init(); // get a curl_easy handle to use
if (!curlEasy) {
msg_printf(0, MSG_ERROR, "%s\n", "Couldn't create curlEasy handle\n");
return 1; // returns 0 (CURLM_OK) on successful handle creation
}
return 1; // returns 0 (CURLM_OK) on successful handle creation
}
// OK, we have a handle, now open an asynchronous libcurl connection
// OK, we have a handle, now open an asynchronous libcurl connection
// set the URL to use
curlErr = curl_easy_setopt(curlEasy, CURLOPT_URL, m_url);
// set the URL to use
curlErr = curl_easy_setopt(curlEasy, CURLOPT_URL, m_url);
/*
CURLOPT_SSL_VERIFYHOST
/*
CURLOPT_SSL_VERIFYHOST
Pass a long as parameter.
@ -282,171 +280,169 @@ When the value is 0, the connection succeeds regardless of the names in the cert
The default, since 7.10, is 2.
The checking this option controls is of the identity that the server claims. The server could be lying. To control lying, see CURLOPT_SSL_VERIFYPEER.
*/
curlErr = curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYHOST, 2L);
*/
curlErr = curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYHOST, 2L);
// disable "tough" certificate checking (i.e. self-signed is OK)
// if zero below, will accept self-signed certificates (cert not 3rd party trusted)
// if non-zero below, you need a valid 3rd party CA (i.e. Verisign, Thawte)
curlErr = curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYPEER, 0L);
// disable "tough" certificate checking (i.e. self-signed is OK)
// if zero below, will accept self-signed certificates (cert not 3rd party trusted)
// if non-zero below, you need a valid 3rd party CA (i.e. Verisign, Thawte)
curlErr = curl_easy_setopt(curlEasy, CURLOPT_SSL_VERIFYPEER, 0L);
// set the user agent as this boinc client & version
curlErr = curl_easy_setopt(curlEasy, CURLOPT_USERAGENT, g_user_agent_string);
// set the user agent as this boinc client & version
curlErr = curl_easy_setopt(curlEasy, CURLOPT_USERAGENT, g_user_agent_string);
// note: custom headers here means EVERYTHING needs to be set here,
// including form content types. Probably best just to set the user agent above
// and let libcurl handle the headers.
// note: custom headers here means EVERYTHING needs to be set here,
// including form content types. Probably best just to set the user agent above
// and let libcurl handle the headers.
// create custom header for BOINC
/*
pcurlList = curl_slist_append(pcurlList, "Pragma: no-cache");
pcurlList = curl_slist_append(pcurlList, "Cache-Control: no-cache");
// create custom header for BOINC
#if 0
pcurlList = curl_slist_append(pcurlList, "Pragma: no-cache");
pcurlList = curl_slist_append(pcurlList, "Cache-Control: no-cache");
pcurlList = curl_slist_append(pcurlList, g_user_agent_string);
pcurlList = curl_slist_append(pcurlList, g_user_agent_string);
//sprintf(strTmp, "Host: %s:%d", url_hostname, port);
//pcurlList = curl_slist_append(pcurlList, strTmp);
if (offset>0.0f) {
file_offset = offset;
sprintf(strTmp, "Range: bytes=%.0f-", offset);
pcurlList = curl_slist_append(pcurlList, strTmp);
}
pcurlList = curl_slist_append(pcurlList, "Connection: close");
pcurlList = curl_slist_append(pcurlList, "Accept: *\/*");
//sprintf(strTmp, "Host: %s:%d", url_hostname, port);
//pcurlList = curl_slist_append(pcurlList, strTmp);
if (offset>0.0f) {
file_offset = offset;
sprintf(strTmp, "Range: bytes=%.0f-", offset);
pcurlList = curl_slist_append(pcurlList, strTmp);
}
pcurlList = curl_slist_append(pcurlList, "Connection: close");
pcurlList = curl_slist_append(pcurlList, "Accept: *\/*");
// "Proxy-Authorization: Basic %s\015\012"
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
// "Proxy-Authorization: Basic %s\015\012"
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
#endif
*/
// bypass any signal handlers that curl may want to install
curlErr = curl_easy_setopt(curlEasy, CURLOPT_NOSIGNAL, 1L);
// bypass progress meter
curlErr = curl_easy_setopt(curlEasy, CURLOPT_NOPROGRESS, 1L);
// force curl to use HTTP/1.0 (which the old BOINC http libraries did)
//curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_MAXREDIRS, 5L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_AUTOREFERER, 1L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_FOLLOWLOCATION, 1L);
// bypass any signal handlers that curl may want to install
curlErr = curl_easy_setopt(curlEasy, CURLOPT_NOSIGNAL, 1L);
// bypass progress meter
curlErr = curl_easy_setopt(curlEasy, CURLOPT_NOPROGRESS, 1L);
// force curl to use HTTP/1.0 (which the old BOINC http libraries did)
//curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_MAXREDIRS, 5L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_AUTOREFERER, 1L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_FOLLOWLOCATION, 1L);
// setup any proxy they may need
setupProxyCurl();
// setup any proxy they may need
setupProxyCurl();
// set the content type in the header (defined at the top -- app/octect-stream)
pcurlList = curl_slist_append(pcurlList, g_content_type);
// set the content type in the header (defined at the top -- app/octect-stream)
pcurlList = curl_slist_append(pcurlList, g_content_type);
// we'll need to setup an output file for the reply
if (outfile && strlen(outfile)>0) {
fileOut = boinc_fopen(outfile, "wb");
if (!fileOut) {
msg_printf(NULL, MSG_ERROR,
"HTTP_CURL:libcurl_exec(): Can't setup HTTP response output file %s\n", outfile);
io_done = true;
http_op_retval = ERR_FOPEN;
http_op_state = HTTP_STATE_DONE;
return -3;
}
// CMC Note: we can make the libcurl_write "fancier" in the future,
// for now it just fwrite's to the file request, which is sufficient
curlErr = curl_easy_setopt(curlEasy, CURLOPT_WRITEFUNCTION, libcurl_write);
// note that in my lib_write I'm sending in a pointer to this instance of HTTP_OP
curlErr = curl_easy_setopt(curlEasy, CURLOPT_WRITEDATA, this);
}
// we'll need to setup an output file for the reply
if (outfile && strlen(outfile)>0) {
fileOut = boinc_fopen(outfile, "wb");
if (!fileOut) {
msg_printf(NULL, MSG_ERROR,
"HTTP_CURL:libcurl_exec(): Can't setup HTTP response output file %s\n", outfile);
io_done = true;
http_op_retval = ERR_FOPEN;
http_op_state = HTTP_STATE_DONE;
return -3;
}
// CMC Note: we can make the libcurl_write "fancier" in the future,
// for now it just fwrite's to the file request, which is sufficient
curlErr = curl_easy_setopt(curlEasy, CURLOPT_WRITEFUNCTION, libcurl_write);
// note that in my lib_write I'm sending in a pointer to this instance of HTTP_OP
curlErr = curl_easy_setopt(curlEasy, CURLOPT_WRITEDATA, this);
}
if (bPost) { // POST
want_upload = true;
want_download = false;
if (infile && strlen(infile)>0) {
fileIn = boinc_fopen(infile, "rb");
if (!fileIn) {
msg_printf(NULL, MSG_ERROR, "HTTP_CURL:libcurl_exec(): no input file %s\n", infile);
io_done = true;
http_op_retval = ERR_FOPEN;
http_op_state = HTTP_STATE_DONE;
return -1;
}
}
// send offset range if needed
if (offset>0.0f) {
file_offset = offset;
sprintf(strTmp, "Range: bytes=%.0f-", offset);
pcurlList = curl_slist_append(pcurlList, strTmp);
}
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
if (bPost) { // POST
want_upload = true;
want_download = false;
if (infile && strlen(infile)>0) {
fileIn = boinc_fopen(infile, "rb");
if (!fileIn) {
msg_printf(NULL, MSG_ERROR, "HTTP_CURL:libcurl_exec(): no input file %s\n", infile);
io_done = true;
http_op_retval = ERR_FOPEN;
http_op_state = HTTP_STATE_DONE;
return -1;
}
}
// send offset range if needed
if (offset>0.0f) {
file_offset = offset;
sprintf(strTmp, "Range: bytes=%.0f-", offset);
pcurlList = curl_slist_append(pcurlList, strTmp);
}
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
// set the data file info to read for the PUT/POST
// note the use of this curl typedef for large filesizes
// set the data file info to read for the PUT/POST
// note the use of this curl typedef for large filesizes
/* HTTP PUT method
curl_off_t fs = (curl_off_t) content_length;
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE, content_length);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READDATA, fileIn);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE_LARGE, fs);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PUT, 1L);
*/
/* HTTP PUT method
curl_off_t fs = (curl_off_t) content_length;
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE, content_length);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READDATA, fileIn);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_INFILESIZE_LARGE, fs);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PUT, 1L);
*/
// HTTP POST method
// set the multipart form for the file -- boinc just has the one section (file)
/* CMC -- if we ever want to do POST as multipart forms someday
// (many seem to prefer it that way, i.e. libcurl)
pcurlFormStart = pcurlFormEnd = NULL;
curl_formadd(&pcurlFormStart, &pcurlFormEnd,
// HTTP POST method
// set the multipart form for the file -- boinc just has the one section (file)
/* CMC -- if we ever want to do POST as multipart forms someday
// (many seem to prefer it that way, i.e. libcurl)
pcurlFormStart = pcurlFormEnd = NULL;
curl_formadd(&pcurlFormStart, &pcurlFormEnd,
CURLFORM_FILECONTENT, infile,
CURLFORM_CONTENTSLENGTH, content_length,
CURLFORM_CONTENTSLENGTH, content_length,
CURLFORM_CONTENTTYPE, g_content_type,
CURLFORM_END);
curl_formadd(&post, &last,
CURLFORM_END);
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "logotype-image",
CURLFORM_FILECONTENT, "curl.png", CURLFORM_END);
*/
*/
//curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPPOST, pcurlFormStart);
curl_off_t fs = (curl_off_t) content_length;
//curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPPOST, pcurlFormStart);
curl_off_t fs = (curl_off_t) content_length;
pByte = NULL;
lSeek = 0; // initialize the vars we're going to use for byte transfers
pByte = NULL;
lSeek = 0; // initialize the vars we're going to use for byte transfers
// CMC Note: we can make the libcurl_read "fancier" in the future,
// for now it just fwrite's to the file request, which is sufficient
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDSIZE_LARGE, fs);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READFUNCTION, libcurl_read);
// note that in my lib_write I'm sending in a pointer to this instance of HTTP_OP
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READDATA, this);
// CMC Note: we can make the libcurl_read "fancier" in the future,
// for now it just fwrite's to the file request, which is sufficient
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDS, NULL);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POSTFIELDSIZE_LARGE, fs);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READFUNCTION, libcurl_read);
// note that in my lib_write I'm sending in a pointer to this instance of HTTP_OP
curlErr = curl_easy_setopt(curlEasy, CURLOPT_READDATA, this);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POST, 1L);
} else { // GET
want_upload = false;
want_download = true;
curlErr = curl_easy_setopt(curlEasy, CURLOPT_POST, 1L);
} else { // GET
want_upload = false;
want_download = true;
// now write the header, pcurlList gets freed in net_xfer_curl
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
// now write the header, pcurlList gets freed in net_xfer_curl
if (pcurlList) { // send custom headers if required
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPHEADER, pcurlList);
}
// setup the GET!
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPGET, 1L);
}
// setup the GET!
curlErr = curl_easy_setopt(curlEasy, CURLOPT_HTTPGET, 1L);
}
// last but not least, add this to the curl_multi
curlMErr = curl_multi_add_handle(g_curlMulti, curlEasy);
if (curlMErr != CURLM_OK && curlMErr != CURLM_CALL_MULTI_PERFORM) { // bad error, couldn't attach easy curl handle
// last but not least, add this to the curl_multi
curlMErr = curl_multi_add_handle(g_curlMulti, curlEasy);
if (curlMErr != CURLM_OK && curlMErr != CURLM_CALL_MULTI_PERFORM) { // bad error, couldn't attach easy curl handle
msg_printf(0, MSG_ERROR, "%s\n", "Couldn't add curlEasy handle to curlMulti\n");
return curlMErr; // returns 0 (CURLM_OK) on successful handle creation
}
return curlMErr; // returns 0 (CURLM_OK) on successful handle creation
}
// that should about do it, the net_xfer_set polling will actually start the transaction
// for this HTTP_OP
return 0;
// that should about do it, the net_xfer_set polling will actually start the transaction
// for this HTTP_OP
return 0;
}
@ -459,7 +455,7 @@ int HTTP_OP::init_post2(
double size;
//char proxy_buf[256];
strcpy(m_url, url);
strcpy(m_url, url);
parse_url(url, url_hostname, port, filename);
//PROXY::init(url_hostname, port);
//NET_XFER::init(get_proxy_server_name(url_hostname),get_proxy_port(port), HTTP_BLOCKSIZE);
@ -478,7 +474,7 @@ int HTTP_OP::init_post2(
content_length += strlen(req1);
http_op_type = HTTP_OP_POST2;
http_op_state = HTTP_STATE_CONNECTING;
return HTTP_OP::libcurl_exec(url, in, NULL, offset, true);
return HTTP_OP::libcurl_exec(url, in, NULL, offset, true);
}
// Returns true if the HTTP operation is complete
@ -495,7 +491,7 @@ HTTP_OP_SET::HTTP_OP_SET(NET_XFER_SET* p) {
//
int HTTP_OP_SET::insert(HTTP_OP* ho) {
int retval;
retval = net_xfers->insert(ho);
retval = net_xfers->insert(ho);
if (retval) return retval;
http_ops.push_back(ho);
return 0;
@ -543,170 +539,161 @@ int HTTP_OP::set_proxy(PROXY_INFO *new_pi) {
return 0;
}
size_t libcurl_write(void *ptr, size_t size, size_t nmemb, HTTP_OP* phop)
{
// take the stream param as a FILE* and write to disk
//CMC TODO: maybe assert stRead == size*nmemb, add exception handling on phop members
size_t stWrite = fwrite(ptr, size, nmemb, (FILE*) phop->fileOut);
phop->bytes_xferred += (double)(stWrite);
//if (phop->bytes_xferred == (int) phop->content_length)
//{ // that's all we need!
//}
phop->update_speed(); // this should update the transfer speed
return stWrite;
size_t libcurl_write(void *ptr, size_t size, size_t nmemb, HTTP_OP* phop) {
// take the stream param as a FILE* and write to disk
//CMC TODO: maybe assert stRead == size*nmemb, add exception handling on phop members
size_t stWrite = fwrite(ptr, size, nmemb, (FILE*) phop->fileOut);
phop->bytes_xferred += (double)(stWrite);
//if (phop->bytes_xferred == (int) phop->content_length)
//{ // that's all we need!
//}
phop->update_speed(); // this should update the transfer speed
return stWrite;
}
size_t libcurl_read( void *ptr, size_t size, size_t nmemb, HTTP_OP* phop)
{
// OK here's the deal -- phop points to the calling object,
// which has already pre-opened the file. we'll want to
// use pByte as a pointer for fseek calls into the file, and
// write out size*nmemb # of bytes to ptr
size_t libcurl_read( void *ptr, size_t size, size_t nmemb, HTTP_OP* phop) {
// OK here's the deal -- phop points to the calling object,
// which has already pre-opened the file. we'll want to
// use pByte as a pointer for fseek calls into the file, and
// write out size*nmemb # of bytes to ptr
// take the stream param as a FILE* and write to disk
//if (pByte) delete [] pByte;
//pByte = new unsigned char[content_length];
//memset(pByte, 0x00, content_length); // may as will initialize it!
// take the stream param as a FILE* and write to disk
//if (pByte) delete [] pByte;
//pByte = new unsigned char[content_length];
//memset(pByte, 0x00, content_length); // may as will initialize it!
// note that fileIn was opened earlier, go to lSeek from the top and read from there
size_t stSend = size * nmemb;
size_t stRead = 0;
// note that fileIn was opened earlier, go to lSeek from the top and read from there
size_t stSend = size * nmemb;
int stRead = 0;
// if (phop->http_op_type == HTTP_OP_POST2) {
if (phop->req1 && ! phop->bSentHeader) { // need to send headers first, then data file
// uck -- the way 'post2' is done, you have to read the
// header bytes, and then cram on the file upload bytes
// if (phop->http_op_type == HTTP_OP_POST2) {
if (phop->req1 && ! phop->bSentHeader) { // need to send headers first, then data file
// uck -- the way 'post2' is done, you have to read the
// header bytes, and then cram on the file upload bytes
// so requests from 0 to strlen(req1)-1 are from memory,
// and from strlen(req1) to content_length are from the file
// so requests from 0 to strlen(req1)-1 are from memory,
// and from strlen(req1) to content_length are from the file
// just send the headers from htp->req1 if needed
if (phop->lSeek < (long) strlen(phop->req1)) {
// need to read header, either just starting to read (i.e.
// this is the first time in this function for this phop)
// or the last read didn't ask for the entire header
// just send the headers from htp->req1 if needed
if (phop->lSeek < (long) strlen(phop->req1)) {
// need to read header, either just starting to read (i.e.
// this is the first time in this function for this phop)
// or the last read didn't ask for the entire header
stRead = strlen(phop->req1) - phop->lSeek; // how much of header left to read
stRead = strlen(phop->req1) - phop->lSeek; // how much of header left to read
// only memcpy if request isn't out of bounds
if (stRead < 0) {
stRead = 0;
}
else {
memcpy(ptr, (void*)(phop->req1 + phop->lSeek), stRead);
}
phop->lSeek += (long) stRead; // increment lSeek to new position
phop->bytes_xferred += (double)(stRead);
// see if we're done with headers
phop->bSentHeader = (bool)(phop->lSeek >= (long) strlen(phop->req1));
// reset lSeek if done to make it easier for file operations
if (phop->bSentHeader) phop->lSeek = 0;
return stRead; //
}
}
// now for file to read in (if any), also don't bother if this request
// was just enough for the header (which was taken care of above)
if (phop->fileIn) {
// note we'll have to fudge lSeek a little if there was
// also a header, just use a temp var
//size_t stOld = stRead; // we'll want to save the ptr location of last stRead
// only memcpy if request isn't out of bounds
if (stRead < 0) {
stRead = 0;
} else {
memcpy(ptr, (void*)(phop->req1 + phop->lSeek), stRead);
}
phop->lSeek += (long) stRead; // increment lSeek to new position
phop->bytes_xferred += (double)(stRead);
// see if we're done with headers
phop->bSentHeader = (bool)(phop->lSeek >= (long) strlen(phop->req1));
// reset lSeek if done to make it easier for file operations
if (phop->bSentHeader) phop->lSeek = 0;
return stRead; //
}
}
// now for file to read in (if any), also don't bother if this request
// was just enough for the header (which was taken care of above)
if (phop->fileIn) {
// note we'll have to fudge lSeek a little if there was
// also a header, just use a temp var
//size_t stOld = stRead; // we'll want to save the ptr location of last stRead
// keep a separate pointer to "bump ahead" the pointer for the file data
// as ptr may have been used above for the header info
//unsigned char *ptr2;
// get the file seek offset, both from the offset requested (added)
// as well as the size of the header above discounted
// - ((phop->req1 && stRead>0) ? stRead :
// (phop->req1 ? strlen(phop->req1) : 0L))
long lFileSeek = phop->lSeek
+ (long) phop->file_offset;
fseek(phop->fileIn, lFileSeek, SEEK_SET);
if (!feof(phop->fileIn)) { // CMC TODO: better error checking for size*nmemb
// i.e. that we don't go overbounds of the file etc, we can check against
// content_length (which includes the strlen(req1) also)
// note the use of stOld to get to the right position in case the header was read in above
//ptr2 = (unsigned char*)ptr +(int)stOld;
stRead = fread(ptr, 1, stSend, phop->fileIn);
}
phop->lSeek += (long) stRead; // increment lSeek to new position
phop->bytes_xferred += (double)(stRead);
}
phop->update_speed(); // this should update the transfer speed
return stRead;
// keep a separate pointer to "bump ahead" the pointer for the file data
// as ptr may have been used above for the header info
//unsigned char *ptr2;
// get the file seek offset, both from the offset requested (added)
// as well as the size of the header above discounted
// - ((phop->req1 && stRead>0) ? stRead :
// (phop->req1 ? strlen(phop->req1) : 0L))
long lFileSeek = phop->lSeek + (long) phop->file_offset;
fseek(phop->fileIn, lFileSeek, SEEK_SET);
if (!feof(phop->fileIn)) { // CMC TODO: better error checking for size*nmemb
// i.e. that we don't go overbounds of the file etc, we can check against
// content_length (which includes the strlen(req1) also)
// note the use of stOld to get to the right position in case the header was read in above
//ptr2 = (unsigned char*)ptr +(int)stOld;
stRead = fread(ptr, 1, stSend, phop->fileIn);
}
phop->lSeek += (long) stRead; // increment lSeek to new position
phop->bytes_xferred += (double)(stRead);
}
phop->update_speed(); // this should update the transfer speed
return stRead;
}
void HTTP_OP::setupProxyCurl()
{
// CMC: use the libcurl proxy routines with this object's proxy information struct
/* PROXY_INFO pi useful members:
pi.http_server_name
pi.http_server_port
pi.http_user_name
pi.http_user_passwd
pi.socks5_user_name
pi.socks5_user_passwd
pi.socks_server_name
pi.socks_server_port
pi.socks_version
pi.use_http_auth
pi.use_http_proxy
pi.use_socks_proxy
void HTTP_OP::setupProxyCurl() {
// CMC: use the libcurl proxy routines with this object's proxy information struct
/* PROXY_INFO pi useful members:
pi.http_server_name
pi.http_server_port
pi.http_user_name
pi.http_user_passwd
pi.socks5_user_name
pi.socks5_user_passwd
pi.socks_server_name
pi.socks_server_port
pi.socks_version
pi.use_http_auth
pi.use_http_proxy
pi.use_socks_proxy
Curl self-explanatory setopt params for proxies:
CURLOPT_HTTPPROXYTUNNEL
CURLOPT_PROXYTYPE (pass in CURLPROXY_HTTP or CURLPROXY_SOCKS5)
CURLOPT_PROXYPORT -- a long port #
CURLOPT_PROXY - pass in char* of the proxy url
CURLOPT_PROXYUSERPWD -- a char* in the format username:password
CURLOPT_HTTPAUTH -- pass in one of CURLAUTH_BASIC, CURLAUTH_DIGEST,
CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLAUTH_ANY, CURLAUTH_ANYSAFE
CURLOPT_PROXYAUTH -- "or" | the above bitmasks -- only basic, digest, ntlm work
*/
Curl self-explanatory setopt params for proxies:
CURLOPT_HTTPPROXYTUNNEL
CURLOPT_PROXYTYPE (pass in CURLPROXY_HTTP or CURLPROXY_SOCKS5)
CURLOPT_PROXYPORT -- a long port #
CURLOPT_PROXY - pass in char* of the proxy url
CURLOPT_PROXYUSERPWD -- a char* in the format username:password
CURLOPT_HTTPAUTH -- pass in one of CURLAUTH_BASIC, CURLAUTH_DIGEST,
CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLAUTH_ANY, CURLAUTH_ANYSAFE
CURLOPT_PROXYAUTH -- "or" | the above bitmasks -- only basic, digest, ntlm work
*/
CURLcode curlErr;
CURLcode curlErr;
// CMC Note: the string szCurlProxyUserPwd must remain in memory
// outside of this method (libcurl relies on it later when it makes
// the proxy connection), so it has been placed as a member data for HTTP_OP
memset(szCurlProxyUserPwd,0x00,128);
// CMC Note: the string szCurlProxyUserPwd must remain in memory
// outside of this method (libcurl relies on it later when it makes
// the proxy connection), so it has been placed as a member data for HTTP_OP
memset(szCurlProxyUserPwd,0x00,128);
if (pi.use_http_proxy)
{ // setup a basic http proxy
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.http_server_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.http_server_name);
if (pi.use_http_proxy) {
// setup a basic http proxy
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.http_server_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.http_server_name);
if (pi.use_http_auth)
{
if (pi.use_http_auth) {
/* testing!
fprintf(stdout, "Using httpauth for proxy: %s:%d %s:%s\n",
pi.http_server_name, pi.http_server_port,
pi.http_user_name, pi.http_user_passwd);
fprintf(stdout, "Using httpauth for proxy: %s:%d %s:%s\n",
pi.http_server_name, pi.http_server_port,
pi.http_user_name, pi.http_user_passwd);
*/
sprintf(szCurlProxyUserPwd, "%s:%s", pi.http_user_name, pi.http_user_passwd);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, szCurlProxyUserPwd);
}
}
else {
if (pi.use_socks_proxy)
{
//pi.socks_version -- picks between socks5 & socks4 -- but libcurl only socks5!
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.socks_server_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.socks_server_name);
sprintf(szCurlProxyUserPwd, "%s:%s", pi.http_user_name, pi.http_user_passwd);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, szCurlProxyUserPwd);
}
} else {
if (pi.use_socks_proxy) {
//pi.socks_version -- picks between socks5 & socks4 -- but libcurl only socks5!
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYPORT, (long) pi.socks_server_port);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXY, (char*) pi.socks_server_name);
if (strlen(pi.socks5_user_passwd)>0 || strlen(pi.socks5_user_name)>0)
{
sprintf(szCurlProxyUserPwd, "%s:%s", pi.socks5_user_name, pi.socks5_user_passwd);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, szCurlProxyUserPwd);
}
}
}
if (
strlen(pi.socks5_user_passwd)>0 || strlen(pi.socks5_user_name)>0
) {
sprintf(szCurlProxyUserPwd, "%s:%s", pi.socks5_user_name, pi.socks5_user_passwd);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_PROXYUSERPWD, szCurlProxyUserPwd);
}
}
}
}
const char *BOINC_RCSID_57f273bb60 = "$Id$";
#endif // not _USE_CURL

View File

@ -24,12 +24,6 @@
// CMC Note: This was redone to use libcurl ref: http://curl.haxx.se/libcurl
// to allow ease of use for SSL/HTTPS etc
// -D_USE_CURL in your C flags will build a "curl" BOINC client
// note the ifdef _USE_CURL in the *_curl.C/.h files to bypass
// this code (similarly the ifndef _USE_CURL in http/net_xfer/proxy.C/.h)
#ifdef _USE_CURL // only adds this file if user wants to link against libcurl
#ifndef _HTTP_
#define _HTTP_
@ -151,5 +145,3 @@ public:
extern void parse_url(const char* url, char* host, int &port, char* file);
#endif //__HTTP_H
#endif // _USE_CURL

View File

@ -58,10 +58,8 @@ typedef void (CALLBACK* IdleTrackerTerm)();
#include "client_msgs.h"
#include "main.h"
#ifdef _USE_CURL // CMC do the curl initialization here in main
extern int curl_init(void);
extern int curl_cleanup(void);
#endif
// Display a message to the user.
// Depending on the priority, the message may be more or less obtrusive
@ -330,9 +328,7 @@ int main(int argc, char** argv) {
init_core_client(argc, argv);
#ifdef _USE_CURL
curl_init();
#endif
#ifdef _WIN32
// Initialize WinSock
@ -428,9 +424,7 @@ int main(int argc, char** argv) {
}
#endif
#ifdef _USE_CURL
curl_cleanup();
#endif
return retval;
}

View File

@ -28,11 +28,7 @@
#include <cstdio>
#endif
#ifdef _USE_CURL
#include "net_xfer_curl.h"
#else
#include "net_xfer.h"
#endif
#include "miofile.h"
// there's one of these each for upload and download

View File

@ -17,7 +17,6 @@
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifdef _USE_CURL
#include "cpp.h"
@ -436,5 +435,3 @@ void NET_XFER_SET::check_active(bool& up, bool& down) {
}
const char *BOINC_RCSID_e0a7088e04 = "$Id$";
#endif //_USE_CURL

View File

@ -17,8 +17,6 @@
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifdef _USE_CURL
#ifndef _NET_XFER_
#define _NET_XFER_
@ -165,5 +163,3 @@ public:
};
#endif // _H
#endif // _USE_CURL

View File

@ -23,11 +23,7 @@
#include <vector>
#include "client_types.h"
#ifdef _USE_CURL
#include "http_curl.h"
#else
#include "http.h"
#endif
#include "prefs.h"
// SCHEDULER_OP encapsulates the mechanism for

View File

@ -30,7 +30,6 @@ boinc_gui_SOURCES = \
DlgAccountManagerSignup.cpp \
DlgAccountManagerStatus.cpp \
DlgDialupCredentials.cpp \
DlgAttachProject.cpp \
DlgOptions.cpp \
DlgSelectComputer.cpp \
LogBOINC.cpp \

View File

@ -252,8 +252,42 @@ esac
dnl m4/boinc_getsockopt.m4
BOINC_GETSOCKOPT_TYPE
dnl m4/check_ssl.m4
CHECK_SSL
dnl ---------- SSL (m4/check_ssl.m4)
##CHECK_SSL
dnl ---------- libcurl (m4/libcurl.m4) ------------------------------
if test "${enable_client}" = yes; then
LIBCURL_CHECK_CONFIG([yes], [7.13.2], [haveCurl=yes], [haveCurl=no])
if test "${haveCurl}" != yes; then
AC_MSG_ERROR([
================================================================================
ERROR: could not find (recent enough) development-libs for libcurl.
This library is required to build the boinc-client.
(If you don't want to build the client, use --disable-client with configure.
If libcurl-dev is installed on your system, make sure that the script
'curl-config' is found in your PATH, and that
'curl-config --version' gives something recent enough (see above).
You can download libcurl from: http://curl.haxx.se/
================================================================================
])
else
if test "${enable_debug}" = yes; then
echo "LIBCURL = ${LIBCURL}"
echo "LIBCURL_CPPFLAGS = ${LIBCURL_CPPFLAGS}"
fi
## add libcurl et al. to the list of statically linked libs
STATIC_LIB_LIST="${STATIC_LIB_LIST} curl idn crypto ssl"
CPPFLAGS="${CPPFLAGS} ${LIBCURL_CPPFLAGS}"
fi
fi
dnl save the libs
SAVELIBS_AAF="${LIBS}"
@ -269,10 +303,14 @@ SAH_CHECK_LIB([socket], [bind],
[BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"])
SAH_CHECK_LIB([z], [gzopen],
[BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${sah_lib_last}"])
SAH_CHECK_LIB([crypto], [RSA_new],
[BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} -L${SSLDIR}/lib ${sah_lib_last}"])
SAH_CHECK_LIB([ssl], [main],
[BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} -L${SSLDIR}/lib ${sah_lib_last}"])
dnl the following are only checked for libcurl: don't save anything
SAH_CHECK_LIB([crypto], [RSA_new], [])
SAH_CHECK_LIB([ssl], [SSL_accept],[])
SAH_CHECK_LIB([idn], [idn_free],[])
dnl if curl is ok, we add the full LIBCURL to the boinc-libs
SAH_CHECK_LIB([curl], [curl_easy_init],
[BOINC_EXTRA_LIBS="${BOINC_EXTRA_LIBS} ${LIBCURL}"])
LIBS=${SAVELIBS_AAF}
dnl check for pthread
@ -404,7 +442,6 @@ if test -e "/proc/meminfo"; then
AC_DEFINE(HAVE__PROC_MEMINFO, 1, [Define to 1 if /proc/meminfo exists])
fi
dnl ---------- wxWidgets --------------------------------------------------
AM_OPTIONS_WXCONFIG
@ -472,16 +509,20 @@ if ( test "${disable_static_client}" != yes ) && ( test "${enable_client}" = yes
echo "NOTE: Building portable client binaries"
echo "----------"
fi
SAH_CHECK_LIB([stdc++],[sscanf],[
AC_DEFINE([HAVE_LIBSTDC__],[1],[Define to 1 if you have the stdc++ library])
SAH_CHECK_LIB([c],[atexit], [
AC_DEFINE([HAVE_LIBC],[1],[Define to 1 if you have the c library])
CLIENTLIBS="${CLIENTLIBS} ${sah_lib_last}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
SAH_CHECK_LIB([gcc],[sscanf], [
AC_DEFINE([HAVE_LIBGCC],[1],[Define to 1 if you have the gcc library])
CLIENTLIBS="${CLIENTLIBS} ${sah_lib_last}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
SAH_CHECK_LIB([gcc_eh],[_Unwind_Resume],[
AC_DEFINE([HAVE_LIBGCC_EH],[1],[Define to 1 if you have the gcc_eh library])
CLIENTLIBS="${CLIENTLIBS} ${sah_lib_last}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
SAH_CHECK_LIB([gcc],[sscanf], [
AC_DEFINE([HAVE_LIBGCC],[1],[Define to 1 if you have the gcc library])
SAH_CHECK_LIB([stdc++],[sscanf],[
AC_DEFINE([HAVE_LIBSTDC__],[1],[Define to 1 if you have the stdc++ library])
CLIENTLIBS="${CLIENTLIBS} ${sah_lib_last}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
SAH_CHECK_LIB([m],[sin], [
@ -492,10 +533,6 @@ SAH_CHECK_LIB([pthread],[pthread_join],[
AC_DEFINE([HAVE_LIBPTHREAD],[1],[Define to 1 if you have the pthread library])
CLIENTLIBS="${CLIENTLIBS} ${sah_lib_last}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
SAH_CHECK_LIB([c],[atexit], [
AC_DEFINE([HAVE_LIBC],[1],[Define to 1 if you have the c library])
CLIENTLIBS="${CLIENTLIBS} ${sah_lib_last}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
SAH_CHECK_LDFLAG([-nodefaultlibs],[CLIENTLIBS="-nodefaultlibs ${CLIENTLIBS}"])
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5

View File

@ -189,7 +189,8 @@ void DB_USER::db_print(char* buf){
"posts=%d, "
"seti_id=%d, seti_nresults=%d, seti_last_result_time=%d, "
"seti_total_cpu=%.15e, signature='%s', has_profile=%d, "
"cross_project_id='%s', passwd_hash='%s', email_validated=%d",
"cross_project_id='%s', passwd_hash='%s', "
"email_validated=%d, donated=%d",
create_time, email_addr, name,
authenticator,
country, postal_code,
@ -199,7 +200,8 @@ void DB_USER::db_print(char* buf){
posts,
seti_id, seti_nresults, seti_last_result_time,
seti_total_cpu, signature, has_profile,
cross_project_id, passwd_hash, email_validated
cross_project_id, passwd_hash,
email_validated, donated
);
UNESCAPE(email_addr);
UNESCAPE(name);
@ -241,6 +243,7 @@ void DB_USER::db_parse(MYSQL_ROW &r) {
strcpy2(cross_project_id, r[i++]);
strcpy2(passwd_hash, r[i++]);
email_validated = atoi(r[i++]);
donated = atoi(r[i++]);
}
void DB_TEAM::db_print(char* buf){

View File

@ -151,6 +151,7 @@ struct USER {
char cross_project_id[256];
char passwd_hash[256];
bool email_validated;
int donated;
void clear();
};

View File

@ -100,6 +100,7 @@ create table user (
cross_project_id varchar(254) not null,
passwd_hash varchar(254) not null,
email_validated smallint not null,
donated smallint not null,
primary key (id)
) type=InnoDB;

View File

@ -67,8 +67,19 @@ You'll need to install the following software before building BOINC:
<td><br></td>
<td><br></td>
</tr>
<tr>
<td><a href=http://www.openssl.org/>OpenSSL</a> version 0.9.8 or higher
(included with the BOINC source distribution for Windows)
</td>
<td>X</td>
<td>X</td>
<td><br></td>
<td><br></td>
<td><br></td>
</tr>
<tr>
<td><a href=http://curl.haxx.se/>libcurl</a> version 7.14.0 or higher
(included with the BOINC source distribution for Windows)
</td>
<td><br></td>
<td>X</td>
@ -77,7 +88,7 @@ You'll need to install the following software before building BOINC:
<td><br></td>
</tr>
<tr>
<td><a href=http://www.wxwidgets.org/>WxWidgets</a> 2.6
<td><a href=http://www.wxwidgets.org/>WxWidgets</a> 2.6.1
</td>
<td><br></td>
<td><br></td>

View File

@ -263,7 +263,7 @@ function print_login_form_aux($next_url, $user) {
start_table();
row1("Log in with email/password");
row2("Email address:", "<input name=email_addr size=40>");
row2("Password:", "<input name=passwd size=40>");
row2("Password:", "<input type=password name=passwd size=40>");
row1("Log in with account key");
row2("Your account key:
<br><font size=-2>

View File

@ -282,6 +282,10 @@ function update_8_05_2005() {
do_query("update user set email_validated=1");
}
function update_8_25_2005() {
do_query("alter table user add donated smallint not null");
}
//update_10_25_2004();
?>

View File

@ -21,6 +21,8 @@
#define _BOINC_NETWORK_H_
#include <string.h>
#include <unistd.h>
#include "config.h"
struct FDSET_GROUP {
fd_set read_fds;

230
m4/libcurl.m4 Normal file
View File

@ -0,0 +1,230 @@
# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
# [ACTION-IF-YES], [ACTION-IF-NO])
# ----------------------------------------------------------
# David Shaw <dshaw@jabberwocky.com> Jun-21-2005
#
# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
# specify whether to default to --with-libcurl or --without-libcurl.
# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
# minimum version of libcurl to accept. Pass the version as a regular
# version number like 7.10.1. If not supplied, any version is
# accepted. ACTION-IF-YES is a list of shell commands to run if
# libcurl was successfully found and passed the various tests.
# ACTION-IF-NO is a list of shell commands that are run otherwise.
# Note that using --without-libcurl does run ACTION-IF-NO.
#
# This macro defines HAVE_LIBCURL if a working libcurl setup is found,
# and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary values.
# Other useful defines are LIBCURL_FEATURE_xxx where xxx are the
# various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
# where yyy are the various protocols supported by libcurl. Both xxx
# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
# the macro for the complete list of possible defines. Shell
# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
# defined to 'yes' for those features and protocols that were found.
# Note that xxx and yyy keep the same capitalization as in the
# curl-config list (e.g. it's "HTTP" and not "http").
#
# Users may override the detected values by doing something like:
# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
#
# For the sake of sanity, this macro assumes that any libcurl that is
# found is after version 7.7.2, the first version that included the
# curl-config script. Note that it is very important for people
# packaging binary versions of libcurl to include this script!
# Without curl-config, we can only guess what protocols are available.
AC_DEFUN([LIBCURL_CHECK_CONFIG],
[
AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
AH_TEMPLATE([LIBCURL_PROTOCOL_GOPHER],[Defined if libcurl supports GOPHER])
AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
AC_ARG_WITH(libcurl,
AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
[_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
if test "$_libcurl_with" != "no" ; then
AC_PROG_AWK
_libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
_libcurl_try_link=yes
if test -d "$_libcurl_with" ; then
CPPFLAGS="${CPPFLAGS} -I$withval/include"
LDFLAGS="${LDFLAGS} -L$withval/lib"
fi
AC_PATH_PROG([_libcurl_config],[curl-config])
if test x$_libcurl_config != "x" ; then
AC_CACHE_CHECK([for the version of libcurl],
[libcurl_cv_lib_curl_version],
[libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
_libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
_libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
if test $_libcurl_wanted -gt 0 ; then
AC_CACHE_CHECK([for libcurl >= version $2],
[libcurl_cv_lib_version_ok],
[
if test $_libcurl_version -ge $_libcurl_wanted ; then
libcurl_cv_lib_version_ok=yes
else
libcurl_cv_lib_version_ok=no
fi
])
fi
if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
if test x"$LIBCURL_CPPFLAGS" = "x" ; then
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
fi
if test x"$LIBCURL" = "x" ; then
LIBCURL=`$_libcurl_config --libs`
# This is so silly, but Apple actually has a bug in their
# curl-config script. Fixed in Tiger, but there are still
# lots of Panther installs around.
case "${host}" in
powerpc-apple-darwin7*)
LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
;;
esac
fi
# All curl-config scripts support --feature
_libcurl_features=`$_libcurl_config --feature`
# Is it modern enough to have --protocols? (7.12.4)
if test $_libcurl_version -ge 461828 ; then
_libcurl_protocols=`$_libcurl_config --protocols`
fi
else
_libcurl_try_link=no
fi
unset _libcurl_wanted
fi
if test $_libcurl_try_link = yes ; then
# we didn't find curl-config, so let's see if the user-supplied
# link line (or failing that, "-lcurl") is enough.
LIBCURL=${LIBCURL-"-lcurl"}
AC_CACHE_CHECK([whether libcurl is usable],
[libcurl_cv_lib_curl_usable],
[
_libcurl_save_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
_libcurl_save_libs=$LIBS
LIBS="$LIBS $LIBCURL"
AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
/* Try and use a few common options to force a failure if we are
missing symbols or can't link. */
int x;
curl_easy_setopt(NULL,CURLOPT_URL,NULL);
x=CURL_ERROR_SIZE;
x=CURLOPT_WRITEFUNCTION;
x=CURLOPT_FILE;
x=CURLOPT_ERRORBUFFER;
x=CURLOPT_STDERR;
x=CURLOPT_VERBOSE;
]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
CPPFLAGS=$_libcurl_save_cppflags
LIBS=$_libcurl_save_libs
unset _libcurl_save_cppflags
unset _libcurl_save_libs
])
if test $libcurl_cv_lib_curl_usable = yes ; then
# Does curl_free() exist in this version of libcurl?
# If not, fake it with free()
_libcurl_save_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
_libcurl_save_libs=$LIBS
LIBS="$LIBS $LIBCURL"
AC_CHECK_FUNC(curl_free,,
AC_DEFINE(curl_free,free,
[Define curl_free() as free() if our version of curl lacks curl_free.]))
CPPFLAGS=$_libcurl_save_cppflags
LIBS=$_libcurl_save_libs
unset _libcurl_save_cppflags
unset _libcurl_save_libs
AC_DEFINE(HAVE_LIBCURL,1,
[Define to 1 if you have a functional curl library.])
AC_SUBST(LIBCURL_CPPFLAGS)
AC_SUBST(LIBCURL)
for _libcurl_feature in $_libcurl_features ; do
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
done
if test "x$_libcurl_protocols" = "x" ; then
# We don't have --protocols, so just assume that all
# protocols are available
_libcurl_protocols="HTTP FTP GOPHER FILE TELNET LDAP DICT"
if test x$libcurl_feature_SSL = xyes ; then
_libcurl_protocols="$_libcurl_protocols HTTPS"
# FTPS wasn't standards-compliant until version
# 7.11.0
if test $_libcurl_version -ge 461568; then
_libcurl_protocols="$_libcurl_protocols FTPS"
fi
fi
fi
for _libcurl_protocol in $_libcurl_protocols ; do
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
done
fi
fi
unset _libcurl_try_link
unset _libcurl_version_parse
unset _libcurl_config
unset _libcurl_feature
unset _libcurl_features
unset _libcurl_protocol
unset _libcurl_protocols
unset _libcurl_version
fi
if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
# This is the IF-NO path
ifelse([$4],,:,[$4])
else
# This is the IF-YES path
ifelse([$3],,:,[$3])
fi
unset _libcurl_with
])dnl

View File

@ -162,7 +162,7 @@ AC_CACHE_CHECK([$tmp_msg],
SAH_FIND_STATIC_LIB(${libname})
if test -n "${tmp_lib_name}"
then
LIBS="${sah_save_libs} ${tmp_lib_name}"
LIBS="${tmp_lib_name} ${sah_save_libs}"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#define CONFIG_TEST 1
@ -195,7 +195,7 @@ sah_static_lib_last="`eval echo '${'$varname'}'`"
#
if test "${sah_static_lib_last}" != "no"
then
LIBS="${LIBS} ${sah_static_lib_last}"
LIBS="${sah_static_lib_last} ${LIBS}"
AC_DEFINE_UNQUOTED([$ac_uc_defn], [1],
[Define to 1 if the $1 library has the function $2]
)
@ -240,7 +240,7 @@ AC_CACHE_CHECK([$tmp_msg],
for libname in ${sah_dynamic_checklibs}
do
tmp_lib_name="${libname}"
LIBS="${sah_save_libs} ${ld_dynamic_option} ${tmp_lib_name}"
LIBS="${ld_dynamic_option} ${tmp_lib_name} ${sah_save_libs}"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#define CONFIG_TEST 1
@ -260,7 +260,7 @@ AC_CACHE_CHECK([$tmp_msg],
if test "${tmp_res}" = "no"
then
tmp_lib_name="${libname}"
LIBS="${sah_save_libs} ${tmp_lib_name}"
LIBS="${tmp_lib_name} ${sah_save_libs}"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
#define CONFIG_TEST 1
@ -289,7 +289,7 @@ sah_dynamic_lib_last="`eval echo '${'$varname'}'`"
#
if test "${sah_dynamic_lib_last}" != "no"
then
LIBS="${LIBS} ${sah_dynamic_lib_last}"
LIBS="${sah_dynamic_lib_last} ${LIBS}"
AC_DEFINE_UNQUOTED([$ac_uc_defn], [1],
[Define to 1 if the $1 library has the function $2]
)

View File

@ -50,7 +50,7 @@ using namespace std;
#define PIDFILE "file_deleter.pid"
#define SLEEP_INTERVAL 5
#define RESULTS_PER_WU 4 // an estimation of redundancy
#define RESULTS_PER_WU 4 // an estimate of redundancy
SCHED_CONFIG config;
@ -65,7 +65,7 @@ int get_file_path(char *filename, char* upload_dir, int fanout, char* path) {
if (boinc_file_exists(path)) {
return 0;
}
// TODO: get rid of the old hash in about 3/2005
//
dir_hier_path(filename, upload_dir, fanout, false, path);
@ -111,17 +111,17 @@ int wu_delete_files(WORKUNIT& wu) {
);
retval = unlink(pathname);
if (retval && strlen(config.download_dir_alt)) {
sprintf(pathname, "%s/%s", config.download_dir_alt, filename);
retval = unlink(pathname);
sprintf(pathname, "%s/%s", config.download_dir_alt, filename);
retval = unlink(pathname);
}
if (retval) {
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"[WU#%d] unlink %s failed: %d\n",
wu.id, filename, retval
);
mthd_retval = ERR_UNLINK;
mthd_retval = ERR_UNLINK;
} else {
count_deleted++;
count_deleted++;
}
}
}
@ -172,17 +172,17 @@ int result_delete_files(RESULT& result) {
} else {
retval = unlink(pathname);
if (retval) {
mthd_retval = ERR_UNLINK;
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"[RESULT#%d] unlink %s returned %d %s\n",
result.id, pathname, retval,
(retval && errno)?strerror(errno):""
mthd_retval = ERR_UNLINK;
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"[RESULT#%d] unlink %s returned %d %s\n",
result.id, pathname, retval,
(retval && errno)?strerror(errno):""
);
} else {
count_deleted++;
log_messages.printf(SCHED_MSG_LOG::NORMAL,
"[RESULT#%d] unlinked %s\n", result.id, pathname
);
count_deleted++;
log_messages.printf(SCHED_MSG_LOG::NORMAL,
"[RESULT#%d] unlinked %s\n", result.id, pathname
);
}
}
}
@ -222,9 +222,9 @@ bool do_pass(bool retry_error) {
}
if (retry_error) {
sprintf(buf, "where file_delete_state=%d or file_delete_state=%d %s limit 1000", FILE_DELETE_READY, FILE_DELETE_ERROR, mod_clause);
sprintf(buf, "where file_delete_state=%d or file_delete_state=%d %s limit 1000", FILE_DELETE_READY, FILE_DELETE_ERROR, mod_clause);
} else {
sprintf(buf, "where file_delete_state=%d %s limit 1000", FILE_DELETE_READY, mod_clause);
sprintf(buf, "where file_delete_state=%d %s limit 1000", FILE_DELETE_READY, mod_clause);
}
while (!wu.enumerate(buf)) {
did_something = true;
@ -234,10 +234,10 @@ bool do_pass(bool retry_error) {
retval = wu_delete_files(wu);
}
if (retval) {
wu.file_delete_state = FILE_DELETE_ERROR;
wu.file_delete_state = FILE_DELETE_ERROR;
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "[WU#%d] update failed: %d\n", wu.id, retval);
} else {
wu.file_delete_state = FILE_DELETE_DONE;
wu.file_delete_state = FILE_DELETE_DONE;
}
sprintf(buf, "file_delete_state=%d", wu.file_delete_state);
retval= wu.update_field(buf);
@ -246,10 +246,10 @@ bool do_pass(bool retry_error) {
for (result_loop_count=0; result_loop_count < RESULTS_PER_WU; result_loop_count++) {
if ( retry_error ) {
sprintf(buf, "where file_delete_state=%d or file_delete_state=%d %s limit 1000",
FILE_DELETE_READY, FILE_DELETE_ERROR, mod_clause);
sprintf(buf, "where file_delete_state=%d or file_delete_state=%d %s limit 1000",
FILE_DELETE_READY, FILE_DELETE_ERROR, mod_clause);
} else {
sprintf(buf, "where file_delete_state=%d %s limit 1000", FILE_DELETE_READY, mod_clause);
sprintf(buf, "where file_delete_state=%d %s limit 1000", FILE_DELETE_READY, mod_clause);
}
while (!result.enumerate(buf)) {
@ -259,13 +259,13 @@ bool do_pass(bool retry_error) {
retval = result_delete_files(result);
}
if (retval) {
result.file_delete_state = FILE_DELETE_ERROR;
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "[RESULT#%d] update failed: %d\n", result.id, retval);
result.file_delete_state = FILE_DELETE_ERROR;
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "[RESULT#%d] update failed: %d\n", result.id, retval);
} else {
result.file_delete_state = FILE_DELETE_DONE;
result.file_delete_state = FILE_DELETE_DONE;
}
sprintf(buf, "file_delete_state=%d", result.file_delete_state);
retval= result.update_field(buf);
sprintf(buf, "file_delete_state=%d", result.file_delete_state);
retval= result.update_field(buf);
}
}
@ -320,10 +320,13 @@ int delete_antique_files(int max_to_delete) {
char pathname[1024];
int retval;
FILE_RECORD fr=files_to_delete.front();
check_stop_daemons();
FILE_RECORD fr = files_to_delete.front();
check_stop_daemons();
retval=get_file_path((char *)fr.name.c_str(), config.upload_dir, config.uldl_dir_fanout, pathname);
retval = get_file_path(
(char*)fr.name.c_str(), config.upload_dir,
config.uldl_dir_fanout, pathname
);
if (retval) {
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"get_file_path(%s) failed: %d\n",
@ -332,23 +335,22 @@ int delete_antique_files(int max_to_delete) {
return -1;
}
strcpy(timestamp, time_to_string(fr.date_modified));
strcpy(timestamp, time_to_string(fr.date_modified));
log_messages.printf(SCHED_MSG_LOG::DEBUG,
"deleting [antique %s] %s\n",
timestamp, pathname
);
if (unlink(pathname)) {
int save_error=errno;
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"unlink(%s) failed: %s\n",
pathname, strerror(save_error)
int save_error=errno;
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"unlink(%s) failed: %s\n",
pathname, strerror(save_error)
);
return -1;
}
else {
return -1;
} else {
nfiles++;
files_to_delete.pop_front();
}
files_to_delete.pop_front();
}
} // while
return nfiles;
}
@ -368,7 +370,7 @@ int add_antiques_to_list(int days) {
if (!apache_info) {
log_messages.printf(SCHED_MSG_LOG::CRITICAL, "no user named 'apache' found!\n");
return -1;
return -1;
}
sprintf(command, "find %s -type f -mtime +%d", config.upload_dir, days);
@ -385,50 +387,50 @@ int add_antiques_to_list(int days) {
while (fgets(single_line, 1024, fp)) {
char pathname[1024];
char *fname_at_end=NULL;
int nchars=strlen(single_line);
struct stat statbuf;
char *err=NULL;
char *fname_at_end=NULL;
int nchars=strlen(single_line);
struct stat statbuf;
const char *err=NULL;
FILE_RECORD fr;
// We can interrupt this at any point.
// pclose() is called when process exits.
// We can interrupt this at any point.
// pclose() is called when process exits.
check_stop_daemons();
// Do serious sanity checking on the path before
// adding the file!!
//
if (!err && nchars > 1022) err="line too long";
if (!err && nchars < dirlen + 1) err="path shorter than upload directory name";
if (!err && single_line[nchars-1] != '\n') err="no newline terminator in line";
if (!err && strncmp(config.upload_dir, single_line, dirlen)) err="upload directory not in path";
if (!err && single_line[dirlen] != '/') err="no slash separator in path";
if (!err) single_line[nchars-1]='\0';
if (!err && stat(single_line, &statbuf)) err="stat failed";
if (!err && statbuf.st_mtime > del_time) err="file too recent";
if (!err && apache_info->pw_uid != statbuf.st_uid) err="file not owned by httpd user";
if (!err && !(fname_at_end=rindex(single_line+dirlen, '/'))) err="no trailing filename";
if (!err) fname_at_end++;
if (!err && !strlen(fname_at_end)) err="trailing filename too short";
if (!err && get_file_path(fname_at_end, config.upload_dir, config.uldl_dir_fanout, pathname)) err="get_file_path() failed";
if (!err && strcmp(pathname, single_line)) err="file in wrong hierarchical upload subdirectory";
// Do serious sanity checking on the path before
// adding the file!!
//
if (!err && nchars > 1022) err="line too long";
if (!err && nchars < dirlen + 1) err="path shorter than upload directory name";
if (!err && single_line[nchars-1] != '\n') err="no newline terminator in line";
if (!err && strncmp(config.upload_dir, single_line, dirlen)) err="upload directory not in path";
if (!err && single_line[dirlen] != '/') err="no slash separator in path";
if (!err) single_line[nchars-1]='\0';
if (!err && stat(single_line, &statbuf)) err="stat failed";
if (!err && statbuf.st_mtime > del_time) err="file too recent";
if (!err && apache_info->pw_uid != statbuf.st_uid) err="file not owned by httpd user";
if (!err && !(fname_at_end=rindex(single_line+dirlen, '/'))) err="no trailing filename";
if (!err) fname_at_end++;
if (!err && !strlen(fname_at_end)) err="trailing filename too short";
if (!err && get_file_path(fname_at_end, config.upload_dir, config.uldl_dir_fanout, pathname)) err="get_file_path() failed";
if (!err && strcmp(pathname, single_line)) err="file in wrong hierarchical upload subdirectory";
if (err) {
if (err) {
log_messages.printf(SCHED_MSG_LOG::CRITICAL,
"Can't list %s for deletion: %s\n",
single_line, err
"Can't list %s for deletion: %s\n",
single_line, err
);
// This file deleting business is SERIOUS. Give up at the
// first sign of ANYTHING amiss.
//
pclose(fp);
return -3;
}
// This file deleting business is SERIOUS. Give up at the
// first sign of ANYTHING amiss.
//
pclose(fp);
return -3;
}
// insert this file onto the list
fr.date_modified = statbuf.st_mtime;
fr.name = fname_at_end;
files_to_delete.push_back(fr);
fr.date_modified = statbuf.st_mtime;
fr.name = fname_at_end;
files_to_delete.push_back(fr);
unsorted = true;
nfiles++;
@ -467,7 +469,7 @@ int find_antique_files() {
int days = 1 + (time(0) - wu.create_time)/86400;
if (days<31) days=31;
return add_antiques_to_list(days);
return add_antiques_to_list(days);
}
return 0;
}