From: Greg Farnum Date: Sat, 30 Jul 2016 00:59:28 +0000 (-0700) Subject: client: pass UserPerm to chdir() and getcwd() X-Git-Tag: v11.0.1~36^2~56 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ba678199de535dbf9555922d38952d5043db1185;p=ceph.git client: pass UserPerm to chdir() and getcwd() Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 3d658ebdee8..35250d608ce 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8815,25 +8815,26 @@ int Client::fstat(int fd, struct stat *stbuf, const UserPerm& perms, int mask) // not written yet, but i want to link! -int Client::chdir(const char *relpath, std::string &new_cwd) +int Client::chdir(const char *relpath, std::string &new_cwd, + const UserPerm& perms) { Mutex::Locker lock(client_lock); tout(cct) << "chdir" << std::endl; tout(cct) << relpath << std::endl; filepath path(relpath); InodeRef in; - int r = path_walk(path, &in); + int r = path_walk(path, &in, perms); if (r < 0) return r; if (cwd != in) cwd.swap(in); ldout(cct, 3) << "chdir(" << relpath << ") cwd now " << cwd->ino << dendl; - getcwd(new_cwd); + getcwd(new_cwd, perms); return 0; } -void Client::getcwd(string& dir) +void Client::getcwd(string& dir, const UserPerm& perms) { filepath path; ldout(cct, 10) << "getcwd " << *cwd << dendl; @@ -8857,7 +8858,6 @@ void Client::getcwd(string& dir) filepath path(in->ino); req->set_filepath(path); req->set_inode(in); - UserPerm perms(get_uid(), get_gid()); // FIXME int res = make_request(req, perms); if (res < 0) break; diff --git a/src/client/Client.h b/src/client/Client.h index eb0d2a2b37b..0bdd6bc3142 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1039,8 +1039,8 @@ public: int statfs(const char *path, struct statvfs *stbuf); // crap - int chdir(const char *s, std::string &new_cwd); - void getcwd(std::string& cwd); + int chdir(const char *s, std::string &new_cwd, const UserPerm& perms); + void getcwd(std::string& cwd, const UserPerm& perms); // namespace ops int opendir(const char *name, dir_result_t **dirpp, const UserPerm& perms); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index e2c7ac6754b..17623d4cecd 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1214,7 +1214,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) // Client users should remember their path, but since this // is just a synthetic client we ignore it. std::string ignore; - client->chdir(a, ignore); + client->chdir(a, ignore, perms); } else if (strcmp(op, "statfs") == 0) { struct statvfs stbuf; client->statfs("/", &stbuf); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 1b96861ebf2..6c6bca40a6c 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -225,15 +225,15 @@ public: return client; } - const char *get_cwd() + const char *get_cwd(const UserPerm& perms) { - client->getcwd(cwd); + client->getcwd(cwd, perms); return cwd.c_str(); } - int chdir(const char *to) + int chdir(const char *to, const UserPerm& perms) { - return client->chdir(to, cwd); + return client->chdir(to, cwd, perms); } CephContext *get_ceph_context() const { @@ -453,14 +453,16 @@ extern "C" int ceph_get_local_osd(struct ceph_mount_info *cmount) extern "C" const char* ceph_getcwd(struct ceph_mount_info *cmount) { - return cmount->get_cwd(); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_cwd(perms); } extern "C" int ceph_chdir (struct ceph_mount_info *cmount, const char *s) { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->chdir(s); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->chdir(s, perms); } extern "C" int ceph_opendir(struct ceph_mount_info *cmount,