Fixed inverted access control permissions bug.

Fixed an (admitedly quite silly) bug that caused the access control
descisions to be inverted.
This commit is contained in:
BritishTeapot 2025-03-18 10:03:32 +01:00
parent c59123330f
commit 67a148c7aa
2 changed files with 10 additions and 5 deletions

View File

@ -264,7 +264,7 @@ static int xmp_unlink(const char *path) {
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); // 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); free(pi.name);
return -EACCES; 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)); // 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); free(pi.name);
return -EACCES; 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); pi.name = get_process_name_by_pid(pi.PID);
// fprintf(stderr, "%s, %d\n", path, ask_access(path, pi)); // 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); free(pi.name);
return -EACCES; return -EACCES;
} }

View File

@ -71,14 +71,19 @@ int ask_access(const char *filename, struct process_info pi) {
// to manually check the output. // to manually check the output.
char buffer[1024]; char buffer[1024];
while (fgets(buffer, sizeof(buffer), fp)) { while (fgets(buffer, sizeof(buffer), fp)) {
if (strcmp(buffer, "Allow this time.\n") == 0) { if (strcmp(buffer, "Allow this time\n") == 0) {
pclose(fp); pclose(fp);
return 2; return 2;
} }
} }
int zenity_exit_code = WEXITSTATUS(pclose(fp)); 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;
} }
/** /**