Hi,

On Sun, Feb 05, 2012 at 06:31:02PM +0400, Andranik Hayrapetyan wrote:
> It sends f-ticks to syslog, and syslog place f-ticks in /var/log/massage
> withe many other log information.
> How can I set here facility for syslog (local0 eg.) , to be able to control
> the f-ticks and place them to the file I want or send to eduroam f-ticks
> server???

There's currently no option to set the syslog facility
specifically in rlm_linelog. It will always log to the same
syslog_facility set in radiusd.conf.

If you want it different to the main server syslog, try the patch
below (majority of which taken from mainconfig.c), or pull from
https://github.com/mcnewton/freeradius-server/commit/089c108c472a6a9d2a21ae86b41343b06274f95d

In modules/linelog, set:

linelog {
  filename = syslog
  syslog_facility = local0
  ...
}

Alternatively, use syslog-ng (for example) and filter based on the
content of the log string.

Cheers,

Matthew


>From 089c108c472a6a9d2a21ae86b41343b06274f95d Mon Sep 17 00:00:00 2001
From: Matthew Newton <m...@leicester.ac.uk>
Date: Sun, 5 Feb 2012 23:05:27 +0000
Subject: [PATCH] Add syslog_facility option to rlm_linelog

---
 src/modules/rlm_linelog/rlm_linelog.c |   86 ++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 1 deletions(-)

diff --git a/src/modules/rlm_linelog/rlm_linelog.c 
b/src/modules/rlm_linelog/rlm_linelog.c
index 1257555..98b264d 100644
--- a/src/modules/rlm_linelog/rlm_linelog.c
+++ b/src/modules/rlm_linelog/rlm_linelog.c
@@ -48,11 +48,80 @@ RCSID("$Id$")
 #endif
 
 /*
+ * Syslog facilities taken from main/mainconfig.c
+ * Alternatively, it could be not declared static there, and
+ * be declared here as extern const FR_NAME_NUMBER str2fac[];
+ */
+static const FR_NAME_NUMBER str2fac[] = {
+#ifdef LOG_KERN
+       { "kern", LOG_KERN },
+#endif
+#ifdef LOG_USER
+       { "user", LOG_USER },
+#endif
+#ifdef LOG_MAIL
+       { "mail", LOG_MAIL },
+#endif
+#ifdef LOG_DAEMON
+       { "daemon", LOG_DAEMON },
+#endif
+#ifdef LOG_AUTH
+       { "auth", LOG_AUTH },
+#endif
+#ifdef LOG_LPR
+       { "lpr", LOG_LPR },
+#endif
+#ifdef LOG_NEWS
+       { "news", LOG_NEWS },
+#endif
+#ifdef LOG_UUCP
+       { "uucp", LOG_UUCP },
+#endif
+#ifdef LOG_CRON
+       { "cron", LOG_CRON },
+#endif
+#ifdef LOG_AUTHPRIV
+       { "authpriv", LOG_AUTHPRIV },
+#endif
+#ifdef LOG_FTP
+       { "ftp", LOG_FTP },
+#endif
+#ifdef LOG_LOCAL0
+       { "local0", LOG_LOCAL0 },
+#endif
+#ifdef LOG_LOCAL1
+       { "local1", LOG_LOCAL1 },
+#endif
+#ifdef LOG_LOCAL2
+       { "local2", LOG_LOCAL2 },
+#endif
+#ifdef LOG_LOCAL3
+       { "local3", LOG_LOCAL3 },
+#endif
+#ifdef LOG_LOCAL4
+       { "local4", LOG_LOCAL4 },
+#endif
+#ifdef LOG_LOCAL5
+       { "local5", LOG_LOCAL5 },
+#endif
+#ifdef LOG_LOCAL6
+       { "local6", LOG_LOCAL6 },
+#endif
+#ifdef LOG_LOCAL7
+       { "local7", LOG_LOCAL7 },
+#endif
+       { NULL, -1 }
+};
+
+
+/*
  *     Define a structure for our module configuration.
  */
 typedef struct rlm_linelog_t {
        CONF_SECTION    *cs;
        char            *filename;
+       char            *syslog_facility;
+       int             facility;
        int             permissions;
        char            *group;
        char            *line;
@@ -71,6 +140,8 @@ typedef struct rlm_linelog_t {
 static const CONF_PARSER module_config[] = {
        { "filename",  PW_TYPE_STRING_PTR,
          offsetof(rlm_linelog_t,filename), NULL,  NULL},
+       { "syslog_facility",  PW_TYPE_STRING_PTR,
+         offsetof(rlm_linelog_t,syslog_facility), NULL,  NULL},
        { "permissions",  PW_TYPE_INTEGER,
          offsetof(rlm_linelog_t,permissions), NULL,  "0600"},
        { "group",  PW_TYPE_STRING_PTR,
@@ -125,6 +196,19 @@ static int linelog_instantiate(CONF_SECTION *conf, void 
**instance)
                linelog_detach(inst);
                return -1;
        }
+#else
+       inst->facility = 0;
+
+       if (inst->syslog_facility) {
+               inst->facility = fr_str2int(str2fac, inst->syslog_facility, -1);
+               if (inst->facility < 0) {
+                       radlog(L_ERR, "rlm_linelog: Bad syslog facility '%s'", 
inst->syslog_facility);
+                       linelog_detach(inst);
+                       return -1;
+               }
+       }
+
+       inst->facility |= LOG_INFO;
 #endif
 
        if (!inst->line) {
@@ -314,7 +398,7 @@ static int do_linelog(void *instance, REQUEST *request)
 
 #ifdef HAVE_SYSLOG_H
        } else {
-               syslog(LOG_INFO, "%s", line);
+               syslog(inst->facility, "%s", line);
 #endif
        }
 
-- 
1.7.2.5


-- 
Matthew Newton, Ph.D. <m...@le.ac.uk>

Systems Architect (UNIX and Networks), Network Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom

For IT help contact helpdesk extn. 2253, <ith...@le.ac.uk>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to