Code: Select all
--- a/apps/kate/main.cpp
+++ b/apps/kate/main.cpp
@@ -44,24 +44,24 @@
int main(int argc, char **argv)
{
-#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
- // Prohibit using sudo or kdesu (but allow using the root user directly)
- if (getuid() == 0) {
- if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
- std::cout << "Running Kate with sudo can cause bugs and expose you to security vulnerabilities. "
- "Instead use Kate normally and you will be prompted for elevated privileges when "
- "saving documents if needed."
- << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Running Kate with kdesu can cause bugs and expose you to security vulnerabilities. "
- "Instead use Kate normally and you will be prompted for elevated privileges when "
- "saving documents if needed."
- << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
+/* #if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU) */
+/* // Prohibit using sudo or kdesu (but allow using the root user directly) */
+/* if (getuid() == 0) { */
+/* if (!qEnvironmentVariableIsEmpty("SUDO_USER")) { */
+/* std::cout << "Running Kate with sudo can cause bugs and expose you to security vulnerabilities. " */
+/* "Instead use Kate normally and you will be prompted for elevated privileges when " */
+/* "saving documents if needed." */
+/* << std::endl; */
+/* return EXIT_FAILURE; */
+/* } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) { */
+/* std::cout << "Running Kate with kdesu can cause bugs and expose you to security vulnerabilities. " */
+/* "Instead use Kate normally and you will be prompted for elevated privileges when " */
+/* "saving documents if needed." */
+/* << std::endl; */
+/* return EXIT_FAILURE; */
+/* } */
+/* } */
+/* #endif */
/**
* init resources from our static lib
*/
--- a/apps/kwrite/main.cpp
+++ b/apps/kwrite/main.cpp
@@ -24,24 +24,24 @@
extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
{
-#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
- // Prohibit using sudo or kdesu (but allow using the root user directly)
- if (getuid() == 0) {
- if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
- std::cout << "Running KWrite with sudo can cause bugs and expose you to security vulnerabilities. "
- "Instead use KWrite normally and you will be prompted for elevated privileges when "
- "saving documents if needed."
- << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Running KWrite with kdesu can cause bugs and expose you to security vulnerabilities. "
- "Instead use KWrite normally and you will be prompted for elevated privileges when "
- "saving documents if needed."
- << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
+/* #if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU) */
+/* // Prohibit using sudo or kdesu (but allow using the root user directly) */
+/* if (getuid() == 0) { */
+/* if (!qEnvironmentVariableIsEmpty("SUDO_USER")) { */
+/* std::cout << "Running KWrite with sudo can cause bugs and expose you to security vulnerabilities. " */
+/* "Instead use KWrite normally and you will be prompted for elevated privileges when " */
+/* "saving documents if needed." */
+/* << std::endl; */
+/* return EXIT_FAILURE; */
+/* } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) { */
+/* std::cout << "Running KWrite with kdesu can cause bugs and expose you to security vulnerabilities. " */
+/* "Instead use KWrite normally and you will be prompted for elevated privileges when " */
+/* "saving documents if needed." */
+/* << std::endl; */
+/* return EXIT_FAILURE; */
+/* } */
+/* } */
+/* #endif */
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
/**

Code: Select all
if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)Code: Select all
--- a/apps/lib/kateapp.cpp 2023-05-08 06:28:50.000000000 +0300
+++ b/apps/lib/kateapp.cpp 2023-06-04 22:51:24.602759941 +0300
@@ -98,29 +98,6 @@
void KateApp::initPreApplicationCreation(bool detach)
{
-#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
- // Prohibit using sudo or kdesu (but allow using the root user directly)
- if (getuid() == 0) {
- setlocale(LC_ALL, "");
- bindtextdomain("kate", KDE_INSTALL_FULL_LOCALEDIR);
- if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
- auto message = kli18n(
- "Running this editor with sudo can cause bugs and expose you to security vulnerabilities. "
- "Instead use this editor normally and you will be prompted for elevated privileges when "
- "saving documents if needed.");
- std::cout << dgettext("kate", message.untranslatedText()) << std::endl;
- exit(EXIT_FAILURE);
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- auto message = kli18n(
- "Running this editor with kdesu can cause bugs and expose you to security vulnerabilities. "
- "Instead use this editor normally and you will be prompted for elevated privileges when "
- "saving documents if needed.");
- std::cout << dgettext("kate", message.untranslatedText()) << std::endl;
- exit(EXIT_FAILURE);
- }
- }
-#endif
-
/**
* enable dark mode for title bar on Windows
*/
Code: Select all
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -103,13 +103,6 @@
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->hide();
-#ifndef Q_OS_WIN
- if (getuid() == 0) {
- // We must be logged in as the root user; show a big scary warning
- showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning);
- }
-#endif
-
// Initialize filter bar
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(GeneralSettings::filterBar());
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -50,19 +50,6 @@
int main(int argc, char **argv)
{
-#ifndef Q_OS_WIN
- // Prohibit using sudo or kdesu (but allow using the root user directly)
- if (getuid() == 0) {
- if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
- std::cout << "Running Dolphin with sudo can cause bugs and expose you to security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Running Dolphin with kdesu can cause bugs and expose you to security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
-
/**
* enable high dpi support
*/

Created three directories (/etc/portage/patches/kde-apps/{kate,kate-lib,kwrite}) and put in every of them patch file.You need to apply this patch to each of kde-apps/{kate,kate-lib,kwrite}
Code: Select all
# kate
Running this editor with sudo can cause bugs and expose you to security vulnerabilities. Instead use this editor normally and you will be prompted for elevated privileges when saving documents if needed.
Code: Select all
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphinFor this version the patch is slightly different.psands wrote:Has anyone tried the dolphin patch on 23.08.3
Code: Select all
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -107,13 +107,6 @@
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->hide();
-#ifndef Q_OS_WIN
- if (getuid() == 0) {
- // We must be logged in as the root user; show a big scary warning
- showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning);
- }
-#endif
-
// Initialize filter bar
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(GeneralSettings::filterBar());
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -50,25 +50,6 @@
int main(int argc, char **argv)
{
-#ifndef Q_OS_WIN
- // Prohibit using sudo or kdesu (but allow using the root user directly)
- if (getuid() == 0) {
- if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
- std::cout << "Running Dolphin with sudo is not supported as it can cause bugs and expose you to security vulnerabilities. Instead, install the "
- "`kio-admin` package from your distro and use it to manage root-owned locations by right-clicking on them and selecting "Open as "
- "Administrator"."
- << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Running Dolphin with kdesu is not supported as it can cause bugs and expose you to security vulnerabilities. Instead, install the "
- "`kio-admin` package from your distro and use it to manage root-owned locations by right-clicking on them and selecting "Open as "
- "Administrator"."
- << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
-
/**
* enable high dpi support
*/