Loading fs/src/adafs_ops/access.cpp +50 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ // #include "access.h" #include "metadata_ops.h" /** * Checks access for mask (can be R_OK, W_OK, or X_OK (or combined) AFAIK and not verified) against metadata's mode. Loading @@ -12,7 +13,7 @@ * @param mask * @return */ int chk_access(const Metadata& md, const int mask) { int chk_access(const Metadata& md, int mask) { ADAFS_DATA->logger->debug("chk_access() enter: metadata_uid {} fusecontext_uid {}", md.uid(), fuse_get_context()->uid); // root user is a god Loading Loading @@ -44,3 +45,50 @@ int chk_access(const Metadata& md, const int mask) { return -EACCES; } /** * Check if uid from fuse context (i.e., the caller) equals the uid from the object * @param md * @return */ int chk_uid(const Metadata& md) { // root user is a god if (fuse_get_context()->uid == 0) return 0; // if user is the user of md, he/she has access if (fuse_get_context()->uid == md.uid()) return 0; // else no access return -EACCES; } /** * Changes the mode from an object to given mode * @param md * @param mode * @return */ // XXX error handling int chmod(Metadata& md, mode_t mode, const bfs::path& path) { auto path_hash = ADAFS_DATA->hashf(path.string()); md.mode((uint32_t) mode); write_metadata_field(md.mode(), path_hash, md_field_map.at(Md_fields::mode)); #ifdef ACMtime md.update_ACM_time(true, true, true); write_metadata_field(md.atime(), path_hash, md_field_map.at(Md_fields::atime)); write_metadata_field(md.ctime(), path_hash, md_field_map.at(Md_fields::ctime)); write_metadata_field(md.mtime(), path_hash, md_field_map.at(Md_fields::mtime)); #endif return 0; } fs/src/adafs_ops/access.h +4 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,10 @@ #include "../classes/metadata.h" int chk_access(const Metadata& md, const int mask); int chk_access(const Metadata& md, int mask); int chk_uid(const Metadata& md); int chmod(Metadata& md, mode_t mode, const bfs::path& path); #endif //FS_ACCESS_H fs/src/fuse_ops.h +0 −4 Original line number Diff line number Diff line Loading @@ -25,9 +25,7 @@ int adafs_rmdir(const char* p); // I/O int adafs_read(const char* p, char* buf, size_t size, off_t offset, struct fuse_file_info* fi); int adafs_write(const char* p, const char* buf, size_t size, off_t offset, struct fuse_file_info* fi); int adafs_truncate(const char* p, off_t offset, struct fuse_file_info* fi); // Loading @@ -35,9 +33,7 @@ int adafs_flush(const char* p, struct fuse_file_info* fi); // access int adafs_access(const char* p, int mask); int adafs_chmod(const char* p, mode_t mode, struct fuse_file_info* fi); int adafs_chown(const char* p, uid_t uid, gid_t gid, struct fuse_file_info* fi); // file system miscellaneous Loading fs/src/fuse_ops/access.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -36,10 +36,18 @@ int adafs_access(const char* p, int mask) { * may also be NULL if the file is open. */ int adafs_chmod(const char* p, mode_t mode, struct fuse_file_info* fi) { ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_chmod() enter: name '{}' mode {}", p, mode); ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_chmod() enter: name '{}' mode {:o}", p, mode); auto path = bfs::path(p); auto md = make_shared<Metadata>(); auto err = get_metadata(*md, path); if (err) return err; return 0; // for chmod only the uid matters AFAIK err = chk_uid(*md); if (err) return err; return chmod(*md, mode, path); } /** Change the owner and group of a file Loading fs/src/fuse_ops/io.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -88,8 +88,9 @@ int adafs_write(const char* p, const char* buf, size_t size, off_t offset, struc write_metadata_field(md->size(), path_hash, md_field_map.at(Md_fields::size)); #ifdef ACMtime md->update_ACM_time(true, false, true); md->update_ACM_time(true, true, true); write_metadata_field(md->atime(), path_hash, md_field_map.at(Md_fields::atime)); write_metadata_field(md->ctime(), path_hash, md_field_map.at(Md_fields::ctime)); write_metadata_field(md->mtime(), path_hash, md_field_map.at(Md_fields::mtime)); #endif Loading Loading
fs/src/adafs_ops/access.cpp +50 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ // #include "access.h" #include "metadata_ops.h" /** * Checks access for mask (can be R_OK, W_OK, or X_OK (or combined) AFAIK and not verified) against metadata's mode. Loading @@ -12,7 +13,7 @@ * @param mask * @return */ int chk_access(const Metadata& md, const int mask) { int chk_access(const Metadata& md, int mask) { ADAFS_DATA->logger->debug("chk_access() enter: metadata_uid {} fusecontext_uid {}", md.uid(), fuse_get_context()->uid); // root user is a god Loading Loading @@ -44,3 +45,50 @@ int chk_access(const Metadata& md, const int mask) { return -EACCES; } /** * Check if uid from fuse context (i.e., the caller) equals the uid from the object * @param md * @return */ int chk_uid(const Metadata& md) { // root user is a god if (fuse_get_context()->uid == 0) return 0; // if user is the user of md, he/she has access if (fuse_get_context()->uid == md.uid()) return 0; // else no access return -EACCES; } /** * Changes the mode from an object to given mode * @param md * @param mode * @return */ // XXX error handling int chmod(Metadata& md, mode_t mode, const bfs::path& path) { auto path_hash = ADAFS_DATA->hashf(path.string()); md.mode((uint32_t) mode); write_metadata_field(md.mode(), path_hash, md_field_map.at(Md_fields::mode)); #ifdef ACMtime md.update_ACM_time(true, true, true); write_metadata_field(md.atime(), path_hash, md_field_map.at(Md_fields::atime)); write_metadata_field(md.ctime(), path_hash, md_field_map.at(Md_fields::ctime)); write_metadata_field(md.mtime(), path_hash, md_field_map.at(Md_fields::mtime)); #endif return 0; }
fs/src/adafs_ops/access.h +4 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,10 @@ #include "../classes/metadata.h" int chk_access(const Metadata& md, const int mask); int chk_access(const Metadata& md, int mask); int chk_uid(const Metadata& md); int chmod(Metadata& md, mode_t mode, const bfs::path& path); #endif //FS_ACCESS_H
fs/src/fuse_ops.h +0 −4 Original line number Diff line number Diff line Loading @@ -25,9 +25,7 @@ int adafs_rmdir(const char* p); // I/O int adafs_read(const char* p, char* buf, size_t size, off_t offset, struct fuse_file_info* fi); int adafs_write(const char* p, const char* buf, size_t size, off_t offset, struct fuse_file_info* fi); int adafs_truncate(const char* p, off_t offset, struct fuse_file_info* fi); // Loading @@ -35,9 +33,7 @@ int adafs_flush(const char* p, struct fuse_file_info* fi); // access int adafs_access(const char* p, int mask); int adafs_chmod(const char* p, mode_t mode, struct fuse_file_info* fi); int adafs_chown(const char* p, uid_t uid, gid_t gid, struct fuse_file_info* fi); // file system miscellaneous Loading
fs/src/fuse_ops/access.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -36,10 +36,18 @@ int adafs_access(const char* p, int mask) { * may also be NULL if the file is open. */ int adafs_chmod(const char* p, mode_t mode, struct fuse_file_info* fi) { ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_chmod() enter: name '{}' mode {}", p, mode); ADAFS_DATA->logger->info("##### FUSE FUNC ###### adafs_chmod() enter: name '{}' mode {:o}", p, mode); auto path = bfs::path(p); auto md = make_shared<Metadata>(); auto err = get_metadata(*md, path); if (err) return err; return 0; // for chmod only the uid matters AFAIK err = chk_uid(*md); if (err) return err; return chmod(*md, mode, path); } /** Change the owner and group of a file Loading
fs/src/fuse_ops/io.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -88,8 +88,9 @@ int adafs_write(const char* p, const char* buf, size_t size, off_t offset, struc write_metadata_field(md->size(), path_hash, md_field_map.at(Md_fields::size)); #ifdef ACMtime md->update_ACM_time(true, false, true); md->update_ACM_time(true, true, true); write_metadata_field(md->atime(), path_hash, md_field_map.at(Md_fields::atime)); write_metadata_field(md->ctime(), path_hash, md_field_map.at(Md_fields::ctime)); write_metadata_field(md->mtime(), path_hash, md_field_map.at(Md_fields::mtime)); #endif Loading