]> git.ipfire.org Git - thirdparty/sarg.git/blob - getconf.c
Merge commit 'd82e81174c6b544f0718736c5'
[thirdparty/sarg.git] / getconf.c
1 /*
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
3 * 1998, 2010
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
24 *
25 */
26
27 #include "include/conf.h"
28 #include "include/defs.h"
29
30 #define SET_LIST(list) list,sizeof(list)/sizeof(list[0])
31
32 extern numlist hours, weekdays;
33
34 struct param_list
35 {
36 //! The name of the value of the parameter.
37 const char *name;
38 //! The bit to set if the value is found.
39 unsigned long int value;
40 //! The value is invalid if any bit of this mask is set in the parameter.
41 unsigned long int exclude;
42 };
43
44 struct sort_list
45 {
46 //! The name of the value of the parameter.
47 const char *name;
48 //! The bit to set if the value is found.
49 unsigned long int value;
50 };
51
52 static struct param_list report_type_values[]=
53 {
54 {"users_sites",REPORT_TYPE_USERS_SITES,0},
55 {"topusers",REPORT_TYPE_TOPUSERS,0},
56 {"topsites",REPORT_TYPE_TOPSITES,0},
57 {"sites_users",REPORT_TYPE_SITES_USERS,0},
58 {"date_time",REPORT_TYPE_DATE_TIME,0},
59 {"denied",REPORT_TYPE_DENIED,0},
60 {"auth_failures",REPORT_TYPE_AUTH_FAILURES,0},
61 {"site_user_time_date",REPORT_TYPE_SITE_USER_TIME_DATE,0},
62 {"downloads",REPORT_TYPE_DOWNLOADS,0},
63 };
64
65 static struct param_list data_field_values[]=
66 {
67 {"user",DATA_FIELD_USER,0},
68 {"date",DATA_FIELD_DATE,0},
69 {"time",DATA_FIELD_TIME,0},
70 {"url",DATA_FIELD_URL,0},
71 {"connect",DATA_FIELD_CONNECT,0},
72 {"bytes",DATA_FIELD_BYTES,0},
73 {"in_cache",DATA_FIELD_IN_CACHE,0},
74 {"out_cache",DATA_FIELD_OUT_CACHE,0},
75 {"elapsed",DATA_FIELD_ELAPSED,0},
76 };
77
78 static struct param_list topuserfields_values[]=
79 {
80 {"NUM",TOPUSERFIELDS_NUM,0},
81 {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
82 {"USERID",TOPUSERFIELDS_USERID,0},
83 {"CONNECT",TOPUSERFIELDS_CONNECT,0},
84 {"BYTES",TOPUSERFIELDS_BYTES,0},
85 {"%BYTES",TOPUSERFIELDS_SETYB,0},
86 {"SETYB",TOPUSERFIELDS_SETYB,0},
87 {"IN-CACHE-OUT",TOPUSERFIELDS_IN_CACHE_OUT,0},
88 {"USED_TIME",TOPUSERFIELDS_USED_TIME,0},
89 {"MILISEC",TOPUSERFIELDS_MILISEC,0},
90 {"%TIME",TOPUSERFIELDS_PTIME,0},
91 {"TOTAL",TOPUSERFIELDS_TOTAL,0},
92 {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
93 };
94
95 static struct param_list userreportfields_values[]=
96 {
97 {"CONNECT",USERREPORTFIELDS_CONNECT,0},
98 {"BYTES",USERREPORTFIELDS_BYTES,0},
99 {"%BYTES",USERREPORTFIELDS_SETYB,0},
100 {"SETYB",USERREPORTFIELDS_SETYB,0},
101 {"IN-CACHE-OUT",USERREPORTFIELDS_IN_CACHE_OUT,0},
102 {"USED_TIME",USERREPORTFIELDS_USED_TIME,0},
103 {"MILISEC",USERREPORTFIELDS_MILISEC,0},
104 {"%TIME",USERREPORTFIELDS_PTIME,0},
105 {"TOTAL",USERREPORTFIELDS_TOTAL,0},
106 {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
107 };
108
109 static struct param_list index_values[]=
110 {
111 {"yes",INDEX_YES,~INDEX_YES},
112 {"no",INDEX_NO,~INDEX_NO},
113 {"only",INDEX_ONLY,~INDEX_ONLY},
114 };
115
116 static struct param_list index_tree_values[]=
117 {
118 {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE},
119 {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE},
120 };
121
122 static struct param_list ntml_userformat_values[]=
123 {
124 {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER},
125 {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER},
126 };
127
128 static struct param_list recnouser_values[]=
129 {
130 {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP},
131 {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE},
132 {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY},
133 };
134
135 static struct param_list datafileurl_values[]=
136 {
137 {"ip",DATAFILEURL_IP,~DATAFILEURL_IP},
138 {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME},
139 };
140
141 static struct param_list displayvalue_values[]=
142 {
143 {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES},
144 {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV},
145 };
146
147 static struct param_list datetime_values[]=
148 {
149 {"elap",DATETIME_ELAP,0},
150 {"bytes",DATETIME_BYTE,0},
151 };
152
153 static struct param_list realtime_unauth_values[]=
154 {
155 {"show",REALTIME_UNAUTH_REC_SHOW,~REALTIME_UNAUTH_REC_SHOW},
156 {"ignore",REALTIME_UNAUTH_REC_IGNORE,~REALTIME_UNAUTH_REC_IGNORE},
157 };
158
159 struct sort_list topuser_sort[]=
160 {
161 {"BYTES",TOPUSER_SORT_BYTES},
162 {"USER",TOPUSER_SORT_USER},
163 {"CONNECT",TOPUSER_SORT_CONNECT},
164 {"TIME",TOPUSER_SORT_TIME},
165 };
166
167 struct sort_list topsite_sort[]=
168 {
169 {"BYTES",TOPSITE_SORT_BYTES},
170 {"CONNECT",TOPSITE_SORT_CONNECT},
171 };
172
173 struct sort_list user_sort[]=
174 {
175 {"BYTES",USER_SORT_BYTES},
176 {"SITE",USER_SORT_SITE},
177 {"CONNECT",USER_SORT_CONNECT},
178 {"TIME",USER_SORT_TIME},
179 };
180
181 static int is_param(const char *param,const char *buf)
182 {
183 int plen;
184
185 plen=strlen(param);
186 if (strncmp(buf,param,plen) != 0) return(0);
187 buf+=plen;
188 if ((unsigned char)*buf>' ') return(0);
189 return(1);
190 }
191
192 static int getparam_string(const char *param,char *buf,char *value,int value_size)
193 {
194 int plen;
195
196 plen=strlen(param);
197 if (strncmp(buf,param,plen) != 0) return(0);
198 buf+=plen;
199 if ((unsigned char)*buf>' ') return(0);
200 while (*buf && (unsigned char)*buf<=' ') buf++;
201
202 if (strlen(buf)>=value_size) {
203 debuga(_("The string value of parameter \"%s\" is too long\n"),param);
204 exit(EXIT_FAILURE);
205 }
206 strcpy(value,buf);
207 fixnone(value);
208 return(1);
209 }
210
211 static int getparam_quoted(const char *param,char *buf,char *value,int value_size)
212 {
213 int plen;
214 int i;
215
216 plen=strlen(param);
217 if (strncmp(buf,param,plen) != 0) return(0);
218 buf+=plen;
219 if ((unsigned char)*buf>' ') return(0);
220 while (*buf && (unsigned char)*buf<=' ') buf++;
221
222 if (*buf != '\"') {
223 debuga(_("Missing double quote after parameter \"%s\"\n"),param);
224 exit(EXIT_FAILURE);
225 }
226 buf++;
227
228 value_size--;
229 for (i=0 ; i<value_size && *buf && *buf!='\"' ; i++) {
230 value[i]=*buf++;
231 }
232 value[i]='\0';
233
234 if (*buf != '\"') {
235 debuga(_("Missing double quote after parameter \"%s\" or value is more than %d bytes long\n"),param,value_size);
236 exit(EXIT_FAILURE);
237 }
238 fixnone(value);
239 return(1);
240 }
241
242 static int getparam_2words(const char *param,char *buf,char *word1,int word1_size,char *word2,int word2_size)
243 {
244 int plen;
245 int i;
246
247 plen=strlen(param);
248 if (strncmp(buf,param,plen) != 0) return(0);
249 buf+=plen;
250 if ((unsigned char)*buf>' ') return(0);
251 while (*buf && (unsigned char)*buf<=' ') buf++;
252
253 for (i=0 ; i<word1_size && *buf && (unsigned char)*buf>' ' ; i++)
254 word1[i]=*buf++;
255 if (i>=word1_size) {
256 debuga(_("The first word of parameter \"%s\" is more than %d bytes long\n"),param,word1_size-1);
257 exit(EXIT_FAILURE);
258 }
259 if (*buf!=' ') {
260 debuga(_("Missing second word for parameter \"%s\"\n"),param);
261 exit(EXIT_FAILURE);
262 }
263 word1[i]=0;
264
265 while (*buf && (unsigned char)*buf<=' ') buf++;
266
267 for (i=0 ; i<word2_size && *buf && (unsigned char)*buf>' ' ; i++)
268 word2[i]=*buf++;
269 if (i>=word2_size) {
270 debuga(_("The second word of parameter \"%s\" is more than %d bytes long\n"),param,word2_size-1);
271 exit(EXIT_FAILURE);
272 }
273 word2[i]=0;
274
275 fixnone(word1);
276 fixnone(word2);
277 return(1);
278 }
279
280 static int getparam_int(const char *param,char *buf,int *value)
281 {
282 int plen;
283 int next;
284
285 plen=strlen(param);
286 if (strncmp(buf,param,plen) != 0) return(0);
287 buf+=plen;
288 if ((unsigned char)*buf>' ') return(0);
289 while (*buf && (unsigned char)*buf<=' ') buf++;
290
291 next=0;
292 if (sscanf(buf,"%d%n",value,&next) != 1 || (unsigned char)buf[next] > ' ') {
293 debuga(_("The integer value of parameter \"%s\" is invalid\n"),param);
294 exit(EXIT_FAILURE);
295 }
296 return(1);
297 }
298
299 static int getparam_bool(const char *param,char *buf,bool *value)
300 {
301 int plen;
302 int i;
303 const char *bool_str="yes,true,on,1";
304
305 plen=strlen(param);
306 if (strncmp(buf,param,plen) != 0) return(0);
307 buf+=plen;
308 if ((unsigned char)*buf>' ') return(0);
309 while (*buf && (unsigned char)*buf<=' ') buf++;
310
311 *value=false;
312 for ( ; *bool_str ; bool_str+=i) {
313 for (i=0 ; bool_str[i] && bool_str[i]!=',' ; i++);
314 if (strncasecmp(bool_str,buf,i)==0) {
315 *value=true;
316 break;
317 }
318 if (bool_str[i]==',') i++;
319 }
320 return(1);
321 }
322
323 static int getparam_list(const char *param,struct param_list *options,int noptions,char *buf,unsigned long int *value)
324 {
325 int plen;
326 char *str;
327 int i;
328
329 plen=strlen(param);
330 if (strncmp(buf,param,plen) != 0) return(0);
331 buf+=plen;
332 if ((unsigned char)*buf>' ') return(0);
333 while (*buf && (unsigned char)*buf<=' ') buf++;
334
335 *value=0UL;
336 while (*buf) {
337 str=buf;
338 while (*str && (unsigned char)*str>' ' && *str!=';') str++;
339 if (*str) {
340 *str++='\0';
341 while (*str && ((unsigned char)*str<=' ' || *str==';')) str++;
342 }
343 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
344 if (i>=noptions) {
345 debuga(_("Unknown value \"%s\" for parameter \"%s\"\n"),buf,param);
346 exit(EXIT_FAILURE);
347 }
348 if ((*value & options[i].exclude)!=0) {
349 debuga(_("Value \"%s\" conflicts with other selected values for parameter \"%s\"\n"),buf,param);
350 exit(EXIT_FAILURE);
351 }
352 *value|=options[i].value;
353 buf=str;
354 }
355 return(1);
356 }
357
358 static int getparam_sort(const char *param,struct sort_list *options,int noptions,char *buf,unsigned long int *value)
359 {
360 int plen;
361 char *str, *order;
362 int i;
363
364 plen=strlen(param);
365 if (strncmp(buf,param,plen) != 0) return(0);
366 buf+=plen;
367 if ((unsigned char)*buf>' ') return(0);
368 while (*buf && (unsigned char)*buf<=' ') buf++;
369
370 str=buf;
371 order=NULL;
372 while (*str && (unsigned char)*str>' ') str++;
373 if (*str) {
374 *str++='\0';
375 while (*str && (unsigned char)*str<=' ') str++;
376 order=str;
377 }
378 for (i=0 ; i<noptions && strcasecmp(buf,options[i].name) ; i++);
379 if (i>=noptions) {
380 debuga(_("Unknown sort criterion \"%s\" for parameter \"%s\"\n"),buf,param);
381 exit(EXIT_FAILURE);
382 }
383 *value|=options[i].value;
384
385 if (order) {
386 str=order;
387 while (*str && (unsigned char)*str>' ') str++;
388 if (*str) {
389 *str++='\0';
390 while (*str && (unsigned char)*str<=' ') str++;
391 }
392 if (strcasecmp(order,"reverse")==0 || strcasecmp(order,"D")==0) {
393 *value|=SORT_REVERSE;
394 } else if (strcasecmp(order,"normal")!=0 && strcasecmp(order,"A")!=0) {
395 debuga(_("Unknown sort order \"%s\" for parameter \"%s\"\n"),order,param);
396 exit(EXIT_FAILURE);
397 }
398 }
399
400 buf=str;
401 return(1);
402 }
403
404 static void parmtest(char *buf)
405 {
406 char wbuf[2048];
407 struct getwordstruct gwarea;
408
409 while (*buf && (unsigned char)*buf<=' ') buf++;
410
411 if(*buf == '#' || *buf == '\0')
412 return;
413
414 if(debugz)
415 printf(_("SARG: TAG: %s\n"),buf);
416
417 if (getparam_string("background_color",buf,BgColor,sizeof(BgColor))>0) return;
418
419 if (getparam_string("text_color",buf,TxColor,sizeof(TxColor))>0) return;
420
421 if (getparam_string("text_bgcolor",buf,TxBgColor,sizeof(TxBgColor))>0) return;
422
423 if (getparam_string("title_color",buf,TiColor,sizeof(TiColor))>0) return;
424
425 if (getparam_string("logo_image",buf,LogoImage,sizeof(LogoImage))>0) return;
426
427 if (getparam_quoted("logo_text",buf,LogoText,sizeof(LogoText))>0) return;
428
429 if (getparam_string("logo_text_color",buf,LogoTextColor,sizeof(LogoTextColor))>0) return;
430
431 if (getparam_string("background_image",buf,BgImage,sizeof(BgImage))>0) return;
432
433 if (getparam_bool("show_sarg_info",buf,&ShowSargInfo)>0) return;
434
435 if (getparam_bool("show_sarg_logo",buf,&ShowSargLogo)>0) return;
436
437 if (getparam_string("font_face",buf,FontFace,sizeof(FontFace))>0) return;
438
439 if (getparam_string("header_color",buf,HeaderColor,sizeof(HeaderColor))>0) return;
440
441 if (getparam_string("header_bgcolor",buf,HeaderBgColor,sizeof(HeaderBgColor))>0) return;
442
443 if (getparam_string("font_size",buf,FontSize,sizeof(FontSize))>0) return;
444
445 if (getparam_string("header_font_size",buf,HeaderFontSize,sizeof(HeaderFontSize))>0) return;
446
447 if (getparam_string("title_font_size",buf,TitleFontSize,sizeof(TitleFontSize))>0) return;
448
449 if (getparam_2words("image_size",buf,Width,sizeof(Width),Height,sizeof(Height))>0) return;
450
451 if (getparam_quoted("title",buf,Title,sizeof(Title))>0) return;
452
453 if (getparam_bool("resolve_ip",buf,&Ip2Name)>0) return;
454
455 if (getparam_bool("user_ip",buf,&UserIp)>0) return;
456
457 if (getparam_string("max_elapsed",buf,MaxElapsed,sizeof(MaxElapsed))>0) return;
458
459 if (is_param("date_format",buf)) {
460 getword_start(&gwarea,buf);
461 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
462 debuga(_("Maybe you have a broken record or garbage in \"date_format\" parameter\n"));
463 exit(EXIT_FAILURE);
464 }
465 strncpy(DateFormat,gwarea.current,1);
466 fixnone(DateFormat);
467 return;
468 }
469
470 if (is_param("hours",buf)) {
471 if( getnumlist( buf, &hours, 24, 24 ) ) {
472 debuga(_("Error: Invalid syntax in hours tag!\n"));
473 exit( 1 );
474 }
475 return;
476 }
477
478 if (is_param("weekdays",buf)) {
479 if( getnumlist( buf, &weekdays, 7, 7 ) ) {
480 debuga(_("Error: Invalid syntax in weekdays tag!\n"));
481 exit( 1 );
482 }
483 return;
484 }
485
486 if (getparam_sort("topuser_sort_field",SET_LIST(topuser_sort),buf,&TopuserSort)>0) return;
487
488 if (getparam_sort("user_sort_field",SET_LIST(user_sort),buf,&UserSort)>0) return;
489
490 if (is_param("access_log",buf)>0) {
491 if (AccessLogFromCmdLine==0) {
492 if (NAccessLog>=MAXLOGS) {
493 debuga(_("Too many log files in configuration file\n"));
494 exit(EXIT_FAILURE);
495 }
496 getparam_string("access_log",buf,AccessLog[NAccessLog],MAX_LOG_FILELEN);
497 NAccessLog++;
498 }
499 return;
500 }
501
502 if (is_param("redirector_log",buf)>0) {
503 if (RedirectorLogFromCmdLine==0) {
504 if (NRedirectorLogs>=MAX_REDIRECTOR_LOGS) {
505 debuga(_("Too many redirector log files in configuration file\n"));
506 exit(EXIT_FAILURE);
507 }
508 getparam_string("redirector_log",buf,RedirectorLogs[NRedirectorLogs],MAX_REDIRECTOR_FILELEN);
509 NRedirectorLogs++;
510 }
511 return;
512 }
513
514 if (getparam_string("useragent_log",buf,UserAgentLog,sizeof(UserAgentLog))>0) return;
515
516 if (getparam_string("exclude_hosts",buf,ExcludeHosts,sizeof(ExcludeHosts))>0) return;
517
518 if (getparam_string("exclude_codes",buf,ExcludeCodes,sizeof(ExcludeCodes))>0) return;
519
520 if (getparam_string("exclude_users",buf,ExcludeUsers,sizeof(ExcludeUsers))>0) return;
521
522 if (getparam_string("password",buf,PasswdFile,sizeof(PasswdFile))>0) return;
523
524 if (getparam_string("temporary_dir",buf,TempDir,sizeof(TempDir))>0) return;
525
526 if (getparam_list("report_type",SET_LIST(report_type_values),buf,&ReportType)>0) return;
527
528 if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
529
530 if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return;
531
532 if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) {
533 PerUserLimit=atoi(wbuf);
534 return;
535 }
536
537 if (getparam_int("lastlog",buf,&LastLog)>0) return;
538
539 if (getparam_bool("remove_temp_files",buf,&RemoveTempFiles)>0) return;
540
541 if (getparam_string("replace_index",buf,ReplaceIndex,sizeof(ReplaceIndex))>0) return;
542
543 if (getparam_list("index_tree",SET_LIST(index_tree_values),buf,&IndexTree)>0) return;
544
545 if (getparam_list("index",SET_LIST(index_values),buf,&Index)>0) return;
546
547 if (getparam_bool("overwrite_report",buf,&OverwriteReport)>0) return;
548
549 if (getparam_list("records_without_userid",SET_LIST(recnouser_values),buf,&RecordsWithoutUser)>0) return;
550
551 if (getparam_bool("use_comma",buf,&UseComma)>0) return;
552
553 if (getparam_string("mail_utility",buf,MailUtility,sizeof(MailUtility))>0) return;
554
555 if (getparam_int("topsites_num",buf,&TopSitesNum)>0) return;
556
557 if (getparam_int("topuser_num",buf,&TopUsersNum)>0) return;
558
559 if (getparam_string("usertab",buf,UserTabFile,sizeof(UserTabFile))>0) return;
560
561 if (getparam_string("index_sort_order",buf,IndexSortOrder,sizeof(IndexSortOrder))>0) return;
562
563 if (getparam_sort("topsites_sort_order",SET_LIST(topsite_sort),buf,&TopsitesSort)>0) return;
564
565 if (getparam_bool("long_url",buf,&LongUrl)>0) return;
566
567 if (getparam_string("dansguardian_conf",buf,DansGuardianConf,sizeof(DansGuardianConf))>0) return;
568
569 if (getparam_string("squidguard_conf",buf,SquidGuardConf,sizeof(SquidGuardConf))>0) return;
570
571 if (getparam_list("date_time_by",SET_LIST(datetime_values),buf,&datetimeby)>0) return;
572
573 if (getparam_string("charset",buf,CharSet,sizeof(CharSet))>0) {
574 ccharset(CharSet);
575 return;
576 }
577
578 if (getparam_quoted("user_invalid_char",buf,UserInvalidChar,sizeof(UserInvalidChar))>0) return;
579
580 if (getparam_quoted("include_users",buf,IncludeUsers+1,sizeof(IncludeUsers)-2)>0) {
581 IncludeUsers[0]=':';
582 strcat(IncludeUsers,":");
583 return;
584 }
585
586 if (getparam_quoted("exclude_string",buf,ExcludeString,sizeof(ExcludeString))>0) return;
587
588 if (getparam_bool("privacy",buf,&Privacy)>0) return;
589
590 if (getparam_quoted("privacy_string",buf,PrivacyString,sizeof(PrivacyString))>0) return;
591
592 if (getparam_string("privacy_string_color",buf,PrivacyStringColor,sizeof(PrivacyStringColor))>0) return;
593
594 if (getparam_bool("show_successful_message",buf,&SuccessfulMsg)>0) return;
595
596 if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
597
598 if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
599
600 if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
601
602 if (getparam_list("user_report_fields",SET_LIST(userreportfields_values),buf,&UserReportFields)>0) return;
603
604 if (getparam_string("datafile",buf,DataFile,sizeof(DataFile))>0) return;
605
606 if (getparam_quoted("datafile_delimiter",buf,DataFileDelimiter,sizeof(DataFileDelimiter))>0) return;
607
608 if (getparam_list("datafile_fields",SET_LIST(data_field_values),buf,&DataFileFields)>0) return;
609
610 if (getparam_list("datafile_url",SET_LIST(datafileurl_values),buf,&DataFileUrl)>0) return;
611
612 if (getparam_string("parsed_output_log",buf,ParsedOutputLog,sizeof(ParsedOutputLog))>0) return;
613
614 if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return;
615
616 if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return;
617
618 if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return;
619
620 if (getparam_int("denied_report_limit",buf,&DeniedReportLimit)>0) return;
621
622 if (getparam_int("siteusers_report_limit",buf,&SiteUsersReportLimit)>0) return;
623
624 if (getparam_int("dansguardian_report_limit",buf,&DansGuardianReportLimit)>0) return;
625
626 if (getparam_int("squidguard_report_limit",buf,&SquidGuardReportLimit)>0) return;
627
628 if (getparam_int("user_report_limit",buf,&UserReportLimit)>0) return;
629
630 if (getparam_int("download_report_limit",buf,&DownloadReportLimit)>0) return;
631
632 if (getparam_string("www_document_root",buf,wwwDocumentRoot,sizeof(wwwDocumentRoot))>0) return;
633
634 if (getparam_string("block_it",buf,BlockIt,sizeof(BlockIt))>0) return;
635
636 if (getparam_string("external_css_file",buf,ExternalCSSFile,sizeof(ExternalCSSFile))>0) return;
637
638 if (getparam_bool("user_authentication",buf,&UserAuthentication)>0) return;
639
640 if (getparam_string("AuthUserTemplateFile",buf,wbuf,sizeof(wbuf))>0) {
641 char dir[MAXLEN];
642
643 if (is_absolute(wbuf)) {
644 if (strlen(wbuf)>=sizeof(AuthUserTemplateFile)) {
645 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
646 exit(EXIT_FAILURE);
647 }
648 strcpy(AuthUserTemplateFile,wbuf);
649 } else {
650 strcpy(dir,ConfigFile);
651 if (snprintf(AuthUserTemplateFile,sizeof(AuthUserTemplateFile),"%s/%s",dirname(dir),wbuf)>=sizeof(AuthUserTemplateFile)) {
652 debuga(_("Template file name is too long in parameter \"AuthUserTemplateFile\"\n"));
653 exit(EXIT_FAILURE);
654 }
655 }
656 return;
657 }
658
659 if (is_param("download_suffix",buf)) {
660 char warea[MAXLEN];
661
662 getparam_quoted("download_suffix",buf,warea,sizeof(warea));
663 set_download_suffix(warea);
664 return;
665 }
666
667 if (getparam_bool("graphs",buf,&Graphs)>0) return;
668
669 if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return;
670
671 if (getparam_string("redirector_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) return;
672 if (getparam_string("squidguard_log_format",buf,RedirectorLogFormat,sizeof(RedirectorLogFormat))>0) {
673 debuga(_("squidguard_log_format is deprecated and has been replaced by redirector_log_format. Please update your configuration file.\n"));
674 return;
675 }
676
677 if (getparam_bool("redirector_filter_out_date",buf,&RedirectorFilterOutDate)>0) return;
678 if (getparam_bool("redirector_ignore_date",buf,&RedirectorFilterOutDate)>0) {
679 /*
680 Due to an old bug in sarg before version 2.3, the option was having the opposite action than implied by the name.
681 */
682 debuga(_("redirector_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to redirector_ignore_date. Please update your configuration file.\n"));
683 RedirectorFilterOutDate=!RedirectorFilterOutDate;
684 return;
685 }
686 if (getparam_bool("squidguard_ignore_date",buf,&RedirectorFilterOutDate)>0) {
687 debuga(_("squidguard_ignore_date is deprecated and has been replaced by redirector_filter_out_date that does the action implied by its name as opposed to squidguard_ignore_date. Please update your configuration file.\n"));
688 RedirectorFilterOutDate=!RedirectorFilterOutDate;
689 return;
690 }
691
692 if (getparam_bool("dansguardian_filter_out_date",buf,&DansguardianFilterOutDate)>0) return;
693 if (getparam_bool("dansguardian_ignore_date",buf,&DansguardianFilterOutDate)>0) {
694 debuga(_("dansguardian_ignore_date is deprecated and has been replaced by dansguardian_filter_out_date that does the action implied by its name as opposed to dansguardian_ignore_date. Please update your configuration file.\n"));
695 DansguardianFilterOutDate=!DansguardianFilterOutDate;
696 return;
697 }
698
699 if (getparam_string("ulimit",buf,Ulimit,sizeof(Ulimit))>0) return;
700
701 if (getparam_list("ntlm_user_format",SET_LIST(ntml_userformat_values),buf,&NtlmUserFormat)>0) return;
702
703 if (getparam_string("realtime_types",buf,RealtimeTypes,sizeof(RealtimeTypes))>0) return;
704
705 if (getparam_list("realtime_unauthenticated_records",SET_LIST(realtime_unauth_values),buf,&RealtimeUnauthRec)>0) return;
706
707 if (getparam_int("realtime_refresh_time",buf,&realtime_refresh)>0) return;
708
709 if (getparam_int("realtime_access_log_lines",buf,&realtime_access_log_lines)>0) return;
710
711 if (getparam_string("LDAPHost",buf,LDAPHost,sizeof(LDAPHost))>0) return;
712
713 if (getparam_int("LDAPPort",buf,&LDAPPort)>0) return;
714
715 if (getparam_int("LDAPProtocolVersion",buf,&LDAPProtocolVersion)>0) return;
716
717 if (getparam_string("LDAPBindDN",buf,LDAPBindDN,sizeof(LDAPBindDN))>0) return;
718
719 if (getparam_string("LDAPBindPW",buf,LDAPBindPW,sizeof(LDAPBindPW))>0) return;
720
721 if (getparam_string("LDAPBaseSearch",buf,LDAPBaseSearch,sizeof(LDAPBaseSearch))>0) return;
722
723 if (getparam_string("LDAPFilterSearch",buf,LDAPFilterSearch,sizeof(LDAPFilterSearch))>0) return;
724
725 if (getparam_string("LDAPTargetAttr",buf,LDAPTargetAttr,sizeof(LDAPTargetAttr))>0) return;
726
727 if (getparam_string("graph_font",buf,GraphFont,sizeof(GraphFont))>0) return;
728
729 if(strstr(buf,"squid24") != 0) {
730 squid24=true;
731 return;
732 }
733
734 if(strstr(buf,"byte_cost") != 0) {
735 getword_start(&gwarea,buf);
736 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
737 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
738 exit(EXIT_FAILURE);
739 }
740 cost=atol(gwarea.current);
741 if (getword_multisep(wbuf,sizeof(wbuf),&gwarea,' ')<0) {
742 debuga(_("The \"byte_cost\" parameter of the configuration file is invalid\n"));
743 exit(EXIT_FAILURE);
744 }
745 nocost=my_atoll(gwarea.current);
746 return;
747 }
748
749 printf(_("SARG: Unknown option %s\n"),buf);
750 }
751
752 void getconf(void)
753 {
754
755 FILE *fp_in;
756 char buf[MAXLEN];
757
758 if(debug)
759 debuga(_("Loading configuration from %s\n"),ConfigFile);
760
761 if ((fp_in = fopen(ConfigFile, "r")) == NULL) {
762 debuga(_("(getconf) Cannot open file %s\n"),ConfigFile);
763 exit(EXIT_FAILURE);
764 }
765
766 while (fgets(buf, sizeof(buf), fp_in) != NULL) {
767 fixendofline(buf);
768
769 if(debugm)
770 printf("SYSCONFDIR %s\n",buf);
771
772 parmtest(buf);
773
774 }
775
776 fclose(fp_in);
777 return;
778 }