diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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 }; |