mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-01-31 01:13:04 +09:00
Dont allow running the program as the root user
This commit is contained in:
@@ -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;
|
||||
|
||||
11
src/main.cpp
11
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();
|
||||
|
||||
Reference in New Issue
Block a user