Compare commits

...

2 Commits

Author SHA1 Message Date
BritishTeapot
67a148c7aa Fixed inverted access control permissions bug.
Fixed an (admitedly quite silly) bug that caused the access control
descisions to be inverted.
2025-03-18 10:03:32 +01:00
BritishTeapot
c59123330f Updated .gitignore 2025-03-18 09:55:20 +01:00
3 changed files with 11 additions and 5 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ build/*
.clang-tidy
.cache
test/protected/*
compile_commands.json

View File

@ -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;
}

View File

@ -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;
}
/**