template<ceph::LockPolicy lp>
-AuthClientHandler<lp>*
-AuthClientHandler<lp>::create(CephContext *cct, int proto,
- RotatingKeyRing<lp> *rkeys)
+AuthClientHandler*
+AuthClientHandler::create(CephContext *cct, int proto,
+ RotatingKeyRing<lp> *rkeys)
{
switch (proto) {
case CEPH_AUTH_CEPHX:
return new CephxClientHandler<lp>(cct, rkeys);
case CEPH_AUTH_NONE:
- return new AuthNoneClientHandler<lp>(cct, rkeys);
+ return new AuthNoneClientHandler{cct};
default:
return NULL;
}
}
// explicitly instantiate only the classes we need
-template class AuthClientHandler<ceph::LockPolicy::MUTEX>;
+template AuthClientHandler*
+AuthClientHandler::create<ceph::LockPolicy::MUTEX>(
+ CephContext *cct,
+ int proto,
+ RotatingKeyRing<ceph::LockPolicy::MUTEX> *rkeys);
#include "auth/Auth.h"
#include "common/lock_policy.h"
-#include "common/lock_shared_mutex.h"
class CephContext;
struct MAuthReply;
template<ceph::LockPolicy> class RotatingKeyRing;
-template<ceph::LockPolicy lock_policy>
class AuthClientHandler {
protected:
CephContext *cct;
uint32_t want;
uint32_t have;
uint32_t need;
- mutable SharedMutexT<lock_policy> lock;
public:
explicit AuthClientHandler(CephContext *cct_)
- : cct(cct_), global_id(0), want(CEPH_ENTITY_TYPE_AUTH), have(0), need(0),
- lock{SharedMutex<lock_policy>::create("AuthClientHandler::lock")}
+ : cct(cct_), global_id(0), want(CEPH_ENTITY_TYPE_AUTH), have(0), need(0)
{}
virtual ~AuthClientHandler() {}
void init(const EntityName& n) { name = n; }
void set_want_keys(__u32 keys) {
- std::unique_lock l{lock};
want = keys | CEPH_ENTITY_TYPE_AUTH;
validate_tickets();
}
virtual void set_global_id(uint64_t id) = 0;
- static AuthClientHandler<lock_policy>*
+ template<ceph::LockPolicy lock_policy>
+ static AuthClientHandler*
create(CephContext *cct, int proto, RotatingKeyRing<lock_policy> *rkeys);
protected:
virtual void validate_tickets() = 0;
{
ldout(cct, 10) << "build_request" << dendl;
- std::shared_lock l{lock};
-
if (need & CEPH_ENTITY_TYPE_AUTH) {
/* authenticate */
CephXRequestHeader header;
int CephxClientHandler<lp>::handle_response(int ret, bufferlist::const_iterator& indata)
{
ldout(cct, 10) << "handle_response ret = " << ret << dendl;
- std::unique_lock l{lock};
if (ret < 0)
return ret; // hrm!
template<LockPolicy lp>
AuthAuthorizer *CephxClientHandler<lp>::build_authorizer(uint32_t service_id) const
{
- std::shared_lock l{lock};
ldout(cct, 10) << "build_authorizer for service " << ceph_entity_type_name(service_id) << dendl;
return tickets.build_authorizer(service_id);
}
template<LockPolicy lp>
void CephxClientHandler<lp>::prepare_build_request()
{
- std::unique_lock l{lock};
ldout(cct, 10) << "validate_tickets: want=" << want << " need=" << need
<< " have=" << have << dendl;
validate_tickets();
template<LockPolicy lp>
bool CephxClientHandler<lp>::need_tickets()
{
- std::unique_lock l{lock};
validate_tickets();
ldout(cct, 20) << "need_tickets: want=" << want
class KeyRing;
template<LockPolicy lock_policy>
-class CephxClientHandler : public AuthClientHandler<lock_policy> {
+class CephxClientHandler : public AuthClientHandler {
bool starting;
/* envelope protocol parameters */
RotatingKeyRing<lock_policy> *rotating_secrets;
KeyRing *keyring;
- using AuthClientHandler<lock_policy>::cct;
- using AuthClientHandler<lock_policy>::global_id;
- using AuthClientHandler<lock_policy>::want;
- using AuthClientHandler<lock_policy>::have;
- using AuthClientHandler<lock_policy>::need;
- using AuthClientHandler<lock_policy>::lock;
-
public:
CephxClientHandler(CephContext *cct_,
RotatingKeyRing<lock_policy> *rsecrets)
- : AuthClientHandler<lock_policy>(cct_),
+ : AuthClientHandler(cct_),
starting(false),
server_challenge(0),
tickets(cct_),
}
void reset() override {
- std::unique_lock l{lock};
starting = true;
server_challenge = 0;
}
bool need_tickets() override;
void set_global_id(uint64_t id) override {
- std::unique_lock l{lock};
global_id = id;
tickets.global_id = id;
}
#include "common/ceph_context.h"
#include "common/config.h"
-template<LockPolicy lock_policy>
-class AuthNoneClientHandler : public AuthClientHandler<lock_policy> {
- using AuthClientHandler<lock_policy>::cct;
- using AuthClientHandler<lock_policy>::global_id;
- using AuthClientHandler<lock_policy>::lock;
+class AuthNoneClientHandler : public AuthClientHandler {
public:
- AuthNoneClientHandler(CephContext *cct_,
- RotatingKeyRing<lock_policy> *rkeys)
- : AuthClientHandler<lock_policy>(cct_) {}
+ AuthNoneClientHandler(CephContext *cct_)
+ : AuthClientHandler(cct_) {}
void reset() override { }
int get_protocol() const override { return CEPH_AUTH_NONE; }
AuthAuthorizer *build_authorizer(uint32_t service_id) const override {
- std::shared_lock l{lock};
AuthNoneAuthorizer *auth = new AuthNoneAuthorizer();
if (auth) {
auth->build_authorizer(cct->_conf->name, global_id);
bool need_tickets() override { return false; }
void set_global_id(uint64_t id) override {
- std::unique_lock l{lock};
global_id = id;
}
private:
}
auth.reset(
- AuthClientHandler<LockPolicy::MUTEX>::create(cct,m->protocol, keyring));
+ AuthClientHandler::create(cct,m->protocol, keyring));
if (!auth) {
ldout(cct, 10) << "no handler for protocol " << m->protocol << dendl;
if (m->result == -ENOTSUP) {
class LogClient;
class AuthAuthorizer;
class AuthMethodList;
-template<LockPolicy> class AuthClientHandler;
+class AuthClientHandler;
class KeyRing;
template<LockPolicy> class RotatingKeyRing;
ConnectionRef get_con() {
return con;
}
- std::unique_ptr<AuthClientHandler<LockPolicy::MUTEX>>& get_auth() {
+ std::unique_ptr<AuthClientHandler>& get_auth() {
return auth;
}
State state = State::NONE;
ConnectionRef con;
- std::unique_ptr<AuthClientHandler<LockPolicy::MUTEX>> auth;
+ std::unique_ptr<AuthClientHandler> auth;
uint64_t global_id;
};
bool got_config = false;
// authenticate
- std::unique_ptr<AuthClientHandler<LockPolicy::MUTEX>> auth;
+ std::unique_ptr<AuthClientHandler> auth;
uint32_t want_keys = 0;
uint64_t global_id = 0;
Cond auth_cond;
if (!auth_cluster_required.is_supported_auth(CEPH_AUTH_CEPHX)) {
// auth_none
dout(20) << __func__ << " building auth_none authorizer" << dendl;
- AuthNoneClientHandler<LockPolicy::MUTEX> handler(g_ceph_context, nullptr);
+ AuthNoneClientHandler handler{g_ceph_context};
handler.set_global_id(0);
*authorizer = handler.build_authorizer(service_id);
return true;