From 67a148c7aa418488084c7b0753d1769fcc2f48ab Mon Sep 17 00:00:00 2001 From: BritishTeapot Date: Tue, 18 Mar 2025 10:03:32 +0100 Subject: [PATCH] Fixed inverted access control permissions bug. Fixed an (admitedly quite silly) bug that caused the access control descisions to be inverted. --- src/fuse_operations.c | 6 +++--- src/ui-socket.c | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/fuse_operations.c b/src/fuse_operations.c index 5e56661..3f95315 100644 --- a/src/fuse_operations.c +++ b/src/fuse_operations.c @@ -264,7 +264,7 @@ static int xmp_unlink(const char *path) { // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (interactive_access(real_filename(path), pi)) { + if (!interactive_access(real_filename(path), pi)) { free(pi.name); return -EACCES; } @@ -392,7 +392,7 @@ static int xmp_create(const char *path, mode_t mode, // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (interactive_access(real_filename(path), pi)) { + if (!interactive_access(real_filename(path), pi)) { free(pi.name); return -EACCES; } @@ -417,7 +417,7 @@ static int xmp_open(const char *path, struct fuse_file_info *fi) { pi.name = get_process_name_by_pid(pi.PID); // fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); - if (interactive_access(real_filename(path), pi)) { + if (!interactive_access(real_filename(path), pi)) { free(pi.name); return -EACCES; } diff --git a/src/ui-socket.c b/src/ui-socket.c index 157ad96..fd66dbd 100644 --- a/src/ui-socket.c +++ b/src/ui-socket.c @@ -71,14 +71,19 @@ int ask_access(const char *filename, struct process_info pi) { // to manually check the output. char buffer[1024]; while (fgets(buffer, sizeof(buffer), fp)) { - if (strcmp(buffer, "Allow this time.\n") == 0) { + if (strcmp(buffer, "Allow this time\n") == 0) { pclose(fp); return 2; } } int zenity_exit_code = WEXITSTATUS(pclose(fp)); - return zenity_exit_code; + // zenity returns 1 on "No" >:( + if (zenity_exit_code == 0) { + return 1; + } + + return 0; } /**