}
if (!indata.end())
return false;
-
+
+ has_key_flag = true;
+
return true;
}
::encode(nonce, info);
session_key.encrypt(info, enc_info);
::encode(enc_info, bl);
- return now;
+ return now;
}
/*
CryptoKey session_key;
{
bufferlist bl;
- service_secret.decrypt(enc_ticket, bl);
+ if (service_secret.decrypt(enc_ticket, bl) < 0)
+ return false;
bufferlist::iterator p = bl.begin();
::decode(ticket, p);
::decode(session_key, p);
string nonce;
{
bufferlist info;
- session_key.decrypt(enc_info, info);
+ if (session_key.decrypt(enc_info, info) < 0)
+ return false;
bufferlist::iterator p = info.begin();
::decode(timestamp, p);
::decode(nonce, p);
bufferlist reply;
timestamp += 1;
::encode(timestamp, reply);
- session_key.encrypt(reply, enc_reply);
+ if (session_key.encrypt(reply, enc_reply) < 0)
+ return false;
return true;
}
bool ServiceTicket::verify_reply_authenticator(utime_t then, bufferlist& enc_reply)
{
bufferlist reply;
- session_key.decrypt(enc_reply, reply);
+ if (session_key.decrypt(enc_reply, reply) < 0)
+ return false;
bufferlist::iterator p = reply.begin();
utime_t later;
::decode(later, p);
- if (then + 1 == later)
+ dout(0) << "later=" << later << " then=" << then << dendl;
+ if (then + 1 == later) {
return true;
+ }
+
return false;
}
bufferlist enc_ticket; // opaque to us
string nonce;
utime_t renew_after, expires;
+ bool has_key_flag;
+
+ ServiceTicket() : has_key_flag(false) {}
// to build our ServiceTicket
bool verify_authenticate_reply(CryptoKey& client_secret,
// to access the service
utime_t build_authenticator(bufferlist& bl);
bool verify_reply_authenticator(utime_t then, bufferlist& enc_reply);
+
+ bool has_key() { return has_key_flag; }
};
int AuthClientHandler::generate_request(bufferlist& bl)
{
+ dout(0) << "status=" << status << dendl;
if (status < 0) {
return status;
}
{
CephXRequestHeader header;
- if (!auth_session_key.length()) {
+ if (!auth_ticket.has_key()) {
+ dout(0) << "auth ticket: doesn't have key" << dendl;
/* we first need to get the principle/auth session key */
header.request_type = CEPHX_GET_AUTH_SESSION_KEY;
return 0;
}
- if (!cur_cap) {
- uint32_t left_caps = (want_caps ^ have_caps) & want_caps;
+ dout(0) << "want_keys=" << hex << want_keys << " have_keys=" << have_keys << dec << dendl;
- for (uint32_t i=0; i<sizeof(left_caps)*8; i++) {
- cur_cap = (left_caps & (1 << i));
- if (cur_cap)
- break;
- }
- if (!cur_cap) /* done */
- return 0;
- }
+ if (want_keys == have_keys)
+ return 0;
- ::encode(cur_cap, bl);
+ header.request_type = CEPHX_GET_PRINCIPAL_SESSION_KEY | want_keys;
+
+ ::encode(header, bl);
+
+ auth_ts = auth_ticket.build_authenticator(bl);
return 0;
}
bufferptr p(PRINCIPAL_SECRET, sizeof(PRINCIPAL_SECRET) - 1);
secret.set_secret(CEPH_SECRET_AES, p);
- auth_ticket.verify_authenticate_reply(secret, indata);
+ if (!auth_ticket.verify_authenticate_reply(secret, indata)) {
+ dout(0) << "could not verify authenticate reply" << dendl;
+ return -EPERM;
+ }
+
+ if (want_keys)
+ ret = -EAGAIN;
}
break;
case CEPHX_GET_PRINCIPAL_SESSION_KEY:
- dout(0) << "FIXME: CEPHX_GET_PRINCIPAL_SESSION_KEY" << dendl;
+ dout(0) << "CEPHX_GET_PRINCIPAL_SESSION_KEY" << dendl;
+ {
+ }
break;
case CEPHX_OPEN_SESSION:
#include "messages/MClientMount.h"
#include "messages/MClientMountAck.h"
+#include "auth/AuthProtocol.h"
+
#include "include/librados.h"
#define RADOS_LIST_MAX_ENTRIES 1024
monclient.mount(g_conf.client_mount_timeout);
dout(0) << "librados: before monclient.authorize()" << dendl;
- monclient.authorize(g_conf.client_mount_timeout);
+ monclient.authorize(CEPHX_PRINCIPAL_MON | CEPHX_PRINCIPAL_OSD,
+ g_conf.client_mount_timeout);
lock.Lock();
return unmount_handler.do_op(timeout);
}
-int MonClient::authorize(double mount_timeout)
+int MonClient::authorize(uint32_t want_keys, double mount_timeout)
{
Mutex::Locker l(auth_lock);
int ret;
+ auth_client_handler.set_request_keys(want_keys);
+
do {
MonClientAuthHandler h(this);
int mount(double mount_timeout);
int unmount(double timeout);
- int authorize(double timeout);
+ int authorize(uint32_t want_keys, double timeout);
void send_mon_message(Message *m, bool new_mon=false);
void note_mon_leader(int m) {