diff --git a/src/utils/tor.cpp b/src/utils/tor.cpp index 475f459..d1ab811 100644 --- a/src/utils/tor.cpp +++ b/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; diff --git a/src/utils/tor.h b/src/utils/tor.h index 22f0e35..22ab243 100644 --- a/src/utils/tor.h +++ b/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;