Skip to content

Commit

Permalink
Enforce compiler signature check (and install the signature).
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ford committed Feb 17, 2011
1 parent c5bf240 commit b47924a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions rakelib/install.rake
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ namespace :install do

FileList[
'runtime/index',
'runtime/signature',
'runtime/platform.conf',
'runtime/**/*.rb{a,c}',
'runtime/**/load_order.txt'
Expand Down
4 changes: 2 additions & 2 deletions rakelib/kernel.rake
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ file compiler_signature => compiler_files + parser_ext_files do |t|
hd = digest.hexdigest
hash = hd[0, 16].to_i(16) ^ hd[16,16].to_i(16) ^ hd[32,8].to_i(16)

File.open t.name, "w" do |file|
File.open t.name, "wb" do |file|
file.puts "# This file is generated by rakelib/kernel.rake. The signature"
file.puts "# is used to ensure that only current .rbc files are loaded."
file.puts "#"
file.puts "Rubinius::Signature = #{hash}"
end

File.open "runtime/signature", "w" do |file|
File.open "runtime/signature", "wb" do |file|
file.puts hash
end
end
Expand Down
2 changes: 1 addition & 1 deletion vm/builtin/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace rubinius {
}

uint64_t ver = version->to_ulong_long();
if(ver > 0 && cf->version > 0 && cf->version != ver) {
if(ver > 0 && cf->version != ver) {
return Primitives::failure();
}

Expand Down
7 changes: 4 additions & 3 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ namespace rubinius {
std::string dirs = root + "/index";
std::ifstream stream(dirs.c_str());
if(!stream) {
std::cerr << "It appears that " << root << "/index is missing.\n";
exit(1);
std::string error = "Unable to load kernel index: " + root;
throw std::runtime_error(error);
}

// Load the ruby file to prepare for bootstrapping Ruby!
Expand All @@ -526,7 +526,8 @@ namespace rubinius {
Integer::from(state, signature_));
sig_stream.close();
} else {
G(rubinius)->set_const(state, "Signature", Integer::from(state, 0));
std::string error = "Unable to load compiler signature file: " + sig_path;
throw std::runtime_error(error);
}

// Load alpha
Expand Down

0 comments on commit b47924a

Please sign in to comment.