Patchwork [BUG:1750,1/1] implement volume level address allow/reject setting

login
register
Submitter Csaba Henk
Date 2010-10-04 13:41:27
Message ID <1286199687-8598-1-git-send-email-csaba@gluster.com>
Download mbox | patch
Permalink /patch/5239/
State Accepted
Headers show

Comments

Csaba Henk - 2010-10-04 13:41:27
Signed-off-by: Csaba Henk <csaba@gluster.com>
---
 xlators/mgmt/glusterd/src/glusterd-volgen.c |   44 ++++++++++++++++++++-------
 1 files changed, 33 insertions(+), 11 deletions(-)

Patch

diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 9e672a5..bef676d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -105,8 +105,8 @@  static struct volopt_map_entry glusterd_volopt_map[] = {
         {"ping-timeout",                "protocol/client"},
 
         {"inode-lru-limit",             "protocol/server"},
-        {"auth.addr.*.allow",           "protocol/server"},
-        {"auth.addr.*.reject",          "protocol/server"},
+        {"allow",                       "protocol/server:!server-auth"},
+        {"reject",                      "protocol/server:!server-auth"},
 
         {"write-behind",                "performance/write-behind:!perf"},
         {"read-ahead",                  "performance/read-ahead:!perf"},
@@ -128,6 +128,7 @@  struct volopt_map_entry2 {
 };
 
 static struct volopt_map_entry2 default_volopt_map2[] = {
+        {"allow",         NULL, NULL, "*"},
         {"write-behind",  NULL, NULL, "on"},
         {"read-ahead",    NULL, NULL, "on"},
         {"io-cache",      NULL, NULL, "on"},
@@ -647,6 +648,34 @@  get_vol_transport_type (glusterd_volinfo_t *volinfo, char *tt)
 }
 
 static int
+server_auth_option_handler (glusterfs_graph_t *graph,
+                            struct volopt_map_entry2 *vme2, void *param)
+{
+        xlator_t *xl = NULL;
+        xlator_list_t *trav = NULL;
+        char *aa = NULL;
+        int   ret   = 0;
+
+        if (strcmp (vme2->option, "!server-auth") != 0)
+                return 0;
+
+        xl = first_of (graph);
+
+        for (trav = xl->children; trav; trav = trav->next) {
+                ret = gf_asprintf (&aa, "auth.addr.%s.%s", trav->xlator->name,
+                                   vme2->key);
+                if (ret != -1) {
+                        ret = xlator_set_option (xl, aa, vme2->value);
+                        GF_FREE (aa);
+                }
+                if (ret)
+                        return -1;
+        }
+
+        return 0;
+}
+
+static int
 server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
                       dict_t *set_dict, void *param)
 {
@@ -656,7 +685,6 @@  server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
         xlator_t *xl = NULL;
         xlator_t *txl = NULL;
         xlator_t *rbxl = NULL;
-        char     *aaa = NULL;
         int       ret = 0;
         char      transt[16] = {0,};
 
@@ -729,14 +757,8 @@  server_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
         if (ret)
                 return -1;
 
-        ret = gf_asprintf (&aaa, "auth.addr.%s.allow", path);
-        if (ret == -1) {
-                gf_log ("", GF_LOG_ERROR, "Out of memory");
-
-                return -1;
-        }
-        ret = xlator_set_option (xl, aaa, "*");
-        GF_FREE (aaa);
+        ret = volgen_graph_set_options_generic (graph, set_dict, NULL,
+                                                &server_auth_option_handler);
 
         return ret;
 }