]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: set up entity name on startup
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 24 Sep 2009 19:28:39 +0000 (12:28 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 24 Sep 2009 19:28:39 +0000 (12:28 -0700)
src/auth/Auth.h
src/config.cc
src/config.h

index 4f5104e336d7d642ea79f88e1e694f93183692b3..8565524800823d20cbedc84fcbd29ac1b1209883 100644 (file)
@@ -82,23 +82,29 @@ struct EntityName {
     string pre = s.substr(0, pos);
     const char *pres = pre.c_str();
 
-    if (strcmp(pres, "auth") == 0) {
+    set_type(pres);
+
+    name = s.substr(pos + 1);
+
+    return true;
+  }
+
+  void set_type(const char *type) {
+    if (strcmp(type, "auth") == 0) {
       entity_type = CEPHX_PRINCIPAL_AUTH;
-    } else if (strcmp(pres, "mon") == 0) {
+    } else if (strcmp(type, "mon") == 0) {
       entity_type = CEPHX_PRINCIPAL_MON;
-    } else if (strcmp(pres, "osd") == 0) {
+    } else if (strcmp(type, "osd") == 0) {
       entity_type = CEPHX_PRINCIPAL_OSD;
-    } else if (strcmp(pres, "mds") == 0) {
+    } else if (strcmp(type, "mds") == 0) {
       entity_type = CEPHX_PRINCIPAL_MDS;
-    } else if (strcmp(pres, "client") == 0) {
-      entity_type = CEPHX_PRINCIPAL_CLIENT;
     } else {
-      return false;
+      entity_type = CEPHX_PRINCIPAL_CLIENT;
     }
-
-    name = s.substr(pos + 1);
-
-    return true;
+  }
+  void from_type_id(const char *type, const char *id) {
+    set_type(type);
+    name = id;
   }
 };
 WRITE_CLASS_ENCODER(EntityName);
index da554e1818c0dbbbc14b9db4313adb6367df5c18..b1450fb03fa69e7d689058374ff333952ed2864d 100644 (file)
@@ -39,6 +39,7 @@ stringtable g_stab;
 #include "common/dyn_snprintf.h"
 
 #include "auth/ExportControl.h"
+#include "auth/Auth.h"
 
 static bool show_config = false;
 
@@ -959,6 +960,10 @@ void parse_startup_config_options(std::vector<const char*>& args, bool isdaemon,
        g_conf.name = g_conf.type;
     }
   }
+  g_conf.entity_name = new EntityName;
+  assert(g_conf.entity_name);
+
+  g_conf.entity_name->from_type_id(g_conf.type, g_conf.id);
 
   if (cf)
        delete cf;
index 04979e9dc74fb61dc3e18f107a10ab36bd6c2841..5cfbedb00569b68ec84a4c5d421c18577bc47c2b 100644 (file)
@@ -35,6 +35,8 @@ extern entity_addr_t g_my_addr;
 
 extern bool g_daemon;
 
+struct EntityName;
+
 struct md_config_t {
   char *type;
   char *id;
@@ -149,6 +151,7 @@ struct md_config_t {
   double auth_mon_ticket_ttl;
   double auth_service_ticket_ttl;
   int auth_nonce_len;
+  EntityName *entity_name;
 
   // client
   int      client_cache_size;