Skip to content

Commit

Permalink
cauthtool: set auid in data member format instead of as (ignored) tex…
Browse files Browse the repository at this point in the history
…t key
  • Loading branch information
Greg Farnum committed Mar 5, 2010
1 parent 6d6eba3 commit 4020dd1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/cauthtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace std;

void usage()
{
cout << " usage: [--create-keyring] [--gen-key] [--name=<name>] [--caps=<filename>] [--list] [--print-key] <filename>" << std::endl;
cout << " usage: [--create-keyring] [--gen-key] [--name=<name>] [--set-uid=uid] [--caps=<filename>] [--list] [--print-key] <filename>" << std::endl;
exit(1);
}

Expand All @@ -47,6 +47,8 @@ int main(int argc, const char **argv)
const char *name = "";
const char *caps_fn = NULL;
const char *import_keyring = NULL;
bool set_auid = false;
__u64 auid = CEPH_AUTH_UID_DEFAULT;

FOR_EACH_ARG(args) {
if (CONF_ARG_EQ("gen-key", 'g')) {
Expand All @@ -65,6 +67,9 @@ int main(int argc, const char **argv)
CONF_SAFE_SET_ARG_VAL(&create_keyring, OPT_BOOL);
} else if (CONF_ARG_EQ("import-keyring", '\0')) {
CONF_SAFE_SET_ARG_VAL(&import_keyring, OPT_STR);
} else if (CONF_ARG_EQ("set-uid", 'u')) {
CONF_SAFE_SET_ARG_VAL(&auid, OPT_LONGLONG);
set_auid = true;
} else if (!fn) {
fn = args[i];
} else
Expand Down Expand Up @@ -157,7 +162,7 @@ int main(int argc, const char **argv)
}
if (add_key) {
if (!name) {
cerr << "must speicfy a name to add a key" << std::endl;
cerr << "must specify a name to add a key" << std::endl;
exit(1);
}
EntityAuth eauth;
Expand Down Expand Up @@ -194,6 +199,14 @@ int main(int argc, const char **argv)
keyring.set_caps(ename, caps);
modified = true;
}
if (set_auid) {
if (!name) {
cerr << "must specify a name to set a uid" << std::endl;
exit(1);
}
keyring.set_uid(ename, auid);
modified = true;
}

// read commands
if (list) {
Expand Down

0 comments on commit 4020dd1

Please sign in to comment.