aboutsummaryrefslogtreecommitdiff
path: root/kms/client
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-12-31 17:07:28 +0100
committerdec05eba <dec05eba@protonmail.com>2023-12-31 17:07:28 +0100
commit8afc473441dabb221e829659f6d694accfe30dee (patch)
tree16906811c40ca16476907aed8fda4f3134511a6c /kms/client
parentc340cb05177277ab0f20bf16ae9797fa5812fec9 (diff)
Avoid pkexec with flatpak if possible
Diffstat (limited to 'kms/client')
-rw-r--r--kms/client/kms_client.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c
index 0b28b48..2713c6f 100644
--- a/kms/client/kms_client.c
+++ b/kms/client/kms_client.c
@@ -251,10 +251,11 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) {
goto err;
} else if(pid == 0) { /* child */
if(inside_flatpak) {
- 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", "/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 };
execvp(args[0], (char *const*)args);
}
@@ -265,6 +266,7 @@ 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 */