diff --git a/kate/main.cpp b/kate/main.cpp --- a/kate/main.cpp +++ b/kate/main.cpp @@ -51,9 +51,24 @@ #include "qtsingleapplication/qtsingleapplication.h" #endif +#ifndef Q_OS_WIN +#include +#endif +#include + int main(int argc, char **argv) { +#ifndef Q_OS_WIN + /** + * Check whether we are running as root + **/ + 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; + } +#endif /** * init resources from our static lib */ diff --git a/kwrite/main.cpp b/kwrite/main.cpp --- a/kwrite/main.cpp +++ b/kwrite/main.cpp @@ -42,8 +42,23 @@ #include "../urlinfo.h" +#ifndef Q_OS_WIN +#include +#endif +#include + extern "C" Q_DECL_EXPORT int main(int argc, char **argv) { +#ifndef Q_OS_WIN + /** + * Check whether we are running as root + **/ + 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; + } +#endif /** * Create application first * Enforce application name even if the executable is renamed