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

« back to all changes in this revision

Viewing changes to src/modules/rlm_linelog/rlm_linelog.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_linelog.c
3
3
 *
4
 
 * Version:     $Id: rlm_linelog.c,v 1.16 2008/02/27 14:15:48 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_linelog.c,v 1.16 2008/02/27 14:15:48 aland Exp $")
 
25
RCSID("$Id$")
26
26
 
27
27
#include <freeradius-devel/radiusd.h>
28
28
#include <freeradius-devel/modules.h>
34
34
#ifdef HAVE_SYSLOG_H
35
35
#include <syslog.h>
36
36
 
37
 
#ifndef LOG_AUTHPRIV
38
 
#define LOG_AUTHPRIV LOG_USER
39
 
#endif
40
 
 
41
 
#ifndef LOG_PID
42
 
#define LOG_PID (0)
43
 
#endif
44
 
 
45
37
#ifndef LOG_INFO
46
38
#define LOG_INFO (0)
47
39
#endif
49
41
 
50
42
/*
51
43
 *      Define a structure for our module configuration.
52
 
 *
53
 
 *      These variables do not need to be in a structure, but it's
54
 
 *      a lot cleaner to do so, and a pointer to the structure can
55
 
 *      be used as the instance handle.
56
44
 */
57
45
typedef struct rlm_linelog_t {
 
46
        CONF_SECTION    *cs;
58
47
        char            *filename;
59
48
        char            *line;
 
49
        char            *reference;
60
50
} rlm_linelog_t;
61
51
 
62
52
/*
73
63
          offsetof(rlm_linelog_t,filename), NULL,  NULL},
74
64
        { "format",  PW_TYPE_STRING_PTR,
75
65
          offsetof(rlm_linelog_t,line), NULL,  NULL},
 
66
        { "reference",  PW_TYPE_STRING_PTR,
 
67
          offsetof(rlm_linelog_t,reference), NULL,  NULL},
76
68
        { NULL, -1, 0, NULL, NULL }             /* end the list */
77
69
};
78
70
 
81
73
{
82
74
        rlm_linelog_t *inst = instance;
83
75
 
84
 
 
85
76
        free(inst);
86
77
        return 0;
87
78
}
114
105
                return -1;
115
106
        }
116
107
 
117
 
#ifdef HAVE_SYSLOG_H
 
108
#ifndef HAVE_SYSLOG_H
118
109
        if (strcmp(inst->filename, "syslog") == 0) {
119
110
                radlog(L_ERR, "rlm_linelog: Syslog output is not supported");
120
111
                linelog_detach(inst);
128
119
                return -1;
129
120
        }
130
121
 
 
122
        inst->cs = conf;
131
123
        *instance = inst;
132
124
 
133
125
        return 0;
200
192
        int fd = -1;
201
193
        char buffer[4096];
202
194
        char line[1024];
203
 
        rlm_linelog_t *inst;
204
 
 
205
 
        inst = (rlm_linelog_t*) instance;
206
 
 
 
195
        rlm_linelog_t *inst = (rlm_linelog_t*) instance;
 
196
        const char *value = inst->line;
 
197
 
 
198
        if (inst->reference) {
 
199
                CONF_ITEM *ci;
 
200
                CONF_PAIR *cp;
 
201
 
 
202
                radius_xlat(line + 1, sizeof(line) - 2, inst->reference,
 
203
                            request, linelog_escape_func);
 
204
                line[0] = '.';  /* force to be in current section */
 
205
 
 
206
                /*
 
207
                 *      Don't allow it to go back up
 
208
                 */
 
209
                if (line[1] == '.') goto do_log;
 
210
 
 
211
                ci = cf_reference_item(NULL, inst->cs, line);
 
212
                if (!ci) {
 
213
                        RDEBUG2("No such entry \"%s\"", line);
 
214
                        return RLM_MODULE_NOOP;
 
215
                }
 
216
 
 
217
                if (!cf_item_is_pair(ci)) {
 
218
                        RDEBUG2("Entry \"%s\" is not a variable assignment ", line);
 
219
                        goto do_log;
 
220
                }
 
221
 
 
222
                cp = cf_itemtopair(ci);
 
223
                value = cf_pair_value(cp);
 
224
                if (!value) {
 
225
                        RDEBUG2("Entry \"%s\" has no value", line);
 
226
                        goto do_log;
 
227
                }
 
228
 
 
229
                /*
 
230
                 *      Value exists, but is empty.  Don't log anything.
 
231
                 */
 
232
                if (!*value) return RLM_MODULE_OK;
 
233
        }
 
234
 
 
235
 do_log:
207
236
        /*
208
237
         *      FIXME: Check length.
209
238
         */
222
251
        /*
223
252
         *      FIXME: Check length.
224
253
         */
225
 
        radius_xlat(line, sizeof(line) - 1, inst->line, request,
 
254
        radius_xlat(line, sizeof(line) - 1, value, request,
226
255
                    linelog_escape_func);
227
256
 
228
257
        if (fd >= 0) {
233
262
 
234
263
#ifdef HAVE_SYSLOG_H
235
264
        } else {
236
 
                syslog(LOG_AUTHPRIV | LOG_PID | LOG_INFO, "%s", line);
 
265
                syslog(LOG_INFO, "%s", line);
237
266
#endif
238
267
        }
239
268
 
259
288
                do_linelog,     /* pre-proxy */
260
289
                do_linelog,     /* post-proxy */
261
290
                do_linelog      /* post-auth */
 
291
#ifdef WITH_COA
 
292
                , do_linelog,   /* recv-coa */
 
293
                do_linelog      /* send-coa */
 
294
#endif
262
295
        },
263
296
};