Skip to content

Commit

Permalink
Merge pull request ceph#23304 from smithfarm/wip-23776
Browse files Browse the repository at this point in the history
 tools: ceph-authtool: report correct number of caps when creating keyring

Reviewed-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo authored Oct 18, 2018
2 parents bdd7114 + aef4fc8 commit f9d66bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/auth/Auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct EntityAuth {
WRITE_CLASS_ENCODER(EntityAuth)

static inline ostream& operator<<(ostream& out, const EntityAuth& a) {
return out << "auth(key=" << a.key << " with " << a.caps.size() << " caps)";
return out << "auth(key=" << a.key << ")";
}

struct AuthCapsInfo {
Expand Down
9 changes: 8 additions & 1 deletion src/test/cli/ceph-authtool/add-key.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creating kring

$ ceph-authtool kring --add-key 'AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ== 18446744073709551615'
added entity client.admin auth auth(key=AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ== with 0 caps)
added entity client.admin auth(key=AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ==)

# cram makes matching escape-containing lines with regexps a bit ugly
$ ceph-authtool kring --list
Expand All @@ -18,3 +18,10 @@ Test --add-key with empty argument
$ ceph-authtool kring -C --name=mon.* --add-key= --cap mon 'allow *'
Option --add-key requires an argument
[1]

$ ceph-authtool test.keyring --create-keyring --mode 0644
creating test.keyring

$ ceph-authtool test.keyring --name client.test --cap osd 'allow rwx' --cap mon 'allow r' --add-key 'AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ== 18446744073709551615'
added entity client.test auth(key=AQAK7yxNeF+nHBAA0SgSdbs8IkJrxroDeJ6SwQ==)
added 2 caps to entity client.test
7 changes: 6 additions & 1 deletion src/tools/ceph_authtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ int main(int argc, const char **argv)

// keyring --------
bool modified = false;
bool added_entity = false;
KeyRing keyring;

bufferlist bl;
Expand Down Expand Up @@ -248,7 +249,8 @@ int main(int argc, const char **argv)
}
keyring.add(ename, eauth);
modified = true;
cout << "added entity " << ename << " auth " << eauth << std::endl;
cout << "added entity " << ename << " " << eauth << std::endl;
added_entity = true;
}
if (!caps_fn.empty()) {
ConfFile cf;
Expand Down Expand Up @@ -276,6 +278,9 @@ int main(int argc, const char **argv)
keyring.set_caps(ename, caps);
modified = true;
}
if (added_entity && caps.size() > 0) {
cout << "added " << caps.size() << " caps to entity " << ename << std::endl;
}

// read commands
if (list) {
Expand Down

0 comments on commit f9d66bb

Please sign in to comment.