diff --git a/kate/main.cpp b/kate/main.cpp --- a/kate/main.cpp +++ b/kate/main.cpp @@ -61,13 +61,15 @@ int main(int argc, char **argv) { #ifndef Q_OS_WIN - /** - * Check whether we are running as root - **/ + // Prohibit using sudo or kdesu (but allow using the root user directly) if (getuid() == 0) { - std::cout << "Executing Kate as root is not possible. To edit files as root use:" << std::endl; - std::cout << "SUDO_EDITOR=kate sudoedit " << std::endl; - return 0; + if (!qEnvironmentVariableIsEmpty("SUDO_USER")) { + std::cout << "Executing Kate with sudo is not possible due to unfixable security vulnerabilities." << std::endl; + return EXIT_FAILURE; + } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) { + std::cout << "Executing Kate with kdesu is not possible due to unfixable security vulnerabilities." << std::endl; + return EXIT_FAILURE; + } } #endif /** diff --git a/kwrite/main.cpp b/kwrite/main.cpp --- a/kwrite/main.cpp +++ b/kwrite/main.cpp @@ -50,13 +50,15 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv) { #ifndef Q_OS_WIN - /** - * Check whether we are running as root - **/ + // Prohibit using sudo or kdesu (but allow using the root user directly) if (getuid() == 0) { - std::cout << "Executing KWrite as root is not possible. To edit files as root use:" << std::endl; - std::cout << "SUDO_EDITOR=kwrite sudoedit " << std::endl; - return 0; + if (!qEnvironmentVariableIsEmpty("SUDO_USER")) { + std::cout << "Executing Kate with sudo is not possible due to unfixable security vulnerabilities." << std::endl; + return EXIT_FAILURE; + } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) { + std::cout << "Executing Kate with kdesu is not possible due to unfixable security vulnerabilities." << std::endl; + return EXIT_FAILURE; + } } #endif /**