Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Desktop Environments
  • Search

kdesu dolphin as root not possible [SOLVED-again]

Problems with GUI applications? Questions about X, KDE, Gnome, Fluxbox, etc.? Come on in. NOTE: For multimedia, go up one forum
Post Reply
Advanced search
164 posts
  • Page 7 of 7
    • Jump to page:
  • Previous
  • 1
  • …
  • 3
  • 4
  • 5
  • 6
  • 7
Author
Message
psands
n00b
n00b
Posts: 19
Joined: Mon Aug 12, 2019 12:40 am

  • Quote

Post by psands » Wed Nov 30, 2022 5:14 pm

Perfect thanks again
Top
psands
n00b
n00b
Posts: 19
Joined: Mon Aug 12, 2019 12:40 am

  • Quote

Post by psands » Mon Apr 03, 2023 12:30 pm

Problem with patch for (kate, kwrite)-22.12.3
the dolphin patch is still ok
Top
proteusx
Guru
Guru
User avatar
Posts: 340
Joined: Mon Jan 21, 2008 11:35 am

  • Quote

Post by proteusx » Mon Apr 03, 2023 1:33 pm

The last patch still works for kate and kwrite 22.12.3.
Here it is again:

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))
     /**
Top
psands
n00b
n00b
Posts: 19
Joined: Mon Aug 12, 2019 12:40 am

  • Quote

Post by psands » Mon Apr 03, 2023 2:46 pm

Sorry I must have used the wrong patch. Everything is working fine now. Thanks again
Top
Blind_Sniper
Guru
Guru
Posts: 372
Joined: Fri Apr 20, 2018 9:48 am

  • Quote

Post by Blind_Sniper » Mon Jul 10, 2023 3:45 pm

Cannot get kate-23.04.2 working with sudo/kdesu.
Seems the snippet of code which starts with

Code: Select all

if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
missed in main.cpp. So patch doesn't work
I found that code in kateapp.cpp and tried to remove it and build kate, but it doesn't help, kate still refuses to start as root.

Any idea where was that blocking code hidden?
GNU is Not Usable
Top
proteusx
Guru
Guru
User avatar
Posts: 340
Joined: Mon Jan 21, 2008 11:35 am

  • Quote

Post by proteusx » Mon Jul 10, 2023 5:17 pm

You need to apply this patch to each of kde-apps/{kate,kate-lib,kwrite}

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
      */
Here is the patch for dolphin too:

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
      */
Top
Blind_Sniper
Guru
Guru
Posts: 372
Joined: Fri Apr 20, 2018 9:48 am

  • Quote

Post by Blind_Sniper » Mon Jul 10, 2023 5:38 pm

You need to apply this patch to each of kde-apps/{kate,kate-lib,kwrite}
Created three directories (/etc/portage/patches/kde-apps/{kate,kate-lib,kwrite}) and put in every of them patch file.
Emerge compiles without errors, but kate still doesn't start:

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.
GNU is Not Usable
Top
Blind_Sniper
Guru
Guru
Posts: 372
Joined: Fri Apr 20, 2018 9:48 am

  • Quote

Post by Blind_Sniper » Mon Jul 10, 2023 5:44 pm

The same for kwrite, refuses to start

Added:
It turned out that it was necessary to rebuilt kate-lib too.
Now it works.
Thanks!
GNU is Not Usable
Top
proteusx
Guru
Guru
User avatar
Posts: 340
Joined: Mon Jan 21, 2008 11:35 am

  • Quote

Post by proteusx » Mon Jul 10, 2023 8:02 pm

@Blind_Sniper
The patches, applied exactly as you describe, work here, even for the latest 23.04.3
I can run all three apps with su, su -, sudo and kdesu
See screenshot
Top
psands
n00b
n00b
Posts: 19
Joined: Mon Aug 12, 2019 12:40 am

  • Quote

Post by psands » Mon Nov 27, 2023 5:38 pm

Has anyone tried the dolphin patch on 23.08.3
Top
Ridrok
Tux's lil' helper
Tux's lil' helper
Posts: 127
Joined: Sun Jan 26, 2014 3:17 pm
Location: France

  • Quote

Post by Ridrok » Mon Nov 27, 2023 5:43 pm

On another side this works for Dolphin without patching it, so should work with kate or kwrite too.

Code: Select all

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphin
Top
proteusx
Guru
Guru
User avatar
Posts: 340
Joined: Mon Jan 21, 2008 11:35 am

  • Quote

Post by proteusx » Mon Nov 27, 2023 11:40 pm

psands wrote:Has anyone tried the dolphin patch on 23.08.3
For this version the patch is slightly different.

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
      */
Top
psands
n00b
n00b
Posts: 19
Joined: Mon Aug 12, 2019 12:40 am

  • Quote

Post by psands » Tue Nov 28, 2023 5:07 pm

Thanks
Top
psands
n00b
n00b
Posts: 19
Joined: Mon Aug 12, 2019 12:40 am

  • Quote

Post by psands » Tue Oct 15, 2024 12:04 am

Does the patch work on dolphin-24.08.1 ?
Top
Post Reply

164 posts
  • Page 7 of 7
    • Jump to page:
  • Previous
  • 1
  • …
  • 3
  • 4
  • 5
  • 6
  • 7

Return to “Desktop Environments”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic