]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: some authmon fixes
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 18 Sep 2009 17:08:25 +0000 (10:08 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 18 Sep 2009 17:08:25 +0000 (10:08 -0700)
src/auth/Auth.h
src/authtool.cc
src/mon/AuthMonitor.cc

index 660c6ac40a8ed866fc951b5b505c6ef0109f5703..c1253fabae42d157148608b62ee920746ef5d7fb 100644 (file)
@@ -96,7 +96,7 @@ struct EntityName {
       return false;
     }
 
-    name = s.substr(pos);
+    name = s.substr(pos + 1);
 
     return true;
   }
index ab7592b00dc48c6ea93980f7fbd2b92f8bb7abc8..7165ba8ad852617a5fc34e55a2c9db72ecd0c287 100644 (file)
@@ -25,9 +25,6 @@ void usage()
   exit(1);
 }
 
-
-
-
 int main(int argc, const char **argv)
 {
   vector<const char*> args;
index 19325199f9403da2ca2520c7bc2c70f609761d92..2bdc6fdda86e1fe65d4a06d76b1bcae6a98af75e 100644 (file)
@@ -287,11 +287,22 @@ bool AuthMonitor::prepare_command(MMonCommand *m)
       string entity_name = m->cmd[2];
 
       AuthLibEntry entry;
-      entry.name.from_str(entity_name);
+      if (!entry.name.from_str(entity_name)) {
+        ss << "bad entity name";
+        rs = -EINVAL;
+        goto done;
+      }
 
       bufferlist bl = m->get_data();
+      dout(0) << "AuthMonitor::prepare_command bl.length()=" << bl.length() << dendl;
       bufferlist::iterator iter = bl.begin();
-      ::decode(entry.secret, iter);
+      try {
+        ::decode(entry.secret, iter);
+      } catch (buffer::error *err) {
+        ss << "error decoding key";
+        rs = -EINVAL;
+        goto done;
+      }
 
       AuthLibIncremental inc;
       dout(0) << "storing auth for " << entity_name  << dendl;
@@ -303,7 +314,7 @@ bool AuthMonitor::prepare_command(MMonCommand *m)
       getline(ss, rs);
       paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
       return true;
-    } else if (m->cmd[1] == "del" && m->cmd.size() >= 5) {
+    } else if (m->cmd[1] == "del" && m->cmd.size() >= 3) {
       string name = m->cmd[2];
       AuthLibEntry entry;
       entry.name.from_str(name);