diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-02-22 17:18:12 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-02-22 17:18:12 +0100 |
commit | 9b4fede6e6c5d25c4901d95e77638ae17535c91f (patch) | |
tree | c42a7b79d707307f66185b656393f3149d628d85 | |
parent | 7a95e47aac884ea80a5f1dca2c62a16b3144cd39 (diff) |
Launch gsr-kms-server with setuid instead of pkexec (fix for openSUSE)
-rw-r--r-- | main.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -12,6 +12,7 @@ #include <sys/capability.h> #define KMS_SERVER_PROXY_FILEPATH "/var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/kms-server-proxy" +#define GSR_KMS_SERVER_FILEPATH "/var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/gsr-kms-server" #define GSR_GLOBAL_HOTKEYS_FILEPATH "/var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/gsr-global-hotkeys" static bool readlink_realpath(const char *filepath, char *buffer) { @@ -253,13 +254,18 @@ static int launch_gsr_kms_server(const char *initial_socket_path, const char *ca return execv(args[0], (char *const*)args); } - const char *args[] = { "pkexec", GSR_GLOBAL_HOTKEYS_FILEPATH, initial_socket_path, card_path, NULL }; + if(setuid(0) == -1) { + fprintf(stderr, "Error: failed to switch to root user to launch gsr-kms-server\n"); + return 1; + } + + const char *args[] = { GSR_KMS_SERVER_FILEPATH, initial_socket_path, card_path, NULL }; return execvp(args[0], (char *const*)args); } else if(geteuid() == 0) { /* is current user root? */ if(!set_gsr_files_set_permissions_and_capabilities(kms_server_proxy_local_filepath)) return 1; - const char *args[] = { GSR_GLOBAL_HOTKEYS_FILEPATH, initial_socket_path, card_path, NULL }; + const char *args[] = { GSR_KMS_SERVER_FILEPATH, initial_socket_path, card_path, NULL }; return execv(args[0], (char *const*)args); } else { remove_local_gsr_files(user_homepath); |