File 0001-Don-t-require-password-when-changing-settings.patch of Package kwalletmanager
From fd06cccb9ff5b8e4099a78a795503eb052d506d6 Mon Sep 17 00:00:00 2001
From: Christophe Marin <christophe@krop.fr>
Date: Thu, 15 Feb 2024 19:16:54 +0100
Subject: [PATCH] Don't require password when changing settings
See https://bugzilla.suse.com/show_bug.cgi?id=1217190
The kauth helper is useless and doesn't improve security.
---
CMakeLists.txt | 5 ---
src/CMakeLists.txt | 4 +--
src/konfigurator/CMakeLists.txt | 32 ++++++++++---------
src/konfigurator/konfigurator.cpp | 53 ++++++++-----------------------
src/konfigurator/konfigurator.h | 15 ++++-----
5 files changed, 37 insertions(+), 72 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 059b0f1c..3d3eafae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,11 +37,6 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX KWALLETMANAGER
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/src/kwalletmanager_version.h"
)
-option(ENABLE_KAUTH "Enable KAuth support (Disabled for Flatpak builds)" ON)
-if (ENABLE_KAUTH)
- find_package(KF6 ${KF_MIN_VERSION} REQUIRED Auth)
-endif()
-
find_package(KF6 ${KF_MIN_VERSION} REQUIRED
Archive
Config
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 69ff4807..bc9fa218 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,2 @@
-if (ENABLE_KAUTH)
- add_subdirectory(konfigurator)
-endif()
+add_subdirectory(konfigurator)
add_subdirectory(manager)
diff --git a/src/konfigurator/CMakeLists.txt b/src/konfigurator/CMakeLists.txt
index cba75123..778ebcd9 100644
--- a/src/konfigurator/CMakeLists.txt
+++ b/src/konfigurator/CMakeLists.txt
@@ -10,7 +10,6 @@ ki18n_wrap_ui(kcm_kwallet5 walletconfigwidget.ui )
target_link_libraries(kcm_kwallet5
Qt6::Core
- KF6::AuthCore
KF6::CoreAddons
KF6::KCMUtils
KF6::Wallet
@@ -20,19 +19,22 @@ target_link_libraries(kcm_kwallet5
install(TARGETS kcm_kwallet5 DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/kcms/systemsettings_qwidgets)
-########### kauth helper ################
-add_executable(kcm_kwallet_helper5)
-target_sources(kcm_kwallet_helper5 PRIVATE savehelper.cpp savehelper.h)
-
-target_link_libraries(kcm_kwallet_helper5
- Qt6::Core
- KF6::AuthCore
- KF6::Wallet
- KF6::CoreAddons
-)
+# The helper is not improving security and was disabled.
+# See https://bugzilla.suse.com/show_bug.cgi?id=1217190
-install(TARGETS kcm_kwallet_helper5 DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
-
-kauth_install_helper_files(kcm_kwallet_helper5 org.kde.kcontrol.kcmkwallet5 root)
-kauth_install_actions(org.kde.kcontrol.kcmkwallet5 kwallet.actions)
+########### kauth helper ################
+# add_executable(kcm_kwallet_helper5)
+# target_sources(kcm_kwallet_helper5 PRIVATE savehelper.cpp savehelper.h)
+#
+# target_link_libraries(kcm_kwallet_helper5
+# Qt6::Core
+# KF6::AuthCore
+# KF6::Wallet
+# KF6::CoreAddons
+# )
+
+# install(TARGETS kcm_kwallet_helper5 DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
+
+# kauth_install_helper_files(kcm_kwallet_helper5 org.kde.kcontrol.kcmkwallet5 root)
+# kauth_install_actions(org.kde.kcontrol.kcmkwallet5 kwallet.actions)
diff --git a/src/konfigurator/konfigurator.cpp b/src/konfigurator/konfigurator.cpp
index 36ad4b9a..c7bdccb4 100644
--- a/src/konfigurator/konfigurator.cpp
+++ b/src/konfigurator/konfigurator.cpp
@@ -7,8 +7,6 @@
#include "konfigurator.h"
#include "../kwalletmanager_version.h"
-#include <KAuth/ActionReply>
-#include <KAuth/ExecuteJob>
#include <KConfigGroup>
#include <KMessageBox>
#include <KPluginFactory>
@@ -32,12 +30,11 @@
K_PLUGIN_CLASS_WITH_JSON(KWalletConfig, "kwalletconfig.json")
-KWalletConfig::KWalletConfig(QObject *parent, const KPluginMetaData &data)
+KWalletConfig::KWalletConfig(QObject* parent, const KPluginMetaData& data)
: KCModule(parent, data)
, _wcw(new WalletConfigWidget(widget()))
, _cfg(KSharedConfig::openConfig(QStringLiteral("kwalletrc"), KConfig::NoGlobals))
{
- setAuthActionName(QStringLiteral("org.kde.kcontrol.kcmkwallet5.save"));
auto vbox = new QVBoxLayout(widget());
vbox->setContentsMargins(0, 0, 0, 0);
vbox->addWidget(_wcw);
@@ -59,11 +56,11 @@ KWalletConfig::KWalletConfig(QObject *parent, const KPluginMetaData &data)
connect(_wcw->_accessList, &QTreeWidget::customContextMenuRequested, this, &KWalletConfig::customContextMenuRequested);
connect(_wcw->_secretServiceAPI, &QCheckBox::clicked, this, &KWalletConfig::configChanged);
- QStyle *style = widget()->style();
+ QStyle* style = widget()->style();
_wcw->launchButtonBar->setContentsMargins(style->pixelMetric(QStyle::PM_LayoutLeftMargin),
- 0,
- style->pixelMetric(QStyle::PM_LayoutRightMargin),
- style->pixelMetric(QStyle::PM_LayoutBottomMargin));
+ 0,
+ style->pixelMetric(QStyle::PM_LayoutRightMargin),
+ style->pixelMetric(QStyle::PM_LayoutBottomMargin));
_wcw->_accessList->setAllColumnsShowFocus(true);
_wcw->_accessList->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -107,7 +104,7 @@ QString KWalletConfig::newWallet()
if (!ok) {
return {};
}
- KWallet::Wallet *w = KWallet::Wallet::openWallet(n, widget()->topLevelWidget()->winId());
+ KWallet::Wallet* w = KWallet::Wallet::openWallet(n, widget()->topLevelWidget()->winId());
if (!w) {
return {};
}
@@ -239,30 +236,6 @@ void KWalletConfig::load()
void KWalletConfig::save()
{
- QVariantMap args;
- KAuth::Action action(QLatin1String("org.kde.kcontrol.kcmkwallet5.save"));
- action.setHelperId(QStringLiteral("org.kde.kcontrol.kcmkwallet5"));
-
- widget()->window()->winId();
- action.setParentWindow(widget()->window()->windowHandle());
- if (!action.isValid()) {
- qDebug() << "There's no authAction, not saving settings";
- return;
- }
- action.setArguments(args);
-
- KAuth::ExecuteJob *j = action.execute();
-
- if (!j->exec()) {
- if (j->error() == KAuth::ActionReply::AuthorizationDeniedError) {
- KMessageBox::error(widget(), i18n("Permission denied."), i18n("KDE Wallet Control Module"));
- } else {
- KMessageBox::error(widget(), i18n("Error while authenticating action:\n%1", j->errorString()), i18n("KDE Wallet Control Module"));
- }
- load();
- return;
- }
-
KConfigGroup config(_cfg, QStringLiteral("Wallet"));
config.writeEntry("Enabled", _wcw->_enabled->isChecked());
config.writeEntry("Launch Manager", _wcw->_launchManager->isChecked());
@@ -291,10 +264,10 @@ void KWalletConfig::save()
_cfg->deleteGroup(QStringLiteral("Auto Deny"));
config = _cfg->group(QStringLiteral("Auto Allow"));
for (int i = 0; i < _wcw->_accessList->topLevelItemCount(); ++i) {
- QTreeWidgetItem *parentItem = _wcw->_accessList->topLevelItem(i);
+ QTreeWidgetItem* parentItem = _wcw->_accessList->topLevelItem(i);
QStringList al;
for (int j = 0; j < parentItem->childCount(); ++j) {
- QTreeWidgetItem *childItem = parentItem->child(j);
+ QTreeWidgetItem* childItem = parentItem->child(j);
if (childItem->text(2) == i18n("Always Allow")) {
al << childItem->text(1);
}
@@ -304,10 +277,10 @@ void KWalletConfig::save()
config = _cfg->group(QStringLiteral("Auto Deny"));
for (int i = 0; i < _wcw->_accessList->topLevelItemCount(); ++i) {
- QTreeWidgetItem *parentItem = _wcw->_accessList->topLevelItem(i);
+ QTreeWidgetItem* parentItem = _wcw->_accessList->topLevelItem(i);
QStringList al;
for (int j = 0; j < parentItem->childCount(); ++j) {
- QTreeWidgetItem *childItem = parentItem->child(j);
+ QTreeWidgetItem* childItem = parentItem->child(j);
if (childItem->text(2) == i18n("Always Deny")) {
al << childItem->text(1);
}
@@ -349,9 +322,9 @@ void KWalletConfig::defaults()
setNeedsSave(true);
}
-void KWalletConfig::customContextMenuRequested(const QPoint &pos)
+void KWalletConfig::customContextMenuRequested(const QPoint& pos)
{
- QTreeWidgetItem *item = _wcw->_accessList->itemAt(pos);
+ QTreeWidgetItem* item = _wcw->_accessList->itemAt(pos);
if (item && item->parent()) {
auto m = new QMenu(widget());
m->setTitle(item->parent()->text(0));
@@ -363,7 +336,7 @@ void KWalletConfig::customContextMenuRequested(const QPoint &pos)
void KWalletConfig::deleteEntry()
{
- QList<QTreeWidgetItem *> items = _wcw->_accessList->selectedItems();
+ QList<QTreeWidgetItem*> items = _wcw->_accessList->selectedItems();
if (items.count() == 1 && items[0]) {
delete items[0];
setNeedsSave(true);
diff --git a/src/konfigurator/konfigurator.h b/src/konfigurator/konfigurator.h
index fa508c1b..461a79bd 100644
--- a/src/konfigurator/konfigurator.h
+++ b/src/konfigurator/konfigurator.h
@@ -7,25 +7,22 @@
#ifndef _KWALLETKONFIGURATOR_H
#define _KWALLETKONFIGURATOR_H
#include "ui_walletconfigwidget.h"
-#include <KAuth/Action>
#include <KCModule>
#include <KSharedConfig>
-class WalletConfigWidget : public QWidget, public Ui::WalletConfigWidget
-{
+class WalletConfigWidget : public QWidget, public Ui::WalletConfigWidget {
public:
- WalletConfigWidget(QWidget *parent)
+ WalletConfigWidget(QWidget* parent)
: QWidget(parent)
{
setupUi(this);
}
};
-class KWalletConfig : public KCModule
-{
+class KWalletConfig : public KCModule {
Q_OBJECT
public:
- explicit KWalletConfig(QObject *parent, const KPluginMetaData &data);
+ explicit KWalletConfig(QObject* parent, const KPluginMetaData& data);
~KWalletConfig() override;
void load() override;
@@ -39,11 +36,11 @@ public Q_SLOTS:
void newNetworkWallet();
void updateWalletLists();
void deleteEntry();
- void customContextMenuRequested(const QPoint &pos);
+ void customContextMenuRequested(const QPoint& pos);
private:
QString newWallet();
- WalletConfigWidget *const _wcw;
+ WalletConfigWidget* const _wcw;
KSharedConfig::Ptr _cfg;
};
--
2.51.0