Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
kdesu dolphin as root not possible [SOLVED-again]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

Goto page Previous  1, 2, 3, 4, 5, 6, 7  
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
psands
n00b
n00b


Joined: 12 Aug 2019
Posts: 18

PostPosted: Wed Nov 30, 2022 5:14 pm    Post subject: Reply with quote

Perfect thanks again
Back to top
View user's profile Send private message
psands
n00b
n00b


Joined: 12 Aug 2019
Posts: 18

PostPosted: Mon Apr 03, 2023 12:30 pm    Post subject: Reply with quote

Problem with patch for (kate, kwrite)-22.12.3
the dolphin patch is still ok
Back to top
View user's profile Send private message
proteusx
Guru
Guru


Joined: 21 Jan 2008
Posts: 338

PostPosted: Mon Apr 03, 2023 1:33 pm    Post subject: Reply with quote

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

--- 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))
     /**
Back to top
View user's profile Send private message
psands
n00b
n00b


Joined: 12 Aug 2019
Posts: 18

PostPosted: Mon Apr 03, 2023 2:46 pm    Post subject: Reply with quote

Sorry I must have used the wrong patch. Everything is working fine now. Thanks again
Back to top
View user's profile Send private message
Blind_Sniper
Guru
Guru


Joined: 20 Apr 2018
Posts: 340

PostPosted: Mon Jul 10, 2023 3:45 pm    Post subject: Reply with quote

Cannot get kate-23.04.2 working with sudo/kdesu.
Seems the snippet of code which starts with
Code:
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
Back to top
View user's profile Send private message
proteusx
Guru
Guru


Joined: 21 Jan 2008
Posts: 338

PostPosted: Mon Jul 10, 2023 5:17 pm    Post subject: Reply with quote

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

--- 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:
dolphin-23.04.2-root.patch:

--- 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
      */
Back to top
View user's profile Send private message
Blind_Sniper
Guru
Guru


Joined: 20 Apr 2018
Posts: 340

PostPosted: Mon Jul 10, 2023 5:38 pm    Post subject: Reply with quote

Quote:
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:
# 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
Back to top
View user's profile Send private message
Blind_Sniper
Guru
Guru


Joined: 20 Apr 2018
Posts: 340

PostPosted: Mon Jul 10, 2023 5:44 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
proteusx
Guru
Guru


Joined: 21 Jan 2008
Posts: 338

PostPosted: Mon Jul 10, 2023 8:02 pm    Post subject: Reply with quote

@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
Back to top
View user's profile Send private message
psands
n00b
n00b


Joined: 12 Aug 2019
Posts: 18

PostPosted: Mon Nov 27, 2023 5:38 pm    Post subject: Reply with quote

Has anyone tried the dolphin patch on 23.08.3
Back to top
View user's profile Send private message
Ridrok
Tux's lil' helper
Tux's lil' helper


Joined: 26 Jan 2014
Posts: 87
Location: France

PostPosted: Mon Nov 27, 2023 5:43 pm    Post subject: Reply with quote

On another side this works for Dolphin without patching it, so should work with kate or kwrite too.
Code:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphin
Back to top
View user's profile Send private message
proteusx
Guru
Guru


Joined: 21 Jan 2008
Posts: 338

PostPosted: Mon Nov 27, 2023 11:40 pm    Post subject: Reply with quote

psands wrote:
Has anyone tried the dolphin patch on 23.08.3

For this version the patch is slightly different.
dolphin-23.08.3-root.patch:

--- 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
      */
Back to top
View user's profile Send private message
psands
n00b
n00b


Joined: 12 Aug 2019
Posts: 18

PostPosted: Tue Nov 28, 2023 5:07 pm    Post subject: Reply with quote

Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7
Page 7 of 7

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum