For someone who has an unpatched version, if you run dolphin started by root, but in a separate user namespace, does it work?
Code: Select all
/usr/bin/sudo /usr/bin/unshare --user -- dolphinCode: Select all
/usr/bin/sudo /usr/bin/unshare --user -- dolphin
It works if source files are unchanged, but it doesn't work if something was changed and you have to re-write patch. This case it easier to edit source file than re-create patch every time. I just editing main.cpp and do not waiting when someone will re-create and share patch suitable for new file version.Hu wrote:That is what the patches do for you, so you don't have to edit it by hand every time.


Code: Select all
$ pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphinCode: Select all
$ pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true kateCode: Select all
$ pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true kwriteCode: Select all
$ tail -n 3 ~/.bashrc
alias dolroot="pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphin"
alias kateroot="pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true kate"
alias kwriteroot="pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true kwrite"Code: Select all
$ dolroot
$ kateroot
$ kwriterootCode: Select all
~ $ pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphin
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/env' as the super user
Authenticating as: root
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ====
Error executing command as another user: Not authorized
This incident has been reported.
1. GDBus? Isn't that in GNOME or one of the other desktop environments that uses GNOME's GLib? Are you by any chance using Dolphin in a different desktop environment to KDE?proteusx wrote:Code: Select all
~ $ pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphin ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ==== Authentication is needed to run `/usr/bin/env' as the super user Authenticating as: root polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie ==== AUTHENTICATION FAILED ==== Error executing command as another user: Not authorized This incident has been reported.
Code: Select all
ps -ef | grep -E 'polkit.*agent' | grep -v grep
fitzcar+ 828 1 0 01:37 ? 00:00:00 /usr/lib64/libexec/polkit-kde-authentication-agent-1
Code: Select all
$ dolrootCode: Select all
$ sudo dolphinCode: Select all
$ kdesu dolphinCode: Select all
$ ls -la *root
-rwx------ 1 fitzcarraldo fitzcarraldo 115 Jul 30 15:33 dolroot
-rwx------ 1 fitzcarraldo fitzcarraldo 112 Jul 30 15:34 kateroot
-rwx------ 1 fitzcarraldo fitzcarraldo 114 Jul 30 15:34 kwriterootCode: Select all
$ cat dolroot
#!/bin/bash
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphinThis is great mate, even though it wasn't necessarily meant for me, still, i'd like to thank you for posting.Fitzcarraldo wrote:Ah, OK, if you don't have Polkit installed then the Polkit command pkexec is obviously not going to work.
But for 'normal' KDE Plasma 5 users it will work as shown in my earlier post. And, with either an alias or a two-line wrapper script, this method is as easy as the old method of using sudo or kdesu that KDE's Martin Gräßlin disabled*:
Code: Select all
$ dolrootCode: Select all
$ sudo dolphinIf an alias is used, rooted-Dolphin can be launched from the command line but cannot be launched via KDE's Application Launcher menu or KRunner. If a wrapper script is used, rooted-Dolphin can be launched from the user's command line and via KDE's Application Launcher menu (and therefore via KRunner too):Code: Select all
$ kdesu dolphin
Code: Select all
$ ls -la *root -rwx------ 1 fitzcarraldo fitzcarraldo 115 Jul 30 15:33 dolroot -rwx------ 1 fitzcarraldo fitzcarraldo 112 Jul 30 15:34 kateroot -rwx------ 1 fitzcarraldo fitzcarraldo 114 Jul 30 15:34 kwriterootAfter adding entries for dolroot, kateroot and kwriteroot to the KDE Application Launcher's menu, you can press Alt+F2 as usual to display the KRunner launcher then enter 'dolroot', 'kateroot' or 'kwriteroot' (without the quotes, obviously) in the KRunner window to launch Dolphin/Kate/KWrite as root. A window will pop-up for you to enter the root user's password.Code: Select all
$ cat dolroot #!/bin/bash pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphin
* Thankfully KDE's Nathaniel Graham is pragmatic, unlike KDE's Martin Gräßlin:
D12795 - Re-allow running Dolphin as the root user (but still not using sudo)
D12732 - Show a warning when running as the root user
Code: Select all
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true dolphinCode: Select all
alias kdesu='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true'
Code: Select all
[32;01m * [39;49;00mPackage: kde-apps/kwrite-19.04.3
[32;01m * [39;49;00mRepository: gentoo
[32;01m * [39;49;00mMaintainer: kde@gentoo.org
[32;01m * [39;49;00mUSE: abi_x86_64 amd64 elibc_glibc handbook kernel_linux userland_GNU
[32;01m * [39;49;00mFEATURES: network-sandbox preserve-libs sandbox userpriv usersandbox
>>> Unpacking source...
>>> Unpacking kate-19.04.3.tar.xz to /var/tmp/portage/kde-apps/kwrite-19.04.3/work
>>> Source unpacked in /var/tmp/portage/kde-apps/kwrite-19.04.3/work
>>> Preparing source in /var/tmp/portage/kde-apps/kwrite-19.04.3/work/kate-19.04.3 ...
[32;01m*[0m Applying kwrite-allow-root.patch ...
1 out of 1 hunk FAILED -- saving rejects to file kwrite/main.cpp.rej
[A[95C [34;01m[ [31;01m!![34;01m ][0m
[31;01m*[0m ERROR: kde-apps/kwrite-19.04.3::gentoo failed (prepare phase):
[31;01m*[0m patch -p1 failed with /etc/portage/patches/kde-apps/kwrite-19.04.3/kwrite-allow-root.patch
[31;01m*[0m
[31;01m*[0m Call stack:
[31;01m*[0m ebuild.sh, line 125: Called src_prepare
[31;01m*[0m environment, line 2644: Called kde5_src_prepare
[31;01m*[0m environment, line 2092: Called cmake-utils_src_prepare
[31;01m*[0m environment, line 1191: Called default_src_prepare
[31;01m*[0m phase-functions.sh, line 937: Called __eapi6_src_prepare
[31;01m*[0m environment, line 309: Called eapply_user
[31;01m*[0m environment, line 1406: Called eapply '/etc/portage/patches/kde-apps/kwrite-19.04.3/kwrite-allow-root.patch'
[31;01m*[0m environment, line 1376: Called _eapply_patch '/etc/portage/patches/kde-apps/kwrite-19.04.3/kwrite-allow-root.patch'
[31;01m*[0m environment, line 1314: Called __helpers_die 'patch -p1 failed with /etc/portage/patches/kde-apps/kwrite-19.04.3/kwrite-allow-root.patch'
[31;01m*[0m isolated-functions.sh, line 119: Called die
[31;01m*[0m The specific snippet of code:
[31;01m*[0m die "$@"
[31;01m*[0m
[31;01m*[0m If you need support, post the output of `emerge --info '=kde-apps/kwrite-19.04.3::gentoo'`,
[31;01m*[0m the complete build log and the output of `emerge -pqv '=kde-apps/kwrite-19.04.3::gentoo'`.
[31;01m*[0m The complete build log is located at '/var/log/portage/kde-apps:kwrite-19.04.3:20190812-001053.log'.
[31;01m*[0m For convenience, a symlink to the build log is located at '/var/tmp/portage/kde-apps/kwrite-19.04.3/temp/build.log'.
[31;01m*[0m The ebuild environment file is located at '/var/tmp/portage/kde-apps/kwrite-19.04.3/temp/environment'.
[31;01m*[0m Working directory: '/var/tmp/portage/kde-apps/kwrite-19.04.3/work/kate-19.04.3'
[31;01m*[0m S: '/var/tmp/portage/kde-apps/kwrite-19.04.3/work/kate-19.04.3'Code: Select all
--- a/kwrite/main.cpp
+++ b/kwrite/main.cpp
@@ -50,18 +50,6 @@
extern "C" Q_DECL_EXPORT 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 << "Executing KWrite with sudo is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Executing KWrite with kdesu is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
/**
* Create application first
* Enforce application name even if the executable is renamedCode: Select all
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -46,19 +46,6 @@
extern "C" Q_DECL_EXPORT int kdemain(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 << "Executing Dolphin with sudo is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Executing Dolphin with kdesu is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
-
QApplication app(argc, argv);
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("system-file-manager"), app.windowIcon()));
Code: Select all
diff -Naur orig/src/dolphinviewcontainer.cpp patched/src/dolphinviewcontainer.cpp
--- orig/src/dolphinviewcontainer.cpp 2019-09-03 00:15:08.000000000 +0300
+++ patched/src/dolphinviewcontainer.cpp 2019-09-15 12:45:14.451444593 +0300
@@ -136,13 +136,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);
diff -Naur orig/src/main.cpp patched/src/main.cpp
--- orig/src/main.cpp 2019-09-03 00:15:08.000000000 +0300
+++ patched/src/main.cpp 2019-09-15 12:43:55.923439868 +0300
@@ -46,19 +46,6 @@
extern "C" Q_DECL_EXPORT int kdemain(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 << "Executing Dolphin with sudo is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Executing Dolphin with kdesu is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
-
QApplication app(argc, argv);
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("system-file-manager"), app.windowIcon()));
Code: Select all
alias kdol="kdesu dolphin" Code: Select all
alias kdol="export XDG_CURRENT_DESKTOP=kde && dolphin"Code: Select all
gentoo-main ~ # kdol
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kf5.kservice.services: The desktop entry file "/usr/share/applications/org.gnupg.pinentry-qt.desktop" has Type= "Application" but no Exec line
kf5.kservice.sycoca: Invalid Service : "/usr/share/applications/org.gnupg.pinentry-qt.desktop"
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kf5.kio.core: "Could not enter folder tags:/."Did the patch fail?wrc1944 wrote:Sorry to report, but none of the last few dolphin patches have worked on my systems.
Code: Select all
~$ kdesu dolphinCode: Select all
Don't need password!!Code: Select all
~$ su -
~# dolphinI'll re-apply the patch, and rebuild dolphin. and rebuild kde-plasma/kde-cli-tools with the kdesu flag enabled.gentoo-main ~ # emerge kde-cli-tools -pv
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild R ] kde-plasma/kde-cli-tools-5.16.5:5::gentoo USE="X handbook -debug -kdesu -test" 0 KiB
Code: Select all
IUSE="kdesu X"
REQUIRED_USE="kdesu? ( X )"I think it means you can have kdesu only with X.wrc1944 wrote:
Hmm... Just checked the ebuild, and found:Is kdesu the default, and if so, why the REQUIRED_USE="kdesu? with the question mark? Does this mean kdesu flag must be used with X?Code: Select all
IUSE="kdesu X" REQUIRED_USE="kdesu? ( X )"
Code: Select all
alias kdol="kdesu dolphin"Code: Select all
diff -Naur orig/src/dolphinviewcontainer.cpp patched/src/dolphinviewcontainer.cpp
--- orig/src/dolphinviewcontainer.cpp 2019-09-03 00:15:08.000000000 +0300
+++ patched/src/dolphinviewcontainer.cpp 2019-09-15 12:45:14.451444593 +0300
@@ -136,13 +136,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);
diff -Naur orig/src/main.cpp patched/src/main.cpp
--- orig/src/main.cpp 2019-09-03 00:15:08.000000000 +0300
+++ patched/src/main.cpp 2019-09-15 12:43:55.923439868 +0300
@@ -46,19 +46,6 @@
extern "C" Q_DECL_EXPORT int kdemain(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 << "Executing Dolphin with sudo is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
- std::cout << "Executing Dolphin with kdesu is not possible due to unfixable security vulnerabilities." << std::endl;
- return EXIT_FAILURE;
- }
- }
-#endif
-
QApplication app(argc, argv);
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("system-file-manager"), app.windowIcon()));