Tor: properly overwrite old binary

This commit is contained in:
tobtoht 2021-02-05 19:43:14 +01:00
parent cfd1942b38
commit 69551efde3
No known key found for this signature in database
GPG Key ID: 1CADD27F41F45C3C
2 changed files with 10 additions and 2 deletions

View File

@ -211,8 +211,12 @@ bool Tor::unpackBins() {
TorVersion embeddedVersion = this->stringToVersion(QString(TOR_VERSION));
TorVersion filesystemVersion = this->getVersion(torPath);
qDebug() << QString("Tor versions: embedded %1, filesystem %2").arg(embeddedVersion.toString(), filesystemVersion.toString());
if (embeddedVersion > filesystemVersion) {
QFile::remove(torPath);
if (TorVersion::isValid(filesystemVersion) && (embeddedVersion > filesystemVersion)) {
qInfo() << "Embedded version is newer, overwriting.";
QFile::setPermissions(torPath, QFile::ReadOther | QFile::WriteOther);
if (!QFile::remove(torPath)) {
qWarning() << "Unable to remove old Tor binary";
};
}
qDebug() << "Writing Tor executable to " << this->torPath;

View File

@ -54,6 +54,10 @@ struct TorVersion
QString::number(patch), QString::number(release));
}
static bool isValid(const TorVersion &v) {
return v != TorVersion();
}
int major;
int minor;
int patch;