diff --git a/checkin_notes b/checkin_notes index 9c260111ea..dcc942e78d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -11556,3 +11556,31 @@ David April 13 2004 sched/ make_work.C + +David April 13 2004 + - Changes in the parsing of WU template files: + - Any unrecognized elements in a + are now just copied to the output. + So you can include attributes like + and they'll get propagated correctly. + - The following items can now be included in a WU template: + rsc_fpops_est + rsc_fpops_bound + rsc_memory_bound + rsc_disk_bound + delay_bound + min_quorum + target_nresults + max_error_results + max_total_results + + These are not copied to the output, + but are used to populate the WORKUNIT + (which is now passed in as an arg) + + The latter means that 'create_work' (the cmdline program) is simplified; + it can now take as few as 4 args + + tools + backend_lib.C + create_work.C diff --git a/db/db_base.C b/db/db_base.C index 9810e2ff9d..ad4b6d09a9 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -207,7 +207,7 @@ int DB_BASE::sum(double& x, char* field, char* clause) { // convert a string into a form that allows it to be used // in SQL queries delimited by single quotes: -// replace ' with \', \ with \\ +// replace ' with \', \ with \\ // void escape_string(char* field, int len) { char buf[MAX_QUERY_LEN]; diff --git a/doc/backend_programs.php b/doc/backend_programs.php index eb193d77a0..8622d08263 100644 --- a/doc/backend_programs.php +++ b/doc/backend_programs.php @@ -20,9 +20,9 @@ for registering the workunits in the database.

During testing, you can create a single workunit using create_work, -then use +then use the daemon program make_work -to make copies as needed to maintain a supply of work. +to copy this workunit as needed to maintain a given supply of work.

Transitioning

diff --git a/doc/software.php b/doc/software.php index 29e2a900e7..e4e0ab1c81 100644 --- a/doc/software.php +++ b/doc/software.php @@ -27,7 +27,8 @@ Required on the database server: After installing and running the server, grant permissions for your own account and for -the account under which Apache runs: +the account under which Apache runs +('nobody' in the following; may be different on your machine):

     mysql -u root
     grant all on *.* to yourname@localhost;
diff --git a/doc/tools_work.php b/doc/tools_work.php
index b71d0d0623..b05ba1b8ab 100644
--- a/doc/tools_work.php
+++ b/doc/tools_work.php
@@ -14,17 +14,26 @@ A WU template file has the form
 
",htmlspecialchars("
 
     0
-    [ ... ]
+    [ , other attributes]
 
 [ ... ]
 
     
-        0
+        0
         NAME
     
     [ ... ]
     [ -flags xyz ]
     [ name=val&name=val ]
+    [ x ]
+    [ x ]
+    [ x ]
+    [ x ]
+    [ x ]
+    [ x ]
+    [ x ]
+    [ x ]
+    [ x ]
 
 "), "
 
