Skip to content

Commit

Permalink
rgw_file: return of RGWFileHandle::FLAG_EXACT_MATCH
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mattbenjamin committed Feb 23, 2017
1 parent dea8d1e commit c26190d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/include/rados/rgw_file.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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

int rgw_lookup(struct rgw_fs *rgw_fs,
struct rgw_file_handle *parent_fh, const char *path,
Expand Down
6 changes: 5 additions & 1 deletion src/rgw/rgw_file.cc
Expand Up @@ -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;
Expand Down

0 comments on commit c26190d

Please sign in to comment.