From: Alan T. DeKok Date: Wed, 25 Oct 2017 10:43:47 +0000 (-0400) Subject: add "allow_duplicates" config. Helps with #2094 X-Git-Tag: release_3_0_16~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57af39fbe76f8182d513bc08fb005bc3e6b4609b;p=thirdparty%2Ffreeradius-server.git add "allow_duplicates" config. Helps with #2094 --- diff --git a/raddb/mods-available/sqlippool b/raddb/mods-available/sqlippool index 84d69e59616..8f149325cf3 100644 --- a/raddb/mods-available/sqlippool +++ b/raddb/mods-available/sqlippool @@ -39,6 +39,11 @@ sqlippool { # attribute_name = Framed-IP-Address + # + # Assign the IP address, even if the attribute already exists + # +# allow_duplicates = no + # Attribute which should be considered unique per NAS # # Using NAS-Port gives behaviour similar to rlm_ippool. (And ACS) diff --git a/src/modules/rlm_sqlippool/rlm_sqlippool.c b/src/modules/rlm_sqlippool/rlm_sqlippool.c index 78a0c106c46..58c652a18a1 100644 --- a/src/modules/rlm_sqlippool/rlm_sqlippool.c +++ b/src/modules/rlm_sqlippool/rlm_sqlippool.c @@ -46,6 +46,7 @@ typedef struct rlm_sqlippool_t { char const *pool_name; bool ipv6; //!< Whether or not we do IPv6 pools. + bool allow_duplicates; //!< assign even if it already exists char const *attribute_name; //!< name of the IP address attribute int framed_ip_address; //!< the attribute number for Framed-IP(v6)-Address @@ -129,6 +130,7 @@ static CONF_PARSER module_config[] = { { "ipv6", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sqlippool_t, ipv6), NULL}, + { "allow_duplicates", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sqlippool_t, allow_duplicates), NULL}, { "attribute_name", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_sqlippool_t, attribute_name), NULL}, { "allocate-begin", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_DEPRECATED, rlm_sqlippool_t, allocate_begin), NULL }, @@ -511,7 +513,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_post_auth(void *instance, REQUEST *reque /* * If there is already an attribute in the reply do nothing */ - if (fr_pair_find_by_num(request->reply->vps, inst->framed_ip_address, 0, TAG_ANY) != NULL) { + if (!inst->allow_duplicates && (fr_pair_find_by_num(request->reply->vps, inst->framed_ip_address, 0, TAG_ANY) != NULL)) { RDEBUG("%s already exists", inst->attribute_name); return do_logging(request, inst->log_exists, RLM_MODULE_NOOP);