aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-02-16 22:02:16 +0100
committerdec05eba <dec05eba@protonmail.com>2024-02-16 22:02:20 +0100
commit9b5c4b5a1e68843ed187ca0dcec83dd8a4a83e18 (patch)
tree4b002b7e387a2c0d70506fbb1535d83f1fc91b3d
parentdece0984026405bd83a0d948c66e0cb50d4b8a90 (diff)
Move local kms-server-proxy to ~/.local/share/gpu-screen-recorder
-rw-r--r--README.md4
-rw-r--r--main.c19
2 files changed, 11 insertions, 12 deletions
diff --git a/README.md b/README.md
index 0a6b410..6f18154 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
This program fixes password prompt spam in GPU Screen Recorder when used from flatpak.
This program is meant to be ran with flatpak-spawn --host. This program is not meant to be run by the user and is automatically launched from GPU Screen Recorder flatpak.
When this program is first run, it executes itself with pkexec and in that case it sets CAP_SYS_ADMIN capability on itself
-after copying self to ~/.local/bin and launches gsr-kms-server (in flatpak location).
-When this program is run after that it will check if its run from ~/.local/bin or launch that and it will see that the program has CAP_SYS_ADMIN capability
+after copying self to ~/.local/share/gpu-screen-recorder and launches gsr-kms-server (in flatpak location).
+When this program is run after that it will check if its run from ~/.local/share/gpu-screen-recorder or launch that and it will see that the program has CAP_SYS_ADMIN capability
and will launch gsr-kms-server (in flatpak location). This program also sets CAP_SYS_ADMIN on gsr-kms-server in the flatpak app directory.
The reason all of this is needed is because `setcap cap_sys_admin+ep gsr-kms-server` can't be done in the flatpak because of sandboxing so this is only done when you install GPU Screen Recorder
diff --git a/main.c b/main.c
index 13ece70..c9f21c8 100644
--- a/main.c
+++ b/main.c
@@ -59,15 +59,14 @@ static int create_local_kms_server_proxy_directory(const char *home) {
char path[PATH_MAX];
int err;
- snprintf(path, sizeof(path), "%s/.local", home);
- err = mkdir(path, S_IRWXU);
- if(err == -1 && errno != EEXIST)
- return 0;
-
- snprintf(path, sizeof(path), "%s/.local/bin", home);
- err = mkdir(path, S_IRWXU);
- if(err == -1 && errno != EEXIST)
- return 0;
+ const char *paths[] = { ".local", ".local/share", ".local/share/gpu-screen-recorder", NULL };
+ for(size_t i = 0; paths[i]; ++i) {
+ const char *path_part = paths[i];
+ snprintf(path, sizeof(path), "%s/%s", home, path_part);
+ err = mkdir(path, S_IRWXU);
+ if(err == -1 && errno != EEXIST)
+ return 0;
+ }
return 1;
}
@@ -120,7 +119,7 @@ int main(int argc, char **argv) {
return 1;
char kms_server_proxy_local_filepath[PATH_MAX];
- snprintf(kms_server_proxy_local_filepath, sizeof(kms_server_proxy_local_filepath), "%s/.local/bin/kms-server-proxy", user_homepath);
+ snprintf(kms_server_proxy_local_filepath, sizeof(kms_server_proxy_local_filepath), "%s/.local/share/gpu-screen-recorder/kms-server-proxy", user_homepath);
if(file_has_sys_admin_capability(gsr_kms_server_filepath)) {
const char *args[] = { gsr_kms_server_filepath, initial_socket_path, card_path, NULL };