Skip to content
Browse files

Merge pull request #101 from philmayers/escape-context2

Re-work escape functions to have REQUEST* and context variables
  • Loading branch information...
2 parents 150632f + f9a7f79 commit 9fa5e646fecfb25e2d526ca37c2db8b6849c039e @alandekok alandekok committed Oct 5, 2012
Showing with 214 additions and 357 deletions.
  1. +3 −3 src/include/radiusd.h
  2. +1 −1 src/main/auth.c
  3. +1 −1 src/main/evaluate.c
  4. +1 −1 src/main/exec.c
  5. +1 −2 src/main/listen.c
  6. +1 −1 src/main/log.c
  7. +7 −7 src/main/mainconfig.c
  8. +2 −2 src/main/modcall.c
  9. +2 −1 src/main/radconf2xml.c
  10. +2 −1 src/main/radmin.c
  11. +2 −1 src/main/radwho.c
  12. +2 −4 src/main/realms.c
  13. +1 −1 src/main/tls.c
  14. +4 −4 src/main/valuepair.c
  15. +38 −76 src/main/xlat.c
  16. +6 −6 src/modules/rlm_acctlog/rlm_acctlog.c
  17. +1 −1 src/modules/rlm_attr_filter/rlm_attr_filter.c
  18. +3 −3 src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c
  19. +6 −7 src/modules/rlm_cache/rlm_cache.c
  20. +2 −2 src/modules/rlm_detail/rlm_detail.c
  21. +1 −1 src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c
  22. +1 −2 src/modules/rlm_exec/rlm_exec.c
  23. +1 −1 src/modules/rlm_expiration/rlm_expiration.c
  24. +1 −1 src/modules/rlm_expr/paircmp.c
  25. +16 −23 src/modules/rlm_expr/rlm_expr.c
  26. +2 −2 src/modules/rlm_fastusers/rlm_fastusers.c
  27. +1 −1 src/modules/rlm_files/rlm_files.c
  28. +2 −2 src/modules/rlm_ippool/rlm_ippool.c
  29. +12 −12 src/modules/rlm_ldap/rlm_ldap.c
  30. +6 −4 src/modules/rlm_linelog/rlm_linelog.c
  31. +1 −1 src/modules/rlm_logintime/rlm_logintime.c
  32. +6 −9 src/modules/rlm_mschap/rlm_mschap.c
  33. +2 −2 src/modules/rlm_pap/rlm_pap.c
  34. +2 −2 src/modules/rlm_perl/rlm_perl.c
  35. +3 −3 src/modules/rlm_policy/evaluate.c
  36. +4 −4 src/modules/rlm_radutmp/rlm_radutmp.c
  37. +7 −7 src/modules/rlm_redis/rlm_redis.c
  38. +1 −1 src/modules/rlm_rediswho/rlm_rediswho.c
  39. +6 −6 src/modules/rlm_rest/rest.c
  40. +6 −5 src/modules/rlm_soh/rlm_soh.c
  41. +20 −29 src/modules/rlm_sql/rlm_sql.c
  42. +1 −1 src/modules/rlm_sql/rlm_sql.h
  43. +1 −1 src/modules/rlm_sql/sql.c
  44. +9 −10 src/modules/rlm_sql_log/rlm_sql_log.c
  45. +7 −93 src/modules/rlm_sqlcounter/rlm_sqlcounter.c
  46. +9 −9 src/modules/rlm_sqlippool/rlm_sqlippool.c
