From 5452c3d1d7ecc810eaac7a66184e34324dfa84f8 Mon Sep 17 00:00:00 2001 From: fedir Date: Thu, 1 May 2025 16:17:50 +0200 Subject: [PATCH] Added filename translation to the ui-socker --- src/ui-socket.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ui-socket.c b/src/ui-socket.c index 2c921cc..ad2549e 100644 --- a/src/ui-socket.c +++ b/src/ui-socket.c @@ -12,6 +12,7 @@ #include #define _GNU_SOURCE #include "perm_permissions_table.h" +#include "real_filename.h" #include "temp_permissions_table.h" #include "ui-socket.h" #include @@ -70,7 +71,7 @@ access_t ask_access(const char *filename, struct process_info proc_info) { "zenity --question --extra-button \"Allow this time\" --title " "\"Allow Access?\" --text \"Allow process " "%s with PID %d to access %s\"", - proc_info.name, proc_info.PID, filename); + proc_info.name, proc_info.PID, filename, get_mountpoint()); if (ret < 0) { // If asprintf fails, the contents of command are undefined (see man @@ -126,20 +127,25 @@ access_t ask_access(const char *filename, struct process_info proc_info) { */ int interactive_access(const char *filename, struct process_info proc_info, int opts) { + char *real_path = real_filename(filename); - access_t access = check_temp_access(filename, proc_info); + access_t access = check_temp_access(real_path, proc_info); if (access == ALLOW) { + free(real_path); return 1; } if (access == DENY) { + free(real_path); return 0; } - access = check_perm_access(filename, proc_info); + access = check_perm_access(real_path, proc_info); if (access == ALLOW) { + free(real_path); return 1; } if (access == DENY) { + free(real_path); return 0; } @@ -147,30 +153,36 @@ int interactive_access(const char *filename, struct process_info proc_info, // permissions are granted if (opts & GRANT_PERM) { - give_perm_access(filename, proc_info); + give_perm_access(real_path, proc_info); + free(real_path); return 1; } if (opts & GRANT_TEMP) { - set_temp_access(filename, proc_info, SET_ALLOW); + set_temp_access(real_path, proc_info, SET_ALLOW); + free(real_path); return 1; } - access_t user_response = ask_access(filename, proc_info); + access_t user_response = ask_access(real_path, proc_info); if (user_response == ALLOW) { - give_perm_access(filename, proc_info); + give_perm_access(real_path, proc_info); + free(real_path); return 1; } if (user_response == ALLOW_TEMP) { - set_temp_access(filename, proc_info, SET_ALLOW); + set_temp_access(real_path, proc_info, SET_ALLOW); + free(real_path); return 1; } if (user_response == DENY) { - set_temp_access(filename, proc_info, SET_DENY); + set_temp_access(real_path, proc_info, SET_DENY); + free(real_path); return 0; } + free(real_path); // deny on unknown options. return 0; }