summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-08-03 09:36:20 +0200
committerGitHub <noreply@github.com>2021-08-03 09:36:20 +0200
commitc6879b150f6094d3836a86b0182d017f8cb8d3d1 (patch)
treedcd6c353ccae605f688dd10bbaf0404b3a99148a
parenta7f24080a24577b6d05039277cc66828cc9b9c7d (diff)
parent9c34db6cb4da0578505da82c059758410ff01877 (diff)
Merge pull request #51107 from Calinou/warn-engine-run-as-root
Print a warning when the engine is started as `root`/superuser
-rw-r--r--main/main.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 02c3dffd11..92ab52eecd 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1596,6 +1596,13 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
rendering_server->set_print_gpu_profile(true);
}
+#ifdef UNIX_ENABLED
+ // Print warning after initializing the renderer but before initializing audio.
+ if (OS::get_singleton()->get_environment("USER") == "root" && !OS::get_singleton()->has_environment("GODOT_SILENCE_ROOT_WARNING")) {
+ WARN_PRINT("Started the engine as `root`/superuser. This is a security risk, and subsystems like audio may not work correctly.\nSet the environment variable `GODOT_SILENCE_ROOT_WARNING` to 1 to silence this warning.");
+ }
+#endif
+
OS::get_singleton()->initialize_joypads();
/* Initialize Audio Driver */