diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-11-24 22:53:29 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-11-24 22:53:29 +0100 |
commit | a872c07f7a1a8d65ee507a33bac9b023d9d936b4 (patch) | |
tree | 080f5ba4ab435e531bbaa1c40fe9640dedbc7f48 /src | |
parent | b57bc8505d2c62d79ca1c980f902bde1cc4b3f99 (diff) |
Dont allow running the program as the root user
Diffstat (limited to 'src')
-rw-r--r-- | src/Overlay.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 720bb2e..2475a77 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -1436,7 +1436,7 @@ namespace gsr { mgl_context *context = mgl_get_context(); Display *display = (Display*)context->connection; - if(is_compositor_running(display, 0)) + if(gsr_info.system_info.display_server != DisplayServer::X11 || is_compositor_running(display, 0)) return false; bool window_texture_loaded = false; diff --git a/src/main.cpp b/src/main.cpp index 0b3035d..4a36fe7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,11 @@ static bool is_socket_disconnected(int socket) { int main(void) { setlocale(LC_ALL, "C"); // Sigh... stupid C + if(geteuid() == 0) { + fprintf(stderr, "Error: don't run gsr-ui as the root user\n"); + return 1; + } + // Cant get window texture when prime-run is used disable_prime_run(); @@ -92,6 +97,7 @@ int main(void) { } mgl_context *context = mgl_get_context(); + const int x11_socket = XConnectionNumber((Display*)context->connection); egl_functions egl_funcs; egl_funcs.eglGetError = (decltype(egl_funcs.eglGetError))context->gl.eglGetProcAddress("eglGetError"); @@ -192,8 +198,6 @@ int main(void) { if(!replay_save_hotkey_registered) fprintf(stderr, "error: failed to register hotkey alt+f10 for saving replay because the hotkey is registered by another program\n"); - const int x11_socket = XConnectionNumber((Display*)context->connection); - mgl::Clock frame_delta_clock; while(running) { if(is_socket_disconnected(x11_socket)) { @@ -201,8 +205,7 @@ int main(void) { break; } - const double frame_delta_seconds = frame_delta_clock.get_elapsed_time_seconds(); - frame_delta_clock.restart(); + const double frame_delta_seconds = frame_delta_clock.restart(); gsr::set_frame_delta_seconds(frame_delta_seconds); global_hotkeys.poll_events(); |