]>
Commit | Line | Data |
---|---|---|
f34dc1af PG |
1 | diff -Naur radsecproxy-1.5-orig/debug.c radsecproxy-1.5/debug.c |
2 | --- radsecproxy-1.5-orig/debug.c 2011-10-01 10:26:44.000000000 +0200 | |
3 | +++ radsecproxy-1.5/debug.c 2011-12-12 14:43:32.000000000 +0100 | |
4 | @@ -28,6 +28,9 @@ | |
5 | static char *debug_filepath = NULL; | |
6 | static FILE *debug_file = NULL; | |
7 | static int debug_syslogfacility = 0; | |
8 | +#if defined(WANT_FTICKS) | |
9 | +static int fticks_syslogfacility = 0; | |
10 | +#endif | |
11 | static uint8_t debug_timestamp = 0; | |
12 | ||
13 | void debug_init(char *ident) { | |
14 | @@ -64,40 +67,60 @@ | |
15 | return debug_level; | |
16 | } | |
17 | ||
18 | -int debug_set_destination(char *dest) { | |
19 | - static const char *facstrings[] = { "LOG_DAEMON", "LOG_MAIL", "LOG_USER", "LOG_LOCAL0", | |
20 | - "LOG_LOCAL1", "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4", | |
21 | - "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", NULL }; | |
22 | - static const int facvals[] = { LOG_DAEMON, LOG_MAIL, LOG_USER, LOG_LOCAL0, | |
23 | - LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, | |
24 | - LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 }; | |
25 | +int debug_set_destination(char *dest, int log_type) { | |
26 | + static const char *facstrings[] = { | |
27 | + "LOG_DAEMON", "LOG_MAIL", "LOG_USER", "LOG_LOCAL0", | |
28 | + "LOG_LOCAL1", "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4", | |
29 | + "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", NULL }; | |
30 | + static const int facvals[] = { | |
31 | + LOG_DAEMON, LOG_MAIL, LOG_USER, LOG_LOCAL0, | |
32 | + LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, | |
33 | + LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 }; | |
34 | extern int errno; | |
35 | int i; | |
36 | ||
37 | if (!strncasecmp(dest, "file:///", 8)) { | |
38 | - debug_filepath = stringcopy(dest + 7, 0); | |
39 | - debug_file = fopen(debug_filepath, "a"); | |
40 | - if (!debug_file) { | |
41 | - debug_file = stderr; | |
42 | - debugx(1, DBG_ERR, "Failed to open logfile %s\n%s", | |
43 | - debug_filepath, strerror(errno)); | |
44 | + if (log_type != LOG_TYPE_FTICKS) { | |
45 | + debug_filepath = stringcopy(dest + 7, 0); | |
46 | + debug_file = fopen(debug_filepath, "a"); | |
47 | + if (!debug_file) { | |
48 | + debug_file = stderr; | |
49 | + debugx(1, DBG_ERR, "Failed to open logfile %s\n%s", | |
50 | + debug_filepath, strerror(errno)); | |
51 | + } | |
52 | + setvbuf(debug_file, NULL, _IONBF, 0); | |
53 | + } else { | |
54 | + debug(DBG_WARN, "FTicksSyslogFacility starting with file:/// not " | |
55 | + "permitted, assuming default F-Ticks destination"); | |
56 | } | |
57 | - setvbuf(debug_file, NULL, _IONBF, 0); | |
58 | return 1; | |
59 | } | |
60 | - if (!strncasecmp(dest, "x-syslog://", 11)) { | |
61 | - dest += 11; | |
62 | - if (*dest == '/') | |
63 | - dest++; | |
64 | + if (!strncasecmp(dest, "x-syslog://", 11) || log_type == LOG_TYPE_FTICKS) { | |
65 | + if (!strncasecmp(dest, "x-syslog://", 11)) { | |
66 | + dest += 11; | |
67 | + if (*dest == '/') | |
68 | + dest++; | |
69 | + } | |
70 | if (*dest) { | |
71 | for (i = 0; facstrings[i]; i++) | |
72 | if (!strcasecmp(dest, facstrings[i])) | |
73 | break; | |
74 | if (!facstrings[i]) | |
75 | debugx(1, DBG_ERR, "Unknown syslog facility %s", dest); | |
76 | - debug_syslogfacility = facvals[i]; | |
77 | - } else | |
78 | - debug_syslogfacility = LOG_DAEMON; | |
79 | + if (log_type != LOG_TYPE_FTICKS) | |
80 | + debug_syslogfacility = facvals[i]; | |
81 | +#if defined(WANT_FTICKS) | |
82 | + else if (log_type == LOG_TYPE_FTICKS) | |
83 | + fticks_syslogfacility = facvals[i]; | |
84 | +#endif | |
85 | + } else { | |
86 | + if (log_type != LOG_TYPE_FTICKS) | |
87 | + debug_syslogfacility = LOG_DAEMON; | |
88 | +#if defined(WANT_FTICKS) | |
89 | + else if (log_type == LOG_TYPE_FTICKS) | |
90 | + fticks_syslogfacility = 0; | |
91 | +#endif | |
92 | + } | |
93 | openlog(debug_ident, LOG_PID, debug_syslogfacility); | |
94 | return 1; | |
95 | } | |
96 | @@ -213,6 +236,20 @@ | |
97 | exit(err); | |
98 | } | |
99 | ||
100 | +#if defined(WANT_FTICKS) | |
101 | +void fticks_debug(const char *format, ...) { | |
102 | + int priority; | |
103 | + va_list ap; | |
104 | + va_start(ap, format); | |
105 | + if (!debug_syslogfacility && !fticks_syslogfacility) | |
106 | + debug_logit(0xff, format, ap); | |
107 | + else { | |
108 | + priority = LOG_DEBUG | fticks_syslogfacility; | |
109 | + vsyslog(priority, format, ap); | |
110 | + va_end(ap); | |
111 | + } | |
112 | +} | |
113 | +#endif | |
114 | /* Local Variables: */ | |
115 | /* c-file-style: "stroustrup" */ | |
116 | /* End: */ | |
117 | diff -Naur radsecproxy-1.5-orig/debug.h radsecproxy-1.5/debug.h | |
118 | --- radsecproxy-1.5-orig/debug.h 2011-10-01 10:26:44.000000000 +0200 | |
119 | +++ radsecproxy-1.5/debug.h 2011-12-12 14:46:04.000000000 +0100 | |
120 | @@ -17,6 +17,9 @@ | |
121 | #define DBG_WARN 64 | |
122 | #define DBG_ERR 128 | |
123 | ||
124 | +#define LOG_TYPE_DEBUG 0 | |
125 | +#define LOG_TYPE_FTICKS 1 | |
126 | + | |
127 | void debug_init(char *ident); | |
128 | void debug_set_level(uint8_t level); | |
129 | void debug_timestamp_on(); | |
130 | @@ -25,8 +28,11 @@ | |
131 | void debugx(int status, uint8_t level, char *format, ...); | |
132 | void debugerrno(int err, uint8_t level, char *format, ...); | |
133 | void debugerrnox(int err, uint8_t level, char *format, ...); | |
134 | -int debug_set_destination(char *dest); | |
135 | +int debug_set_destination(char *dest, int log_type); | |
136 | void debug_reopen_log(); | |
137 | +#if defined(WANT_FTICKS) | |
138 | +void fticks_debug(const char *format, ...); | |
139 | +#endif | |
140 | ||
141 | /* Local Variables: */ | |
142 | /* c-file-style: "stroustrup" */ | |
143 | diff -Naur radsecproxy-1.5-orig/fticks.c radsecproxy-1.5/fticks.c | |
144 | --- radsecproxy-1.5-orig/fticks.c 2011-10-08 16:03:47.000000000 +0200 | |
145 | +++ radsecproxy-1.5/fticks.c 2011-11-30 13:03:37.000000000 +0100 | |
146 | @@ -152,7 +152,7 @@ | |
147 | } | |
148 | } | |
149 | } | |
150 | - debug(0xff, | |
151 | + fticks_debug( | |
152 | "F-TICKS/eduroam/1.0#REALM=%s#VISCOUNTRY=%s#%sCSI=%s#RESULT=%s#", | |
153 | realm, | |
154 | client->conf->fticks_viscountry, | |
155 | diff -Naur radsecproxy-1.5-orig/radsecproxy.c radsecproxy-1.5/radsecproxy.c | |
156 | --- radsecproxy-1.5-orig/radsecproxy.c 2011-10-08 16:03:48.000000000 +0200 | |
157 | +++ radsecproxy-1.5/radsecproxy.c 2011-12-12 14:46:25.000000000 +0100 | |
158 | @@ -3085,6 +3085,7 @@ | |
159 | "FTicksReporting", CONF_STR, &fticks_reporting_str, | |
160 | "FTicksMAC", CONF_STR, &fticks_mac_str, | |
161 | "FTicksKey", CONF_STR, &fticks_key_str, | |
162 | + "FTicksSyslogFacility", CONF_STR, &options.ftickssyslogfacility, | |
163 | #endif | |
164 | NULL | |
165 | )) | |
166 | @@ -3239,8 +3240,18 @@ | |
167 | options.loglevel = loglevel; | |
168 | else if (options.loglevel) | |
169 | debug_set_level(options.loglevel); | |
170 | - if (!foreground) | |
171 | - debug_set_destination(options.logdestination ? options.logdestination : "x-syslog:///"); | |
172 | + if (!foreground) { | |
173 | + debug_set_destination(options.logdestination | |
174 | + ? options.logdestination | |
175 | + : "x-syslog:///", LOG_TYPE_DEBUG); | |
176 | +#if defined(WANT_FTICKS) | |
177 | + if (options.ftickssyslogfacility) { | |
178 | + debug_set_destination(options.ftickssyslogfacility, | |
179 | + LOG_TYPE_FTICKS); | |
180 | + free(options.ftickssyslogfacility); | |
181 | + } | |
182 | +#endif | |
183 | + } | |
184 | free(options.logdestination); | |
185 | ||
186 | if (!list_first(clconfs)) | |
187 | diff -Naur radsecproxy-1.5-orig/radsecproxy.conf.5.xml radsecproxy-1.5/radsecproxy.conf.5.xml | |
188 | --- radsecproxy-1.5-orig/radsecproxy.conf.5.xml 2011-10-08 15:59:25.000000000 +0200 | |
189 | +++ radsecproxy-1.5/radsecproxy.conf.5.xml 2011-11-30 13:03:58.000000000 +0100 | |
190 | @@ -243,6 +243,24 @@ | |
191 | </varlistentry> | |
192 | ||
193 | <varlistentry> | |
194 | + <term><literal>FTicksSyslogFacility</literal></term> | |
195 | + <listitem> | |
196 | + <para> | |
197 | + The FTicksSyslogFacility option is used to specify | |
198 | + a dedicated syslog facility for F-Ticks messages. | |
199 | + This allows easy filtering of F-Ticks messages. | |
200 | + By default, if FTicksSyslogFacility is not given, | |
201 | + F-Ticks messages are written to the LogDestination. | |
202 | + </para> | |
203 | + <para> | |
204 | + For F-Ticks messages always LOG_DEBUG level is used. | |
205 | + Note that FTicksSyslogFacility value specifying a file | |
206 | + (via file:/// prefix) is ignored. | |
207 | + </para> | |
208 | + </listitem> | |
209 | + </varlistentry> | |
210 | + | |
211 | + <varlistentry> | |
212 | <term><literal>ListenUDP</literal></term> | |
213 | <listitem> | |
214 | <para> | |
215 | diff -Naur radsecproxy-1.5-orig/radsecproxy.conf-example radsecproxy-1.5/radsecproxy.conf-example | |
216 | --- radsecproxy-1.5-orig/radsecproxy.conf-example 2011-10-08 15:00:14.000000000 +0200 | |
217 | +++ radsecproxy-1.5/radsecproxy.conf-example 2011-11-30 13:03:58.000000000 +0100 | |
218 | @@ -57,6 +57,14 @@ | |
219 | #FTicksReporting None | |
220 | #FTicksMAC Static | |
221 | ||
222 | +# You can optionally specify FTicksSyslogFacility to use a dedicated | |
223 | +# syslog facility for F-Ticks messages. This allows easy filtering | |
224 | +# of F-Ticks messages. | |
225 | +# For F-Ticks messages always LOG_DEBUG level is used. | |
226 | +# Please note that FTicksSyslogFacility cannot specify a file (file:///...) | |
227 | +#FTicksSyslogFacility log_local1 | |
228 | +#FTicksSyslogFacility x-syslog:///log_local1 | |
229 | + | |
230 | # There is an option for doing some simple loop prevention. Note that | |
231 | # the LoopPrevention directive can be used in server blocks too, | |
232 | # overriding what's set here in the basic settings. | |
233 | diff -Naur radsecproxy-1.5-orig/radsecproxy.h radsecproxy-1.5/radsecproxy.h | |
234 | --- radsecproxy-1.5-orig/radsecproxy.h 2011-10-08 14:35:39.000000000 +0200 | |
235 | +++ radsecproxy-1.5/radsecproxy.h 2011-11-30 13:03:47.000000000 +0100 | |
236 | @@ -55,6 +55,7 @@ | |
237 | ||
238 | struct options { | |
239 | char *logdestination; | |
240 | + char *ftickssyslogfacility; | |
241 | char *ttlattr; | |
242 | uint32_t ttlattrtype[2]; | |
243 | uint8_t addttl; |