소스 검색

Merge pull request #51107 from Calinou/warn-engine-run-as-root

Print a warning when the engine is started as `root`/superuser
Rémi Verschelde 4 년 전
부모
커밋
c6879b150f
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      main/main.cpp

+ 7 - 0
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 */