~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/mon/AuthMonitor.cc

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#define dout_prefix _prefix(mon, paxos->get_version())
40
40
static ostream& _prefix(Monitor *mon, version_t v) {
41
41
  return *_dout << dbeginl
42
 
                << "mon" << mon->whoami
 
42
                << "mon." << mon->name << "@" << mon->rank
43
43
                << (mon->is_starting() ? (const char*)"(starting)":(mon->is_leader() ? (const char*)"(leader)":(mon->is_peon() ? (const char*)"(peon)":(const char*)"(?\?)")))
44
44
                << ".auth v" << v << " ";
45
45
}
57
57
  rot_inc.op = KeyServerData::AUTH_INC_SET_ROTATING;
58
58
  if (!mon->key_server.updated_rotating(rot_inc.rotating_bl, last_rotating_ver))
59
59
    return;
60
 
  dout(0) << "AuthMonitor::tick() updated rotating, now calling propose_pending" << dendl;
 
60
  dout(10) << "AuthMonitor::tick() updated rotating, now calling propose_pending" << dendl;
61
61
  push_cephx_inc(rot_inc);
62
62
  propose_pending();
63
63
}
80
80
 
81
81
void AuthMonitor::on_active()
82
82
{
83
 
  dout(0) << "AuthMonitor::on_active()" << dendl;
 
83
  dout(10) << "AuthMonitor::on_active()" << dendl;
84
84
 
85
85
  if (!mon->is_leader())
86
86
    return;
92
92
 
93
93
void AuthMonitor::create_initial(bufferlist& bl)
94
94
{
95
 
  dout(0) << "create_initial -- creating initial map" << dendl;
 
95
  dout(10) << "create_initial -- creating initial map" << dendl;
96
96
  if (g_conf.keyring) {
97
 
    dout(0) << "reading initial keyring " << dendl;
 
97
    dout(10) << "reading initial keyring " << dendl;
98
98
    bufferlist bl;
99
99
 
100
100
    string k = g_conf.keyring;
111
111
        bufferlist::iterator iter = bl.begin();
112
112
        ::decode(keyring, iter);
113
113
        read_ok = true;
114
 
      } catch (buffer::error *err) {
 
114
      } catch (const buffer::error &err) {
115
115
        cerr << "error reading file " << g_conf.keyring << std::endl;
116
116
      }
117
117
      if (read_ok)
129
129
 
130
130
bool AuthMonitor::update_from_paxos()
131
131
{
132
 
  dout(0) << "AuthMonitor::update_from_paxos()" << dendl;
 
132
  dout(10) << "AuthMonitor::update_from_paxos()" << dendl;
133
133
  version_t paxosv = paxos->get_version();
134
134
  version_t keys_ver = mon->key_server.get_ver();
135
135
  if (paxosv == keys_ver) return true;
203
203
  assert(mon->is_leader());
204
204
 
205
205
  max_global_id += g_conf.mon_globalid_prealloc;
206
 
  dout(0) << "increasing max_global_id to " << max_global_id << dendl;
 
206
  dout(10) << "increasing max_global_id to " << max_global_id << dendl;
207
207
  Incremental inc;
208
208
  inc.inc_type = GLOBAL_ID;
209
209
  inc.max_global_id = max_global_id;
220
220
  version_t paxosv = paxos->get_version();
221
221
  version_t keys_ver = mon->key_server.get_ver();
222
222
 
223
 
  dout(0) << "AuthMonitor::init() paxosv=" << paxosv << dendl;
 
223
  dout(10) << "AuthMonitor::init() paxosv=" << paxosv << dendl;
224
224
 
225
225
  if (paxosv == keys_ver) return;
226
226
  assert(paxosv >= keys_ver);
230
230
    bufferlist latest;
231
231
    version_t v = paxos->get_latest(latest);
232
232
    if (v) {
233
 
      dout(0) << "AuthMonitor::init() startup: loading summary e" << v << dendl;
 
233
      dout(10) << "AuthMonitor::init() startup: loading summary e" << v << dendl;
234
234
      bufferlist::iterator p = latest.begin();
235
235
      __u8 v;
236
236
      ::decode(v, p);
264
264
 
265
265
bool AuthMonitor::preprocess_query(PaxosServiceMessage *m)
266
266
{
267
 
  dout(0) << "preprocess_query " << *m << " from " << m->get_orig_source_inst() << dendl;
 
267
  dout(10) << "preprocess_query " << *m << " from " << m->get_orig_source_inst() << dendl;
268
268
  switch (m->get_type()) {
269
269
  case MSG_MON_COMMAND:
270
270
    return preprocess_command((MMonCommand*)m);
313
313
uint64_t AuthMonitor::assign_global_id(MAuth *m, bool should_increase_max)
314
314
{
315
315
  int total_mon = mon->monmap->size();
316
 
  dout(10) << "AuthMonitor::assign_global_id m=" << *m << " mon=" << mon->whoami << "/" << total_mon
 
316
  dout(10) << "AuthMonitor::assign_global_id m=" << *m << " mon=" << mon->rank << "/" << total_mon
317
317
           << " last_allocated=" << last_allocated_id << " max_global_id=" <<  max_global_id << dendl;
318
318
 
319
319
  uint64_t next_global_id = last_allocated_id + 1;
322
322
    int remainder = next_global_id % total_mon;
323
323
    if (remainder)
324
324
      remainder = total_mon - remainder;
325
 
    next_global_id += remainder + mon->whoami;
 
325
    next_global_id += remainder + mon->rank;
326
326
    dout(10) << "next_global_id should be " << next_global_id << dendl;
327
327
  }
328
328
 
352
352
 
353
353
bool AuthMonitor::prep_auth(MAuth *m, bool paxos_writable)
354
354
{
355
 
  dout(0) << "prep_auth() blob_size=" << m->get_auth_payload().length() << dendl;
 
355
  dout(10) << "prep_auth() blob_size=" << m->get_auth_payload().length() << dendl;
356
356
 
357
357
  MonSession *s = (MonSession *)m->get_connection()->get_priv();
358
358
  if (!s) {
380
380
      ::decode(supported, indata);
381
381
      ::decode(entity_name, indata);
382
382
      ::decode(s->global_id, indata);
383
 
    } catch (buffer::error *e) {
384
 
      dout(0) << "failed to decode initial auth message" << dendl;
 
383
    } catch (const buffer::error &e) {
 
384
      dout(10) << "failed to decode initial auth message" << dendl;
385
385
      ret = -EINVAL;
386
386
      goto reply;
387
387
    }
393
393
    }
394
394
    start = true;
395
395
  } else if (!s->auth_handler) {
396
 
      dout(0) << "protocol specified but no s->auth_handler" << dendl;
 
396
      dout(10) << "protocol specified but no s->auth_handler" << dendl;
397
397
      ret = -EINVAL;
398
398
      goto reply;
399
399
  }
436
436
      s->caps.parse(iter);
437
437
      s->caps.set_auid(auid);
438
438
    }
439
 
  } catch (buffer::error *err) {
 
439
  } catch (const buffer::error &err) {
440
440
    ret = -EINVAL;
441
441
    dout(0) << "caught error when trying to handle auth request, probably malformed request" << dendl;
442
442
  }
443
443
 
444
444
reply:
445
445
  reply = new MAuthReply(proto, &response_bl, ret, s->global_id);
446
 
  mon->messenger->send_message(reply, m->get_orig_source_inst());
 
446
  mon->send_reply(m, reply);
447
447
  m->put();
448
448
done:
449
449
  s->put();
562
562
      KeyRing keyring;
563
563
      try {
564
564
        ::decode(keyring, iter);
565
 
      } catch (buffer::error *err) {
 
565
      } catch (const buffer::error &err) {
566
566
        ss << "error decoding keyring";
567
567
        rs = -EINVAL;
568
568
        goto done;
584
584
      }
585
585
 
586
586
      bufferlist bl = m->get_data();
587
 
      dout(0) << "AuthMonitor::prepare_command bl.length()=" << bl.length() << dendl;
 
587
      dout(10) << "AuthMonitor::prepare_command bl.length()=" << bl.length() << dendl;
588
588
      bufferlist::iterator iter = bl.begin();
589
589
      KeyRing keyring;
590
590
      try {
591
591
        ::decode(keyring, iter);
592
 
      } catch (buffer::error *err) {
 
592
      } catch (const buffer::error &err) {
593
593
        ss << "error decoding keyring";
594
594
        rs = -EINVAL;
595
595
        goto done;