From a921882e7c676d68ed67b54301b49fd9bed42945 Mon Sep 17 00:00:00 2001 From: Brad Hubbard Date: Mon, 29 May 2017 19:25:43 +1000 Subject: [PATCH] osd: Reverse order of op_has_sufficient_caps and do_pg_op Fixes: http://tracker.ceph.com/issues/19790 Signed-off-by: Brad Hubbard --- .../singleton-nomsgr/all/pool-access.yaml | 9 ++++++++ qa/workunits/rados/test_pool_access.sh | 23 +++++++++++++++++++ src/osd/PrimaryLogPG.cc | 8 +++---- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 qa/suites/rados/singleton-nomsgr/all/pool-access.yaml create mode 100755 qa/workunits/rados/test_pool_access.sh diff --git a/qa/suites/rados/singleton-nomsgr/all/pool-access.yaml b/qa/suites/rados/singleton-nomsgr/all/pool-access.yaml new file mode 100644 index 00000000000..d49a5979704 --- /dev/null +++ b/qa/suites/rados/singleton-nomsgr/all/pool-access.yaml @@ -0,0 +1,9 @@ +roles: +- [mon.a, mgr.x, osd.0, osd.1, client.0] +tasks: +- install: +- ceph: +- workunit: + clients: + all: + - rados/test_pool_access.sh diff --git a/qa/workunits/rados/test_pool_access.sh b/qa/workunits/rados/test_pool_access.sh new file mode 100755 index 00000000000..8597b7147c8 --- /dev/null +++ b/qa/workunits/rados/test_pool_access.sh @@ -0,0 +1,23 @@ +#!/bin/bash -x + +set -e + +expect_1() +{ + set -x + set +e + "$@" + if [ $? == 1 ]; then return 0; else return 1; fi +} + + +key=`ceph auth get-or-create-key client.poolaccess1 mon 'allow r' osd 'allow *'` +rados --id poolaccess1 --key $key -p rbd ls + +key=`ceph auth get-or-create-key client.poolaccess2 mon 'allow r' osd 'allow * pool=nopool'` +expect_1 rados --id poolaccess2 --key $key -p rbd ls + +key=`ceph auth get-or-create-key client.poolaccess3 mon 'allow r' osd 'allow rw pool=nopool'` +expect_1 rados --id poolaccess3 --key $key -p rbd ls + +echo OK diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 3f5adc1f33d..b50624963a5 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1877,15 +1877,15 @@ void PrimaryLogPG::do_op(OpRequestRef& op) } } - if (op->includes_pg_op()) { - return do_pg_op(op); - } - if (!op_has_sufficient_caps(op)) { osd->reply_op_error(op, -EPERM); return; } + if (op->includes_pg_op()) { + return do_pg_op(op); + } + // object name too long? if (m->get_oid().name.size() > cct->_conf->osd_max_object_name_len) { dout(4) << "do_op name is longer than "