]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: pass UserPerm to chdir() and getcwd()
authorGreg Farnum <gfarnum@redhat.com>
Sat, 30 Jul 2016 00:59:28 +0000 (17:59 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:50 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/libcephfs.cc

index 3d658ebdee8659ba82a73a8365e4183f150d4294..35250d608cef37135b9df33dfab45fd17ed3f901 100644 (file)
@@ -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;
index eb0d2a2b37be93dab3ad0153c83fcfdf96d85515..0bdd6bc3142603605cb7705b3794c6f3470d3e6a 100644 (file)
@@ -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);
index e2c7ac6754b1b0ab2dfaf7541349385663edee96..17623d4cecd3a8074daa2f122c469b84ede471c7 100644 (file)
@@ -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);
index 1b96861ebf217f140c61625ed69e70285d584676..6c6bca40a6cd3dd2315d666a41c16af29120f3f8 100644 (file)
@@ -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,