Mercurial > trustbridge
comparison ui/installwrapper.cpp @ 1084:b8fb6bf7f980
(issue118) Add signature check for cinst.exe and mozilla.exe
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 11 Sep 2014 15:17:39 +0200 |
parents | a12e6172d82c |
children | a7a72353d6d2 |
comparison
equal
deleted
inserted
replaced
1083:d6dc1144895b | 1084:b8fb6bf7f980 |
---|---|
14 #include <QDir> | 14 #include <QDir> |
15 #include <QDebug> | 15 #include <QDebug> |
16 | 16 |
17 #include "logging.h" | 17 #include "logging.h" |
18 #include "util.h" | 18 #include "util.h" |
19 #include "binverify.h" | |
19 | 20 |
20 #define INSTALL_TIMEOUT 3600000 /* Wait up to an hour */ | 21 #define INSTALL_TIMEOUT 3600000 /* Wait up to an hour */ |
21 | 22 |
22 InstallWrapper::InstallWrapper(QObject* parent, | 23 InstallWrapper::InstallWrapper(QObject* parent, |
23 const QString& path, const QStringList& choices): | 24 const QString& path, const QStringList& choices): |
77 emit error(tr("Failed to write temporary file.")); | 78 emit error(tr("Failed to write temporary file.")); |
78 return; | 79 return; |
79 } | 80 } |
80 | 81 |
81 #ifdef WIN32 | 82 #ifdef WIN32 |
83 bin_verify_result vres = verify_binary(cinstFileName.toUtf8().constData(), | |
84 cinstFileName.toUtf8().size()); | |
85 | |
86 if (vres.result != VerifyValid) { | |
87 emit error(tr("Integrity check of the certificate installation process failed. ") | |
88 + "\n" + tr("Please reinstall the Software.")); | |
89 return; | |
90 } | |
91 | |
82 /* QProcess on Windows uses CreateProcess but we have to | 92 /* QProcess on Windows uses CreateProcess but we have to |
83 * use the runas shell command to get the UAC prompt if necessary. | 93 * use the runas shell command to get the UAC prompt if necessary. |
84 * So we have to handle the process ourself. Starting with | 94 * So we have to handle the process ourself. Starting with |
85 * shell execute also means that we can not have stdout and stderr | 95 * shell execute also means that we can not have stdout and stderr |
86 * redirection. This is the reason we use command line parameters | 96 * redirection. This is the reason we use command line parameters |
114 if (!ShellExecuteExW(&shExecInfo)) { | 124 if (!ShellExecuteExW(&shExecInfo)) { |
115 char* errmsg = getLastErrorMsg(); | 125 char* errmsg = getLastErrorMsg(); |
116 QString qerrmsg = QString::fromUtf8(errmsg); | 126 QString qerrmsg = QString::fromUtf8(errmsg); |
117 free(errmsg); | 127 free(errmsg); |
118 emit error(tr("Error executing process: %1").arg(qerrmsg)); | 128 emit error(tr("Error executing process: %1").arg(qerrmsg)); |
129 fclose(vres.fptr); | |
119 return; | 130 return; |
120 } | 131 } |
121 | 132 |
122 retval = WaitForSingleObject(shExecInfo.hProcess, INSTALL_TIMEOUT); | 133 retval = WaitForSingleObject(shExecInfo.hProcess, INSTALL_TIMEOUT); |
123 | 134 |
125 if (retval == WAIT_FAILED) { | 136 if (retval == WAIT_FAILED) { |
126 char* errmsg = getLastErrorMsg(); | 137 char* errmsg = getLastErrorMsg(); |
127 QString qerrmsg = QString::fromUtf8(errmsg); | 138 QString qerrmsg = QString::fromUtf8(errmsg); |
128 free(errmsg); | 139 free(errmsg); |
129 emit error (tr("Error monitoring process: %1").arg(qerrmsg)); | 140 emit error (tr("Error monitoring process: %1").arg(qerrmsg)); |
141 fclose(vres.fptr); | |
130 return; | 142 return; |
131 } else { | 143 } else { |
132 emit error (tr("Certificate installation timed out.")); | 144 emit error (tr("Certificate installation timed out.")); |
145 fclose(vres.fptr); | |
133 return; | 146 return; |
134 } | 147 } |
135 } | 148 } |
136 | 149 |
137 if (GetExitCodeProcess(shExecInfo.hProcess, &retval)) { | 150 if (GetExitCodeProcess(shExecInfo.hProcess, &retval)) { |
142 char* errmsg = getLastErrorMsg(); | 155 char* errmsg = getLastErrorMsg(); |
143 QString qerrmsg = QString::fromUtf8(errmsg); | 156 QString qerrmsg = QString::fromUtf8(errmsg); |
144 free(errmsg); | 157 free(errmsg); |
145 emit error (tr("Failed to check process status: %1").arg(qerrmsg)); | 158 emit error (tr("Failed to check process status: %1").arg(qerrmsg)); |
146 CloseHandle(shExecInfo.hProcess); | 159 CloseHandle(shExecInfo.hProcess); |
160 fclose(vres.fptr); | |
147 return; | 161 return; |
148 } | 162 } |
149 CloseHandle(shExecInfo.hProcess); | 163 CloseHandle(shExecInfo.hProcess); |
164 fclose(vres.fptr); | |
150 | 165 |
151 if (retval != 0) { | 166 if (retval != 0) { |
152 /* TODO make this nicer */ | 167 /* TODO make this nicer */ |
153 emit error (tr("The process failed with return code. %1").arg(retval)); | 168 emit error (tr("The process failed with return code. %1").arg(retval)); |
154 return; | 169 return; |