diff --git a/tools/backend_lib.cpp b/tools/backend_lib.cpp index 3c61792ab4..edee36a90f 100644 --- a/tools/backend_lib.cpp +++ b/tools/backend_lib.cpp @@ -51,6 +51,8 @@ using std::string; +// the random part of output filenames needs to be hard to guess +// static struct random_init { random_init() { srand48(getpid() + time(0)); @@ -158,9 +160,11 @@ int create_result( int retval; initialize_result(result, wu); + result.random = lrand48(); + result.priority += priority_increase; sprintf(result.name, "%s_%s", wu.name, result_name_suffix); - sprintf(base_outfile_name, "%s_", result.name); + sprintf(base_outfile_name, "%s_%ld", result.name, lrand48()); retval = read_filename( result_template_filename, result_template, sizeof(result_template) ); diff --git a/tools/process_result_template.cpp b/tools/process_result_template.cpp index a1cabe0c03..bd55dd619f 100644 --- a/tools/process_result_template.cpp +++ b/tools/process_result_template.cpp @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include "boinc_db.h" #include "error_numbers.h" @@ -34,18 +32,9 @@ #include "fcgi_stdio.h" #endif -#define OUTFILE_MACRO "" -// the random part of output filenames needs to be hard to guess -// -static struct random_init { - random_init() { - srand48(getpid() + time(0)); - } -} random_init; - // Add a signature at the end of every element, // int add_signatures(char* xml, R_RSA_PRIVATE_KEY& key) { @@ -118,8 +107,6 @@ int remove_signatures(char* xml) { // macro-substitute a result template: // - replace OUTFILE_x with base_filename_x, etc. -// - replace RANDFILE_x with base_filename_r_x, etc., where r is a -// large random number // - add signatures for file uploads // - strip enclosing tags // @@ -133,7 +120,7 @@ int process_result_template( SCHED_CONFIG& config_loc ) { char* p,*q; - char temp[BLOB_SIZE], buf[256], buf2[256]; + char temp[BLOB_SIZE], buf[256]; int retval; while (1) { @@ -151,22 +138,6 @@ int process_result_template( strcat(p, temp); continue; } - p = strstr(result_template, RANDFILE_MACRO); - if (p) { - q = p+strlen(RANDFILE_MACRO); - char* endptr = strstr(q, "/>"); - if (!endptr) return ERR_XML_PARSE; - if (strchr(q, '>') != endptr+1) return ERR_XML_PARSE; - *endptr = 0; - strcpy(buf, q); - sprintf(buf2, "%ld_", lrand48()); - strcpy(temp, endptr+2); - strcpy(p, base_filename); - strcpy(p, buf2); - strcat(p, buf); - strcat(p, temp); - continue; - } p = strstr(result_template, UPLOAD_URL_MACRO); if (p) { strcpy(temp, p+strlen(UPLOAD_URL_MACRO));