]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
authtool: set generated key to specific uid if one is given
authorGreg Farnum <gregf@hq.newdream.net>
Fri, 26 Feb 2010 23:34:50 +0000 (15:34 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 2 Mar 2010 18:02:03 +0000 (10:02 -0800)
src/cauthtool.cc

index 7a14b857cfed3bbc041d6263b17be1c68df9e173..8158cce10d408f2bb2362f82729928f79a88f5c4 100644 (file)
@@ -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 --set-uid=x] [--name=<name>] [--caps=<filename>] [--list] [--print-key] <filename>" << std::endl;
   exit(1);
 }
 
@@ -47,6 +47,7 @@ int main(int argc, const char **argv)
   const char *name = "";
   const char *caps_fn = NULL;
   const char *import_keyring = NULL;
+  __u64 auth_uid = 0;
 
   FOR_EACH_ARG(args) {
     if (CONF_ARG_EQ("gen-key", 'g')) {
@@ -65,6 +66,8 @@ 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(&auth_uid, OPT_LONGLONG);
     } else if (!fn) {
       fn = args[i];
     } else 
@@ -152,6 +155,8 @@ int main(int argc, const char **argv)
   if (gen_key) {
     EntityAuth eauth;
     eauth.key.create(CEPH_CRYPTO_AES);
+    if (auth_uid)
+      eauth.auth_uid = (__u64)auth_uid;
     keyring.add(ename, eauth);
     modified = true;
   }