]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: standardize on -n/--name [type.]name
authorSage Weil <sage@newdream.net>
Fri, 26 Mar 2010 23:04:26 +0000 (16:04 -0700)
committerSage Weil <sage@newdream.net>
Fri, 26 Mar 2010 23:04:26 +0000 (16:04 -0700)
src/cauthtool.cc
src/config.cc

index b77aa3b6533b25788354c1fb81e2dd528efc6597..17834324d15528ad519f318c958dd2eec2f97e94 100644 (file)
@@ -44,19 +44,17 @@ int main(int argc, const char **argv)
   bool list = false;
   bool print_key = false;
   bool create_keyring = false;
-  const char *name = "";
   const char *caps_fn = NULL;
   const char *import_keyring = NULL;
   bool set_auid = false;
   __u64 auid = CEPH_AUTH_UID_DEFAULT;
+  const char *name = g_conf.name;
 
   FOR_EACH_ARG(args) {
     if (CONF_ARG_EQ("gen-key", 'g')) {
       CONF_SAFE_SET_ARG_VAL(&gen_key, OPT_BOOL);
     } else if (CONF_ARG_EQ("add-key", 'a')) {
       CONF_SAFE_SET_ARG_VAL(&add_key, OPT_STR);
-    } else if (CONF_ARG_EQ("name", 'n')) {
-      CONF_SAFE_SET_ARG_VAL(&name, OPT_STR);
     } else if (CONF_ARG_EQ("list", 'l')) {
       CONF_SAFE_SET_ARG_VAL(&list, OPT_BOOL);
     } else if (CONF_ARG_EQ("caps", '\0')) {
index 0dff78f0cee2b74a9c7bb1c7e589a2581c5b4740..d4b594d9206018182e415a1ecbb290119a27079e 100644 (file)
@@ -1005,9 +1005,9 @@ void parse_startup_config_options(std::vector<const char*>& args, bool isdaemon,
     } else if (isdaemon && CONF_ARG_EQ("foreground", 'f')) {
       g_conf.daemonize = false;
       g_conf.log_to_stdout = false;
-    } else if (isdaemon && CONF_ARG_EQ("id", 'i')) {
+    } else if (isdaemon && (CONF_ARG_EQ("id", 'i') || CONF_ARG_EQ("name", 'n'))) {
       CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
-    } else if (!isdaemon && CONF_ARG_EQ("id", 'I')) {
+    } else if (!isdaemon && (CONF_ARG_EQ("id", 'I') || CONF_ARG_EQ("name", 'n'))) {
       CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
     } else {
       nargs.push_back(args[i]);
@@ -1018,15 +1018,24 @@ void parse_startup_config_options(std::vector<const char*>& args, bool isdaemon,
 
   if (module_type) {
     g_conf.type = strdup(module_type);
-
     if (g_conf.id) {
-       int len = strlen(module_type) + strlen(g_conf.id) + 2;
-       g_conf.name = (char *)malloc(len);
-       snprintf(g_conf.name, len, "%s.%s", g_conf.type, g_conf.id);
-       g_conf.alt_name = (char *)malloc(len - 1);
-       snprintf(g_conf.alt_name, len - 1, "%s%s", module_type, g_conf.id);
+      // is it "type.name"?
+      const char *dot = strchr(g_conf.id, '.');
+      if (dot) {
+       int tlen = dot - g_conf.id;
+       g_conf.type = (char *)malloc(tlen + 1);
+       memcpy(g_conf.type, g_conf.id, tlen);
+       g_conf.type[tlen] = 0;
+       g_conf.id = strdup(dot + 1);
+      }
+      
+      int len = strlen(g_conf.type) + strlen(g_conf.id) + 2;
+      g_conf.name = (char *)malloc(len);
+      snprintf(g_conf.name, len, "%s.%s", g_conf.type, g_conf.id);
+      g_conf.alt_name = (char *)malloc(len - 1);
+      snprintf(g_conf.alt_name, len - 1, "%s%s", module_type, g_conf.id);
     } else {
-       g_conf.name = g_conf.type;
+      g_conf.name = g_conf.type;
     }
   }
   g_conf.entity_name = new EntityName;