@@ -32,12 +41,15 @@ The components are: "; list_start(); list_item(htmlspecialchars(", "), -"Each pair describes an input file"); +"Each pair describes an input file"); list_item(htmlspecialchars(""), "The command-line arguments to be passed to the main program."); list_item(htmlspecialchars(""), "A list of environment variables in the form name=value&name=value&name=value."); +list_item("Other elements", + "Work unit attributes" +); list_end(); echo" When a workunit is created, the template file is processed as follows: @@ -49,7 +61,8 @@ It is replaced with elements giving the filename, download URL, MD5 checksum, and size.
  • Within a <file_ref> element, -<file_number>x</file_number> is replaced with the filename. +<file_number>x</file_number> is replaced with an element +giving the filename.

    Result template files

    @@ -90,6 +103,8 @@ create_work -wu_name name // workunit name -wu_template filename // WU template filename -result_template filename // result template filename + + // The following are normally supplied in config.xml: [ -db_name x ] // database name [ -db_passwd x ] // database password [ -db_host x ] // database host @@ -97,17 +112,20 @@ create_work [ -upload_url x ] // URL for output file upload [ -download_url x ] // base URL for input file download [ -download_dir x ] // where to move input files + [ -keyfile x ] // path of upload private key + + // The following are normally supplied in the WU template: [ -rsc_fpops_est x ] [ -rsc_fpops_bound x ] [ -rsc_memory_bound x ] [ -rsc_disk_bound x ] - [ -keyfile x ] // path of upload private key [ -delay_bound x ] [ -min_quorum x ] [ -target_nresults x ] [ -max_error_results x ] [ -max_total_results x ] [ -max_success_results x ] + infile_1 ... infile_m // input files

  • The workunit parameters are documented here. @@ -155,10 +173,11 @@ delay_bound All other fields should be zeroed. +

    Make_work

    -The program +The daemon program

     make_work -wu_name name -cushion N
     
    diff --git a/html/forum/edit.php b/html/forum/edit.php index 3fe75cfe8e..21cdbb68ac 100644 --- a/html/forum/edit.php +++ b/html/forum/edit.php @@ -3,6 +3,7 @@ require_once('../inc/forum.inc'); require_once('../inc/util.inc'); +$logged_in_user = get_logged_in_user(); if ($_POST['submit']) { if (empty($_GET['id'])) { @@ -13,13 +14,21 @@ if ($_POST['submit']) { $post = getPost($_GET['id']); $thread = getThread($post->thread); + + if ($logged_in_user->id != $post->user) { + // Can't edit other's posts. + echo "You are not authorized to edit this post."; + exit(); + } updatePost($post->id, $_POST['content']); + if ($post->parent_post==0){ + updateThread($thread->id, $_POST['title']); + } header('Location: thread.php?id='.$thread->id); } -$logged_in_user = get_logged_in_user(); page_head('Forum', $logged_in_user, NULL, 'forum.css'); @@ -45,6 +54,14 @@ show_forum_title($forum, $thread, $category->is_helpdesk); echo "
    id, "\" method=\"POST\">"; start_forum_table(array("Edit Your Post"), array(NULL), 2); +if ($post->parent_post==0) { + //If this is the first post enable the user to change title + echo " + Thread title + title)."\"> + " + ; +}; echo " diff --git a/tools/backend_lib.C b/tools/backend_lib.C index dea94bae29..ce2fee0dfc 100644 --- a/tools/backend_lib.C +++ b/tools/backend_lib.C @@ -25,8 +25,10 @@ #include "boinc_db.h" #include "crypt.h" +#include "error_numbers.h" #include "md5_file.h" #include "parse.h" +#include "util.h" #include "backend_lib.h" @@ -53,12 +55,13 @@ int read_filename(const char* path, char* buf) { // process WU template // static int process_wu_template( - const char* wu_name, char* tmplate, char* out, + WORKUNIT& wu, char* tmplate, const char* dirpath, const char** infiles, int n, const char* upload_url, const char* download_url ) { char* p; char buf[MEDIUM_BLOB_SIZE], md5[33], path[256]; + char out[LARGE_BLOB_SIZE]; int retval, file_number; double nbytes; char open_name[256]; @@ -68,45 +71,89 @@ static int process_wu_template( p = strtok(tmplate, "\n"); while (p) { if (match_tag(p, "")) { - } else if (parse_int(p, "", file_number)) { - } else if (match_tag(p, "")) { - sprintf(path, "%s/%s", dirpath, infiles[file_number]); - retval = md5_file(path, md5, nbytes); - if (retval) { - fprintf(stderr, "process_wu_template: md5_file %d\n", retval); - return 1; + file_number = -1; + strcat(out, "\n"); + while (1) { + p = strtok(0, "\n"); + if (!p) break; + if (parse_int(p, "", file_number)) { + continue; + } else if (match_tag(p, "")) { + if (file_number < 0) { + fprintf(stderr, "No file number found\n"); + return ERR_XML_PARSE; + } + sprintf(path, "%s/%s", dirpath, infiles[file_number]); + retval = md5_file(path, md5, nbytes); + if (retval) { + fprintf(stderr, "process_wu_template: md5_file %d\n", retval); + return retval; + } + sprintf(buf, + " %s\n" + " %s/%s\n" + " %s\n" + " %.0f\n" + "\n", + infiles[file_number], + download_url, infiles[file_number], + md5, + nbytes + ); + strcat(out, buf); + break; + } else { + strcat(out, p); + strcat(out, "\n"); + } } - sprintf(buf, - "\n" - " %s\n" - " %s/%s\n" - " %s\n" - " %.0f\n" - "\n", - infiles[file_number], - download_url, infiles[file_number], - md5, - nbytes - ); - strcat(out, buf); } else if (match_tag(p, "")) { found = true; strcat(out, "\n"); } else if (match_tag(p, "")) { strcat(out, "\n"); } else if (match_tag(p, "")) { - } else if (parse_int(p, "", file_number)) { - } else if (parse_str(p, "", open_name, sizeof(open_name))) { - } else if (match_tag(p, "")) { - sprintf(buf, - "\n" - " %s\n" - " %s\n" - "\n", - infiles[file_number], - open_name - ); - strcat(out, buf); + file_number = -1; + while (1) { + p = strtok(0, "\n"); + if (!p) break; + if (parse_int(p, "", file_number)) { + continue; + } else if (parse_str(p, "", open_name, sizeof(open_name))) { + continue; + } else if (match_tag(p, "")) { + sprintf(buf, + "\n" + " %s\n" + " %s\n" + "\n", + infiles[file_number], + open_name + ); + strcat(out, buf); + break; + } + } + } else if (parse_double(p, "", wu.rsc_fpops_est)) { + continue; + } else if (parse_double(p, "", wu.rsc_fpops_bound)) { + continue; + } else if (parse_double(p, "", wu.rsc_memory_bound)) { + continue; + } else if (parse_double(p, "", wu.rsc_disk_bound)) { + continue; + } else if (parse_int(p, "", wu.delay_bound)) { + continue; + } else if (parse_int(p, "", wu.min_quorum)) { + continue; + } else if (parse_int(p, "", wu.target_nresults)) { + continue; + } else if (parse_int(p, "", wu.max_error_results)) { + continue; + } else if (parse_int(p, "", wu.max_total_results)) { + continue; + } else if (parse_int(p, "", wu.max_success_results)) { + continue; } else { strcat(out, p); strcat(out, "\n"); @@ -117,6 +164,7 @@ static int process_wu_template( fprintf(stderr, "create_work: bad WU template - no \n"); return -1; } + safe_strncpy(wu.xml_doc, out, sizeof(wu.xml_doc)); return 0; } @@ -146,6 +194,7 @@ void initialize_result(DB_RESULT& result, DB_WORKUNIT& wu) { } // Create a new result for the given WU. +// This is called ONLY from the transitioner // int create_result( DB_WORKUNIT& wu, char* result_template, @@ -224,7 +273,7 @@ int create_work( strcpy(wu_template, _wu_template); wu.create_time = time(0); retval = process_wu_template( - wu.name, wu_template, wu.xml_doc, infile_dir, infiles, ninfiles, + wu, wu_template, infile_dir, infiles, ninfiles, upload_url, download_url ); if (retval) { diff --git a/tools/process_result_template.C b/tools/process_result_template.C index b8bd73777a..e7e28589bd 100644 --- a/tools/process_result_template.C +++ b/tools/process_result_template.C @@ -109,6 +109,9 @@ int remove_signatures(char* xml) { // - replace OUTFILE_x with base_filename_x, etc. // - add signatures for file uploads // +// This is called only from the transitioner, +// to create a new result for a WU +// int process_result_template( char* result_template, R_RSA_PRIVATE_KEY& key, @@ -145,6 +148,7 @@ int process_result_template( } // macro-substitute a result template only for UPLOAD_URL_MACRO +// This is called (from create_work()) when a WU is being created // int process_result_template_upload_url_only( char* result_template,