MUtilities development repository
Revision | c6337d4ba0a6c6cc079b3286dfa7969fefcff396 (tree) |
---|---|
Zeit | 2021-06-28 04:21:22 |
Autor | ![]() |
Commiter | LoRd_MuldeR |
Implemented support for CodeSign Verify utility.
@@ -83,7 +83,7 @@ namespace MUtils | ||
83 | 83 | } |
84 | 84 | update_status_t; |
85 | 85 | |
86 | - UpdateChecker(const QString &binCurl, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false); | |
86 | + UpdateChecker(const QString &binCurl, const QString &binVerify, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false); | |
87 | 87 | ~UpdateChecker(void); |
88 | 88 | |
89 | 89 | const int getUpdateStatus(void) const { return m_status; } |
@@ -118,8 +118,7 @@ namespace MUtils | ||
118 | 118 | const quint32 m_installedBuildNo; |
119 | 119 | |
120 | 120 | const QString m_binaryCurl; |
121 | - const QString m_binaryGnuPG; | |
122 | - const QString m_binaryKeys; | |
121 | + const QString m_binaryVerify; | |
123 | 122 | |
124 | 123 | const QScopedPointer<const QHash<QString, QString>> m_environment; |
125 | 124 |
@@ -107,7 +107,6 @@ static const QHash<QString, QString> *initEnvVars(const QString &binCurl) | ||
107 | 107 | QHash<QString, QString> *const environment = new QHash<QString, QString>(); |
108 | 108 | const QString tempfolder = QDir::toNativeSeparators(MUtils::temp_folder()); |
109 | 109 | environment->insert(QLatin1String("CURL_HOME"), tempfolder); |
110 | - environment->insert(QLatin1String("GNUPGHOME"), tempfolder); | |
111 | 110 | const QFileInfo curlFile(binCurl); |
112 | 111 | environment->insert(QLatin1String("CURL_CA_BUNDLE"), QDir::toNativeSeparators(curlFile.absoluteDir().absoluteFilePath(QString("%1.crt").arg(curlFile.completeBaseName())))); |
113 | 112 | return environment; |
@@ -148,12 +147,11 @@ bool MUtils::UpdateCheckerInfo::isComplete(void) | ||
148 | 147 | // Constructor & Destructor |
149 | 148 | //////////////////////////////////////////////////////////// |
150 | 149 | |
151 | -MUtils::UpdateChecker::UpdateChecker(const QString &binCurl, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode) | |
150 | +MUtils::UpdateChecker::UpdateChecker(const QString &binCurl, const QString &binVerify, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode) | |
152 | 151 | : |
153 | 152 | m_updateInfo(new UpdateCheckerInfo()), |
154 | 153 | m_binaryCurl(binCurl), |
155 | - m_binaryGnuPG(binGnuPG), | |
156 | - m_binaryKeys(binKeys), | |
154 | + m_binaryVerify(binVerify), | |
157 | 155 | m_environment(initEnvVars(binCurl)), |
158 | 156 | m_applicationId(applicationId), |
159 | 157 | m_installedBuildNo(installedBuildNo), |
@@ -164,9 +162,9 @@ MUtils::UpdateChecker::UpdateChecker(const QString &binCurl, const QString &binG | ||
164 | 162 | m_status = UpdateStatus_NotStartedYet; |
165 | 163 | m_progress = 0; |
166 | 164 | |
167 | - if(m_binaryCurl.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryKeys.isEmpty()) | |
165 | + if(m_binaryCurl.isEmpty() || m_binaryVerify.isEmpty()) | |
168 | 166 | { |
169 | - MUTILS_THROW("Tools not initialized correctly!"); | |
167 | + MUTILS_THROW("Required tools not initialized correctly!"); | |
170 | 168 | } |
171 | 169 | } |
172 | 170 |
@@ -459,7 +457,7 @@ bool MUtils::UpdateChecker::getUpdateInfo(const QString &url, const QString &out | ||
459 | 457 | { |
460 | 458 | log( "Downloading signature file:", ""); |
461 | 459 | setProgress(MIN_CONNSCORE + 3); |
462 | - if (getFile(QUrl(QString("%1%2.sig2").arg(url, MIRROR_URL_POSTFIX[m_betaUpdates ? 1 : 0])), outFileSign)) | |
460 | + if (getFile(QUrl(QString("%1%2.rsa").arg(url, MIRROR_URL_POSTFIX[m_betaUpdates ? 1 : 0])), outFileSign)) | |
463 | 461 | { |
464 | 462 | return true; /*completed*/ |
465 | 463 | } |
@@ -637,36 +635,16 @@ bool MUtils::UpdateChecker::checkSignature(const QString &file, const QString &s | ||
637 | 635 | return false; |
638 | 636 | } |
639 | 637 | |
640 | - QString keyRingPath(m_binaryKeys); | |
641 | - bool removeKeyring = false; | |
642 | - if (QFileInfo(file).absolutePath().compare(QFileInfo(m_binaryKeys).absolutePath(), Qt::CaseInsensitive) != 0) | |
643 | - { | |
644 | - keyRingPath = make_temp_file(QFileInfo(file).absolutePath(), "gpg"); | |
645 | - removeKeyring = true; | |
646 | - if (!QFile::copy(m_binaryKeys, keyRingPath)) | |
647 | - { | |
648 | - qWarning("CheckSignature: Failed to copy the key-ring file!"); | |
649 | - return false; | |
650 | - } | |
651 | - } | |
652 | - | |
653 | 638 | QStringList args; |
654 | - args << QStringList() << "--homedir" << "."; | |
655 | - args << "--keyring" << QFileInfo(keyRingPath).fileName(); | |
656 | - args << QFileInfo(signature).fileName(); | |
657 | - args << QFileInfo(file).fileName(); | |
639 | + args << QDir::toNativeSeparators(file); | |
640 | + args << QDir::toNativeSeparators(signature); | |
658 | 641 | |
659 | - const int exitCode = execProcess(m_binaryGnuPG, args, QFileInfo(file).absolutePath(), DOWNLOAD_TIMEOUT); | |
642 | + const int exitCode = execProcess(m_binaryVerify, args, QFileInfo(file).absolutePath(), DOWNLOAD_TIMEOUT); | |
660 | 643 | if (exitCode != INT_MAX) |
661 | 644 | { |
662 | 645 | log(QString().sprintf("Exited with code %d", exitCode)); |
663 | 646 | } |
664 | 647 | |
665 | - if (removeKeyring) | |
666 | - { | |
667 | - remove_file(keyRingPath); | |
668 | - } | |
669 | - | |
670 | 648 | return (exitCode == 0); /*completed*/ |
671 | 649 | } |
672 | 650 |