Project

General

Profile

« Previous | Next » 

Revision 71ed7da5

Added by Scott Ullrich about 16 years ago

Add digital secutiry signature check to console upgrades.

View differences:

etc/rc.initial.firmware_update
3 3
<?php
4 4

  
5 5
require("globals.inc");
6
require("util.inc");
6 7
$g['booting'] = true;
7 8

  
8 9
echo "Starting the {$g['product_name']} console firmware update system";
......
159 160
}
160 161

  
161 162
function do_upgrade($path, $type) {
162
	global $g;
163
	global $g, $fp;
164
	
165
	$sigchk = verify_digital_signature($path);
166
	if ($sigchk == 1)
167
		$sig_warning = "The digital signature on this image is invalid.";
168
	else if ($sigchk == 2)
169
		$sig_warning = "This image is not digitally signed.";
170
	else if (($sigchk == 3) || ($sigchk == 4))
171
		$sig_warning = "There has been an error verifying the signature on this image.";
172
	if($sig_warning) {
173
		$sig_warning = "WARNING! ACHTUNG! DANGER!\n\n{$sig_warning}\n\n" .
174
			"This means that the image you uploaded is not an official/supported image and\n" .
175
			"may lead to unexpected behavior or security compromises.\n\n" .
176
			"Only install images that come from sources that you trust, and make sure\n".
177
			"that the image has not been tampered with.\n\n".
178
			"Do you want to install this image anyway at your own risk [n]?";
179
		echo $sig_warning;
180
		$command = strtoupper(chop(fgets($fp)));
181
		if(strtoupper($command) == "Y" or strtoupper($command) == "Y" or strtoupper($command) == "YES") {
182
			echo "\nContinuing upgrade...\n";
183
		} else {
184
			echo "\nUpgrade cancelled.\n\n";
185
			die;
186
		}
187
	}
163 188
	mark_subsystem_dirty('firmwarelock');
164 189
	check_for_kernel_file();
165 190
	echo "\nOne moment please...\nInvoking firmware upgrade...";
......
182 207
exec("rm -f /root/*.md5");
183 208
fclose($fp);
184 209

  
185
?>
210
?>

Also available in: Unified diff