• R/O
  • HTTP
  • SSH
  • HTTPS

MUtilities: Commit

MUtilities development repository


Commit MetaInfo

Revisionc6337d4ba0a6c6cc079b3286dfa7969fefcff396 (tree)
Zeit2021-06-28 04:21:22
AutorLoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

Implemented support for CodeSign Verify utility.

Ändern Zusammenfassung

Diff

--- a/include/MUtils/UpdateChecker.h
+++ b/include/MUtils/UpdateChecker.h
@@ -83,7 +83,7 @@ namespace MUtils
8383 }
8484 update_status_t;
8585
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);
8787 ~UpdateChecker(void);
8888
8989 const int getUpdateStatus(void) const { return m_status; }
@@ -118,8 +118,7 @@ namespace MUtils
118118 const quint32 m_installedBuildNo;
119119
120120 const QString m_binaryCurl;
121- const QString m_binaryGnuPG;
122- const QString m_binaryKeys;
121+ const QString m_binaryVerify;
123122
124123 const QScopedPointer<const QHash<QString, QString>> m_environment;
125124
--- a/src/UpdateChecker.cpp
+++ b/src/UpdateChecker.cpp
@@ -107,7 +107,6 @@ static const QHash<QString, QString> *initEnvVars(const QString &binCurl)
107107 QHash<QString, QString> *const environment = new QHash<QString, QString>();
108108 const QString tempfolder = QDir::toNativeSeparators(MUtils::temp_folder());
109109 environment->insert(QLatin1String("CURL_HOME"), tempfolder);
110- environment->insert(QLatin1String("GNUPGHOME"), tempfolder);
111110 const QFileInfo curlFile(binCurl);
112111 environment->insert(QLatin1String("CURL_CA_BUNDLE"), QDir::toNativeSeparators(curlFile.absoluteDir().absoluteFilePath(QString("%1.crt").arg(curlFile.completeBaseName()))));
113112 return environment;
@@ -148,12 +147,11 @@ bool MUtils::UpdateCheckerInfo::isComplete(void)
148147 // Constructor & Destructor
149148 ////////////////////////////////////////////////////////////
150149
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)
152151 :
153152 m_updateInfo(new UpdateCheckerInfo()),
154153 m_binaryCurl(binCurl),
155- m_binaryGnuPG(binGnuPG),
156- m_binaryKeys(binKeys),
154+ m_binaryVerify(binVerify),
157155 m_environment(initEnvVars(binCurl)),
158156 m_applicationId(applicationId),
159157 m_installedBuildNo(installedBuildNo),
@@ -164,9 +162,9 @@ MUtils::UpdateChecker::UpdateChecker(const QString &binCurl, const QString &binG
164162 m_status = UpdateStatus_NotStartedYet;
165163 m_progress = 0;
166164
167- if(m_binaryCurl.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryKeys.isEmpty())
165+ if(m_binaryCurl.isEmpty() || m_binaryVerify.isEmpty())
168166 {
169- MUTILS_THROW("Tools not initialized correctly!");
167+ MUTILS_THROW("Required tools not initialized correctly!");
170168 }
171169 }
172170
@@ -459,7 +457,7 @@ bool MUtils::UpdateChecker::getUpdateInfo(const QString &url, const QString &out
459457 {
460458 log( "Downloading signature file:", "");
461459 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))
463461 {
464462 return true; /*completed*/
465463 }
@@ -637,36 +635,16 @@ bool MUtils::UpdateChecker::checkSignature(const QString &file, const QString &s
637635 return false;
638636 }
639637
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-
653638 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);
658641
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);
660643 if (exitCode != INT_MAX)
661644 {
662645 log(QString().sprintf("Exited with code %d", exitCode));
663646 }
664647
665- if (removeKeyring)
666- {
667- remove_file(keyRingPath);
668- }
669-
670648 return (exitCode == 0); /*completed*/
671649 }
672650
Show on old repository browser