]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cauthtool: always print entire encoded CryptoKey
authorSage Weil <sage@newdream.net>
Thu, 22 Apr 2010 18:27:00 +0000 (11:27 -0700)
committerSage Weil <sage@newdream.net>
Thu, 22 Apr 2010 18:27:00 +0000 (11:27 -0700)
Make cauthtool -l output consistent with what you need to feed to
mount.ceph(8).

src/auth/Crypto.cc
src/auth/Crypto.h
src/auth/KeyRing.cc
src/cauthtool.cc

index 522dc82d4f1ed3a02e202deaec8f65361d4f2bda..2f7a3812e302eb5e55bee0e3023470f88a4adf2a 100644 (file)
@@ -286,10 +286,9 @@ int CryptoKey::decrypt(const bufferlist& in, bufferlist& out)
 
 void CryptoKey::print(ostream &out) const
 {
-  char foo[secret.length() * 2];
-  int r = ceph_armor(foo, secret.c_str(), secret.c_str() + secret.length());
-  foo[r] = 0;
-  out << foo;
+  string a;
+  encode_base64(a);
+  out << a;
 }
 
 void CryptoKey::to_str(string& s)
index c801f743b83a66621881c215fcb83316dae63337..28de69da2ffd58791daf640709081175dd48c054 100644 (file)
@@ -45,13 +45,14 @@ public:
     secret.c_str();   // make sure it's a single buffer!
   }
 
+  int get_type() const { return type; }
   utime_t get_created() const { return created; }
   void print(ostream& out) const;
 
   int set_secret(int type, bufferptr& s);
   bufferptr& get_secret() { return secret; }
 
-  void encode_base64(string& s) {
+  void encode_base64(string& s) const {
     bufferlist bl;
     encode(bl);
     bufferlist e;
@@ -80,7 +81,7 @@ WRITE_CLASS_ENCODER(CryptoKey);
 static inline ostream& operator<<(ostream& out, const CryptoKey& k)
 {
   k.print(out);
-  return out << " (" << k.get_created() << ")";
+  return out;
 }
 
 
index f17641908e352d3374f25ccf9b3a1e8e59093f80..fdf15bc9a8f101a17e1f1a8248099aa7cd0cd7bf 100644 (file)
@@ -72,8 +72,8 @@ void KeyRing::print(ostream& out)
        p != keys.end();
        ++p) {
     out << p->first << std::endl;
+    out << "\t key: " << p->second.key << std::endl;
     out << "\tauid: " << p->second.auid << std::endl;
-    out << "\tkey: " << p->second.key << std::endl;
 
     for (map<string, bufferlist>::iterator q = p->second.caps.begin();
         q != p->second.caps.end();
index a7cb92f6eed1fb21949691d60cc3a0755b6fe48a..4b7c86e8fab252a6804995239579fd440b3853f4 100644 (file)
@@ -214,9 +214,7 @@ int main(int argc, const char **argv)
   if (print_key) {
     CryptoKey key;
     if (keyring.get_secret(ename, key)) {
-      string a;
-      key.encode_base64(a);
-      cout << a << std::endl;
+      cout << key << std::endl;
     } else {
       cerr << "entity " << ename << " not found" << std::endl;
     }