comparison ui/mainwindow.cpp @ 1365:3d7ddf698480

(issue177) Only install updates with a newer signature on windows
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 21 Nov 2014 18:33:58 +0100
parents c2b76c8a8b82
children 23df332b2a4c
comparison
equal deleted inserted replaced
1364:28885e8c891f 1365:3d7ddf698480
278 mSettings.remove("Software/availableDate"); 278 mSettings.remove("Software/availableDate");
279 return; 279 return;
280 } 280 }
281 bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(), 281 bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(),
282 swFileName.toUtf8().size()); 282 swFileName.toUtf8().size());
283 qDebug() << "Binary verify result: " << verifyResult.result; 283 QDateTime sigDt = QDateTime::fromTime_t (verifyResult.sig_time);
284 if (verifyResult.result != VerifyValid) { 284 QDateTime currentSigDt = mSettings.value("Software/currentSigDt").toDateTime();
285
286 if (verifyResult.result != VerifyValid || (currentSigDt.isValid() && sigDt <= currentSigDt)) {
285 handleLTE(lteInvalidSoftware); 287 handleLTE(lteInvalidSoftware);
286 qDebug() << "Failed to verify downloaded data."; 288 if (verifyResult.result != VerifyValid) {
289 qDebug() << "Failed to verify downloaded data.";
290 } else {
291 qDebug() << "Software update was signed at: " << sigDt;
292 qDebug() << "But the installed software was signed on: " << currentSigDt;
293 if (verifyResult.fptr) {
294 fclose(verifyResult.fptr);
295 }
296 }
287 QFile::remove(swFileName); 297 QFile::remove(swFileName);
288 mSettings.remove("Software/available"); 298 mSettings.remove("Software/available");
289 mSettings.remove("Software/availableDate"); 299 mSettings.remove("Software/availableDate");
290 return; 300 return;
291 } 301 }
412 mSettings.sync(); 422 mSettings.sync();
413 423
414 bin_verify_result vres = verify_binary(filePath.toUtf8().constData(), 424 bin_verify_result vres = verify_binary(filePath.toUtf8().constData(),
415 filePath.toUtf8().size()); 425 filePath.toUtf8().size());
416 426
417 if (vres.result != VerifyValid) { 427 QDateTime sigDt = QDateTime::fromTime_t (vres.sig_time);
428 QDateTime currentSigDt = mSettings.value("Software/currentSigDt").toDateTime();
429
430 if (vres.result != VerifyValid || (currentSigDt.isValid() && sigDt <= currentSigDt)) {
418 handleLTE(lteInvalidSoftware); 431 handleLTE(lteInvalidSoftware);
419 qDebug() << "Invalid software. Not installing"; 432 if (vres.result != VerifyValid) {
433 qDebug() << "Failed to verify installer.";
434 } else {
435 qDebug() << "Software update was signed at: " << sigDt;
436 qDebug() << "But the installed software was signed on: " << currentSigDt;
437 if (vres.fptr) {
438 fclose(vres.fptr);
439 }
440 }
441 QFile::remove(filePath);
442 mSettings.remove("Software/available");
443 mSettings.remove("Software/availableDate");
420 return; 444 return;
421 } 445 }
422 handleLTE(lteInvalidSoftware, true); 446 handleLTE(lteInvalidSoftware, true);
423 QFileInfo fi(QCoreApplication::applicationFilePath()); 447 QFileInfo fi(QCoreApplication::applicationFilePath());
424 QDir installDir = fi.absoluteDir(); 448 QDir installDir = fi.absoluteDir();

http://wald.intevation.org/projects/trustbridge/