From 085ff62c467fcf93732ea09056bdfa4eec938a47 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 22 Oct 2009 11:18:14 -0700 Subject: [PATCH] authtool: print key, too --- src/auth/Crypto.cc | 9 +++++++++ src/auth/Crypto.h | 9 +++++++++ src/authtool.cc | 1 + 3 files changed, 19 insertions(+) diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index bd5a7fc27ea3a..92e8ac46e965e 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -18,6 +18,7 @@ #include "include/ceph_fs.h" #include "config.h" +#include "common/armor.h" #include @@ -284,3 +285,11 @@ int CryptoKey::decrypt(const bufferlist& in, bufferlist& out) return -EOPNOTSUPP; return h->decrypt(this->secret, in, 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; +} diff --git a/src/auth/Crypto.h b/src/auth/Crypto.h index 2cc6d6fef969a..4991461de5b26 100644 --- a/src/auth/Crypto.h +++ b/src/auth/Crypto.h @@ -45,6 +45,9 @@ public: secret.c_str(); // make sure it's a single buffer! } + utime_t get_created() const { return created; } + void print(ostream& out) const; + int set_secret(int type, bufferptr& s); bufferptr& get_secret() { return secret; } @@ -55,6 +58,12 @@ public: }; WRITE_CLASS_ENCODER(CryptoKey); +static inline ostream& operator<<(ostream& out, const CryptoKey& k) +{ + k.print(out); + return out << " (" << k.get_created() << ")"; +} + /* * Driver for a particular algorithm diff --git a/src/authtool.cc b/src/authtool.cc index 5c565e4861432..b37b8579dee44 100644 --- a/src/authtool.cc +++ b/src/authtool.cc @@ -102,6 +102,7 @@ int main(int argc, const char **argv) } else { cout << n << std::endl; } + cout << "\tkey " << iter->second.key << std::endl; map::iterator capsiter = iter->second.caps.begin(); for (; capsiter != iter->second.caps.end(); ++capsiter) { bufferlist::iterator dataiter = capsiter->second.begin(); -- 2.39.5