Added filename translation to the ui-socker
This commit is contained in:
parent
a1445c5423
commit
5452c3d1d7
@ -12,6 +12,7 @@
|
||||
#include <time.h>
|
||||
#define _GNU_SOURCE
|
||||
#include "perm_permissions_table.h"
|
||||
#include "real_filename.h"
|
||||
#include "temp_permissions_table.h"
|
||||
#include "ui-socket.h"
|
||||
#include <pthread.h>
|
||||
@ -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 "
|
||||
"<tt>%s</tt> with PID <tt>%d</tt> to access <tt>%s</tt>\"",
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user