"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/modules/rlm_sql_map/rlm_sql_map.c" between
freeradius-server-3.0.22.tar.bz2 and freeradius-server-3.0.23.tar.bz2

About: FreeRADIUS Server Project - a high performance and highly configurable RADIUS server.

rlm_sql_map.c  (freeradius-server-3.0.22.tar.bz2):rlm_sql_map.c  (freeradius-server-3.0.23.tar.bz2)
skipping to change at line 18 skipping to change at line 18
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/** /**
* $Id: 69d83795aeb7e72c5d4bd99097d3d634b8ed6700 $ * $Id: 5443cf3c4f0ab21a9d0f6cc7c816adb0b1a46ed2 $
* @file rlm_sql_map.c * @file rlm_sql_map.c
* @brief Tracks data usage and other counters using SQL. * @brief Tracks data usage and other counters using SQL.
* *
* @copyright 2001,2006 The FreeRADIUS server project * @copyright 2001,2006 The FreeRADIUS server project
* @copyright 2001 Alan DeKok <aland@ox.org> * @copyright 2001 Alan DeKok <aland@ox.org>
*/ */
RCSID("$Id: 69d83795aeb7e72c5d4bd99097d3d634b8ed6700 $") RCSID("$Id: 5443cf3c4f0ab21a9d0f6cc7c816adb0b1a46ed2 $")
#include <freeradius-devel/radiusd.h> #include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h> #include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h> #include <freeradius-devel/rad_assert.h>
#include <ctype.h> #include <ctype.h>
#include <rlm_sql.h> #include <rlm_sql.h>
#define MAX_QUERY_LEN 2048 #define MAX_QUERY_LEN 2048
skipping to change at line 66 skipping to change at line 66
* *
* Note that the string is dynamically allocated, so it MUST * Note that the string is dynamically allocated, so it MUST
* be freed. When the configuration file parse re-reads the string, * be freed. When the configuration file parse re-reads the string,
* it free's the old one, and strdup's the new one, placing the pointer * it free's the old one, and strdup's the new one, placing the pointer
* to the strdup'd string into 'config.string'. This gets around * to the strdup'd string into 'config.string'. This gets around
* buffer over-flows. * buffer over-flows.
*/ */
static const CONF_PARSER module_config[] = { static const CONF_PARSER module_config[] = {
{ "sql_module_instance", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_REQUIRED , rlm_sql_map_t, sql_instance_name), NULL }, { "sql_module_instance", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_REQUIRED , rlm_sql_map_t, sql_instance_name), NULL },
{ "multiple_rows", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sql_map_t, multipl e_rows), "no" }, { "multiple_rows", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sql_map_t, multipl e_rows), "no" },
{ "query", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_REQUIRE D, rlm_sql_map_t, query), NULL }, { "query", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_XLAT | PW_TYPE_REQUIRE D | PW_TYPE_NOT_EMPTY, rlm_sql_map_t, query), NULL },
CONF_PARSER_TERMINATOR CONF_PARSER_TERMINATOR
}; };
#define SQL_MAX_ATTRMAP (128) #define SQL_MAX_ATTRMAP (128)
static int sql_map_verify(vp_map_t *map, UNUSED void *instance) static int sql_map_verify(vp_map_t *map, UNUSED void *instance)
{ {
/* /*
* Destinations where we can put the VALUE_PAIRs we * Destinations where we can put the VALUE_PAIRs we
skipping to change at line 226 skipping to change at line 226
* @param[in] request Current request. * @param[in] request Current request.
* @param[in] handle associated with entry. * @param[in] handle associated with entry.
* @return * @return
* - Number of maps successfully applied. * - Number of maps successfully applied.
* - -1 on failure. * - -1 on failure.
*/ */
static int sql_map_do(const rlm_sql_map_t *inst, REQUEST *request, rlm_sql_handl e_t **handle) static int sql_map_do(const rlm_sql_map_t *inst, REQUEST *request, rlm_sql_handl e_t **handle)
{ {
vp_map_t const *map; vp_map_t const *map;
int applied = 0; /* How many maps have been applie d to the current request */ int applied = 0; /* How many maps have been applie d to the current request */
int num_rows;
sql_map_row_t ctx; sql_map_row_t ctx;
num_rows = (inst->sql_inst->module->sql_affected_rows)(*handle, inst->sql
_inst->config);
if (num_rows == 0) {
RWDEBUG("No affected rows");
return 0;
}
/* /*
* Cache all of the rows in a simple array. * Cache all of the rows in a simple array.
*/ */
while ((inst->sql_inst->module->sql_fetch_row)(*handle, inst->sql_inst->c onfig) == RLM_SQL_OK) { while ((inst->sql_inst->module->sql_fetch_row)(*handle, inst->sql_inst->c onfig) == RLM_SQL_OK) {
#ifdef __clang_analyzer__ #ifdef __clang_analyzer__
if (!*handle) return -1; /* only true when return code is not RLM _SQL_OK */ if (!*handle) return -1; /* only true when return code is not RLM _SQL_OK */
#endif #endif
ctx.row = (*handle)->row; ctx.row = (*handle)->row;
ctx.num_columns = (inst->sql_inst->module->sql_num_fields)(*handl e, inst->sql_inst->config); ctx.num_columns = (inst->sql_inst->module->sql_num_fields)(*handl e, inst->sql_inst->config);
skipping to change at line 313 skipping to change at line 306
if (map_afrom_cs(&inst->user_map, update, if (map_afrom_cs(&inst->user_map, update,
PAIR_LIST_REPLY, PAIR_LIST_REQUEST, sql_map_verify, inst , PAIR_LIST_REPLY, PAIR_LIST_REQUEST, sql_map_verify, inst ,
SQL_MAX_ATTRMAP) < 0) { SQL_MAX_ATTRMAP) < 0) {
return -1; return -1;
} }
return 0; return 0;
} }
static int mod_bootstrap(CONF_SECTION *conf, void *instance)
{
rlm_sql_map_t *inst = instance;
char const *p = inst->query;
if (!p || !*p) {
cf_log_err_cs(conf, "'query' cannot be empty");
return -1;
}
while (isspace((int) *p)) p++;
if (strncasecmp(p, "select", 6) != 0) {
cf_log_err_cs(conf, "'query' MUST be 'SELECT ...', not 'INSERT' o
r 'UPDATE'");
return -1;
}
return 0;
}
/** Detach from the SQL server and cleanup internal state. /** Detach from the SQL server and cleanup internal state.
* *
*/ */
static int mod_detach(void *instance) static int mod_detach(void *instance)
{ {
rlm_sql_map_t *inst = instance; rlm_sql_map_t *inst = instance;
talloc_free(inst->user_map); talloc_free(inst->user_map);
return 0; return 0;
skipping to change at line 390 skipping to change at line 403
* The server will then take care of ensuring that the module * The server will then take care of ensuring that the module
* is single-threaded. * is single-threaded.
*/ */
extern module_t rlm_sql_map; extern module_t rlm_sql_map;
module_t rlm_sql_map = { module_t rlm_sql_map = {
.magic = RLM_MODULE_INIT, .magic = RLM_MODULE_INIT,
.name = "sqlcounter", .name = "sqlcounter",
.type = RLM_TYPE_THREAD_SAFE, .type = RLM_TYPE_THREAD_SAFE,
.inst_size = sizeof(rlm_sql_map_t), .inst_size = sizeof(rlm_sql_map_t),
.config = module_config, .config = module_config,
.bootstrap = mod_bootstrap,
.instantiate = mod_instantiate, .instantiate = mod_instantiate,
.detach = mod_detach, .detach = mod_detach,
.methods = { .methods = {
[MOD_AUTHENTICATE] = mod_map, [MOD_AUTHENTICATE] = mod_map,
[MOD_AUTHORIZE] = mod_map, [MOD_AUTHORIZE] = mod_map,
[MOD_PREACCT] = mod_map, [MOD_PREACCT] = mod_map,
[MOD_ACCOUNTING] = mod_map, [MOD_ACCOUNTING] = mod_map,
[MOD_PRE_PROXY] = mod_map, [MOD_PRE_PROXY] = mod_map,
[MOD_POST_PROXY] = mod_map, [MOD_POST_PROXY] = mod_map,
[MOD_POST_AUTH] = mod_map, [MOD_POST_AUTH] = mod_map,
 End of changes. 7 change blocks. 
11 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)