From 00e247ee44067f2b3e7ca5f7e6dc2f7934c97181 Mon Sep 17 00:00:00 2001 From: Santosh Kumar Pradhan Date: Wed, 9 Apr 2014 10:19:43 +0530 Subject: gNFS: Support wildcard in RPC auth allow/reject RFE: Support wildcard in "nfs.rpc-auth-allow" and "nfs.rpc-auth-reject". e.g. *.redhat.com 192.168.1[1-5].* 192.168.1[1-5].*, *.redhat.com, 192.168.21.9 Along with wildcard, support for subnetwork or IP range e.g. 192.168.10.23/24 The option will be validated for following categories: 1) Anonymous i.e. "*" 2) Wildcard pattern i.e. string containing any ('*', '?', '[') 3) IPv4 address 4) IPv6 address 5) FQDN 6) subnetwork or IPv4 range Currently this does not support IPv6 subnetwork. Change-Id: Iac8caf5e490c8174d61111dad47fd547d4f67bf4 BUG: 1086097 Signed-off-by: Santosh Kumar Pradhan Reviewed-on: http://review.gluster.org/7485 Reviewed-by: Poornima G Reviewed-by: Harshavardhana Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/options.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libglusterfs/src/options.c') diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index 31e5a681d..a0881b4ad 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -574,6 +574,45 @@ out: return ret; } +static int +xlator_option_validate_mntauth (xlator_t *xl, const char *key, + const char *value, volume_option_t *opt, + char **op_errstr) +{ + int ret = -1; + char *dup_val = NULL; + char *addr_tok = NULL; + char *save_ptr = NULL; + char errstr[4096] = {0,}; + + dup_val = gf_strdup (value); + if (!dup_val) + goto out; + + addr_tok = strtok_r (dup_val, ",", &save_ptr); + if (addr_tok == NULL) + goto out; + while (addr_tok) { + if (!valid_mount_auth_address (addr_tok)) + goto out; + + addr_tok = strtok_r (NULL, ",", &save_ptr); + } + ret = 0; + +out: + if (ret) { + snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not " + "a valid mount-auth-address", key, value, value); + gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); + if (op_errstr) + *op_errstr = gf_strdup (errstr); + } + GF_FREE (dup_val); + + return ret; +} + /*XXX: the rules to validate are as per block-size required for stripe xlator */ static int gf_validate_size (const char *sizestr, volume_option_t *opt) @@ -744,6 +783,7 @@ xlator_option_validate (xlator_t *xl, char *key, char *value, xlator_option_validate_priority_list, [GF_OPTION_TYPE_SIZE_LIST] = xlator_option_validate_size_list, [GF_OPTION_TYPE_ANY] = xlator_option_validate_any, + [GF_OPTION_TYPE_CLIENT_AUTH_ADDR] = xlator_option_validate_mntauth, [GF_OPTION_TYPE_MAX] = NULL, }; -- cgit From a3cb38e3edf005bef73da4c9cfd958474a14d50f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 17 Apr 2014 15:54:34 -0700 Subject: build: MacOSX Porting fixes git@forge.gluster.org:~schafdog/glusterfs-core/osx-glusterfs Working functionality on MacOSX - GlusterD (management daemon) - GlusterCLI (management cli) - GlusterFS FUSE (using OSXFUSE) - GlusterNFS (without NLM - issues with rpc.statd) Change-Id: I20193d3f8904388e47344e523b3787dbeab044ac BUG: 1089172 Signed-off-by: Harshavardhana Signed-off-by: Dennis Schafroth Tested-by: Harshavardhana Tested-by: Dennis Schafroth Reviewed-on: http://review.gluster.org/7503 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/options.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'libglusterfs/src/options.c') diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index a0881b4ad..f63c60476 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -79,7 +79,7 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, goto out; } - if ((opt->validate == GF_OPT_VALIDATE_MIN)) { + if (opt->validate == GF_OPT_VALIDATE_MIN) { if (inputll < opt->min) { snprintf (errstr, 256, "'%lld' in 'option %s %s' is smaller than " @@ -88,8 +88,8 @@ xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); goto out; } - } else if ((opt->validate == GF_OPT_VALIDATE_MAX)) { - if ((inputll > opt->max)) { + } else if (opt->validate == GF_OPT_VALIDATE_MAX) { + if (inputll > opt->max) { snprintf (errstr, 256, "'%lld' in 'option %s %s' is greater than " "maximum value '%.0f'", inputll, key, @@ -118,12 +118,12 @@ static int xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value, volume_option_t *opt, char **op_errstr) { - uint64_t size = 0; + size_t size = 0; int ret = 0; char errstr[256]; /* Check the range */ - if (gf_string2bytesize (value, &size) != 0) { + if (gf_string2bytesize_size (value, &size) != 0) { snprintf (errstr, 256, "invalid number format \"%s\" in option \"%s\"", value, key); @@ -142,13 +142,13 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value, if ((size < opt->min) || (size > opt->max)) { if ((strncmp (key, "cache-size", 10) == 0) && (size > opt->max)) { - snprintf (errstr, 256, "Cache size %"PRId64" is out of " + snprintf (errstr, 256, "Cache size %" GF_PRI_SIZET " is out of " "range [%.0f - %.0f]", size, opt->min, opt->max); gf_log (xl->name, GF_LOG_WARNING, "%s", errstr); } else { snprintf (errstr, 256, - "'%"PRId64"' in 'option %s %s' " + "'%" GF_PRI_SIZET "' in 'option %s %s' " "is out of range [%.0f - %.0f]", size, key, value, opt->min, opt->max); gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); @@ -478,7 +478,7 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, goto out; } - if ((opt->validate == GF_OPT_VALIDATE_MIN)) { + if (opt->validate == GF_OPT_VALIDATE_MIN) { if (input < opt->min) { snprintf (errstr, 256, "'%f' in 'option %s %s' is smaller than " @@ -487,8 +487,8 @@ xlator_option_validate_double (xlator_t *xl, const char *key, const char *value, gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); goto out; } - } else if ((opt->validate == GF_OPT_VALIDATE_MAX)) { - if ((input > opt->max)) { + } else if (opt->validate == GF_OPT_VALIDATE_MAX) { + if (input > opt->max) { snprintf (errstr, 256, "'%f' in 'option %s %s' is greater than " "maximum value '%f'", input, key, @@ -617,12 +617,12 @@ out: static int gf_validate_size (const char *sizestr, volume_option_t *opt) { - uint64_t value = 0; + size_t value = 0; int ret = 0; GF_ASSERT (opt); - if (gf_string2bytesize (sizestr, &value) != 0 || + if (gf_string2bytesize_size (sizestr, &value) != 0 || value < opt->min || value % 512) { ret = -1; @@ -787,7 +787,7 @@ xlator_option_validate (xlator_t *xl, char *key, char *value, [GF_OPTION_TYPE_MAX] = NULL, }; - if (opt->type < 0 || opt->type >= GF_OPTION_TYPE_MAX) { + if (opt->type > GF_OPTION_TYPE_MAX) { gf_log (xl->name, GF_LOG_ERROR, "unknown option type '%d'", opt->type); goto out; @@ -1120,18 +1120,18 @@ pc_or_size (char *in, double *out) { double pc = 0; int ret = 0; - uint64_t size = 0; + size_t size = 0; if (gf_string2percent (in, &pc) == 0) { if (pc > 100.0) { - ret = gf_string2bytesize (in, &size); + ret = gf_string2bytesize_size (in, &size); if (!ret) *out = size; } else { *out = pc; } } else { - ret = gf_string2bytesize (in, &size); + ret = gf_string2bytesize_size (in, &size); if (!ret) *out = size; } @@ -1143,7 +1143,8 @@ DEFINE_INIT_OPT(uint64_t, uint64, gf_string2uint64); DEFINE_INIT_OPT(int64_t, int64, gf_string2int64); DEFINE_INIT_OPT(uint32_t, uint32, gf_string2uint32); DEFINE_INIT_OPT(int32_t, int32, gf_string2int32); -DEFINE_INIT_OPT(uint64_t, size, gf_string2bytesize); +DEFINE_INIT_OPT(size_t, size, gf_string2bytesize_size); +DEFINE_INIT_OPT(uint64_t, size_uint64, gf_string2bytesize_uint64); DEFINE_INIT_OPT(double, percent, gf_string2percent); DEFINE_INIT_OPT(double, percent_or_size, pc_or_size); DEFINE_INIT_OPT(gf_boolean_t, bool, gf_string2boolean); @@ -1158,7 +1159,8 @@ DEFINE_RECONF_OPT(uint64_t, uint64, gf_string2uint64); DEFINE_RECONF_OPT(int64_t, int64, gf_string2int64); DEFINE_RECONF_OPT(uint32_t, uint32, gf_string2uint32); DEFINE_RECONF_OPT(int32_t, int32, gf_string2int32); -DEFINE_RECONF_OPT(uint64_t, size, gf_string2bytesize); +DEFINE_RECONF_OPT(size_t, size, gf_string2bytesize_size); +DEFINE_RECONF_OPT(uint64_t, size_uint64, gf_string2bytesize_uint64); DEFINE_RECONF_OPT(double, percent, gf_string2percent); DEFINE_RECONF_OPT(double, percent_or_size, pc_or_size); DEFINE_RECONF_OPT(gf_boolean_t, bool, gf_string2boolean); -- cgit