]> git.ipfire.org Git - thirdparty/sarg.git/blob - include/conf.h
Protect a few buffers against overflows
[thirdparty/sarg.git] / include / conf.h
1 #include "config.h"
2 #include "info.h"
3 #include "btree_cache.h"
4
5 #ifdef HAVE_WINDOWS_H
6 #include <windows.h>
7 #endif
8 #ifdef HAVE_STDIO_H
9 #include <stdio.h>
10 #endif
11 #ifdef HAVE_STDLIB_H
12 #include <stdlib.h>
13 #endif
14 #ifdef HAVE_STRING_H
15 #include <string.h>
16 #endif
17 #ifdef HAVE_STRINGS_H
18 #include <strings.h>
19 #endif
20 #ifdef HAVE_SYS_TIME_H
21 #include <sys/time.h>
22 #endif
23 #ifdef HAVE_TIME_H
24 #include <time.h>
25 #endif
26 #ifdef HAVE_SYS_RESOURCE_H
27 #include <sys/resource.h>
28 #endif
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32 #if defined(HAVE_SYS_DIRENT_H) && !defined(HAVE_DIRENT_H)
33 #include <sys/dirent.h>
34 #endif
35 #ifdef HAVE_DIRENT_H
36 #include <dirent.h>
37 #endif
38 #ifdef HAVE_SYS_SOCKET_H
39 #include <sys/socket.h>
40 #endif
41 #ifdef HAVE_NETDB_H
42 #include <netdb.h>
43 #endif
44 #ifdef HAVE_TYPES_H
45 #include <types.h>
46 #endif
47 #ifdef HAVE_NETINET_IN_H
48 #include <netinet/in.h>
49 #endif
50 #ifdef HAVE_ARPA_INET_H
51 #include <arpa/inet.h>
52 #endif
53 #ifdef HAVE_SYS_STAT_H
54 #include <sys/stat.h>
55 #endif
56 #ifdef HAVE_CTYPE_H
57 #include <ctype.h>
58 #endif
59 #ifdef HAVE_ERRNO_H
60 #include <errno.h>
61 #endif
62 #ifdef HAVE_SYS_WAIT_H
63 #include <sys/wait.h>
64 #endif
65 #ifdef HAVE_GD_H
66 #define HAVE_GD 1
67 #include <gd.h>
68 #endif
69 #ifdef HAVE_GDFONTL_H
70 #include <gdfontl.h>
71 #endif
72 #ifdef HAVE_GDFONTT_H
73 #include <gdfontt.h>
74 #endif
75 #ifdef HAVE_GDFONTS_H
76 #include <gdfonts.h>
77 #endif
78 #ifdef HAVE_GDFONTMB_H
79 #include <gdfontmb.h>
80 #endif
81 #ifdef HAVE_GDFONTG_H
82 #include <gdfontg.h>
83 #endif
84 #ifdef HAVE_STDARG_H
85 #include <stdarg.h>
86 #endif
87 #ifdef HAVE_INTTYPES_H
88 #include <inttypes.h>
89 #endif
90 #ifdef HAVE_LIMITS_H
91 #include <limits.h>
92 #endif
93 #ifdef HAVE_WINSOCK_H
94 #include <winsock.h>
95 #endif
96 #ifdef HAVE_MATH_H
97 #include <math.h>
98 #endif
99 #ifdef HAVE_LOCALE_H
100 #include <locale.h>
101 #endif
102 #ifdef HAVE_EXECINFO_H
103 #include <execinfo.h>
104 #endif
105 #ifdef HAVE_LIBGEN_H
106 #include <libgen.h>
107 #endif
108 #ifdef HAVE_STDBOOL_H
109 #include <stdbool.h>
110 #else
111 typedef int bool;
112 #define true 1
113 #define false 0
114 #endif
115
116 #if defined(HAVE_FOPEN64)
117 #define _FILE_OFFSET_BITS 64
118 #define MY_FOPEN fopen64
119 #else
120 #define MY_FOPEN fopen
121 #endif
122
123 #if !defined(HAVE_BZERO)
124 #define bzero(mem,size) memset(mem,0,size)
125 #endif
126
127 #if defined(IBERTY_LIB) && !defined(HAVE_MKSTEMP)
128 int mkstemps(char *template, int suffixlen);
129 #define mkstemp(template) mkstemps(template,0)
130 #endif
131
132 #if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
133 #include <libintl.h>
134 #define _(String) gettext(String)
135 #ifdef gettext_noop
136 #define N_(String) gettext_noop(String)
137 #else
138 #define N_(String) (String)
139 #endif
140 #else /* No NLS */
141 #define _(String) (String)
142 #define N_(String) (String)
143 #define ngettext(String,Strings,num) (Strings)
144 #define textdomain(String)
145 #define bindtextdomain(Domain,Directory)
146 #endif //NLS
147
148 #if defined(__MINGW32__)
149 #define mkdir(p,m) _mkdir(p)
150
151 #ifndef WIFEXITED
152 #define WIFEXITED(S) 1
153 #endif
154
155 #ifndef WEXITSTATUS
156 #define WEXITSTATUS(S) (S)
157 #endif
158
159 #endif /*__MINGW32__*/
160
161 #ifndef __GNUC__
162 # define __attribute__(x)
163 #endif
164
165 #define MAXLEN 20000
166 #define MAX_URL_LEN 40000
167 #define MAX_TRUNCATED_URL 512
168 #define MAX_USER_LEN 256
169 #define MAX_USER_FNAME_LEN 128
170 #define MAX_IP_LEN 64
171 #define MAX_DATETIME_LEN 32
172 #define MAXLOGS 255
173 #define MAX_LOG_FILELEN 1024
174 #define MAX_REDIRECTOR_LOGS 64
175 #define MAX_REDIRECTOR_FILELEN 1024
176 /*!
177 Arbitrary limit on the number of days that are accepted in the selected range of the log file.
178 Sarg will complain that there are too many days in the files if this limit is overrun.
179 */
180 #define MAX_DATETIME_DAYS 1000
181
182 #define REPORT_TYPE_USERS_SITES 0x0001UL
183 #define REPORT_TYPE_SITE_USER_TIME_DATE 0x0002UL
184 #define REPORT_TYPE_TOPUSERS 0x0004UL
185 #define REPORT_TYPE_TOPSITES 0x0008UL
186 #define REPORT_TYPE_SITES_USERS 0x0010UL
187 #define REPORT_TYPE_DATE_TIME 0x0020UL
188 #define REPORT_TYPE_DENIED 0x0040UL
189 #define REPORT_TYPE_AUTH_FAILURES 0x0080UL
190 #define REPORT_TYPE_DOWNLOADS 0x0100UL
191
192 #define DATA_FIELD_USER 0x0001UL
193 #define DATA_FIELD_DATE 0x0002UL
194 #define DATA_FIELD_TIME 0x0004UL
195 #define DATA_FIELD_URL 0x0008UL
196 #define DATA_FIELD_CONNECT 0x0010UL
197 #define DATA_FIELD_BYTES 0x0020UL
198 #define DATA_FIELD_IN_CACHE 0x0040UL
199 #define DATA_FIELD_OUT_CACHE 0x0080UL
200 #define DATA_FIELD_ELAPSED 0x0100UL
201
202 #define TOPUSERFIELDS_NUM 0x0001UL
203 #define TOPUSERFIELDS_DATE_TIME 0x0002UL
204 #define TOPUSERFIELDS_USERID 0x0004UL
205 #define TOPUSERFIELDS_CONNECT 0x0008UL
206 #define TOPUSERFIELDS_BYTES 0x0010UL
207 #define TOPUSERFIELDS_SETYB 0x0020UL
208 #define TOPUSERFIELDS_IN_CACHE_OUT 0x0040UL
209 #define TOPUSERFIELDS_USED_TIME 0x0080UL
210 #define TOPUSERFIELDS_MILISEC 0x0100UL
211 #define TOPUSERFIELDS_PTIME 0x0200UL
212 #define TOPUSERFIELDS_TOTAL 0x0400UL
213 #define TOPUSERFIELDS_AVERAGE 0x0800UL
214
215 #define USERREPORTFIELDS_CONNECT 0x0001UL
216 #define USERREPORTFIELDS_BYTES 0x0002UL
217 #define USERREPORTFIELDS_SETYB 0x0004UL
218 #define USERREPORTFIELDS_IN_CACHE_OUT 0x0008UL
219 #define USERREPORTFIELDS_USED_TIME 0x0010UL
220 #define USERREPORTFIELDS_MILISEC 0x0020UL
221 #define USERREPORTFIELDS_PTIME 0x0040UL
222 #define USERREPORTFIELDS_TOTAL 0x0080UL
223 #define USERREPORTFIELDS_AVERAGE 0x0100UL
224
225 #define INDEX_YES 0x0001UL
226 #define INDEX_NO 0x0002UL
227 #define INDEX_ONLY 0x0004UL
228
229 #define INDEX_TREE_DATE 0x0001UL
230 #define INDEX_TREE_FILE 0x0002UL
231
232 #define INDEXFIELDS_DIRSIZE 0x0001UL
233
234 #define NTLMUSERFORMAT_USER 0x0001UL
235 #define NTLMUSERFORMAT_DOMAINUSER 0x0002UL
236
237 #define RECORDWITHOUTUSER_IP 0x0001UL
238 #define RECORDWITHOUTUSER_IGNORE 0x0002UL
239 #define RECORDWITHOUTUSER_EVERYBODY 0x0004UL
240
241 #define DATAFILEURL_IP 0x0001UL
242 #define DATAFILEURL_NAME 0x0002UL
243
244 #define DISPLAY_BYTES 0x0001UL
245 #define DISPLAY_ABBREV 0x0002UL
246
247 #define DATETIME_ELAP 0x0001UL
248 #define DATETIME_BYTE 0x0002UL
249
250 #define REALTIME_UNAUTH_REC_SHOW 0x0001UL
251 #define REALTIME_UNAUTH_REC_IGNORE 0x0002UL
252
253 #define SORT_REVERSE 0x0001
254
255 #define TOPUSER_SORT_REVERSE SORT_REVERSE
256 #define TOPUSER_SORT_BYTES 0x0002UL
257 #define TOPUSER_SORT_USER 0x0004UL
258 #define TOPUSER_SORT_CONNECT 0x0008UL
259 #define TOPUSER_SORT_TIME 0x0010UL
260
261 #define TOPSITE_SORT_REVERSE SORT_REVERSE
262 #define TOPSITE_SORT_BYTES 0x0002UL
263 #define TOPSITE_SORT_CONNECT 0x0004UL
264 #define TOPSITE_SORT_TIME 0x0008UL
265
266 #define USER_SORT_REVERSE SORT_REVERSE
267 #define USER_SORT_BYTES 0x0002UL
268 #define USER_SORT_SITE 0x0004UL
269 #define USER_SORT_CONNECT 0x0008UL
270 #define USER_SORT_TIME 0x0010UL
271
272 //! Value to exclude all the javascripts from the html page.
273 #define HTML_JS_NONE 0x0000
274 //! Bit to include sorttable.js in the html plage.
275 #define HTML_JS_SORTTABLE 0x0001
276
277 //! The character prefixed in front of the host names that are aliased.
278 #define ALIAS_PREFIX '*'
279
280 struct periodstruct
281 {
282 //! The first date of the period.
283 struct tm start;
284 //! The last date of the period.
285 struct tm end;
286 //! The textual representation of the date.
287 char text[40];
288 //! The HTML representation of the date.
289 char html[40];
290 };
291
292 char outdir[MAXLEN];
293 char outdirname[MAXLEN];
294 struct periodstruct period;
295 char code[MAXLEN];
296 char code2[MAXLEN];
297 char tmp[MAXLEN];
298 char parse_out[MAXLEN];
299 char arqtt[MAXLEN];
300 char html[MAXLEN];
301 char ConfigFile[MAXLEN];
302 char df[20];
303 int LastLog;
304 bool RemoveTempFiles;
305 char ReplaceIndex[256];
306 unsigned long int Index;
307 bool OverwriteReport;
308 unsigned long int RecordsWithoutUser;
309 bool UseComma;
310 char MailUtility[PATH_MAX];
311 int TopSitesNum;
312 int TopUsersNum;
313 char ExcludeCodes[256];
314 unsigned long int TopsitesSort;
315 unsigned long int ReportType;
316 char UserTabFile[255];
317 char warea[MAXLEN];
318 char name[MAXLEN];
319 bool LongUrl;
320 bool Ip2Name;
321 int NAccessLog;
322 char AccessLog[MAXLOGS][MAX_LOG_FILELEN];
323 int AccessLogFromCmdLine;
324 char Title[MAXLEN];
325 char BgColor[MAXLEN];
326 char BgImage[MAXLEN];
327 char TxColor[MAXLEN];
328 char TxBgColor[MAXLEN];
329 char TiColor[MAXLEN];
330 char LogoImage[MAXLEN];
331 char LogoText[MAXLEN];
332 char LogoTextColor[MAXLEN];
333 char Width[MAXLEN];
334 char Height[MAXLEN];
335 char FontFace[MAXLEN];
336 char HeaderColor[MAXLEN];
337 char HeaderBgColor[MAXLEN];
338 char FontSize[MAXLEN];
339 char PasswdFile[MAXLEN];
340 char TempDir[MAXLEN];
341 char OutputDir[MAXLEN];
342 char OutputEmail[MAXLEN];
343 unsigned long int TopuserSort;
344 unsigned long int UserSort;
345 char UserAgentLog[255];
346 char module[255];
347 char ExcludeHosts[255];
348 char ExcludeUsers[255];
349 char DateFormat[2];
350 char PerUserLimitFile[255];
351 int PerUserLimit;
352 bool UserIp;
353 char MaxElapsed[255];
354 unsigned long int datetimeby;
355 char CharSet[255];
356 char UserInvalidChar[255];
357 bool Graphs;
358 char GraphDaysBytesBarColor[255];
359 bool Privacy;
360 char PrivacyString[255];
361 char PrivacyStringColor[30];
362 char IncludeUsers[MAXLEN];
363 char ExcludeString[MAXLEN];
364 bool SuccessfulMsg;
365 unsigned long int TopUserFields;
366 unsigned long int UserReportFields;
367 char DataFile[MAXLEN];
368 char DataFileDelimiter[3];
369 unsigned long int DataFileFields;
370 unsigned long int DataFileUrl;
371 bool ShowReadStatistics;
372 char IndexSortOrder[5];
373 char DansGuardianConf[MAXLEN];
374 bool DansguardianFilterOutDate;
375 char SquidGuardConf[MAXLEN];
376 char SquidGuarddbHome[255];
377 char RedirectorLogFormat[4096];
378 int NRedirectorLogs;
379 char RedirectorLogs[MAX_REDIRECTOR_LOGS][MAX_REDIRECTOR_FILELEN];
380 int RedirectorLogFromCmdLine;
381 bool RedirectorFilterOutDate;
382 bool ShowSargInfo;
383 bool BytesInSitesUsersReport;
384 bool ShowSargLogo;
385 char ParsedOutputLog[MAXLEN];
386 char ParsedOutputLogCompress[512];
387 unsigned long int DisplayedValues;
388 char HeaderFontSize[5];
389 char TitleFontSize[5];
390 char wwwDocumentRoot[MAXLEN];
391 char ExternalCSSFile[MAXLEN];
392 char BlockIt[255];
393 unsigned long int NtlmUserFormat;
394 //! How to display the index of the reports.
395 unsigned long int IndexTree;
396 //! The columns to show in the index of the reports.
397 unsigned long int IndexFields;
398 bool UserAuthentication;
399 char AuthUserTemplateFile[1024];
400 //! \c True to use anonymous file and directory names in the report.
401 bool AnonymousOutputFiles;
402 char val1[MAXLEN];
403 char val3[MAXLEN];
404 char val5[MAXLEN];
405 char val6[MAXLEN];
406 char val7[MAXLEN];
407 char val8[MAXLEN];
408 char val9[MAXLEN];
409 char val10[MAXLEN];
410 char val11[MAXLEN];
411 char mask[MAXLEN];
412 char site[MAXLEN];
413 char us[50];
414 char email[MAXLEN];
415 char test[1];
416 char user2[MAXLEN];
417 char wentp[512];
418 char addr[MAXLEN];
419 char Ulimit[6];
420 char RealtimeTypes[1024];
421 char cmd[255];
422 char ImageFile[255];
423 unsigned long int RealtimeUnauthRec;
424 char LDAPHost[255];
425 char LDAPBindDN[512];
426 char LDAPBindPW[255];
427 int LDAPPort;
428 int LDAPProtocolVersion;
429 char LDAPBaseSearch[255];
430 char LDAPFilterSearch[512];
431 char LDAPTargetAttr[64];
432 char GraphFont[MAXLEN];
433 //! The full path to sorttable.js if the table in the reports must be dynamicaly sorted.
434 char SortTableJs[256];
435 //! The name of the file containing the host names to replace by an alias in the report.
436 char HostAliasFile[512];
437
438 int idate;
439 int smartfilter;
440 int denied_count;
441 int download_count;
442 int authfail_count;
443 int dansguardian_count;
444 int redirector_count;
445 int useragent_count;
446 int limit_flag;
447 int z1, z2, z3;
448 int ttopen;
449 int sarglog;
450 int isalog;
451 int dfrom;
452 int duntil;
453 int dataonly;
454 bool indexonly;
455 bool iprel;
456 int langcode;
457 int debug;
458 int debugz;
459 int debugm;
460 int AuthfailReportLimit;
461 int DeniedReportLimit;
462 int DownloadReportLimit;
463 int SiteUsersReportLimit;
464 int DansGuardianReportLimit;
465 int SquidGuardReportLimit;
466 int UserReportLimit;
467 int realtime_refresh;
468 int realtime_access_log_lines;
469 int rc;
470 int ntopsites;
471 int nsitesusers;
472 int nrepday;
473 int ndownload;
474 int ntopuser;
475 bool squid24;
476
477 long long int nocost;
478 float cost;
479
480 typedef struct
481 { int list[ 24 ];
482 int len;
483 } numlist;