aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-04-06 15:08:28 +0200
committerdec05eba <dec05eba@protonmail.com>2024-04-06 15:08:28 +0200
commit9776cc4e7e9037bde5d5ece69f7d1f959da4bfd5 (patch)
tree2ab9da26edc1410a0141f99a0d5b5932c4cadd87 /main.c
parent9b5c4b5a1e68843ed187ca0dcec83dd8a4a83e18 (diff)
Resolve /proc/self/exe fullpath
Diffstat (limited to 'main.c')
-rw-r--r--main.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/main.c b/main.c
index c9f21c8..e59691f 100644
--- a/main.c
+++ b/main.c
@@ -9,12 +9,17 @@
#include <sys/sendfile.h>
#include <sys/capability.h>
-static int get_self_filepath(char *buffer, size_t size) {
- ssize_t bytes_written = readlink("/proc/self/exe", buffer, size - 1);
+static int get_self_filepath(char *buffer) {
+ char self_path[PATH_MAX];
+
+ ssize_t bytes_written = readlink("/proc/self/exe", self_path, sizeof(self_path) - 1);
if(bytes_written == -1)
return 0;
- buffer[bytes_written] = '\0';
+ self_path[bytes_written] = '\0';
+ if(!realpath(self_path, buffer))
+ return 0;
+
return 1;
}
@@ -115,11 +120,11 @@ int main(int argc, char **argv) {
const char *user_homepath = argv[3];
char self_path[PATH_MAX];
- if(!get_self_filepath(self_path, sizeof(self_path)))
+ if(!get_self_filepath(self_path))
return 1;
char kms_server_proxy_local_filepath[PATH_MAX];
- snprintf(kms_server_proxy_local_filepath, sizeof(kms_server_proxy_local_filepath), "%s/.local/share/gpu-screen-recorder/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-1", 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 };