commit 57b8887bbcbb013365af287f0d3288a8bb2b73e6 Author: Simon Quigley Date: Sat Oct 14 19:28:52 2023 -0500 make no use network to DDOS git.launchpad.net diff --git a/debian/changelog b/debian/changelog index 42b51cd..a285a12 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +plasma-distro-release-notifier (20220915-0ubuntu1+69420) UNRELEASED; urgency=medium + + * make no use network to DDOS git.launchpad.net + + -- Simon Quigley Sat, 14 Oct 2023 18:47:32 -0500 + plasma-distro-release-notifier (20220915-0ubuntu1) kinetic; urgency=medium * New upstream tarball release with translations (LP: #1989697) diff --git a/debian/control b/debian/control index ca723f2..68cf116 100644 --- a/debian/control +++ b/debian/control @@ -26,6 +26,7 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, + distro-info-data, python3, python3-update-manager, update-notifier-common diff --git a/debian/patches/0001-get-eol-info-from-lp-src.patch b/debian/patches/0001-get-eol-info-from-lp-src.patch deleted file mode 100644 index 1a18084..0000000 --- a/debian/patches/0001-get-eol-info-from-lp-src.patch +++ /dev/null @@ -1,26 +0,0 @@ -From be403f1a6f97f9b52359cfec1a3e78f86f89cb50 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Erich Eickmeyer -Date: Mon, 12 Sep 2022 11:08:30 -0700 -Subject: [PATCH 1/4] get-eol-info-from-lp-src - ---- - src/distroreleasenotifier.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/distroreleasenotifier.cpp b/src/distroreleasenotifier.cpp -index 1bf7138..fa2ceee 100644 ---- a/src/distroreleasenotifier.cpp -+++ b/src/distroreleasenotifier.cpp -@@ -137,7 +137,7 @@ void DistroReleaseNotifier::checkReleaseUpgradeFinished(int exitCode) - connect(manager, &QNetworkAccessManager::finished, - this, &DistroReleaseNotifier::replyFinished); - -- auto request = QNetworkRequest(QUrl(QStringLiteral("https://releases.neon.kde.org/eol.json"))); -+ auto request = QNetworkRequest(QUrl(QStringLiteral("https://git.launchpad.net/plasma-distro-release-notifier/plain/eol.json?h=eol"))); - request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); - manager->get(request); - } --- -2.37.2 - diff --git a/debian/patches/0001-use-distro-info-data.patch b/debian/patches/0001-use-distro-info-data.patch new file mode 100644 index 0000000..f9fb075 --- /dev/null +++ b/debian/patches/0001-use-distro-info-data.patch @@ -0,0 +1,127 @@ +--- a/src/distroreleasenotifier.cpp ++++ b/src/distroreleasenotifier.cpp +@@ -10,6 +10,7 @@ + #include + + #include ++#include + #include + #include + #include +@@ -132,53 +133,57 @@ void DistroReleaseNotifier::checkRelease + m_version = map.value(QStringLiteral("new_dist_version")).toString(); + m_name = NAME_FROM_FLAVOR ? flavor : KOSRelease().name(); + +- // Download eol notification +- QNetworkAccessManager *manager = new QNetworkAccessManager(this); +- connect(manager, &QNetworkAccessManager::finished, +- this, &DistroReleaseNotifier::replyFinished); +- +- auto request = QNetworkRequest(QUrl(QStringLiteral("https://releases.neon.kde.org/eol.json"))); +- request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); +- manager->get(request); ++ replyFinished(); + } + +-/* +- * Parses the eol.json file which is in a JSON hash of format release_version: eol_date +- * e.g. {"16.04": "2018-10-02"} +- */ +-void DistroReleaseNotifier::replyFinished(QNetworkReply *reply) ++void DistroReleaseNotifier::replyFinished() + { +- qCDebug(NOTIFIER) << reply->error(); +- if (reply->error() != QNetworkReply::NoError) { +- qCWarning(NOTIFIER) << reply->errorString(); +- } +- const QString versionId = KOSRelease().versionId(); +- const QByteArray eolOutput = reply->readAll(); +- const auto document = QJsonDocument::fromJson(eolOutput); +- if (!document.isObject()) { +- qCWarning(NOTIFIER) << "EOL reply failed to parse as document" << eolOutput; ++ // Requires a hard dependency on distro-info-data ++ QFile file(QString::fromUtf8("/usr/share/distro-info/ubuntu.csv")); ++ if (!file.open(QIODevice::ReadOnly)) { + m_notifier->show(m_name, m_version, QDate()); +- return; + } +- const auto map = document.toVariant().toMap(); +- auto dateString = map.value(versionId).toString(); +- if (qEnvironmentVariableIsSet("MOCK_RELEASE")) { +- // If this is a mock we'll construct the date string artificially. +- // Otherwise we'd have to run a server-side generator which is a bit +- // more tricky and detaches the code so if the format changes we may +- // easily forget. +- if (qEnvironmentVariableIsSet("MOCK_EOL")) { +- // already eol +- dateString = QDate::currentDate().addDays(-1).toString(u"yyyy-MM-dd"); +- } else { +- // eol in 3 days +- dateString = QDate::currentDate().addDays(3).toString(u"yyyy-MM-dd"); ++ ++ QTextStream in(&file); ++ bool first_line = true; ++ ++ while (!in.atEnd()) { ++ if (first_line) { ++ first_line = false; ++ continue; ++ } ++ ++ QString l = in.readLine(); ++ QStringList line = l.split(QChar::fromLatin1(',')); ++ ++ // An LTS string with MetaRelease is formatted XX.YY.Z LTS ++ // ubuntu.csv only has XX.YY LTS, so remove the point release if it exists ++ QString version = m_version; ++ QStringList parts = version.split(QChar::fromLatin1('.')); ++ if (parts.size() >= 3) { ++ version = parts[0] + QChar::fromLatin1('.') + parts[1] + QString::fromLatin1(" LTS"); ++ } ++ if (version == line[0]) { ++ // LTS releases have values for eol-server and eol-esm ++ // If a regular release happens to have either, this will need adjustment ++ bool lts = line.length() == 8 ? true : false; ++ QString eol_str = line[5].trimmed(); ++ QDate eol = QDate::fromString(eol_str, QString::fromLatin1("yyyy-MM-dd")); ++ ++ // This is specific to Ubuntu flavors, where the support cycle is 3 years ++ if (lts) { ++ eol = eol.addYears(-2); ++ QStringList ver_parts = version.split(QChar::fromLatin1(' ')); ++ version = ver_parts[0]; ++ } ++ ++ m_notifier->show(m_name, version, eol); ++ ++ break; + } + } +- qCDebug(NOTIFIER) << "versionId:" << versionId; +- qCDebug(NOTIFIER) << "dateString" << dateString; +- m_notifier->show(m_name, m_version, +- QDate::fromString(dateString, Qt::ISODate)); ++ file.close(); ++ + return; + } + +--- a/src/distroreleasenotifier.h ++++ b/src/distroreleasenotifier.h +@@ -10,7 +10,6 @@ + class DBusInterface; + class Notifier; + class QProcess; +-class QNetworkReply; + class UpgraderProcess; + + class DistroReleaseNotifier : public QObject +@@ -24,7 +23,7 @@ private Q_SLOTS: + void releaseUpgradeCheck(); + void releaseUpgradeActivated(); + void forceCheck(); +- void replyFinished(QNetworkReply *reply); ++ void replyFinished(); + + private: + DBusInterface *m_dbus; diff --git a/debian/patches/0004-set-ubuntu-version.patch b/debian/patches/0004-set-ubuntu-version.patch index 243c2e3..4ccdcff 100644 --- a/debian/patches/0004-set-ubuntu-version.patch +++ b/debian/patches/0004-set-ubuntu-version.patch @@ -10,11 +10,9 @@ Subject: [PATCH 4/4] set ubuntu version src/notifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/src/notifier.cpp b/src/notifier.cpp -index f8224ef..99cdc88 100644 --- a/src/notifier.cpp +++ b/src/notifier.cpp -@@ -19,7 +19,7 @@ void Notifier::show(const QString &name, const QString &version, const QDate &eo +@@ -19,7 +19,7 @@ void Notifier::show(const QString &name, // Delayed init. Otherwise we have the KSNI up when no upgrades are available. init(); @@ -23,6 +21,3 @@ index f8224ef..99cdc88 100644 const QString title = i18n("Upgrade available"); QString text = i18n("%1.", label); --- -2.37.2 - diff --git a/debian/patches/series b/debian/patches/series index 5fe4e5a..e2b5a34 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,4 +1,4 @@ -0001-get-eol-info-from-lp-src.patch +0001-use-distro-info-data.patch 0002-replace-neon-strings.patch 0003-dont-replace-ubuntu-with-neon-string.patch 0004-set-ubuntu-version.patch