Created symlinks take ownership from the current user

This commit is contained in:
Sebastian Meßmer 2015-04-23 09:17:23 +02:00
parent 446c07deff
commit 4a1166cfd2
6 changed files with 9 additions and 8 deletions

View File

@ -28,7 +28,7 @@ public:
virtual std::unique_ptr<OpenFile> createAndOpenFile(const std::string &name, mode_t mode, uid_t uid, gid_t gid) = 0;
virtual void createDir(const std::string &name, mode_t mode, uid_t uid, gid_t gid) = 0;
virtual void createSymlink(const std::string &name, const boost::filesystem::path &target) = 0;
virtual void createSymlink(const std::string &name, const boost::filesystem::path &target, uid_t uid, gid_t gid) = 0;
//TODO Allow alternative implementation returning only children names without more information
//virtual std::unique_ptr<std::vector<std::string>> children() const = 0;

View File

@ -13,7 +13,7 @@ class Symlink: public virtual Node {
public:
virtual ~Symlink() {}
virtual boost::filesystem::path target() = 0;
virtual boost::filesystem::path target() const = 0;
};
}

View File

@ -37,7 +37,7 @@ public:
virtual void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) = 0;
//TODO We shouldn't use Dir::Entry here, that's in another layer
virtual std::unique_ptr<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) = 0;
virtual void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from) = 0;
virtual void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) = 0;
virtual void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) = 0;
};

View File

@ -299,7 +299,8 @@ int Fuse::rmdir(const bf::path &path) {
int Fuse::symlink(const bf::path &from, const bf::path &to) {
//printf("symlink(%s, %s)\n", from.c_str(), to.c_str());
try {
_fs->createSymlink(from, to);
auto context = fuse_get_context();
_fs->createSymlink(from, to, context->uid, context->gid);
return 0;
} catch(fspp::fuse::FuseErrnoException &e) {
return -e.getErrno();

View File

@ -159,9 +159,9 @@ void FilesystemImpl::statfs(const bf::path &path, struct statvfs *fsstat) {
_device->statfs(path, fsstat);
}
void FilesystemImpl::createSymlink(const bf::path &to, const bf::path &from) {
void FilesystemImpl::createSymlink(const bf::path &to, const bf::path &from, uid_t uid, gid_t gid) {
auto parent = LoadDir(from.parent_path());
parent->createSymlink(from.filename().native(), to);
parent->createSymlink(from.filename().native(), to, uid, gid);
}
void FilesystemImpl::readSymlink(const bf::path &path, char *buf, size_t size) {

View File

@ -40,8 +40,8 @@ public:
std::unique_ptr<std::vector<Dir::Entry>> readDir(const boost::filesystem::path &path) override;
void utimens(const boost::filesystem::path &path, const timespec times[2]) override;
void statfs(const boost::filesystem::path &path, struct statvfs *fsstat) override;
void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from) override;
void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) override;
void createSymlink(const boost::filesystem::path &to, const boost::filesystem::path &from, uid_t uid, gid_t gid) override;
void readSymlink(const boost::filesystem::path &path, char *buf, size_t size) override;
private:
std::unique_ptr<File> LoadFile(const boost::filesystem::path &path);