mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 09:07:13 +09:00
Avoid pkexec flatpak run if possible
This commit is contained in:
@@ -251,14 +251,19 @@ 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", "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 ?
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else if(has_perm) {
|
||||
const char *args[] = { server_filepath, self->initial_socket_path, card_path, NULL };
|
||||
execvp(args[0], (char *const*)args);
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user