diff --git a/source/auth.cpp b/source/auth.cpp index 014b46b..61e8cd7 100644 --- a/source/auth.cpp +++ b/source/auth.cpp @@ -94,16 +94,22 @@ bool is_subpath(const std::filesystem::path& root, const std::filesystem::path& return mismatch_pair.second == root.end(); } -bool check_access(std::string root, std::string user_id, std::string suffix, std::string path) { - if (not std::filesystem::exists(path)) { - return true; - } +bool check_exists(std::filesystem::path path) { + std::error_code ec; + bool ok = std::filesystem::exists(path, ec); + return ok; +} +bool check_access(std::string root, std::string user_id, std::string suffix, std::string path) { std::filesystem::path user_root = normalize_path(root, user_id, suffix); auto const root_can = user_root.lexically_normal(); auto const path_can = std::filesystem::path(path).lexically_normal(); + if (not check_exists(path_can)) { + return true; + } + if (root_can == path_can) { return true; } diff --git a/source/fs.cpp b/source/fs.cpp index d4c0a13..8eb2678 100644 --- a/source/fs.cpp +++ b/source/fs.cpp @@ -251,7 +251,6 @@ static void hello_ll_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_in int res = response.getRes(); if (res == -1) { - // std::cout << "GETATTR::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -295,8 +294,6 @@ static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) lookup.setParent(parent); lookup.setName(name); - // std::cout << "LOOKUP name: " << name << std::endl; - auto promise = request.send(); auto result = promise.wait(waitScope); auto response = result.getRes(); @@ -308,7 +305,6 @@ static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) int res = response.getRes(); if (res == -1) { - // std::cout << "LOOKUP::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -338,7 +334,7 @@ static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) fuse_reply_entry(req, &e); - // std::cout << "hello_ll_lookup executed correctly: " << payload << std::endl; + // std::cout << "hello_ll_lookup executed correctly" << std::endl; } /** @@ -882,7 +878,6 @@ static void hello_ll_mknod(fuse_req_t req, fuse_ino_t parent, const char *name, int res = response.getRes(); if (res == -1) { - // std::cout << "MKNOD::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -993,7 +988,6 @@ static void hello_ll_create(fuse_req_t req, fuse_ino_t parent, const char *name, int res = response.getRes(); if (res == -1) { - // std::cout << "CREATE::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -1057,7 +1051,6 @@ static void hello_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name, int res = response.getRes(); if (res == -1) { - // std::cout << "MKDIR::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -1294,7 +1287,6 @@ static void hello_ll_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr, int res = response.getRes(); if (res == -1) { - // std::cout << "SETATTR::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -1327,7 +1319,6 @@ static void hello_ll_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name, int res = response.getRes(); if (res == -1) { - // std::cout << "SETXATTR::ENOENT" << std::endl; fuse_reply_err(req, response.getErrno()); return; } @@ -1360,7 +1351,7 @@ static void hello_ll_readlink(fuse_req_t req, fuse_ino_t ino) { fuse_reply_readlink(req, link.c_str()); } - // std::cout << "readlink executed correctly: " << payload << std::endl; + // std::cout << "readlink executed correctly " << std::endl; } // clang-format off diff --git a/source/rpc.cpp b/source/rpc.cpp index 41f8cb2..eeb9017 100644 --- a/source/rpc.cpp +++ b/source/rpc.cpp @@ -120,13 +120,6 @@ class GhostFSImpl final : public GhostFS::Server { return kj::READY_NOW; } - if (not std::filesystem::exists(file_path)) { - int err = errno; - response.setErrno(err); - response.setRes(-1); - return kj::READY_NOW; - } - uint64_t ino; if (not path_to_ino.contains(file_path)) {