View previous topic :: View next topic |
Author |
Message |
psands n00b
Joined: 12 Aug 2019 Posts: 19
|
Posted: Wed Nov 30, 2022 5:14 pm Post subject: |
|
|
Perfect thanks again |
|
Back to top |
|
|
psands n00b
Joined: 12 Aug 2019 Posts: 19
|
Posted: Mon Apr 03, 2023 12:30 pm Post subject: |
|
|
Problem with patch for (kate, kwrite)-22.12.3
the dolphin patch is still ok |
|
Back to top |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 340
|
Posted: Mon Apr 03, 2023 1:33 pm Post subject: |
|
|
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 |
|
|
psands n00b
Joined: 12 Aug 2019 Posts: 19
|
Posted: Mon Apr 03, 2023 2:46 pm Post subject: |
|
|
Sorry I must have used the wrong patch. Everything is working fine now. Thanks again |
|
Back to top |
|
|
Blind_Sniper Guru
Joined: 20 Apr 2018 Posts: 370
|
Posted: Mon Jul 10, 2023 3:45 pm Post subject: |
|
|
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 |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 340
|
Posted: Mon Jul 10, 2023 5:17 pm Post subject: |
|
|
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 |
|
|
Blind_Sniper Guru
Joined: 20 Apr 2018 Posts: 370
|
Posted: Mon Jul 10, 2023 5:38 pm Post subject: |
|
|
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 |
|
|
Blind_Sniper Guru
Joined: 20 Apr 2018 Posts: 370
|
Posted: Mon Jul 10, 2023 5:44 pm Post subject: |
|
|
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 |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 340
|
Posted: Mon Jul 10, 2023 8:02 pm Post subject: |
|
|
@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 |
|
|
psands n00b
Joined: 12 Aug 2019 Posts: 19
|
Posted: Mon Nov 27, 2023 5:38 pm Post subject: |
|
|
Has anyone tried the dolphin patch on 23.08.3 |
|
Back to top |
|
|
Ridrok Tux's lil' helper
Joined: 26 Jan 2014 Posts: 116 Location: France
|
Posted: Mon Nov 27, 2023 5:43 pm Post subject: |
|
|
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 |
|
|
proteusx Guru
Joined: 21 Jan 2008 Posts: 340
|
Posted: Mon Nov 27, 2023 11:40 pm Post subject: |
|
|
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 |
|
|
psands n00b
Joined: 12 Aug 2019 Posts: 19
|
Posted: Tue Nov 28, 2023 5:07 pm Post subject: |
|
|
Thanks |
|
Back to top |
|
|
psands n00b
Joined: 12 Aug 2019 Posts: 19
|
Posted: Tue Oct 15, 2024 12:04 am Post subject: |
|
|
Does the patch work on dolphin-24.08.1 ? |
|
Back to top |
|
|
|