From a1ab5738572a1b12e784379261171c72ff4465b0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 21 May 2008 22:33:21 +0000 Subject: [PATCH] - scheduler: if client has bad code sign key, don't send work svn path=/trunk/boinc/; revision=15270 --- checkin_notes | 6 +++ doc/get_platforms.inc | 96 ++++++++++++++++++++++++++++++++++++++++++ sched/handle_request.C | 12 ++++-- 3 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 doc/get_platforms.inc diff --git a/checkin_notes b/checkin_notes index f9e8708717..f0d3d9b7cf 100644 --- a/checkin_notes +++ b/checkin_notes @@ -4217,3 +4217,9 @@ David May 21 2008 html/user/ white.css + +David May 21 2008 + - scheduler: if client has bad code sign key, don't send work + + sched/ + handle_request.C diff --git a/doc/get_platforms.inc b/doc/get_platforms.inc new file mode 100644 index 0000000000..b986bf1ebb --- /dev/null +++ b/doc/get_platforms.inc @@ -0,0 +1,96 @@ +")) return $tag; + $y = substr($x, strlen($tag)); + $n = strpos($y, $closetag); + if ($n) { + $element = substr($y, 0, $n); + } + $cursor = (strlen($xml) - strlen($x)) + strlen($tag) + strlen($closetag) + strlen($element); + } + return trim($element); +} + +function friendly_name($p) { + switch ($p) { + case 'i686-pc-linux-gnu': return 'Linux/x86'; + case 'windows_intelx86': return 'Windows'; + case 'x86_64-pc-linux-gnu': return 'Linux/x86_64'; + case 'i686-apple-darwin': return 'Mac OS/X'; + case 'powerpc-apple-darwin': return 'Mac OS/X (PowerPC)'; + case 'sparc-sun-solaris2.7': return 'SPARC Solaris 2.7'; + case 'sparc-sun-solaris': return 'SPARC Solaris'; + case 'powerpc64-unknown-linux-gnu': return 'Linux/PowerPC64'; + case 'windows_x86_64': return 'Windows/x86_64'; + } + return $p; +} + +function get_platforms($url) { + $url .= 'get_project_config.php'; + $x = file_get_contents($url); + if (!$x) return null; + $cursor = 0; + $list = null; + $tag = ''; + if (!strstr($x, "")) $tag = ''; + while (1) { + $p = parse_next_element($x, $tag, $cursor); + if (!$p) break; + $list[] = friendly_name($p); + } + return array_unique($list); +} + +function show_list($l) { + $x = ""; + $first = true; + foreach($l as $p) { + if ($first) { + $x .= "$p"; + $first = false; + } else { + $x .= ", $p"; + } + } + return $x; +} + +function get_platforms_cached($url, $argv) { + $u = urlencode($url); + $fname = "/home/boincadm/boinc/doc/platforms/$u"; + $t = @filemtime($fname); + if ($t && $t > time() - 86400) { + $l = json_decode(file_get_contents($fname)); + } else { + $l = get_platforms($url); + if ($l) { + file_put_contents($fname, json_encode($l)); + } else { + if (!file_exists($fname)) { + $l[] = "Unknown"; + file_put_contents($fname, json_encode($l)); + } + } + } + return show_list($l); +} +//echo get_platforms_cached("http://setiathome.berkeley.edu/"); + +function wfPlatforms() { + global $wgParser; + $wgParser->setHook( "platforms", "get_platforms_cached" ); +} + +$wgExtensionFunctions[] = "wfPlatforms"; + +?> diff --git a/sched/handle_request.C b/sched/handle_request.C index a75c88958a..bf54e0e20b 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -880,7 +880,7 @@ int handle_global_prefs(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) { // send it the new one, with a signature based on the old one. // If they don't have a code sign key, send them one // -void send_code_sign_key( +bool send_code_sign_key( SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply, char* code_sign_key ) { char* oldkey, *signature; @@ -904,7 +904,7 @@ void send_code_sign_key( "high" ); reply.insert_message(um); - return; + return false; } if (!strcmp(oldkey, sreq.code_sign_key)) { sprintf(path, "%s/signature_%d", config.key_dir, i); @@ -924,12 +924,13 @@ void send_code_sign_key( } } free(oldkey); - return; + return false; } } } else { safe_strcpy(reply.code_sign_key, code_sign_key); } + return true; } // This routine examines the value @@ -1329,6 +1330,10 @@ void process_request( } } + if (!send_code_sign_key(sreq, reply, code_sign_key)) { + ok_to_send_work = false; + } + // if last RPC was within config.min_sendwork_interval, don't send work // if (!have_no_work && ok_to_send_work && sreq.work_req_seconds > 0) { @@ -1356,7 +1361,6 @@ void process_request( } } - send_code_sign_key(sreq, reply, code_sign_key); handle_msgs_from_host(sreq, reply); if (config.msg_to_host) {