# group = freerad
#
+ # If logging via syslog, the facility can be set here. Otherwise
+ # the syslog_facility option in radiusd.conf will be used.
+ #
+ # syslog_facility = daemon
+
+ #
# The default format string.
format = "This is a log message for %{User-Name}"
static const char *sbindir = NULL;
static const char *run_dir = NULL;
static char *syslog_facility = NULL;
-static const FR_NAME_NUMBER str2fac[] = {
+
+/*
+ * Syslog facility table.
+ */
+const FR_NAME_NUMBER syslog_str2fac[] = {
#ifdef LOG_KERN
{ "kern", LOG_KERN },
#endif
cf_section_free(&cs);
return -1;
}
- mainconfig.syslog_facility = fr_str2int(str2fac, syslog_facility, -1);
+ mainconfig.syslog_facility = fr_str2int(syslog_str2fac, syslog_facility, -1);
if (mainconfig.syslog_facility < 0) {
fprintf(stderr, "radiusd: Error: Unknown syslog_facility %s\n",
syslog_facility);
#endif
/*
+ * Syslog facilities from main/mainconfig.c
+ */
+extern const FR_NAME_NUMBER syslog_str2fac[];
+
+/*
* 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;
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,
linelog_detach(inst);
return -1;
}
+#else
+ inst->facility = 0;
+
+ if (inst->syslog_facility) {
+ inst->facility = fr_str2int(syslog_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) {
#ifdef HAVE_SYSLOG_H
} else {
- syslog(LOG_INFO, "%s", line);
+ syslog(inst->facility, "%s", line);
#endif
}