Absolved fuse operations of responsibility for filename translation
This commit is contained in:
parent
48342b0d5f
commit
ed441b3c5f
@ -11,6 +11,8 @@
|
|||||||
See the file LICENSE.
|
See the file LICENSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "real_filename.h"
|
||||||
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#define FUSE_USE_VERSION 31
|
#define FUSE_USE_VERSION 31
|
||||||
|
|
||||||
@ -94,9 +96,6 @@ const char *get_process_name_by_pid(const int pid) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this somewhere else
|
|
||||||
const char *real_filename(const char *filename) { return filename; }
|
|
||||||
|
|
||||||
static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
|
static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
|
||||||
(void)conn;
|
(void)conn;
|
||||||
cfg->use_ino = 1;
|
cfg->use_ino = 1;
|
||||||
@ -120,6 +119,7 @@ static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
|
|||||||
cfg->attr_timeout = 0;
|
cfg->attr_timeout = 0;
|
||||||
cfg->negative_timeout = 0;
|
cfg->negative_timeout = 0;
|
||||||
fprintf(stderr, "%d\n", getpid());
|
fprintf(stderr, "%d\n", getpid());
|
||||||
|
assert(get_mountpoint() != NULL);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ static int xmp_access(const char *path, int mask) {
|
|||||||
|
|
||||||
// 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), proc_info, 0)) {
|
if (!interactive_access(path, proc_info, 0)) {
|
||||||
free((void *)proc_info.name);
|
free((void *)proc_info.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -323,7 +323,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, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -371,15 +371,14 @@ static int xmp_rename(const char *from, const char *to, unsigned int flags) {
|
|||||||
|
|
||||||
// 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(from), pi, 0)) {
|
if (!interactive_access(from, pi, 0)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the "to" file may exist and the process needs to get persmission to modify
|
// the "to" file may exist and the process needs to get persmission to modify
|
||||||
// it
|
// it
|
||||||
if (source_access(to, F_OK) == 0 &&
|
if (source_access(to, F_OK) == 0 && !interactive_access(to, pi, 0)) {
|
||||||
!interactive_access(real_filename(to), pi, 0)) {
|
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -402,7 +401,7 @@ static int xmp_link(const char *from, const char *to) {
|
|||||||
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(from), pi, 0)) {
|
if (!interactive_access(from, pi, 0)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -427,7 +426,7 @@ static int xmp_chmod(const char *path, mode_t mode, 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, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -458,7 +457,7 @@ static int xmp_chown(const char *path, uid_t uid, gid_t gid,
|
|||||||
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, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -518,7 +517,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, GRANT_PERM)) {
|
if (!interactive_access(path, pi, GRANT_PERM)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -542,7 +541,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, 0)) {
|
if (!interactive_access(path, pi, 0)) {
|
||||||
free(pi.name);
|
free(pi.name);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user