View
6 src/include/radiusd.h
@@ -712,11 +712,11 @@ VALUE_PAIR *radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
int operator);
/* xlat.c */
-typedef size_t (*RADIUS_ESCAPE_STRING)(char *out, size_t outlen, const char *in);
+typedef size_t (*RADIUS_ESCAPE_STRING)(REQUEST *, char *out, size_t outlen, const char *in, void *arg);
int radius_xlat(char * out, int outlen, const char *fmt,
- REQUEST * request, RADIUS_ESCAPE_STRING func);
-typedef size_t (*RAD_XLAT_FUNC)(void *instance, REQUEST *, const char *, char *, size_t, RADIUS_ESCAPE_STRING func);
+ REQUEST * request, RADIUS_ESCAPE_STRING func, void *funcarg);
+typedef size_t (*RAD_XLAT_FUNC)(void *instance, REQUEST *, const char *, char *, size_t);
int xlat_register(const char *module, RAD_XLAT_FUNC func,
void *instance);
void xlat_unregister(const char *module, RAD_XLAT_FUNC func,
View
2 src/main/auth.c
@@ -140,7 +140,7 @@ static int rad_authlog(const char *msg, REQUEST *request, int goodpass)
if (extra_msg) {
extra[0] = ' ';
radius_xlat(extra + 1, sizeof(extra) - 1, extra_msg, request,
- NULL);
+ NULL, NULL);
} else {
*extra = '\0';
}
View
2 src/main/evaluate.c
@@ -101,7 +101,7 @@ static const char *expand_string(char *buffer, size_t sizeof_buffer,
case T_DOUBLE_QUOTED_STRING:
if (!strchr(value, '%')) return value;
- radius_xlat(buffer, sizeof_buffer, value, request, NULL);
+ radius_xlat(buffer, sizeof_buffer, value, request, NULL, NULL);
return buffer;
}
View
2 src/main/exec.c
@@ -215,7 +215,7 @@ pid_t radius_start_program(const char *cmd, REQUEST *request,
if (!request) continue;
- sublen = radius_xlat(to, left - 1, argv[i], request, NULL);
+ sublen = radius_xlat(to, left - 1, argv[i], request, NULL, NULL);
if (sublen <= 0) {
/*
* Fail to be backwards compatible.
View
3 src/main/listen.c
@@ -94,8 +94,7 @@ static int command_write_magic(int newfd, listen_socket_t *sock);
*/
static size_t xlat_listen(UNUSED void *instance, REQUEST *request,
const char *fmt, char *out,
- size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ size_t outlen)
{
const char *value = NULL;
CONF_PAIR *cp;
View
2 src/main/log.c
@@ -257,7 +257,7 @@ void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, ..
*/
radius_xlat(buffer, sizeof(buffer), filename,
- request, NULL); /* FIXME: escape chars! */
+ request, NULL, NULL); /* FIXME: escape chars! */
request->radlog = rl;
p = strrchr(buffer, FR_DIR_SEP);
View
14 src/main/mainconfig.c
@@ -296,7 +296,7 @@ static const CONF_PARSER bootstrap_config[] = {
#define MAX_ARGV (256)
-static size_t config_escape_func(char *out, size_t outlen, const char *in)
+static size_t config_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, const char *in, UNUSED void *arg)
{
size_t len = 0;
static const char *disallowed = "%{}\\'\"`";
@@ -353,8 +353,7 @@ static size_t config_escape_func(char *out, size_t outlen, const char *in)
*/
static size_t xlat_config(void *instance, REQUEST *request,
const char *fmt, char *out,
- size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ size_t outlen)
{
const char *value;
CONF_PAIR *cp;
@@ -367,7 +366,7 @@ static size_t xlat_config(void *instance, REQUEST *request,
/*
* Expand it safely.
*/
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, config_escape_func)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, config_escape_func, NULL)) {
return 0;
}
@@ -392,7 +391,9 @@ static size_t xlat_config(void *instance, REQUEST *request,
}
}
- return func(out, outlen, value);
+ strlcpy(out, value, outlen);
+
+ return strlen(out);
}
@@ -401,8 +402,7 @@ static size_t xlat_config(void *instance, REQUEST *request,
*/
static size_t xlat_client(UNUSED void *instance, REQUEST *request,
const char *fmt, char *out,
- size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ size_t outlen)
{
const char *value = NULL;
CONF_PAIR *cp;
View
4 src/main/modcall.c
@@ -627,7 +627,7 @@ int modcall(int component, modcallable *c, REQUEST *request)
if (!mx->exec) {
radius_xlat(buffer, sizeof(buffer),
- mx->xlat_name, request, NULL);
+ mx->xlat_name, request, NULL, NULL);
} else {
RDEBUG("`%s`", mx->xlat_name);
radius_exec_program(mx->xlat_name, request,
@@ -730,7 +730,7 @@ int modcall(int component, modcallable *c, REQUEST *request)
}
} else {
radius_xlat(buffer, sizeof(buffer),
- child->name, request, NULL);
+ child->name, request, NULL, NULL);
}
null_case = q = NULL;
for(p = g->children; p; p = p->next) {
View
3 src/main/radconf2xml.c
@@ -47,7 +47,8 @@ struct main_config_t mainconfig;
char *request_log_file = NULL;
char *debug_log_file = NULL;
int radius_xlat(UNUSED char *out, UNUSED int outlen, UNUSED const char *fmt,
- UNUSED REQUEST *request, UNUSED RADIUS_ESCAPE_STRING func)
+ UNUSED REQUEST *request,
+ UNUSED RADIUS_ESCAPE_STRING func, UNUSED void *arg)
{
return -1;
}
View
3 src/main/radmin.c
@@ -89,7 +89,8 @@ struct main_config_t mainconfig;
char *request_log_file = NULL;
char *debug_log_file = NULL;
int radius_xlat(UNUSED char *out, UNUSED int outlen, UNUSED const char *fmt,
- UNUSED REQUEST *request, UNUSED RADIUS_ESCAPE_STRING func)
+ UNUSED REQUEST *request,
+ UNUSED RADIUS_ESCAPE_STRING func, UNUSED void *arg)
{
return -1;
}
View
3 src/main/radwho.c
@@ -81,7 +81,8 @@ struct main_config_t mainconfig;
char *request_log_file = NULL;
char *debug_log_file = NULL;
int radius_xlat(char *out, UNUSED int outlen, UNUSED const char *fmt,
- UNUSED REQUEST *request, UNUSED RADIUS_ESCAPE_STRING func)
+ UNUSED REQUEST *request,
+ UNUSED RADIUS_ESCAPE_STRING func, UNUSED void *arg)
{
*out = 0;
return 0;
View
6 src/main/realms.c
@@ -230,8 +230,7 @@ static size_t xlat_cs(CONF_SECTION *cs, const char *fmt, char *out, size_t outle
* Xlat for %{home_server:foo}
*/
static size_t xlat_home_server(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
if (!fmt || !out || (outlen < 1)) return 0;
@@ -248,8 +247,7 @@ static size_t xlat_home_server(UNUSED void *instance, REQUEST *request,
* Xlat for %{home_server_pool:foo}
*/
static size_t xlat_server_pool(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
if (!fmt || !out || (outlen < 1)) return 0;
View
2 src/main/tls.c
@@ -1696,7 +1696,7 @@ int cbtls_verify(int ok, X509_STORE_CTX *ctx)
* previous checks passed.
*/
if (my_ok && conf->check_cert_cn) {
- if (!radius_xlat(cn_str, sizeof(cn_str), conf->check_cert_cn, request, NULL)) {
+ if (!radius_xlat(cn_str, sizeof(cn_str), conf->check_cert_cn, request, NULL, NULL)) {
radlog(L_ERR, "rlm_eap_tls (%s): xlat failed.",
conf->check_cert_cn);
/* if this fails, fail the verification */
View
8 src/main/valuepair.c
@@ -109,7 +109,7 @@ int radius_compare_vps(REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
regmatch_t rxmatch[REQUEST_MAX_REGEX + 1];
snprintf(name, sizeof(name), "%%{%s}", check->name);
- radius_xlat(value, sizeof(value), name, request, NULL);
+ radius_xlat(value, sizeof(value), name, request, NULL, NULL);
/*
* Include substring matches.
@@ -186,7 +186,7 @@ int radius_compare_vps(REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
regmatch_t rxmatch[REQUEST_MAX_REGEX + 1];
snprintf(name, sizeof(name), "%%{%s}", check->name);
- radius_xlat(value, sizeof(value), name, request, NULL);
+ radius_xlat(value, sizeof(value), name, request, NULL, NULL);
/*
* Include substring matches.
@@ -568,7 +568,7 @@ int paircompare(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check,
check_item->flags.do_xlat = 0;
rcode = radius_xlat(buffer, sizeof(buffer),
check_item->vp_strvalue,
- req, NULL);
+ req, NULL, NULL);
/*
* Parse the string into a new value.
@@ -680,7 +680,7 @@ void pairxlatmove(REQUEST *req, VALUE_PAIR **to, VALUE_PAIR **from)
i->flags.do_xlat = 0;
rcode = radius_xlat(buffer, sizeof(buffer),
i->vp_strvalue,
- req, NULL);
+ req, NULL, NULL);
/*
* Parse the string into a new value.
View
114 src/main/xlat.c
@@ -74,14 +74,11 @@ static int xlat_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* up to 8 for regex */
/**
* @brief Convert the value on a VALUE_PAIR to string
*/
-static int valuepair2str(char * out,int outlen,VALUE_PAIR * pair,
- int type, RADIUS_ESCAPE_STRING func)
+static int valuepair2str(char * out,int outlen,VALUE_PAIR * pair, int type)
{
- char buffer[MAX_STRING_LEN * 4];
-
if (pair != NULL) {
- vp_prints_value(buffer, sizeof(buffer), pair, -1);
- return func(out, outlen, buffer);
+ vp_prints_value(out, outlen, pair, -1);
+ return strlen(out);
}
switch (type) {
@@ -130,8 +127,7 @@ static VALUE_PAIR *pairfind_tag(VALUE_PAIR *vps, const DICT_ATTR *da, int tag)
* Dynamically translate for check:, request:, reply:, etc.
*/
static size_t xlat_packet(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
DICT_ATTR *da;
VALUE_PAIR *vp;
@@ -297,7 +293,7 @@ static size_t xlat_packet(void *instance, REQUEST *request,
for (vp = pairfind_tag(vps, da, tag);
vp != NULL;
vp = pairfind_tag(vp->next, da, tag)) {
- count = valuepair2str(out, outlen - 1, vp, da->type, func);
+ count = valuepair2str(out, outlen - 1, vp, da->type);
rad_assert(count <= outlen);
total += count + 1;
outlen -= (count + 1);
@@ -345,7 +341,7 @@ static size_t xlat_packet(void *instance, REQUEST *request,
return snprintf(out, outlen, "%u", vp->vp_integer);
}
- return valuepair2str(out, outlen, vp, da->type, func);
+ return valuepair2str(out, outlen, vp, da->type);
}
vp = pairfind(vps, da->attr, da->vendor);
@@ -472,8 +468,7 @@ static size_t xlat_packet(void *instance, REQUEST *request,
}
localvp.type = da->type;
- return valuepair2str(out, outlen, &localvp,
- da->type, func);
+ return valuepair2str(out, outlen, &localvp, da->type);
}
/*
@@ -487,15 +482,14 @@ static size_t xlat_packet(void *instance, REQUEST *request,
/*
* Convert the VP to a string, and return it.
*/
- return valuepair2str(out, outlen, vp, da->type, func);
+ return valuepair2str(out, outlen, vp, da->type);
}
/**
* @brief Print data as integer, not as VALUE.
*/
static size_t xlat_integer(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
VALUE_PAIR *vp;
@@ -527,8 +521,7 @@ static size_t xlat_integer(UNUSED void *instance, REQUEST *request,
* @brief Print data as hex, not as VALUE.
*/
static size_t xlat_hex(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
size_t i;
uint8_t *p;
@@ -562,8 +555,7 @@ static size_t xlat_hex(UNUSED void *instance, REQUEST *request,
* @brief Prints the current module processing the request
*/
static size_t xlat_module(UNUSED void *instance, REQUEST *request,
- UNUSED const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ UNUSED const char *fmt, char *out, size_t outlen)
{
strlcpy(out, request->module, outlen);
@@ -577,8 +569,7 @@ static size_t xlat_module(UNUSED void *instance, REQUEST *request,
* @see modcall()
*/
static size_t xlat_foreach(void *instance, REQUEST *request,
- UNUSED const char *fmt, char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ UNUSED const char *fmt, char *out, size_t outlen)
{
VALUE_PAIR **pvp;
@@ -592,7 +583,7 @@ static size_t xlat_foreach(void *instance, REQUEST *request,
return 0;
}
- return valuepair2str(out, outlen, (*pvp), (*pvp)->type, func);
+ return valuepair2str(out, outlen, (*pvp), (*pvp)->type);
}
#endif
@@ -604,8 +595,7 @@ static size_t xlat_foreach(void *instance, REQUEST *request,
* expand to "\n\n\n"
*/
static size_t xlat_string(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
int len;
VALUE_PAIR *vp;
@@ -635,8 +625,7 @@ static size_t xlat_string(UNUSED void *instance, REQUEST *request,
* @brief Expand regexp matches %{0} to %{8}
*/
static size_t xlat_regex(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
char *regex;
@@ -645,7 +634,6 @@ static size_t xlat_regex(void *instance, REQUEST *request,
* are already in the "instance".
*/
fmt = fmt; /* -Wunused */
- func = func; /* -Wunused FIXME: do escaping? */
regex = request_data_reference(request, request,
REQUEST_DATA_REGEX | *(int *)instance);
@@ -666,8 +654,7 @@ static size_t xlat_regex(void *instance, REQUEST *request,
* Example %{debug:3}
*/
static size_t xlat_debug(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
int level = 0;
@@ -910,7 +897,7 @@ void xlat_free(void)
*/
static int decode_attribute(const char **from, char **to, int freespace,
REQUEST *request,
- RADIUS_ESCAPE_STRING func)
+ RADIUS_ESCAPE_STRING func, void *funcarg)
{
int do_length = 0;
const char *module_name, *xlat_str;
@@ -1011,7 +998,7 @@ static int decode_attribute(const char **from, char **to, int freespace,
* Expand the first one. If we did, exit the
* conditional.
*/
- retlen = radius_xlat(q, freespace, buffer, request, func);
+ retlen = radius_xlat(q, freespace, buffer, request, func, funcarg);
if (retlen) {
q += retlen;
goto done;
@@ -1023,7 +1010,7 @@ static int decode_attribute(const char **from, char **to, int freespace,
*/
if (expand2) {
retlen = radius_xlat(q, freespace, l,
- request, func);
+ request, func, funcarg);
if (retlen) {
q += retlen;
}
@@ -1119,8 +1106,21 @@ static int decode_attribute(const char **from, char **to, int freespace,
if (!c->internal) RDEBUG3("radius_xlat: Running registered xlat function of module %s for string \'%s\'",
c->module, xlat_str);
- retlen = c->do_xlat(c->instance, request, xlat_str,
- q, freespace, func);
+ if (func) {
+ /* xlat to a temporary buffer, then escape */
+ char tmpbuf[8192];
+ retlen = c->do_xlat(c->instance, request, xlat_str, tmpbuf, sizeof(tmpbuf));
+ if (retlen > 0) {
+ retlen = func(request, q, freespace, tmpbuf, funcarg);
+ if (retlen > 0) {
+ RDEBUG2("string escaped from \'%s\' to \'%s\'", tmpbuf, q);
+ } else if (retlen < 0) {
+ RDEBUG2("string escape failed");
+ }
+ }
+ } else {
+ retlen = c->do_xlat(c->instance, request, xlat_str, q, freespace);
+ }
if (retlen > 0) {
if (do_length) {
snprintf(q, freespace, "%d", retlen);
@@ -1132,7 +1132,7 @@ static int decode_attribute(const char **from, char **to, int freespace,
* Expand the second bit.
*/
RDEBUG2("\t... expanding second conditional");
- retlen = radius_xlat(q, freespace, next, request, func);
+ retlen = radius_xlat(q, freespace, next, request, func, funcarg);
}
q += retlen;
@@ -1141,32 +1141,6 @@ static int decode_attribute(const char **from, char **to, int freespace,
return 0;
}
-/*
- * If the caller doesn't pass xlat an escape function, then
- * we use this one. It simplifies the coding, as the check for
- * func == NULL only happens once.
- */
-static size_t xlat_copy(char *out, size_t outlen, const char *in)
-{
- int freespace = outlen;
-
- if (outlen < 1) return 0;
-
- while ((*in) && (freespace > 1)) {
- /*
- * Copy data.
- *
- * FIXME: Do escaping of bad stuff!
- */
- *(out++) = *(in++);
-
- freespace--;
- }
- *out = '\0';
-
- return (outlen - freespace); /* count does not include NUL */
-}
-
/**
* @brief Replace %whatever in a string.
*
@@ -1180,7 +1154,8 @@ static size_t xlat_copy(char *out, size_t outlen, const char *in)
* @return length of string written @bug should really have -1 for failure
*/
int radius_xlat(char *out, int outlen, const char *fmt,
- REQUEST *request, RADIUS_ESCAPE_STRING func)
+ REQUEST *request,
+ RADIUS_ESCAPE_STRING func, void *funcarg)
{
int c, len, freespace;
const char *p;
@@ -1189,20 +1164,12 @@ int radius_xlat(char *out, int outlen, const char *fmt,
VALUE_PAIR *tmp;
struct tm *TM, s_TM;
char tmpdt[40]; /* For temporary storing of dates */
- int openbraces=0;
/*
* Catch bad modules.
*/
if (!fmt || !out || !request) return 0;
- /*
- * Ensure that we always have an escaping function.
- */
- if (func == NULL) {
- func = xlat_copy;
- }
-
q = out;
p = fmt;
while (*p) {
@@ -1218,11 +1185,6 @@ int radius_xlat(char *out, int outlen, const char *fmt,
* then we assume this brace is NOT literal, but is
* a closing brace and apply it
*/
- if ((c == '}') && openbraces) {
- openbraces--;
- p++; /* skip it */
- continue;
- }
*q++ = *p++;
continue;
}
@@ -1258,7 +1220,7 @@ int radius_xlat(char *out, int outlen, const char *fmt,
} else if (c == '%') switch(*p) {
case '{':
p--;
- if (decode_attribute(&p, &q, freespace, request, func) < 0) return 0;
+ if (decode_attribute(&p, &q, freespace, request, func, funcarg) < 0) return 0;
break;
case '%':
View
12 src/modules/rlm_acctlog/rlm_acctlog.c
@@ -88,26 +88,26 @@ static int do_acctlog_acct(void *instance, REQUEST *request)
if ((pair = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE, 0)) != NULL) {
acctstatustype = pair->vp_integer;
} else {
- radius_xlat(logstr, sizeof(logstr), "packet has no accounting status type. [user '%{User-Name}', nas '%{NAS-IP-Address}']", request, NULL);
+ radius_xlat(logstr, sizeof(logstr), "packet has no accounting status type. [user '%{User-Name}', nas '%{NAS-IP-Address}']", request, NULL, NULL);
radlog(L_ERR, "rlm_acctlog (%s)", logstr);
return RLM_MODULE_INVALID;
}
switch (acctstatustype) {
case PW_STATUS_START:
- radius_xlat(logstr, sizeof(logstr), inst->acctstart, request, NULL);
+ radius_xlat(logstr, sizeof(logstr), inst->acctstart, request, NULL, NULL);
break;
case PW_STATUS_STOP:
- radius_xlat(logstr, sizeof(logstr), inst->acctstop, request, NULL);
+ radius_xlat(logstr, sizeof(logstr), inst->acctstop, request, NULL, NULL);
break;
case PW_STATUS_ALIVE:
- radius_xlat(logstr, sizeof(logstr), inst->acctupdate, request, NULL);
+ radius_xlat(logstr, sizeof(logstr), inst->acctupdate, request, NULL, NULL);
break;
case PW_STATUS_ACCOUNTING_ON:
- radius_xlat(logstr, sizeof(logstr), inst->accton, request, NULL);
+ radius_xlat(logstr, sizeof(logstr), inst->accton, request, NULL, NULL);
break;
case PW_STATUS_ACCOUNTING_OFF:
- radius_xlat(logstr, sizeof(logstr), inst->acctoff, request, NULL);
+ radius_xlat(logstr, sizeof(logstr), inst->acctoff, request, NULL, NULL);
break;
default:
View
2 src/modules/rlm_attr_filter/rlm_attr_filter.c
@@ -199,7 +199,7 @@ static int attr_filter_common(void *instance, REQUEST *request,
int len;
len = radius_xlat(buffer, sizeof(buffer), inst->key,
- request, NULL);
+ request, NULL, NULL);
if (!len) {
return RLM_MODULE_NOOP;
}
View
6 src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c
@@ -178,7 +178,7 @@ static int do_attr_rewrite(void *instance, REQUEST *request)
if (data->new_attr){
/* new_attribute = yes */
- if (!radius_xlat(replace_STR, sizeof(replace_STR), data->replace, request, NULL)) {
+ if (!radius_xlat(replace_STR, sizeof(replace_STR), data->replace, request, NULL, NULL)) {
DEBUG2("%s: xlat on replace string failed.", data->name);
return ret;
}
@@ -274,7 +274,7 @@ static int do_attr_rewrite(void *instance, REQUEST *request)
if (data->nocase)
cflags |= REG_ICASE;
- if (!radius_xlat(search_STR, sizeof(search_STR), data->search, request, NULL) && data->search_len != 0) {
+ if (!radius_xlat(search_STR, sizeof(search_STR), data->search, request, NULL, NULL) && data->search_len != 0) {
DEBUG2("%s: xlat on search string failed.", data->name);
return ret;
}
@@ -367,7 +367,7 @@ static int do_attr_rewrite(void *instance, REQUEST *request)
if (!done_xlat){
if (data->replace_len != 0 &&
- radius_xlat(replace_STR, sizeof(replace_STR), data->replace, request, NULL) == 0) {
+ radius_xlat(replace_STR, sizeof(replace_STR), data->replace, request, NULL, NULL) == 0) {
DEBUG2("%s: xlat on replace string failed.", data->name);
return ret;
}
View
13 src/modules/rlm_cache/rlm_cache.c
@@ -279,7 +279,7 @@ static rlm_cache_entry_t *cache_add(rlm_cache_t *inst, REQUEST *request,
* I don't want to make that change for 2.0.
*/
radius_xlat(buffer, sizeof(buffer), cf_pair_value(cp),
- request, NULL);
+ request, NULL, NULL);
vp = pairmake(p, buffer, cf_pair_operator(cp));
pairadd(vps, vp);
@@ -361,9 +361,8 @@ static int cache_verify(rlm_cache_t *inst)
/*
* Allow single attribute values to be retrieved from the cache.
*/
-static int cache_xlat(void *instance, REQUEST *request,
- char *fmt, char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+static size_t cache_xlat(void *instance, REQUEST *request,
+ const char *fmt, char *out, size_t freespace)
{
rlm_cache_entry_t *c;
rlm_cache_t *inst = instance;
@@ -373,7 +372,7 @@ static int cache_xlat(void *instance, REQUEST *request,
const char *p = fmt;
char buffer[1024];
- radius_xlat(buffer, sizeof(buffer), inst->key, request, NULL);
+ radius_xlat(buffer, sizeof(buffer), inst->key, request, NULL, NULL);
c = cache_find(inst, request, buffer);
@@ -500,7 +499,7 @@ static int cache_instantiate(CONF_SECTION *conf, void **instance)
* Register the cache xlat function
*/
inst->xlat_name = strdup(xlat_name);
- xlat_register(xlat_name, (RAD_XLAT_FUNC)cache_xlat, inst);
+ xlat_register(xlat_name, cache_xlat, inst);
if (!inst->key || !*inst->key) {
radlog(L_ERR, "rlm_cache: You must specify a key");
@@ -576,7 +575,7 @@ static int cache_it(void *instance, REQUEST *request)
VALUE_PAIR *vp;
char buffer[1024];
- radius_xlat(buffer, sizeof(buffer), inst->key, request, NULL);
+ radius_xlat(buffer, sizeof(buffer), inst->key, request, NULL, NULL);
c = cache_find(inst, request, buffer);
View
4 src/modules/rlm_detail/rlm_detail.c
@@ -223,7 +223,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
* feed it through radius_xlat() to expand the
* variables.
*/
- if (radius_xlat(buffer, sizeof(buffer), inst->detailfile, request, NULL) == 0) {
+ if (radius_xlat(buffer, sizeof(buffer), inst->detailfile, request, NULL, NULL) == 0) {
radlog_request(L_ERR, 0, request, "rlm_detail: Failed to expand detail file %s",
inst->detailfile);
return RLM_MODULE_FAIL;
@@ -368,7 +368,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
return RLM_MODULE_FAIL;
}
- if (radius_xlat(timestamp, sizeof(timestamp), inst->header, request, NULL) == 0) {
+ if (radius_xlat(timestamp, sizeof(timestamp), inst->header, request, NULL, NULL) == 0) {
radlog_request(L_ERR, 0, request, "rlm_detail: Unable to expand detail header format %s",
inst->header);
close(outfd);
View
2 src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c
@@ -115,7 +115,7 @@ static int gtc_initiate(void *type_data, EAP_HANDLER *handler)
EAP_DS *eap_ds = handler->eap_ds;
rlm_eap_gtc_t *inst = (rlm_eap_gtc_t *) type_data;
- if (!radius_xlat(challenge_str, sizeof(challenge_str), inst->challenge, handler->request, NULL)) {
+ if (!radius_xlat(challenge_str, sizeof(challenge_str), inst->challenge, handler->request, NULL, NULL)) {
radlog(L_ERR, "rlm_eap_gtc: xlat of \"%s\" failed", inst->challenge);
return 0;
}
View
3 src/modules/rlm_exec/rlm_exec.c
@@ -118,8 +118,7 @@ static VALUE_PAIR **decode_string(REQUEST *request, const char *string)
* Do xlat of strings.
*/
static size_t exec_xlat(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
int result;
rlm_exec_t *inst = instance;
View
2 src/modules/rlm_expiration/rlm_expiration.c
@@ -80,7 +80,7 @@ static int expiration_authorize(void *instance, REQUEST *request)
RDEBUG("Account has expired");
if (data->msg && data->msg[0]){
- if (!radius_xlat(msg, sizeof(msg), data->msg, request, NULL)) {
+ if (!radius_xlat(msg, sizeof(msg), data->msg, request, NULL, NULL)) {
radlog(L_ERR, "rlm_expiration: xlat failed.");
return RLM_MODULE_FAIL;
}
View
2 src/modules/rlm_expr/paircmp.c
@@ -228,7 +228,7 @@ static int genericcmp(void *instance UNUSED,
snprintf(name, sizeof(name), "%%{%s}", check->name);
- radius_xlat(value, sizeof(value), name, req, NULL);
+ radius_xlat(value, sizeof(value), name, req, NULL, NULL);
vp = pairmake(check->name, value, check->operator);
/*
View
39 src/modules/rlm_expr/rlm_expr.c
@@ -235,7 +235,7 @@ static int get_number(REQUEST *request, const char **string, int64_t *answer)
* Do xlat of strings!
*/
static size_t expr_xlat(void *instance, REQUEST *request, const char *fmt,
- char *out, size_t outlen, RADIUS_ESCAPE_STRING func)
+ char *out, size_t outlen)
{
int rcode;
int64_t result;
@@ -248,7 +248,7 @@ static size_t expr_xlat(void *instance, REQUEST *request, const char *fmt,
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, func)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
return 0;
@@ -277,16 +277,15 @@ static size_t expr_xlat(void *instance, REQUEST *request, const char *fmt,
*
*/
static size_t rand_xlat(UNUSED void *instance, REQUEST *request, const char *fmt,
- char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ char *out, size_t outlen)
{
int64_t result;
char buffer[256];
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, func)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
return 0;
@@ -314,8 +313,7 @@ static size_t rand_xlat(UNUSED void *instance, REQUEST *request, const char *fmt
* Format identical to String::Random.
*/
static size_t randstr_xlat(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
char *p;
char buffer[1024];
@@ -328,7 +326,7 @@ static size_t randstr_xlat(UNUSED void *instance, REQUEST *request,
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- len = radius_xlat(buffer, sizeof(buffer), fmt, request, func);
+ len = radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL);
if (!len) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
@@ -426,8 +424,7 @@ static size_t randstr_xlat(UNUSED void *instance, REQUEST *request,
* Example: "%{urlquote:http://example.org/}" == "http%3A%47%47example.org%47"
*/
static size_t urlquote_xlat(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
char *p;
char buffer[1024];
@@ -436,7 +433,7 @@ static size_t urlquote_xlat(UNUSED void *instance, REQUEST *request,
if (outlen <= 1) return 0;
- len = radius_xlat(buffer, sizeof(buffer), fmt, request, func);
+ len = radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL);
if (!len) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
@@ -480,8 +477,7 @@ static size_t urlquote_xlat(UNUSED void *instance, REQUEST *request,
* Example: "%{escape:<img>foo.jpg</img>}" == "=60img=62foo.jpg=60=/img=62"
*/
static size_t escape_xlat(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
rlm_expr_t *inst = instance;
char *p;
@@ -491,7 +487,7 @@ static size_t escape_xlat(UNUSED void *instance, REQUEST *request,
if (outlen <= 1) return 0;
- len = radius_xlat(buffer, sizeof(buffer), fmt, request, func);
+ len = radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL);
if (!len) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
@@ -532,15 +528,14 @@ static size_t escape_xlat(UNUSED void *instance, REQUEST *request,
* Probably only works for ASCII
*/
static size_t lc_xlat(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
char *p, *q;
char buffer[1024];
if (outlen <= 1) return 0;
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, func)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
*out = '\0';
return 0;
}
@@ -564,15 +559,14 @@ static size_t lc_xlat(UNUSED void *instance, REQUEST *request,
* Probably only works for ASCII
*/
static size_t uc_xlat(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
char *p, *q;
char buffer[1024];
if (outlen <= 1) return 0;
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, func)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
*out = '\0';
return 0;
}
@@ -594,15 +588,14 @@ static size_t uc_xlat(UNUSED void *instance, REQUEST *request,
* Example: "%{md5:foo}" == "acbd18db4cc2f85cedef654fccc4a4d8"
*/
static size_t md5_xlat(UNUSED void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
char buffer[1024];
uint8_t digest[16];
int i;
FR_MD5_CTX ctx;
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, func)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
*out = '\0';
return 0;
}
View
4 src/modules/rlm_fastusers/rlm_fastusers.c
@@ -564,7 +564,7 @@ static int fastuser_authorize(void *instance, REQUEST *request)
int len;
len = radius_xlat(buffer, sizeof(buffer), inst->key,
- request, NULL);
+ request, NULL, NULL);
if (len) name = buffer;
else name = "NONE";
}
@@ -721,7 +721,7 @@ static int fastuser_preacct(void *instance, REQUEST *request)
int len;
len = radius_xlat(buffer, sizeof(buffer), inst->key,
- request, NULL);
+ request, NULL, NULL);
if (len) name = buffer;
else name = "NONE";
}
View
2 src/modules/rlm_files/rlm_files.c
@@ -431,7 +431,7 @@ static int file_common(struct file_instance *inst, REQUEST *request,
int len;
len = radius_xlat(buffer, sizeof(buffer), inst->key,
- request, NULL);
+ request, NULL, NULL);
if (len) name = buffer;
else name = "NONE";
}
View
4 src/modules/rlm_ippool/rlm_ippool.c
@@ -337,7 +337,7 @@ static int ippool_accounting(void *instance, REQUEST *request)
}
switch(acctstatustype){
case PW_STATUS_STOP:
- if (!radius_xlat(xlat_str,MAX_STRING_LEN,data->key, request, NULL)){
+ if (!radius_xlat(xlat_str,MAX_STRING_LEN,data->key, request, NULL, NULL)){
RDEBUG("xlat on the 'key' directive failed");
return RLM_MODULE_NOOP;
}
@@ -495,7 +495,7 @@ static int ippool_postauth(void *instance, REQUEST *request)
}
#endif
- if (!radius_xlat(xlat_str,MAX_STRING_LEN,data->key, request, NULL)){
+ if (!radius_xlat(xlat_str,MAX_STRING_LEN,data->key, request, NULL, NULL)){
RDEBUG("xlat on the 'key' directive failed");
return RLM_MODULE_NOOP;
}
View
24 src/modules/rlm_ldap/rlm_ldap.c
@@ -362,7 +362,7 @@ static void fieldcpy(char *, char **);
#endif
static VALUE_PAIR *ldap_pairget(LDAP *, LDAPMessage *, TLDAP_RADIUS *,VALUE_PAIR **,int, ldap_instance *);
static int ldap_groupcmp(void *, REQUEST *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR **);
-static size_t ldap_xlat(void *, REQUEST *, const char *, char *, size_t, RADIUS_ESCAPE_STRING);
+static size_t ldap_xlat(void *, REQUEST *, const char *, char *, size_t);
static LDAP *ldap_connect(void *instance, const char *, const char *, int, int *, char **);
static int read_mappings(ldap_instance* inst);
@@ -957,8 +957,9 @@ static int perform_search(void *instance, LDAP_CONN *conn,
/*
* Translate the LDAP queries.
*/
-static size_t ldap_escape_func(char *out, size_t outlen, const char *in)
+static size_t ldap_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, const char *in, void *arg)
{
+ ldap_instance *inst = arg;
size_t len = 0;
while (in[0]) {
@@ -1042,7 +1043,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req,
return 1;
}
- if (!radius_xlat(basedn, sizeof(basedn), inst->basedn, req, ldap_escape_func)) {
+ if (!radius_xlat(basedn, sizeof(basedn), inst->basedn, req, ldap_escape_func, inst)) {
DEBUG("rlm_ldap::ldap_groupcmp: unable to create basedn.");
return 1;
}
@@ -1051,7 +1052,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req,
char *user_dn = NULL;
if (!radius_xlat(filter, sizeof(filter), inst->filter,
- req, ldap_escape_func)){
+ req, ldap_escape_func, inst)){
DEBUG("rlm_ldap::ldap_groupcmp: unable to create filter");
return 1;
}
@@ -1090,7 +1091,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req,
}
if(!radius_xlat(gr_filter, sizeof(gr_filter),
- inst->groupmemb_filt, req, ldap_escape_func)) {
+ inst->groupmemb_filt, req, ldap_escape_func, inst)) {
DEBUG("rlm_ldap::ldap_groupcmp: unable to create filter.");
return 1;
}
@@ -1214,8 +1215,7 @@ static int ldap_groupcmp(void *instance, REQUEST *req,
* Do an xlat on an LDAP URL
*/
static size_t ldap_xlat(void *instance, REQUEST *request, const char *fmt,
- char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+ char *out, size_t freespace)
{
char url[MAX_FILTER_STR_LEN];
int res;
@@ -1229,7 +1229,7 @@ static size_t ldap_xlat(void *instance, REQUEST *request, const char *fmt,
LDAP_CONN *conn;
DEBUG(" [%s] - ldap_xlat", inst->xlat_name);
- if (!radius_xlat(url, sizeof(url), fmt, request, ldap_escape_func)) {
+ if (!radius_xlat(url, sizeof(url), fmt, request, ldap_escape_func, inst)) {
radlog (L_ERR, " [%s] Unable to create LDAP URL.\n", inst->xlat_name);
return 0;
}
@@ -1377,13 +1377,13 @@ static int ldap_authorize(void *instance, REQUEST * request)
request->username->vp_strvalue);
if (!radius_xlat(filter, sizeof(filter), inst->filter,
- request, ldap_escape_func)) {
+ request, ldap_escape_func, inst)) {
radlog(L_ERR, " [%s] unable to create filter.\n", inst->xlat_name);
return RLM_MODULE_INVALID;
}
if (!radius_xlat(basedn, sizeof(basedn), inst->basedn,
- request, ldap_escape_func)) {
+ request, ldap_escape_func, inst)) {
radlog(L_ERR, " [%s] unable to create basedn.\n", inst->xlat_name);
return RLM_MODULE_INVALID;
}
@@ -1855,13 +1855,13 @@ static int ldap_authenticate(void *instance, REQUEST * request)
while ((vp_user_dn = pairfind(request->config_items,
PW_LDAP_USERDN, 0)) == NULL) {
if (!radius_xlat(filter, sizeof(filter), inst->filter,
- request, ldap_escape_func)) {
+ request, ldap_escape_func, inst)) {
radlog(L_ERR, " [%s] unable to create filter.\n", inst->xlat_name);
return RLM_MODULE_INVALID;
}
if (!radius_xlat(basedn, sizeof(basedn), inst->basedn,
- request, ldap_escape_func)) {
+ request, ldap_escape_func, inst)) {
radlog(L_ERR, " [%s] unable to create basedn.\n", inst->xlat_name);
return RLM_MODULE_INVALID;
}
View
10 src/modules/rlm_linelog/rlm_linelog.c
@@ -165,7 +165,9 @@ static int linelog_instantiate(CONF_SECTION *conf, void **instance)
/*
* Escape unprintable characters.
*/
-static size_t linelog_escape_func(char *out, size_t outlen, const char *in)
+static size_t linelog_escape_func(UNUSED REQUEST *request,
+ char *out, size_t outlen, const char *in,
+ UNUSED void *arg)
{
int len = 0;
@@ -243,7 +245,7 @@ static int do_linelog(void *instance, REQUEST *request)
CONF_PAIR *cp;
radius_xlat(line + 1, sizeof(line) - 2, inst->reference,
- request, linelog_escape_func);
+ request, linelog_escape_func, NULL);
line[0] = '.'; /* force to be in current section */
/*
@@ -281,7 +283,7 @@ static int do_linelog(void *instance, REQUEST *request)
*/
if (strcmp(inst->filename, "syslog") != 0) {
radius_xlat(buffer, sizeof(buffer), inst->filename, request,
- NULL);
+ NULL, NULL);
/* check path and eventually create subdirs */
p = strrchr(buffer,'/');
@@ -326,7 +328,7 @@ static int do_linelog(void *instance, REQUEST *request)
* FIXME: Check length.
*/
radius_xlat(line, sizeof(line) - 1, value, request,
- linelog_escape_func);
+ linelog_escape_func, NULL);
if (fd >= 0) {
strcat(line, "\n");
View
2 src/modules/rlm_logintime/rlm_logintime.c
@@ -197,7 +197,7 @@ static int logintime_authorize(void *instance, REQUEST *request)
char msg[MAX_STRING_LEN];
VALUE_PAIR *tmp;
- if (!radius_xlat(msg, sizeof(msg), data->msg, request, NULL)) {
+ if (!radius_xlat(msg, sizeof(msg), data->msg, request, NULL, NULL)) {
radlog(L_ERR, "rlm_logintime: xlat failed.");
return RLM_MODULE_FAIL;
}
View
15 src/modules/rlm_mschap/rlm_mschap.c
@@ -165,8 +165,7 @@ typedef struct rlm_mschap_t {
* attributes.
*/
static size_t mschap_xlat(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t outlen,
- RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t outlen)
{
size_t i, data_len;
uint8_t *data = NULL;
@@ -177,8 +176,6 @@ static size_t mschap_xlat(void *instance, REQUEST *request,
response = NULL;
- func = func; /* -Wunused */
-
/*
* Challenge means MS-CHAPv1 challenge, or
* hash of MS-CHAPv2 challenge, and peer challenge.
@@ -463,7 +460,7 @@ static size_t mschap_xlat(void *instance, REQUEST *request,
while (isspace(*p)) p++;
- if (!radius_xlat(buf2, sizeof(buf2),p,request,NULL)) {
+ if (!radius_xlat(buf2, sizeof(buf2),p,request,NULL,NULL)) {
RDEBUG("xlat failed");
*buffer = '\0';
return 0;
@@ -489,7 +486,7 @@ static size_t mschap_xlat(void *instance, REQUEST *request,
while (isspace(*p)) p++;
- if (!radius_xlat(buf2, sizeof(buf2),p,request,NULL)) {
+ if (!radius_xlat(buf2, sizeof(buf2),p,request,NULL,NULL)) {
RDEBUG("xlat failed");
*buffer = '\0';
return 0;
@@ -750,7 +747,7 @@ static int do_mschap_cpw(rlm_mschap_t *inst,
*/
if (inst->ntlm_cpw_username) {
- len = radius_xlat(buf, sizeof(buf) - 2, inst->ntlm_cpw_username, request, NULL);
+ len = radius_xlat(buf, sizeof(buf) - 2, inst->ntlm_cpw_username, request, NULL, NULL);
strcat(buf, "\n");
len++;
@@ -763,7 +760,7 @@ static int do_mschap_cpw(rlm_mschap_t *inst,
}
if (inst->ntlm_cpw_domain) {
- len = radius_xlat(buf, sizeof(buf) - 2, inst->ntlm_cpw_domain, request, NULL);
+ len = radius_xlat(buf, sizeof(buf) - 2, inst->ntlm_cpw_domain, request, NULL, NULL);
strcat(buf, "\n");
len++;
@@ -1005,7 +1002,7 @@ static int do_mschap_cpw(rlm_mschap_t *inst,
/*
* perform the xlat
*/
- result_len = radius_xlat(result, sizeof(result), inst->local_cpw, request, NULL);
+ result_len = radius_xlat(result, sizeof(result), inst->local_cpw, request, NULL, NULL);
if (!result_len) {
RDEBUG("Local MS-CHAPv2 password change - xlat didn't give any result, assuming failure");
return -1;
View
4 src/modules/rlm_pap/rlm_pap.c
@@ -730,7 +730,7 @@ static int pap_auth_nt(REQUEST *request, VALUE_PAIR *vp, char *fmsg)
}
strlcpy(buff2, "%{mschap:NT-Hash %{User-Password}}", sizeof(buff2));
- if (!radius_xlat(charbuf, sizeof(charbuf),buff2,request,NULL)){
+ if (!radius_xlat(charbuf, sizeof(charbuf),buff2,request,NULL,NULL)){
RDEBUG("mschap xlat failed");
snprintf(fmsg, sizeof(char[MAX_STRING_LEN]),
"rlm_pap: mschap xlat failed");
@@ -765,7 +765,7 @@ static int pap_auth_lm(REQUEST *request, VALUE_PAIR *vp, char *fmsg)
}
strlcpy(buff2, "%{mschap:LM-Hash %{User-Password}}", sizeof(buff2));
- if (!radius_xlat(charbuf,sizeof(charbuf),buff2,request,NULL)){
+ if (!radius_xlat(charbuf,sizeof(charbuf),buff2,request,NULL,NULL)){
RDEBUG("mschap xlat failed");
snprintf(fmsg, sizeof(char[MAX_STRING_LEN]),
"rlm_pap: mschap xlat failed");
View
4 src/modules/rlm_perl/rlm_perl.c
@@ -321,7 +321,7 @@ static XS(XS_radiusd_radlog)
* The xlat function
*/
static size_t perl_xlat(void *instance, REQUEST *request, char *fmt, char *out,
- size_t freespace, RADIUS_ESCAPE_STRING func)
+ size_t freespace)
{
PERL_INST *inst= (PERL_INST *) instance;
@@ -334,7 +334,7 @@ static size_t perl_xlat(void *instance, REQUEST *request, char *fmt, char *out,
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- if (!radius_xlat(params, sizeof(params), fmt, request, func)) {
+ if (!radius_xlat(params, sizeof(params), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rlm_perl: xlat failed.");
return 0;
}
View
6 src/modules/rlm_policy/evaluate.c
@@ -401,7 +401,7 @@ static int evaluate_print(policy_state_t *state, const policy_item_t *item)
char buffer[1024];
radius_xlat(buffer, sizeof(buffer), this->rhs,
- state->request, NULL);
+ state->request, NULL, NULL);
fprintf(fr_log_fp, "%s", buffer);
if (!strchr(buffer, '\n')) fprintf(fr_log_fp, "\n");
}
@@ -533,7 +533,7 @@ static int evaluate_condition(policy_state_t *state, const policy_item_t *item)
strlcpy(lhs_buffer, data, sizeof(lhs_buffer)); /* FIXME: yuck */
} else if (this->lhs_type == POLICY_LEX_DOUBLE_QUOTED_STRING) {
if (radius_xlat(lhs_buffer, sizeof(lhs_buffer), this->lhs,
- state->request, NULL) > 0) {
+ state->request, NULL, NULL) > 0) {
data = lhs_buffer;
}
}
@@ -824,7 +824,7 @@ static VALUE_PAIR *assign2vp(REQUEST *request,
if ((assign->rhs_type == POLICY_LEX_DOUBLE_QUOTED_STRING) &&
(strchr(assign->rhs, '%') != NULL)) {
radius_xlat(buffer, sizeof(buffer), assign->rhs,
- request, NULL);
+ request, NULL, NULL);
value = buffer;
}
View
8 src/modules/rlm_radutmp/rlm_radutmp.c
@@ -342,7 +342,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
/*
* Get the utmp filename, via xlat.
*/
- radius_xlat(filename, sizeof(filename), inst->filename, request, NULL);
+ radius_xlat(filename, sizeof(filename), inst->filename, request, NULL, NULL);
/*
* See if this was a reboot.
@@ -383,7 +383,7 @@ static int radutmp_accounting(void *instance, REQUEST *request)
* they told us to use.
*/
*buffer = '\0';
- radius_xlat(buffer, sizeof(buffer), inst->username, request, NULL);
+ radius_xlat(buffer, sizeof(buffer), inst->username, request, NULL, NULL);
/*
* Copy the previous translated user name.
@@ -574,7 +574,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
/*
* Get the filename, via xlat.
*/
- radius_xlat(filename, sizeof(filename), inst->filename, request, NULL);
+ radius_xlat(filename, sizeof(filename), inst->filename, request, NULL, NULL);
if ((fd = open(filename, O_RDWR)) < 0) {
/*
@@ -595,7 +595,7 @@ static int radutmp_checksimul(void *instance, REQUEST *request)
}
*login = '\0';
- radius_xlat(login, sizeof(login), inst->username, request, NULL);
+ radius_xlat(login, sizeof(login), inst->username, request, NULL, NULL);
if (!*login) {
close(fd);
return RLM_MODULE_NOOP;
View
14 src/modules/rlm_redis/rlm_redis.c
@@ -137,7 +137,8 @@ static void *redis_create_conn(void *ctx)
return dissocket;
}
-static size_t redis_escape_func(char *out, size_t outlen, const char *in)
+static size_t redis_escape_func(UNUSED REQUEST *request,
+ char *out, size_t outlen, const char *in, UNUSED void *arg)
{
size_t len = 0;
@@ -184,9 +185,8 @@ static size_t redis_escape_func(char *out, size_t outlen, const char *in)
}
-static int redis_xlat(void *instance, REQUEST *request,
- char *fmt, char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+static size_t redis_xlat(void *instance, REQUEST *request,
+ const char *fmt, char *out, size_t freespace)
{
REDIS_INST *inst = instance;
REDISSOCK *dissocket;
@@ -196,7 +196,7 @@ static int redis_xlat(void *instance, REQUEST *request,
char querystr[MAX_QUERY_LEN];
if (!radius_xlat(querystr, sizeof(querystr), fmt, request,
- redis_escape_func)) {
+ redis_escape_func, inst)) {
radlog(L_ERR, "rlm_redis (%s): xlat failed.",
inst->xlat_name);
@@ -263,7 +263,7 @@ static int redis_detach(void *instance)
fr_connection_pool_delete(inst->pool);
if (inst->xlat_name) {
- xlat_unregister(inst->xlat_name, (RAD_XLAT_FUNC)redis_xlat, instance);
+ xlat_unregister(inst->xlat_name, redis_xlat, instance);
free(inst->xlat_name);
}
free(inst->xlat_name);
@@ -366,7 +366,7 @@ static int redis_instantiate(CONF_SECTION *conf, void **instance)
xlat_name = cf_section_name1(conf);
inst->xlat_name = strdup(xlat_name);
- xlat_register(inst->xlat_name, (RAD_XLAT_FUNC)redis_xlat, inst);
+ xlat_register(inst->xlat_name, redis_xlat, inst);
inst->pool = fr_connection_pool_init(conf, inst,
redis_create_conn, NULL,
View
2 src/modules/rlm_rediswho/rlm_rediswho.c
@@ -68,7 +68,7 @@ static int rediswho_command(const char *fmt, REDISSOCK **dissocket_p,
* Do an xlat on the provided string
*/
if (request) {
- if (!radius_xlat(query, sizeof (query), fmt, request, NULL)) {
+ if (!radius_xlat(query, sizeof (query), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rediswho_command: xlat failed on: '%s'", query);
return 0;
}
View
12 src/modules/rlm_rest/rest.c
@@ -1987,15 +1987,15 @@ int rest_request_config(rlm_rest_t *instance, rlm_rest_section_t *section,
if (section->username) {
radius_xlat(buffer, sizeof(buffer),
- section->username, request, NULL);
+ section->username, request, NULL, NULL);
ret = curl_easy_setopt(candle, CURLOPT_USERNAME,
buffer);
if (ret != CURLE_OK) goto error;
}
if (section->password) {
radius_xlat(buffer, sizeof(buffer),
- section->password, request, NULL);
+ section->password, request, NULL, NULL);
ret = curl_easy_setopt(candle, CURLOPT_PASSWORD,
buffer);
@@ -2009,7 +2009,7 @@ int rest_request_config(rlm_rest_t *instance, rlm_rest_section_t *section,
if (section->username) {
radius_xlat(buffer, sizeof(buffer),
- section->username, request, NULL);
+ section->username, request, NULL, NULL);
ret = curl_easy_setopt(candle,
CURLOPT_TLSAUTH_USERNAME,
@@ -2018,7 +2018,7 @@ int rest_request_config(rlm_rest_t *instance, rlm_rest_section_t *section,
}
if (section->password) {
radius_xlat(buffer, sizeof(buffer),
- section->password, request, NULL);
+ section->password, request, NULL, NULL);
ret = curl_easy_setopt(candle,
CURLOPT_TLSAUTH_PASSWORD,
@@ -2373,12 +2373,12 @@ ssize_t rest_uri_build(rlm_rest_t *instance, rlm_rest_section_t *section,
path = (q + 1);
out = buffer;
- out += radius_xlat(out, bufsize, scheme, request, NULL);
+ out += radius_xlat(out, bufsize, scheme, request, NULL, NULL);
free(scheme);
out += radius_xlat(out, (bufsize - (buffer - out)), path, request,
- rest_uri_escape);
+ rest_uri_escape, NULL);
return (buffer - out);
}
View
11 src/modules/rlm_soh/rlm_soh.c
@@ -30,15 +30,15 @@ RCSID("$Id$")
typedef struct rlm_soh_t {
- const char *xlat_name;
+ char *xlat_name;
int dhcp;
} rlm_soh_t;
/*
* Not sure how to make this useful yet...
*/
-static size_t soh_xlat(UNUSED void *instance, REQUEST *request, char *fmt, char *out, size_t outlen, UNUSED RADIUS_ESCAPE_STRING func) {
+static size_t soh_xlat(UNUSED void *instance, REQUEST *request, const char *fmt, char *out, size_t outlen) {
VALUE_PAIR* vp[6];
const char *osname;
@@ -116,6 +116,7 @@ static int soh_detach(void *instance) {
}
static int soh_instantiate(CONF_SECTION *conf, void **instance) {
+ const char *name;
rlm_soh_t *inst;
inst = *instance = rad_malloc(sizeof(*inst));
@@ -129,9 +130,9 @@ static int soh_instantiate(CONF_SECTION *conf, void **instance) {
return -1;
}
- inst->xlat_name = cf_section_name2(conf);
- if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
- inst->xlat_name = strdup(inst->xlat_name);
+ name = cf_section_name2(conf);
+ if (!name) name = cf_section_name1(conf);
+ inst->xlat_name = strdup(name);
xlat_register(inst->xlat_name, soh_xlat, inst);
return 0;
View
49 src/modules/rlm_sql/rlm_sql.c
@@ -39,8 +39,6 @@ RCSID("$Id$")
#include "rlm_sql.h"
-static char *allowed_chars = NULL;
-
static const CONF_PARSER section_config[] = {
{ "reference", PW_TYPE_STRING_PTR,
offsetof(rlm_sql_config_section_t, reference), NULL, ".query"},
@@ -125,7 +123,7 @@ static int fallthrough(VALUE_PAIR *vp)
* Yucky prototype.
*/
static int generate_sql_clients(SQL_INST *inst);
-static size_t sql_escape_func(char *out, size_t outlen, const char *in);
+static size_t sql_escape_func(REQUEST *, char *out, size_t outlen, const char *in, void *arg);
/*
* SQL xlat function
@@ -134,9 +132,8 @@ static size_t sql_escape_func(char *out, size_t outlen, const char *in);
* for inserts, updates and deletes the number of rows afftected will be
* returned instead.
*/
-static int sql_xlat(void *instance, REQUEST *request,
- char *fmt, char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+static size_t sql_xlat(void *instance, REQUEST *request,
+ const char *fmt, char *out, size_t freespace)
{
SQLSOCK *sqlsocket;
SQL_ROW row;
@@ -156,7 +153,7 @@ static int sql_xlat(void *instance, REQUEST *request,
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- if (!radius_xlat(querystr, sizeof(querystr), fmt, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), fmt, request, sql_escape_func, inst)) {
radlog(L_ERR, "rlm_sql (%s): xlat failed.",
inst->config->xlat_name);
return 0;
@@ -404,8 +401,9 @@ static int generate_sql_clients(SQL_INST *inst)
/*
* Translate the SQL queries.
*/
-static size_t sql_escape_func(char *out, size_t outlen, const char *in)
+static size_t sql_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, const char *in, void *arg)
{
+ SQL_INST *inst = arg;
size_t len = 0;
while (in[0]) {
@@ -414,7 +412,7 @@ static size_t sql_escape_func(char *out, size_t outlen, const char *in)
* mime-encoded equivalents.
*/
if ((in[0] < 32) ||
- strchr(allowed_chars, *in) == NULL) {
+ strchr(inst->config->allowed_chars, *in) == NULL) {
/*
* Only 3 or less bytes available.
*/
@@ -472,7 +470,7 @@ int sql_set_user(SQL_INST *inst, REQUEST *request, char *sqlusername, const char
if (username != NULL) {
strlcpy(tmpuser, username, sizeof(tmpuser));
} else if (strlen(inst->config->query_user)) {
- radius_xlat(tmpuser, sizeof(tmpuser), inst->config->query_user, request, NULL);
+ radius_xlat(tmpuser, sizeof(tmpuser), inst->config->query_user, request, NULL, NULL);
} else {
return 0;
}
@@ -521,7 +519,7 @@ static int sql_get_grouplist (SQL_INST *inst, SQLSOCK *sqlsocket, REQUEST *reque
(inst->config->groupmemb_query[0] == 0))
return 0;
- if (!radius_xlat(querystr, sizeof(querystr), inst->config->groupmemb_query, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), inst->config->groupmemb_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "xlat \"%s\" failed.",
inst->config->groupmemb_query);
return -1;
@@ -672,7 +670,7 @@ static int rlm_sql_process_groups(SQL_INST *inst, REQUEST *request, SQLSOCK *sql
return -1;
}
pairadd(&request->packet->vps, sql_group);
- if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_check_query, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_check_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request,
"Error generating query; rejecting user");
/* Remove the grouup we added above */
@@ -700,7 +698,7 @@ static int rlm_sql_process_groups(SQL_INST *inst, REQUEST *request, SQLSOCK *sql
/*
* Now get the reply pairs since the paircompare matched
*/
- if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_reply_query, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_reply_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "Error generating query; rejecting user");
/* Remove the grouup we added above */
pairdelete(&request->packet->vps, PW_SQL_GROUP, 0);
@@ -735,7 +733,7 @@ static int rlm_sql_process_groups(SQL_INST *inst, REQUEST *request, SQLSOCK *sql
/*
* Now get the reply pairs since the paircompare matched
*/
- if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_reply_query, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_group_reply_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "Error generating query; rejecting user");
/* Remove the grouup we added above */
pairdelete(&request->packet->vps, PW_SQL_GROUP, 0);
@@ -784,7 +782,7 @@ static int rlm_sql_detach(void *instance)
if (inst->pool) sql_poolfree(inst);
if (inst->config->xlat_name) {
- xlat_unregister(inst->config->xlat_name,(RAD_XLAT_FUNC)sql_xlat, instance);
+ xlat_unregister(inst->config->xlat_name, sql_xlat, instance);
free(inst->config->xlat_name);
}
@@ -810,12 +808,6 @@ static int rlm_sql_detach(void *instance)
free(*p);
*p = NULL;
}
- /*
- * Catch multiple instances of the module.
- */
- if (allowed_chars == inst->config->allowed_chars) {
- allowed_chars = NULL;
- }
free(inst->config);
inst->config = NULL;
}
@@ -942,7 +934,7 @@ static int rlm_sql_instantiate(CONF_SECTION * conf, void **instance)
* Register the SQL xlat function
*/
inst->config->xlat_name = strdup(xlat_name);
- xlat_register(xlat_name, (RAD_XLAT_FUNC)sql_xlat, inst);
+ xlat_register(xlat_name, sql_xlat, inst);
/*
* Sanity check for crazy people.
@@ -1004,7 +996,6 @@ static int rlm_sql_instantiate(CONF_SECTION * conf, void **instance)
goto error;
}
}
- allowed_chars = inst->config->allowed_chars;
*instance = inst;
@@ -1061,7 +1052,7 @@ static int rlm_sql_authorize(void *instance, REQUEST * request)
/*
* Alright, start by getting the specific entry for the user
*/
- if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_check_query, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_check_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "Error generating query; rejecting user");
sql_release_socket(inst, sqlsocket);
/* Remove the username we (maybe) added above */
@@ -1090,7 +1081,7 @@ static int rlm_sql_authorize(void *instance, REQUEST * request)
/*
* Now get the reply pairs since the paircompare matched
*/
- if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_reply_query, request, sql_escape_func)) {
+ if (!radius_xlat(querystr, sizeof(querystr), inst->config->authorize_reply_query, request, sql_escape_func, inst)) {
radlog_request(L_ERR, 0, request, "Error generating query; rejecting user");
sql_release_socket(inst, sqlsocket);
/* Remove the username we (maybe) added above */
@@ -1238,7 +1229,7 @@ static int rlm_sql_redundant(SQL_INST *inst, REQUEST *request,
*p++ = '.';
if (radius_xlat(p, (sizeof(path) - (p - path)) - 1,
- section->reference, request, NULL) < 0)
+ section->reference, request, NULL, NULL) < 0)
return RLM_MODULE_FAIL;
item = cf_reference_item(NULL, section->cs, path);
@@ -1266,7 +1257,7 @@ static int rlm_sql_redundant(SQL_INST *inst, REQUEST *request,
goto null_query;
radius_xlat(querystr, sizeof(querystr), value, request,
- sql_escape_func);
+ sql_escape_func, inst);
if (!*querystr)
goto null_query;
@@ -1380,7 +1371,7 @@ static int rlm_sql_checksimul(void *instance, REQUEST * request) {
if(sql_set_user(inst, request, sqlusername, NULL) < 0)
return RLM_MODULE_FAIL;
- radius_xlat(querystr, sizeof(querystr), inst->config->simul_count_query, request, sql_escape_func);
+ radius_xlat(querystr, sizeof(querystr), inst->config->simul_count_query, request, sql_escape_func, inst);
/* initialize the sql socket */
sqlsocket = sql_get_socket(inst);
@@ -1424,7 +1415,7 @@ static int rlm_sql_checksimul(void *instance, REQUEST * request) {
return RLM_MODULE_OK;
}
- radius_xlat(querystr, sizeof(querystr), inst->config->simul_verify_query, request, sql_escape_func);
+ radius_xlat(querystr, sizeof(querystr), inst->config->simul_verify_query, request, sql_escape_func, inst);
if(rlm_sql_select_query(&sqlsocket, inst, querystr)) {
sql_release_socket(inst, sqlsocket);
return RLM_MODULE_FAIL;
View
2 src/modules/rlm_sql/rlm_sql.h
@@ -106,7 +106,7 @@ struct sql_inst {
int (*sql_set_user)(SQL_INST *inst, REQUEST *request, char *sqlusername, const char *username);
SQLSOCK *(*sql_get_socket)(SQL_INST * inst);
int (*sql_release_socket)(SQL_INST * inst, SQLSOCK * sqlsocket);
- size_t (*sql_escape_func)(char *out, size_t outlen, const char *in);
+ size_t (*sql_escape_func)(REQUEST *, char *out, size_t outlen, const char *in, void *arg);
int (*sql_query)(SQLSOCK **sqlsocket, SQL_INST *inst, char *query);
int (*sql_select_query)(SQLSOCK **sqlsocket, SQL_INST *inst, char *query);
int (*sql_fetch_row)(SQLSOCK **sqlsocket, SQL_INST *inst);
View
2 src/modules/rlm_sql/sql.c
@@ -424,7 +424,7 @@ void rlm_sql_query_log(SQL_INST *inst, REQUEST *request,
if (!filename) return;
- if (!radius_xlat(buffer, sizeof(buffer), filename, request, NULL)) {
+ if (!radius_xlat(buffer, sizeof(buffer), filename, request, NULL, NULL)) {
radlog(L_ERR, "rlm_sql (%s): xlat failed.",
inst->config->xlat_name);
return;
View
19 src/modules/rlm_sql_log/rlm_sql_log.c
@@ -72,7 +72,6 @@ static const CONF_PARSER module_config[] = {
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
-static char *allowed_chars = NULL;
/*
* Do any per-module initialization that is separate to each
@@ -108,7 +107,6 @@ static int sql_log_instantiate(CONF_SECTION *conf, void **instance)
}
inst->conf_section = conf;
- allowed_chars = inst->allowed_chars;
*instance = inst;
return 0;
}
@@ -143,16 +141,16 @@ static int sql_log_detach(void *instance)
free(*p);
*p = NULL;
}
- allowed_chars = NULL;
free(inst);
return 0;
}
/*
* Translate the SQL queries.
*/
-static size_t sql_escape_func(char *out, size_t outlen, const char *in)
+static size_t sql_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, const char *in, void *arg)
{
+ rlm_sql_log_t *inst = (rlm_sql_log_t *)arg;
int len = 0;
while (in[0]) {
@@ -161,7 +159,7 @@ static size_t sql_escape_func(char *out, size_t outlen, const char *in)
* mime-encoded equivalents.
*/
if ((in[0] < 32) ||
- strchr(allowed_chars, *in) == NULL) {
+ strchr(inst->allowed_chars, *in) == NULL) {
/*
* Only 3 or less bytes available.
*/
@@ -197,8 +195,9 @@ static size_t sql_escape_func(char *out, size_t outlen, const char *in)
return len;
}
-static size_t sql_utf8_escape_func(char *out, size_t outlen, const char *in)
+static size_t sql_utf8_escape_func(UNUSED REQUEST *request, char *out, size_t outlen, const char *in, void *arg)
{
+ rlm_sql_log_t *inst = (rlm_sql_log_t *)arg;
size_t len = 0;
size_t utf8 = 0;
@@ -226,7 +225,7 @@ static size_t sql_utf8_escape_func(char *out, size_t outlen, const char *in)
* mime-encoded equivalents.
*/
if ((in[0] < 32) ||
- strchr(allowed_chars, *in) == NULL) {
+ strchr(inst->allowed_chars, *in) == NULL) {
/*
* Only 3 or less bytes available.
*/