~ubuntu-branches/ubuntu/natty/freeradius/natty-updates

« back to all changes in this revision

Viewing changes to src/modules/rlm_attr_rewrite/rlm_attr_rewrite.c

  • Committer: Bazaar Package Importer
  • Author(s): Josip Rodin
  • Date: 2009-11-23 03:57:37 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20091123035737-zsgtzhfych8hir68
Tags: 2.1.7+dfsg-1
* Adopting the package, closes: #536623.
* New upstream version, closes: #513484.
  + Fixes the blooper in unlang evaluation logic, closes: #526175.
* Used quilt (and added README.source), and moved upstream file patching
  into debian/patches/. The source is no longer in collab-maint git
  (to make it simpler for me to finally get this out the door), but
  kept the .gitignore should we need that again.
* Dropped the dialup_admin/bin/backup_radacct patch (integrated upstream).
* Dropped the raddb/Makefile patch (problem no longer exists upstream).
* Dropped the lib/packet.c lib/radius.c main/listen.c patches (was from
  upstream 2.0.5 anyway).
* Dropped references to otp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Dropped references to snmp.conf, it no longer exists upstream.
  Keep removing the conffile statoverride in prerm.
* Ship /etc/freeradius/modules/* in the freeradius package.
* Stop shipping sites-enabled symlinks in the package and instead create
  them only on initial install, thanks to Matej Vela, closes: #533396.
* Add export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" to the init script
  at the request of John Morrissey, closes: #550143.
* Stop installing /var/run/freeradius in the package to silence Lintian.
  The init script already recreates it at will.
* Remove executable bit from example.pl to silence Lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * rlm_attr_rewrite.c
3
3
 *
4
 
 * Version:  $Id: rlm_attr_rewrite.c,v 1.47 2008/02/09 08:00:55 aland Exp $
 
4
 * Version:  $Id$
5
5
 *
6
6
 *   This program is free software; you can redistribute it and/or modify
7
7
 *   it under the terms of the GNU General Public License as published by
22
22
 */
23
23
 
24
24
#include <freeradius-devel/ident.h>
25
 
RCSID("$Id: rlm_attr_rewrite.c,v 1.47 2008/02/09 08:00:55 aland Exp $")
 
25
RCSID("$Id$")
26
26
 
27
27
#include <freeradius-devel/radiusd.h>
28
28
#include <freeradius-devel/modules.h>
42
42
        int  attr_num;          /* The attribute number */
43
43
        char *search;           /* The pattern to search for */
44
44
        int search_len;         /* The length of the search pattern */
45
 
        char *searchin_str;     /* The VALUE_PAIR list to search in. Can be either packet,reply,proxy,proxy_reply or config */
 
45
        char *searchin_str;     /* The VALUE_PAIR list to search in. Can be either packet,reply,proxy,proxy_reply or control (plus it's alias 'config') */
46
46
        char searchin;          /* The same as above just coded as a number for speed */
47
47
        char *replace;          /* The replacement */
48
48
        int replace_len;        /* The length of the replacement string */
120
120
                        data->searchin = RLM_REGEX_INPACKET;
121
121
                else if (strcmp(data->searchin_str, "config") == 0)
122
122
                        data->searchin = RLM_REGEX_INCONFIG;
 
123
                else if (strcmp(data->searchin_str, "control") == 0)
 
124
                        data->searchin = RLM_REGEX_INCONFIG;
123
125
                else if (strcmp(data->searchin_str, "reply") == 0)
124
126
                        data->searchin = RLM_REGEX_INREPLY;
125
127
                else if (strcmp(data->searchin_str, "proxy") == 0)
130
132
                        radlog(L_ERR, "rlm_attr_rewrite: Illegal searchin directive given. Assuming packet.");
131
133
                        data->searchin = RLM_REGEX_INPACKET;
132
134
                }
133
 
                free((char *)data->searchin_str);
134
135
        }
135
136
        dattr = dict_attrbyname(data->attribute);
136
137
        if (dattr == NULL) {
167
168
        char *ptr, *ptr2;
168
169
        char search_STR[MAX_STRING_LEN];
169
170
        char replace_STR[MAX_STRING_LEN];
170
 
        int replace_len = 0;
171
171
 
172
172
        if ((attr_vp = pairfind(request->config_items, PW_REWRITE_RULE)) != NULL){
173
173
                if (data->name == NULL || strcmp(data->name,attr_vp->vp_strvalue))
180
180
                        DEBUG2("%s: xlat on replace string failed.", data->name);
181
181
                        return ret;
182
182
                }
183
 
                replace_len = strlen(replace_STR);
184
183
                attr_vp = pairmake(data->attribute,replace_STR,0);
185
184
                if (attr_vp == NULL){
186
185
                        DEBUG2("%s: Could not add new attribute %s with value '%s'", data->name,
220
219
                DEBUG2("%s: Added attribute %s with value '%s'", data->name,data->attribute,replace_STR);
221
220
                ret = RLM_MODULE_OK;
222
221
        } else {
 
222
                int replace_len = 0;
 
223
 
223
224
                /* new_attribute = no */
224
225
                switch (data->searchin) {
225
226
                        case RLM_REGEX_INPACKET:
395
396
                DEBUG2("%s: Changed value for attribute %s from '%s' to '%s'", data->name,
396
397
                                data->attribute, attr_vp->vp_strvalue, new_str);
397
398
                if (pairparsevalue(attr_vp, new_str) == NULL) {
398
 
                        DEBUG2("%s: Could not write value '%s' into attribute %s: %s", data->name, new_str, data->attribute, librad_errstr);
 
399
                        DEBUG2("%s: Could not write value '%s' into attribute %s: %s", data->name, new_str, data->attribute, fr_strerror());
399
400
                        return ret;
400
401
                }
401
402