mirror of https://github.com/BOINC/boinc.git
- scheduler: if client has bad code sign key, don't send work
svn path=/trunk/boinc/; revision=15270
This commit is contained in:
parent
605b29ae40
commit
a1ab573857
|
@ -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
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
// Mediawiki extension to show a project's platforms.
|
||||
// The platforms for a given project are stored in a file platforms/URL
|
||||
//
|
||||
function parse_next_element($xml, $tag, &$cursor) {
|
||||
$element = null;
|
||||
$closetag = "</" . substr($tag,1);
|
||||
$pos = substr($xml,$cursor);
|
||||
$x = strstr($pos, $tag);
|
||||
if ($x) {
|
||||
if (strstr($tag, "/>")) 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 = '<platform_name>';
|
||||
if (!strstr($x, "<platform_name>")) $tag = '<platform>';
|
||||
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";
|
||||
|
||||
?>
|
|
@ -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 <min_core_client_version_announced> 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) {
|
||||
|
|
Loading…
Reference in New Issue