diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-12-31 17:09:56 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-12-31 17:09:56 +0100 |
commit | 275d4d1b3277b69dbb2942645cda1b92e31ead76 (patch) | |
tree | 35073ce8690ac28906a6acc16a00598a7a6760c8 /kms | |
parent | 8afc473441dabb221e829659f6d694accfe30dee (diff) |
Avoid pkexec flatpak run if possible
Diffstat (limited to 'kms')
-rw-r--r-- | kms/client/kms_client.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c index 2713c6f..fe19023 100644 --- a/kms/client/kms_client.c +++ b/kms/client/kms_client.c @@ -251,13 +251,18 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { goto err; } else if(pid == 0) { /* child */ if(inside_flatpak) { - const char *args[] = { "flatpak-spawn", "--host", "/var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/gsr-kms-server", self->initial_socket_path, card_path, NULL }; - execvp(args[0], (char *const*)args); - - // If above fails for whatever reason we try this. Maybe some distros dont install flatpak in /var/lib/flatpak/app ? - if(!has_perm) { - const char *args[] = { "flatpak-spawn", "--host", "pkexec", "flatpak", "run", "--command=gsr-kms-server", "com.dec05eba.gpu_screen_recorder", self->initial_socket_path, card_path, NULL }; + if(has_perm) { + const char *args[] = { "flatpak-spawn", "--host", "/var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/gsr-kms-server", self->initial_socket_path, card_path, NULL }; + execvp(args[0], (char *const*)args); + } else { + const char *args[] = { "flatpak-spawn", "--host", "pkexec", "/var/lib/flatpak/app/com.dec05eba.gpu_screen_recorder/current/active/files/bin/gsr-kms-server", self->initial_socket_path, card_path, NULL }; execvp(args[0], (char *const*)args); + + // If above fails for whatever reason we try this. Maybe some distros dont install flatpak in /var/lib/flatpak/app ? + { + const char *args[] = { "flatpak-spawn", "--host", "pkexec", "flatpak", "run", "--command=gsr-kms-server", "com.dec05eba.gpu_screen_recorder", self->initial_socket_path, card_path, NULL }; + execvp(args[0], (char *const*)args); + } } } else if(has_perm) { const char *args[] = { server_filepath, self->initial_socket_path, card_path, NULL }; @@ -266,7 +271,6 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { const char *args[] = { "pkexec", server_filepath, self->initial_socket_path, card_path, NULL }; execvp(args[0], (char *const*)args); } - fprintf(stderr, "gsr error: gsr_kms_client_init: execvp failed, error: %s\n", strerror(errno)); _exit(127); } else { /* parent */ |