int radius_xlat(char * out, int outlen, const char *fmt,
REQUEST * request, RADIUS_ESCAPE_STRING func, void *funcarg);
-typedef size_t (*RAD_XLAT_FUNC)(void *instance, REQUEST *, const char *, char *, size_t, RADIUS_ESCAPE_STRING func);
+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,
*/
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;
*/
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;
}
}
- return func(out, outlen, value);
+ strlcpy(out, value, outlen);
+
+ return strlen(out);
}
*/
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;
* 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;
* 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;
/**
* @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) {
* 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;
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);
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);
}
localvp.type = da->type;
- return valuepair2str(out, outlen, &localvp,
- da->type, func);
+ return valuepair2str(out, outlen, &localvp, da->type);
}
/*
/*
* 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;
* @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;
* @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);
* @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;
return 0;
}
- return valuepair2str(out, outlen, (*pvp), (*pvp)->type, func);
+ return valuepair2str(out, outlen, (*pvp), (*pvp)->type);
}
#endif
* 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;
* @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;
* 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);
* 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;
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(q, freespace, tmpbuf);
+ 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);
* Allow single attribute values to be retrieved from the cache.
*/
static size_t cache_xlat(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t freespace)
{
rlm_cache_entry_t *c;
rlm_cache_t *inst = instance;
* 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;
* 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;
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- if (!radius_xlat(buffer, sizeof(buffer), fmt, request, func, NULL)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
return 0;
*
*/
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, NULL)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
return 0;
* 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];
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- len = radius_xlat(buffer, sizeof(buffer), fmt, request, func, NULL);
+ len = radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL);
if (!len) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
* 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];
if (outlen <= 1) return 0;
- len = radius_xlat(buffer, sizeof(buffer), fmt, request, func, NULL);
+ len = radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL);
if (!len) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
* 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;
if (outlen <= 1) return 0;
- len = radius_xlat(buffer, sizeof(buffer), fmt, request, func, NULL);
+ len = radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL);
if (!len) {
radlog(L_ERR, "rlm_expr: xlat failed.");
*out = '\0';
* 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, NULL)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
*out = '\0';
return 0;
}
* 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, NULL)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
*out = '\0';
return 0;
}
* 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, NULL)) {
+ if (!radius_xlat(buffer, sizeof(buffer), fmt, request, NULL, NULL)) {
*out = '\0';
return 0;
}
#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);
* 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;
* 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;
response = NULL;
- func = func; /* -Wunused */
-
/*
* Challenge means MS-CHAPv1 challenge, or
* hash of MS-CHAPv2 challenge, and peer challenge.
* 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;
/*
* Do an xlat on the provided string (nice recursive operation).
*/
- if (!radius_xlat(params, sizeof(params), fmt, request, func, NULL)) {
+ if (!radius_xlat(params, sizeof(params), fmt, request, NULL, NULL)) {
radlog(L_ERR, "rlm_perl: xlat failed.");
return 0;
}
}
static size_t redis_xlat(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t freespace)
{
REDIS_INST *inst = instance;
REDISSOCK *dissocket;
/*
* Not sure how to make this useful yet...
*/
-static size_t soh_xlat(UNUSED void *instance, REQUEST *request, const 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;
* returned instead.
*/
static size_t sql_xlat(void *instance, REQUEST *request,
- const char *fmt, char *out, size_t freespace,
- UNUSED RADIUS_ESCAPE_STRING func)
+ const char *fmt, char *out, size_t freespace)
{
SQLSOCK *sqlsocket;
SQL_ROW row;