From 435ed5853b9451ab8fdfff722545c57a8f154625 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Sat, 18 Feb 2017 13:49:14 +0100 Subject: [PATCH] Defuse root block While the main point is correct as any application running in the same X session (not sandboxed) can use kate's capability to open a console, we allow (even encourage) running YaST on X11 as root. That way it's only an impact on usability. --- kate/main.cpp | 3 +-- kwrite/main.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) Index: kate/main.cpp =================================================================== --- a/kate/main.cpp 2018-12-25 09:49:15.867478873 +0100 +++ b/kate/main.cpp 2018-12-25 09:49:19.231424088 +0100 @@ -46,21 +46,10 @@ int main(int argc, char **argv) { #ifndef Q_OS_WIN - // Prohibit using sudo or kdesu (but allow using the root user directly) + // Allow running Kate as root, but with a warning if (getuid() == 0) { - if (!qEnvironmentVariableIsEmpty("SUDO_USER")) { - std::cout << "Executing Kate with sudo is not possible due to unfixable security vulnerabilities. " - "It is also not necessary; simply 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 << "Executing Kate with kdesu is not possible due to unfixable security vulnerabilities. " - "It is also not necessary; simply use Kate normally, and you will be prompted for " - "elevated privileges when saving documents if needed." - << std::endl; - return EXIT_FAILURE; - } + std::cout << "THIS IS POTENTIALLY INSECURE!\nTo edit files as root please use:" << std::endl; + std::cout << "SUDO_EDITOR=kate sudoedit " << std::endl; } #endif /** Index: kwrite/main.cpp =================================================================== --- a/kwrite/main.cpp 2018-12-25 09:49:19.231424088 +0100 +++ b/kwrite/main.cpp 2018-12-25 09:50:32.302253532 +0100 @@ -38,21 +38,10 @@ 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) + // Allow running KWrite as root, but with a warning if (getuid() == 0) { - if (!qEnvironmentVariableIsEmpty("SUDO_USER")) { - std::cout << "Executing KWrite with sudo is not possible due to unfixable security vulnerabilities. " - "It is also not necessary; simply 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 << "Executing KWrite with kdesu is not possible due to unfixable security vulnerabilities. " - "It is also not necessary; simply use KWrite normally, and you will be prompted for " - "elevated privileges when saving documents if needed." - << std::endl; - return EXIT_FAILURE; - } + std::cout << "THIS IS POTENTIALLY INSECURE!\nTo edit files as root please use:" << std::endl; + std::cout << "SUDO_EDITOR=kwrite sudoedit " << std::endl; } #endif