diff --git a/checkin_notes b/checkin_notes index 5fcd40181f..6d0b05c1d9 100755 --- a/checkin_notes +++ b/checkin_notes @@ -11650,3 +11650,27 @@ Rom April 15 2004 client/ cpu_benchmark.h + +David April 18 2004 + - Added cross-project identification (scheme developed by Janus Kristensen) + + NOTE: this involves a database change (new field in user table). + You must update your database by adding the field and initializing it + (see html/ops/db_update.php) before using this code. + + client/ + client_types.C,h + cs_scheduler.C + db/ + boinc_db.C,h + schema.sql + html/ + user/ + create_account_action.php + ops/ + db_update.php (new) + py/Boinc/ + database.py + sched/ + db_dump.C + server_types.C diff --git a/client/client_types.C b/client/client_types.C index d80b80c42a..f96e8e10b9 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -52,6 +52,8 @@ void PROJECT::init() { strcpy(project_name, ""); strcpy(user_name, ""); strcpy(team_name, ""); + strcpy(email_hash, ""); + strcpy(cross_project_id, ""); user_total_credit = 0; user_expavg_credit = 0; user_create_time = 0; @@ -268,6 +270,8 @@ int PROJECT::parse_state(FILE* in) { strcpy(project_name, ""); strcpy(user_name, ""); strcpy(team_name, ""); + strcpy(email_hash, ""); + strcpy(cross_project_id, ""); resource_share = 100; exp_avg_cpu = 0; exp_avg_mod_time = 0; @@ -287,6 +291,8 @@ int PROJECT::parse_state(FILE* in) { else if (parse_str(buf, "", project_name, sizeof(project_name))) continue; else if (parse_str(buf, "", user_name, sizeof(user_name))) continue; else if (parse_str(buf, "", team_name, sizeof(team_name))) continue; + else if (parse_str(buf, "", email_hash, sizeof(email_hash))) continue; + else if (parse_str(buf, "", cross_project_id, sizeof(cross_project_id))) continue; else if (parse_double(buf, "", user_total_credit)) continue; else if (parse_double(buf, "", user_expavg_credit)) continue; else if (parse_int(buf, "", (int &)user_create_time)) continue; @@ -339,6 +345,8 @@ int PROJECT::write_state(FILE* out) { " %s\n" " %s\n" " %s\n" + " %s\n" + " %s\n" " %f\n" " %f\n" " %d\n" @@ -357,6 +365,8 @@ int PROJECT::write_state(FILE* out) { project_name, u2.c_str(), t2.c_str(), + email_hash, + cross_project_id, user_total_credit, user_expavg_credit, user_create_time, @@ -391,6 +401,8 @@ void PROJECT::copy_state_fields(PROJECT& p) { safe_strcpy(project_name, p.project_name); safe_strcpy(user_name, p.user_name); safe_strcpy(team_name, p.team_name); + safe_strcpy(email_hash, p.email_hash); + safe_strcpy(cross_project_id, p.cross_project_id); user_total_credit = p.user_total_credit; user_expavg_credit = p.user_expavg_credit; user_create_time = p.user_create_time; diff --git a/client/client_types.h b/client/client_types.h index fa963b5289..b0d33b2897 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -32,6 +32,7 @@ #include #endif +#include "md5_file.h" #include "hostinfo.h" #include "result_state.h" @@ -137,6 +138,8 @@ public: char project_name[256]; // descriptive. not unique char user_name[256]; char team_name[256]; + char email_hash[MD5_LEN]; + char cross_project_id[MD5_LEN]; double user_total_credit; // as reported by server double user_expavg_credit; // as reported by server unsigned int user_create_time; // as reported by server diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index f700ef5eb1..d5114a3046 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -293,9 +293,8 @@ int CLIENT_STATE::remove_trickle_files(PROJECT* project) { return 0; } -// Prepare the scheduler request. This writes the request in XML to a -// file (SCHED_OP_REQUEST_FILE) which is later sent to the scheduling -// server +// Prepare the scheduler request. This writes the request to a +// file (SCHED_OP_REQUEST_FILE) which is later sent to the scheduling server // int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) { FILE* f = boinc_fopen(SCHED_OP_REQUEST_FILE, "wb"); @@ -303,6 +302,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) { RESULT* rp; int retval; double size; + char cross_project_id[MD5_LEN]; if (!f) return ERR_FOPEN; fprintf(f, @@ -351,6 +351,20 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) { } } + // send the maximum of cross_project_id over projects + // with the same email hash as this one + // + strcpy(cross_project_id, p->cross_project_id); + for (i=0; iemail_hash, p->email_hash)) continue; + if (strcmp(project->cross_project_id, cross_project_id) > 0) { + strcpy(cross_project_id, project->cross_project_id); + } + } + fprintf(f, "%s\n", cross_project_id); + fprintf(f, "\n"); for (i=0; iid"); + } +} + +update_4_18_2004(); + +?> diff --git a/html/user/create_account_action.php b/html/user/create_account_action.php index dc2e12ff15..3ad673f81a 100644 --- a/html/user/create_account_action.php +++ b/html/user/create_account_action.php @@ -64,9 +64,10 @@ function show_error($str) { } $authenticator = random_string(); + $cross_project_id = random_string(); $munged_email_addr = munge_email_addr($new_email_addr, $authenticator); $query = sprintf( - "insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts) values(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, '$project_prefs', $teamid, 'home', '', 1, 1)", + "insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts, cross_project_id) values(%d, '%s', '%s', '%s', '%s', '%s', 0, 0, 0, '$project_prefs', $teamid, 'home', '', 1, 1, $cross_project_id)", time(), $munged_email_addr, $new_name, diff --git a/py/Boinc/database.py b/py/Boinc/database.py index dd51bdd544..dcc14642db 100644 --- a/py/Boinc/database.py +++ b/py/Boinc/database.py @@ -102,7 +102,8 @@ class User(DatabaseObject): 'seti_last_result_time', 'seti_total_cpu', 'signature', - 'has_profile' + 'has_profile', + 'cross_project_id' ]) class Team(DatabaseObject): diff --git a/sched/db_dump.C b/sched/db_dump.C index fae3172024..7758e2124f 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -61,6 +61,7 @@ #include "boinc_db.h" #include "util.h" +#include "md5_file.h" #include "parse.h" #include "sched_config.h" @@ -272,12 +273,17 @@ void write_host(HOST& host, FILE* f, bool detail, bool show_user) { void write_user(USER& user, FILE* f, bool detail, bool show_team) { DB_HOST host; - char buf[256]; + char buf[1024]; + char cpid[MD5_LEN]; string name, url; xml_escape(user.name, name); xml_escape(user.url, url); + strcpy(buf, user.cross_project_id); + strcat(buf, user.email_addr); + md5_block((unsigned char*)buf, strlen(buf), cpid); + fprintf(f, "\n" " %d\n" @@ -286,14 +292,16 @@ void write_user(USER& user, FILE* f, bool detail, bool show_team) { " %s\n" " %d\n" " %f\n" - " %f\n", + " %f\n" + " %s\n", user.id, name.c_str(), url.c_str(), user.country, user.create_time, user.total_credit, - user.expavg_credit + user.expavg_credit, + cpid ); if (show_team) { fprintf(f, diff --git a/sched/server_types.C b/sched/server_types.C index 1c7c0a683d..fb6e7c9c68 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -26,6 +26,7 @@ using namespace std; #include #include "parse.h" +#include "md5_file.h" #include "error_numbers.h" #include "util.h" #include "main.h" @@ -175,6 +176,7 @@ int SCHEDULER_REPLY::write(FILE* fout) { unsigned int i, j; string u1, u2, t1, t2; int retval; + char email_hash[MD5_LEN]; fprintf(fout, "\n" @@ -199,6 +201,7 @@ int SCHEDULER_REPLY::write(FILE* fout) { u1 = user.name; xml_escape(u1, u2); + md5_block((unsigned char*)user.email_addr, strlen(user.email_addr), email_hash); fprintf(fout, "%s\n" "%f\n" @@ -206,14 +209,18 @@ int SCHEDULER_REPLY::write(FILE* fout) { "%d\n" "%f\n" "%f\n" - "%s\n", + "%s\n" + "%s\n" + "%s\n", u2.c_str(), user.total_credit, user.expavg_credit, user.create_time, host.total_credit, host.expavg_credit, - host.venue + host.venue, + email_hash, + user.cross_project_id ); // might want to send team credit too.