Browse Source

Tor: properly overwrite old binary

bruteforce
tobtoht 10 months ago
parent
commit
69551efde3
Signed by: tobtoht GPG Key ID: 1CADD27F41F45C3C
  1. 8
      src/utils/tor.cpp
  2. 4
      src/utils/tor.h

8
src/utils/tor.cpp

@ -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;

4
src/utils/tor.h

@ -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;

Loading…
Cancel
Save