]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: return of RGWFileHandle::FLAG_EXACT_MATCH 13607/head
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 23 Feb 2017 15:21:38 +0000 (10:21 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 23 Feb 2017 15:55:51 +0000 (10:55 -0500)
Allow callers of rgw_lookup() on objects attested in an
rgw_readdir() callback the ability to bypass exact match in
RGWLibFS::stat_leaf() case 2, but restore exact match enforcement
for general lookups.

This preserves required common_prefix namespace behavior, but
prevents clients from eerily permitting things like "cd sara0" via
partial name match on "sara01."

Fixes: http://tracker.ceph.com/issues/19059
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/include/rados/rgw_file.h
src/rgw/rgw_file.cc

index dfa1ede18c93facb69f01a425dcee75a7c4cd330..01551001e8754f2de48fd7e817287d7db5e595d7 100644 (file)
@@ -27,7 +27,7 @@ extern "C" {
 
 #define LIBRGW_FILE_VER_MAJOR 1
 #define LIBRGW_FILE_VER_MINOR 1
-#define LIBRGW_FILE_VER_EXTRA 1
+#define LIBRGW_FILE_VER_EXTRA 2
 
 #define LIBRGW_FILE_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
 #define LIBRGW_FILE_VERSION_CODE LIBRGW_FILE_VERSION(LIBRGW_FILE_VER_MAJOR, LIBRGW_FILE_VER_MINOR, LIBRGW_FILE_VER_EXTRA)
@@ -91,6 +91,7 @@ void rgwfile_version(int *major, int *minor, int *extra);
 */
 #define RGW_LOOKUP_FLAG_NONE    0x0000
 #define RGW_LOOKUP_FLAG_CREATE  0x0001
+#define RGW_LOOKUP_FLAG_RCB     0x0002 /* readdir callback hint */
 
 int rgw_lookup(struct rgw_fs *rgw_fs,
              struct rgw_file_handle *parent_fh, const char *path,
index 1803109ddedb8f1990b06e71b47ad828a950c667..9d5e9f4ab6f8d85844d29c5bf560bb9950d77fb2 100644 (file)
@@ -1388,7 +1388,11 @@ int rgw_lookup(struct rgw_fs *rgw_fs,
        return -ENOENT;
     }
   } else {
-    fhr = fs->stat_leaf(parent, path, RGWFileHandle::FLAG_NONE);
+    /* lookup in a readdir callback */
+    uint32_t sl_flags = (flags & RGW_LOOKUP_FLAG_RCB)
+      ? RGWFileHandle::FLAG_NONE
+      : RGWFileHandle::FLAG_EXACT_MATCH;
+    fhr = fs->stat_leaf(parent, path, sl_flags);
     if (! get<0>(fhr)) {
       if (! (flags & RGW_LOOKUP_FLAG_CREATE))
        return -ENOENT;